summaryrefslogtreecommitdiff
path: root/source3/rpc_client/cli_spoolss.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-06 19:52:04 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-06 19:52:04 +0000
commit0f18ca772da544a93799ca130a8f23529aad98f6 (patch)
tree4c66087d1b64dcd216c0958298461621a1bb49a8 /source3/rpc_client/cli_spoolss.c
parentbd6467154e73412753c22022b1615cf471bfa297 (diff)
downloadsamba-0f18ca772da544a93799ca130a8f23529aad98f6.tar.gz
samba-0f18ca772da544a93799ca130a8f23529aad98f6.tar.bz2
samba-0f18ca772da544a93799ca130a8f23529aad98f6.zip
added rpcclient spoolenum command. enumerates printers.
spoolss_r_io_enumprinters doesn't decode strings correctly as printer_info_1/2 code has only been written to write structures, not read them. (This used to be commit 135eaa977385cdd5f572a51f654f14d893347d7b)
Diffstat (limited to 'source3/rpc_client/cli_spoolss.c')
-rw-r--r--source3/rpc_client/cli_spoolss.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index adb850673f..9d8d5f5736 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -33,6 +33,70 @@ extern int DEBUGLEVEL;
/****************************************************************************
+do a SPOOLSS Enum Printers
+****************************************************************************/
+BOOL spoolss_enum_printers(struct cli_state *cli, uint16 fnum,
+ uint32 flags, char *servername,
+ uint32 level,
+ uint32 *count,
+ void ***printers)
+{
+ prs_struct rbuf;
+ prs_struct buf;
+ SPOOL_Q_ENUMPRINTERS q_o;
+ BOOL valid_pol = False;
+
+ if (count == NULL || printers == NULL) return False;
+
+ prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
+
+ /* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
+
+ DEBUG(5,("SPOOLSS Enum Printers (Server: %s level: %d)\n",
+ servername, level));
+
+ make_spoolss_q_enumprinters(&q_o, flags, servername, level, 0x200);
+
+ /* turn parameters into data stream */
+ spoolss_io_q_enumprinters("", &q_o, &buf, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, fnum, SPOOLSS_ENUMPRINTERS, &buf, &rbuf))
+ {
+ SPOOL_R_ENUMPRINTERS r_o;
+ BOOL p;
+
+ ZERO_STRUCT(r_o);
+
+ r_o.level = level;
+
+ spoolss_io_r_enumprinters("", &r_o, &rbuf, 0);
+ p = rbuf.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(5,("SPOOLSS_ENUM_PRINTERS: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ /* ok, at last: we're happy. return the policy handle */
+ (*count) = r_o.returned;
+ (*printers) = r_o.printer.info;
+ valid_pol = True;
+ }
+ }
+
+ prs_mem_free(&rbuf);
+ prs_mem_free(&buf );
+
+ return valid_pol;
+}
+
+/****************************************************************************
do a SPOOLSS Open Printer Ex
****************************************************************************/
BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,