s3-spoolss: add rpccli_spoolss_getjob convenience wrapper.
authorGünther Deschner <gd@samba.org>
Thu, 26 Feb 2009 14:33:57 +0000 (15:33 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 26 Feb 2009 21:02:18 +0000 (22:02 +0100)
Guenther

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

index ce316402721b57a3971532bbdfa3256048fc70cf..30024a8cb46e8ce36c946d852f046cda0d63f161 100644 (file)
@@ -5497,6 +5497,13 @@ WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
                                 uint32_t level,
                                 uint32_t offered,
                                 union spoolss_PrinterInfo *info);
+WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
+                            TALLOC_CTX *mem_ctx,
+                            struct policy_handle *handle,
+                            uint32_t job_id,
+                            uint32_t level,
+                            uint32_t offered,
+                            union spoolss_JobInfo *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 4c1d57e063f85253b10bbfd5587ed396c9df0023..8626627308ff29c4b76671f4c086a71032cfecd0 100644 (file)
@@ -228,6 +228,58 @@ WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
        return werror;
 }
 
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_GetJob
+**********************************************************************/
+
+WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
+                            TALLOC_CTX *mem_ctx,
+                            struct policy_handle *handle,
+                            uint32_t job_id,
+                            uint32_t level,
+                            uint32_t offered,
+                            union spoolss_JobInfo *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_GetJob(cli, mem_ctx,
+                                      handle,
+                                      job_id,
+                                      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_GetJob(cli, mem_ctx,
+                                              handle,
+                                              job_id,
+                                              level,
+                                              &buffer,
+                                              offered,
+                                              info,
+                                              &needed,
+                                              &werror);
+       }
+
+       return werror;
+}
+
+
 /*********************************************************************
  Decode various spoolss rpc's and info levels
  ********************************************************************/