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

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

index f7ca81d60db08d3f8c2332d5c2750e70917f4289..8cefefaf11bcf8a6e1cb634df4f1fdd6e1ee2c11 100644 (file)
@@ -5481,6 +5481,14 @@ WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
                                uint32_t offered,
                                uint32_t *count,
                                union spoolss_FormInfo **info);
+WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli,
+                                         TALLOC_CTX *mem_ctx,
+                                         const char *servername,
+                                         const char *environment,
+                                         uint32_t level,
+                                         uint32_t offered,
+                                         uint32_t *count,
+                                         union spoolss_PrintProcessorInfo **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 5e09787a9cb4b7102eefadc01bf287b0c900cb8e..664220ac19cf1642ab50ad5bd954d03d2a123643 100644 (file)
@@ -330,6 +330,59 @@ WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
        return werror;
 }
 
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumPrintProcessors
+**********************************************************************/
+
+WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli,
+                                         TALLOC_CTX *mem_ctx,
+                                         const char *servername,
+                                         const char *environment,
+                                         uint32_t level,
+                                         uint32_t offered,
+                                         uint32_t *count,
+                                         union spoolss_PrintProcessorInfo **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_EnumPrintProcessors(cli, mem_ctx,
+                                                   servername,
+                                                   environment,
+                                                   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_EnumPrintProcessors(cli, mem_ctx,
+                                                           servername,
+                                                           environment,
+                                                           level,
+                                                           (offered > 0) ? &buffer : NULL,
+                                                           offered,
+                                                           count,
+                                                           info,
+                                                           &needed,
+                                                           &werror);
+       }
+
+       return werror;
+}
 
 /*********************************************************************
  Decode various spoolss rpc's and info levels