s3-spoolss: add rpccli_spoolss_enumprinters convenience wrapper.
authorGünther Deschner <gd@samba.org>
Mon, 9 Mar 2009 21:00:47 +0000 (22:00 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 13 Mar 2009 08:25:23 +0000 (09:25 +0100)
Guenther

source3/include/proto.h
source3/rpc_client/cli_spoolss.c

index 075af413b08b3f116df8ac156ee3d6d0f9050a86..1db9281b164cf52fe42b4b552a430d8274737418 100644 (file)
@@ -5523,6 +5523,14 @@ WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
                                         uint32_t offered,
                                         uint32_t *count,
                                         union spoolss_DriverInfo **info);
+WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
+                                  TALLOC_CTX *mem_ctx,
+                                  uint32_t flags,
+                                  const char *server,
+                                  uint32_t level,
+                                  uint32_t offered,
+                                  uint32_t *count,
+                                  union spoolss_PrinterInfo **info);
 WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
                                 char *name, uint32 flags, uint32 level,
                                 uint32 *num_printers, PRINTER_INFO_CTR *ctr);
index fa70cd8aadddb7e46572b00832c3d99531f356b9..5467c6d7360b642d749b40990a2cbe93adfc4e86 100644 (file)
@@ -651,6 +651,59 @@ WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
        return werror;
 }
 
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumPrinters
+**********************************************************************/
+
+WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
+                                  TALLOC_CTX *mem_ctx,
+                                  uint32_t flags,
+                                  const char *server,
+                                  uint32_t level,
+                                  uint32_t offered,
+                                  uint32_t *count,
+                                  union spoolss_PrinterInfo **info)
+{
+       NTSTATUS status;
+       WERROR werror;
+       uint32_t needed;
+       DATA_BLOB buffer;
+
+       if (offered > 0) {
+               buffer = data_blob_talloc_zero(mem_ctx, offered);
+               W_ERROR_HAVE_NO_MEMORY(buffer.data);
+       }
+
+       status = rpccli_spoolss_EnumPrinters(cli, mem_ctx,
+                                            flags,
+                                            server,
+                                            level,
+                                            (offered > 0) ? &buffer : NULL,
+                                            offered,
+                                            count,
+                                            info,
+                                            &needed,
+                                            &werror);
+
+       if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
+               offered = needed;
+               buffer = data_blob_talloc_zero(mem_ctx, needed);
+               W_ERROR_HAVE_NO_MEMORY(buffer.data);
+
+               status = rpccli_spoolss_EnumPrinters(cli, mem_ctx,
+                                                    flags,
+                                                    server,
+                                                    level,
+                                                    (offered > 0) ? &buffer : NULL,
+                                                    offered,
+                                                    count,
+                                                    info,
+                                                    &needed,
+                                                    &werror);
+       }
+
+       return werror;
+}
 
 /*********************************************************************
  Decode various spoolss rpc's and info levels