diff options
author | Günther Deschner <gd@samba.org> | 2009-03-09 22:00:47 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-03-13 09:25:23 +0100 |
commit | 9397ae5114acf7e18144a9f700846ba7354a4be2 (patch) | |
tree | 8782e9386bee31f9e5c855ad1694f9a564d78d77 | |
parent | 1b3e068e834fb5d99ca7ae9a1daa9fd401b886d5 (diff) | |
download | samba-9397ae5114acf7e18144a9f700846ba7354a4be2.tar.gz samba-9397ae5114acf7e18144a9f700846ba7354a4be2.tar.bz2 samba-9397ae5114acf7e18144a9f700846ba7354a4be2.zip |
s3-spoolss: add rpccli_spoolss_enumprinters convenience wrapper.
Guenther
-rw-r--r-- | source3/include/proto.h | 8 | ||||
-rw-r--r-- | source3/rpc_client/cli_spoolss.c | 53 |
2 files changed, 61 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 075af413b0..1db9281b16 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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); diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index fa70cd8aad..5467c6d736 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -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 |