summaryrefslogtreecommitdiffstats
path: root/source3/rpc_client/cli_spoolss.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2000-08-12 14:26:01 +0000
committerGerald Carter <jerry@samba.org>2000-08-12 14:26:01 +0000
commit74f2fc40dbcd0478d0d1f77cce0b5d9ee5c1aa8d (patch)
tree07aff15948218d8eac1b35b326a54faa03431a81 /source3/rpc_client/cli_spoolss.c
parentcf023a7ce0ba08f3b7e37fecf8219e83c04ed418 (diff)
downloadsamba-74f2fc40dbcd0478d0d1f77cce0b5d9ee5c1aa8d.tar.gz
samba-74f2fc40dbcd0478d0d1f77cce0b5d9ee5c1aa8d.tar.xz
samba-74f2fc40dbcd0478d0d1f77cce0b5d9ee5c1aa8d.zip
FIxed some unmarshalling problems with relstr and unistr arrays
jerry (This used to be commit ce2d20395ae3d41d55030427f4b7b44ce87c605e)
Diffstat (limited to 'source3/rpc_client/cli_spoolss.c')
-rw-r--r--source3/rpc_client/cli_spoolss.c353
1 files changed, 157 insertions, 196 deletions
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index ed5c66ebfc3..af83eb73eee 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -59,34 +59,26 @@ uint32 spoolss_enum_printerdrivers(const char *srv_name, const char *environment
level, buffer, offered);
/* turn parameters into data stream */
- if (!spoolss_io_q_enumprinterdrivers("", &q_o, &buf, 0) ) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
- }
-
- if(!rpc_con_pipe_req(con, SPOOLSS_ENUMPRINTERDRIVERS, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
- }
-
- prs_mem_free(&buf);
- ZERO_STRUCT(r_o);
-
- prs_switch_type(&buffer->prs, UNMARSHALL);
- prs_set_offset(&buffer->prs, 0);
- r_o.buffer=buffer;
+ if (spoolss_io_q_enumprinterdrivers("", &q_o, &buf, 0) &&
+ rpc_con_pipe_req(con, SPOOLSS_ENUMPRINTERDRIVERS, &buf, &rbuf))
+ {
+ prs_mem_free(&buf);
+ ZERO_STRUCT(r_o);
- if(!new_spoolss_io_r_enumprinterdrivers("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- cli_connection_unlink(con);
- }
+ prs_switch_type(&buffer->prs, UNMARSHALL);
+ prs_set_offset(&buffer->prs, 0);
+ r_o.buffer=buffer;
- *needed=r_o.needed;
- *returned=r_o.returned;
+ if(new_spoolss_io_r_enumprinterdrivers("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NOPROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_ENUMPRINTERDRIVERS: %s\n", get_nt_error_msg(r_o.status)));
+ }
+ *needed=r_o.needed;
+ *returned=r_o.returned;
+ }
+ }
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -124,35 +116,29 @@ uint32 spoolss_enum_printers(uint32 flags, fstring srv_name, uint32 level,
make_spoolss_q_enumprinters(&q_o, flags, "", level, buffer, offered);
/* turn parameters into data stream */
- if (!spoolss_io_q_enumprinters("", &q_o, &buf, 0) ) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
- }
-
- if(!rpc_con_pipe_req(con, SPOOLSS_ENUMPRINTERS, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
+ if (spoolss_io_q_enumprinters("", &q_o, &buf, 0) &&
+ rpc_con_pipe_req(con, SPOOLSS_ENUMPRINTERS, &buf, &rbuf))
+ {
+ ZERO_STRUCT(r_o);
- cli_connection_unlink(con);
- }
+ prs_switch_type(&buffer->prs, UNMARSHALL);
+ prs_set_offset(&buffer->prs, 0);
+ r_o.buffer=buffer;
- prs_mem_free(&buf );
- ZERO_STRUCT(r_o);
+ if(new_spoolss_io_r_enumprinters("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ /* report error code */
+ DEBUG(5,("SPOOLSS_ENUMPRINTERS: %s\n", get_nt_error_msg(r_o.status)));
+ }
- prs_switch_type(&buffer->prs, UNMARSHALL);
- prs_set_offset(&buffer->prs, 0);
- r_o.buffer=buffer;
+ *needed=r_o.needed;
+ *returned=r_o.returned;
+ }
- if(!new_spoolss_io_r_enumprinters("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- cli_connection_unlink(con);
}
- *needed=r_o.needed;
- *returned=r_o.returned;
-
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -189,35 +175,28 @@ uint32 spoolss_enum_ports(fstring srv_name, uint32 level,
make_spoolss_q_enumports(&q_o, "", level, buffer, offered);
/* turn parameters into data stream */
- if (!spoolss_io_q_enumports("", &q_o, &buf, 0) ) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
- }
-
- if(!rpc_con_pipe_req(con, SPOOLSS_ENUMPORTS, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
- }
-
- prs_mem_free(&buf );
- ZERO_STRUCT(r_o);
+ if (spoolss_io_q_enumports("", &q_o, &buf, 0) &&
+ rpc_con_pipe_req(con, SPOOLSS_ENUMPORTS, &buf, &rbuf))
+ {
+ prs_mem_free(&buf );
+ ZERO_STRUCT(r_o);
- prs_switch_type(&buffer->prs, UNMARSHALL);
- prs_set_offset(&buffer->prs, 0);
- r_o.buffer=buffer;
+ prs_switch_type(&buffer->prs, UNMARSHALL);
+ prs_set_offset(&buffer->prs, 0);
+ r_o.buffer=buffer;
- if(!new_spoolss_io_r_enumports("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- cli_connection_unlink(con);
+ if(new_spoolss_io_r_enumports("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_ENUMPORTS: %s\n", get_nt_error_msg(r_o.status)));
+ }
+
+ *needed=r_o.needed;
+ *returned=r_o.returned;
+ }
}
- *needed=r_o.needed;
- *returned=r_o.returned;
-
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -252,28 +231,24 @@ uint32 spoolss_enum_jobs(const POLICY_HND *hnd, uint32 firstjob, uint32 numofjob
make_spoolss_q_enumjobs(&q_o, hnd, firstjob, numofjobs, level, buffer, offered);
/* turn parameters into data stream */
- if (!spoolss_io_q_enumjobs("", &q_o, &buf, 0)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- if(!rpc_hnd_pipe_req(hnd, SPOOLSS_ENUMJOBS, &buf, &rbuf))
+ if (spoolss_io_q_enumjobs("", &q_o, &buf, 0) &&
+ rpc_hnd_pipe_req(hnd, SPOOLSS_ENUMJOBS, &buf, &rbuf))
{
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- ZERO_STRUCT(r_o);
- prs_mem_free(&buf );
+ ZERO_STRUCT(r_o);
+ prs_mem_free(&buf );
- r_o.buffer=buffer;
+ r_o.buffer=buffer;
- if(!spoolss_io_r_enumjobs("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- }
-
- *needed=r_o.needed;
- *returned=r_o.returned;
+ if(spoolss_io_r_enumjobs("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_ENUMJOBS: %s\n", get_nt_error_msg(r_o.status)));
+ }
+ *needed=r_o.needed;
+ *returned=r_o.returned;
+ }
+ }
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -313,31 +288,30 @@ uint32 spoolss_enum_printerdata(const POLICY_HND *hnd, uint32 idx,
make_spoolss_q_enumprinterdata(&q_o, hnd, idx, *valuelen, *datalen);
/* turn parameters into data stream */
- if (!spoolss_io_q_enumprinterdata("", &q_o, &buf, 0)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- if(!rpc_hnd_pipe_req(hnd, SPOOLSS_ENUMPRINTERDATA, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- ZERO_STRUCT(r_o);
- prs_mem_free(&buf );
+ if (spoolss_io_q_enumprinterdata("", &q_o, &buf, 0) &&
+ rpc_hnd_pipe_req(hnd, SPOOLSS_ENUMPRINTERDATA, &buf, &rbuf))
+ {
+ ZERO_STRUCT(r_o);
+ prs_mem_free(&buf );
- r_o.data=data;
- r_o.value=value;
+ r_o.data=data;
+ r_o.value=value;
- if(!spoolss_io_r_enumprinterdata("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- }
+ if(spoolss_io_r_enumprinterdata("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_ENUMPRINTERDATA: %s\n", get_nt_error_msg(r_o.status)));
+ }
+
+ *valuelen=r_o.valuesize;
+ *rvaluelen=r_o.realvaluesize;
+ *type=r_o.type;
+ *datalen=r_o.datasize;
+ *rdatalen=r_o.realdatasize;
- *valuelen=r_o.valuesize;
- *rvaluelen=r_o.realvaluesize;
- *type=r_o.type;
- *datalen=r_o.datasize;
- *rdatalen=r_o.realdatasize;
+ }
+ }
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -373,28 +347,25 @@ uint32 spoolss_getprinter(const POLICY_HND *hnd, uint32 level,
make_spoolss_q_getprinter(&q_o, hnd, level, buffer, offered);
/* turn parameters into data stream */
- if (!spoolss_io_q_getprinter("", &q_o, &buf, 0)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- if(!rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTER, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- ZERO_STRUCT(r_o);
- prs_mem_free(&buf );
-
- prs_switch_type(&buffer->prs, UNMARSHALL);
- prs_set_offset(&buffer->prs, 0);
- r_o.buffer=buffer;
+ if (spoolss_io_q_getprinter("", &q_o, &buf, 0) &&
+ rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTER, &buf, &rbuf))
+ {
+ ZERO_STRUCT(r_o);
+ prs_mem_free(&buf );
- if(!spoolss_io_r_getprinter("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- }
+ prs_switch_type(&buffer->prs, UNMARSHALL);
+ prs_set_offset(&buffer->prs, 0);
+ r_o.buffer=buffer;
- *needed=r_o.needed;
+ if(!spoolss_io_r_getprinter("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_GETPRINTER: %s\n", get_nt_error_msg(r_o.status)));
+ }
+ *needed=r_o.needed;
+ }
+ }
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -429,28 +400,26 @@ uint32 spoolss_getprinterdriver(const POLICY_HND *hnd,
make_spoolss_q_getprinterdriver2(&q_o, hnd, environment, level, 2, 0, buffer, offered);
/* turn parameters into data stream */
- if (!spoolss_io_q_getprinterdriver2("", &q_o, &buf, 0)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- if(!rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTERDRIVER2, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- ZERO_STRUCT(r_o);
- prs_mem_free(&buf );
+ if (spoolss_io_q_getprinterdriver2("", &q_o, &buf, 0) &&
+ rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTERDRIVER2, &buf, &rbuf))
+ {
+ ZERO_STRUCT(r_o);
+ prs_mem_free(&buf );
- prs_switch_type(&buffer->prs, UNMARSHALL);
- prs_set_offset(&buffer->prs, 0);
- r_o.buffer=buffer;
+ prs_switch_type(&buffer->prs, UNMARSHALL);
+ prs_set_offset(&buffer->prs, 0);
+ r_o.buffer=buffer;
- if(!spoolss_io_r_getprinterdriver2("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- }
+ if(spoolss_io_r_getprinterdriver2("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_GETPRINTERDRIVER2: %s\n", get_nt_error_msg(r_o.status)));
+ }
- *needed=r_o.needed;
+ *needed=r_o.needed;
+ }
+ }
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -713,28 +682,26 @@ uint32 spoolss_getprinterdata(const POLICY_HND *hnd, const UNISTR2 *valuename,
make_spoolss_q_getprinterdata(&q_o, hnd, valuename, in_size);
/* turn parameters into data stream */
- if (!spoolss_io_q_getprinterdata("", &q_o, &buf, 0)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- if (!rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTERDATA, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
- }
-
- ZERO_STRUCT(r_o);
- prs_mem_free(&buf );
+ if (spoolss_io_q_getprinterdata("", &q_o, &buf, 0) &&
+ rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTERDATA, &buf, &rbuf))
+ {
+ ZERO_STRUCT(r_o);
+ prs_mem_free(&buf );
- r_o.data=data;
+ r_o.data=data;
- if(!spoolss_io_r_getprinterdata("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- }
+ if(spoolss_io_r_getprinterdata("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_GETPRINTERDATA: %s\n", get_nt_error_msg(r_o.status)));
+ }
- *type=r_o.type;
- *out_size=r_o.size;
- *needed=r_o.needed;
+ *type=r_o.type;
+ *out_size=r_o.size;
+ *needed=r_o.needed;
+ }
+ }
prs_mem_free(&rbuf);
prs_mem_free(&buf );
@@ -772,32 +739,26 @@ uint32 spoolss_getprinterdriverdir(fstring srv_name, fstring env_name, uint32 le
buffer, offered);
/* turn parameters into data stream */
- if (!spoolss_io_q_getprinterdriverdir("", &q_o, &buf, 0) ) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
- }
-
- if(!rpc_con_pipe_req(con, SPOOLSS_GETPRINTERDRIVERDIRECTORY, &buf, &rbuf)) {
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
- }
+ if (spoolss_io_q_getprinterdriverdir("", &q_o, &buf, 0) &&
+ rpc_con_pipe_req(con, SPOOLSS_GETPRINTERDRIVERDIRECTORY, &buf, &rbuf))
+ {
+ prs_mem_free(&buf );
+ ZERO_STRUCT(r_o);
- prs_mem_free(&buf );
- ZERO_STRUCT(r_o);
+ prs_switch_type(&buffer->prs, UNMARSHALL);
+ prs_set_offset(&buffer->prs, 0);
+ r_o.buffer=buffer;
- prs_switch_type(&buffer->prs, UNMARSHALL);
- prs_set_offset(&buffer->prs, 0);
- r_o.buffer=buffer;
+ if(spoolss_io_r_getprinterdriverdir("", &r_o, &rbuf, 0))
+ {
+ if (r_o.status != NT_STATUS_NO_PROBLEMO)
+ {
+ DEBUG(0,("SPOOLSS_GETPRINTERDRIVERDIRECTORY: %s\n", get_nt_error_msg(r_o.status)));
+ }
- if(!spoolss_io_r_getprinterdriverdir("", &r_o, &rbuf, 0)) {
- prs_mem_free(&rbuf);
- cli_connection_unlink(con);
- }
- *needed=r_o.needed;
+ *needed=r_o.needed;
+ }
+ }
prs_mem_free(&rbuf);
prs_mem_free(&buf );