s3-spoolss: add rpccli_spoolss_getprinterdriver convenience wrapper.
authorGünther Deschner <gd@samba.org>
Fri, 3 Jul 2009 16:39:58 +0000 (18:39 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 3 Jul 2009 20:05:46 +0000 (22:05 +0200)
Guenther

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

index 2b290116e428e956304f164d85334abef72ba067..7f4907cd9674df9702646f8e672d236d5db19bf6 100644 (file)
@@ -5433,6 +5433,13 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
                                     const char *printername,
                                     uint32_t access_desired,
                                     struct policy_handle *handle);
+WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
+                                      TALLOC_CTX *mem_ctx,
+                                      struct policy_handle *handle,
+                                      const char *architecture,
+                                      uint32_t level,
+                                      uint32_t offered,
+                                      union spoolss_DriverInfo *info);
 WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
                                        TALLOC_CTX *mem_ctx,
                                        struct policy_handle *handle,
index 3f369bdab3c2de92f97d5599076d627427474a51..02a0e168cb63518c840407acfe698d364146684b 100644 (file)
@@ -75,6 +75,56 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
        return WERR_OK;
 }
 
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_GetPrinterDriver
+**********************************************************************/
+
+WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
+                                      TALLOC_CTX *mem_ctx,
+                                      struct policy_handle *handle,
+                                      const char *architecture,
+                                      uint32_t level,
+                                      uint32_t offered,
+                                      union spoolss_DriverInfo *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_GetPrinterDriver(cli, mem_ctx,
+                                                handle,
+                                                architecture,
+                                                level,
+                                                (offered > 0) ? &buffer : NULL,
+                                                offered,
+                                                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_GetPrinterDriver(cli, mem_ctx,
+                                                        handle,
+                                                        architecture,
+                                                        level,
+                                                        &buffer,
+                                                        offered,
+                                                        info,
+                                                        &needed,
+                                                        &werror);
+       }
+
+       return werror;
+}
+
 /**********************************************************************
  convencience wrapper around rpccli_spoolss_GetPrinterDriver2
 **********************************************************************/