s3-spoolss: add rpccli_spoolss_getprinterdriver2 convenience wrapper.
authorGünther Deschner <gd@samba.org>
Tue, 24 Feb 2009 21:18:22 +0000 (22:18 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 24 Feb 2009 21:40:51 +0000 (22:40 +0100)
Guenther

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

index daeef637cafc7a8f7e29da2c6c73b058d32e764e..b41a40565583e75e0d68e907774e8050fbc163ff 100644 (file)
@@ -5465,6 +5465,17 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
                                     const char *printername,
                                     uint32_t access_desired,
                                     struct policy_handle *handle);
+WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct policy_handle *handle,
+                                       const char *architecture,
+                                       uint32_t level,
+                                       uint32_t offered,
+                                       uint32_t client_major_version,
+                                       uint32_t client_minor_version,
+                                       union spoolss_DriverInfo *info,
+                                       uint32_t *server_major_version,
+                                       uint32_t *server_minor_version);
 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 6ad3af1f4ed0a4dfdd4edf98d06bdf384bfa8720..b8f17416cc020f7969e64c9bc9819d062cfd3409 100644 (file)
@@ -75,6 +75,68 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
        return WERR_OK;
 }
 
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_GetPrinterDriver2
+**********************************************************************/
+
+WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct policy_handle *handle,
+                                       const char *architecture,
+                                       uint32_t level,
+                                       uint32_t offered,
+                                       uint32_t client_major_version,
+                                       uint32_t client_minor_version,
+                                       union spoolss_DriverInfo *info,
+                                       uint32_t *server_major_version,
+                                       uint32_t *server_minor_version)
+{
+       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_GetPrinterDriver2(cli, mem_ctx,
+                                                 handle,
+                                                 architecture,
+                                                 level,
+                                                 (offered > 0) ? &buffer : NULL,
+                                                 offered,
+                                                 client_major_version,
+                                                 client_minor_version,
+                                                 info,
+                                                 &needed,
+                                                 server_major_version,
+                                                 server_minor_version,
+                                                 &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_GetPrinterDriver2(cli, mem_ctx,
+                                                         handle,
+                                                         architecture,
+                                                         level,
+                                                         &buffer,
+                                                         offered,
+                                                         client_major_version,
+                                                         client_minor_version,
+                                                         info,
+                                                         &needed,
+                                                         server_major_version,
+                                                         server_minor_version,
+                                                         &werror);
+       }
+
+       return werror;
+}
+
 /*********************************************************************
  Decode various spoolss rpc's and info levels
  ********************************************************************/