diff options
author | Günther Deschner <gd@samba.org> | 2009-07-03 10:10:53 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-07-03 22:05:10 +0200 |
commit | 80b62f579fdf9975c718a75c6d8e623e30578139 (patch) | |
tree | f90928ab82704c93628f61c860401b6b1db6f4f2 | |
parent | e9fc7c5e15ed87710be8f981b969ef411de25918 (diff) | |
download | samba-80b62f579fdf9975c718a75c6d8e623e30578139.tar.gz samba-80b62f579fdf9975c718a75c6d8e623e30578139.tar.bz2 samba-80b62f579fdf9975c718a75c6d8e623e30578139.zip |
spoolss: fill in spoolss_AddPrinter IDL.
Guenther
-rw-r--r-- | librpc/gen_ndr/cli_spoolss.c | 10 | ||||
-rw-r--r-- | librpc/gen_ndr/cli_spoolss.h | 5 | ||||
-rw-r--r-- | librpc/gen_ndr/ndr_spoolss.c | 101 | ||||
-rw-r--r-- | librpc/gen_ndr/spoolss.h | 8 | ||||
-rw-r--r-- | librpc/gen_ndr/srv_spoolss.c | 13 | ||||
-rw-r--r-- | librpc/idl/spoolss.idl | 9 |
6 files changed, 143 insertions, 3 deletions
diff --git a/librpc/gen_ndr/cli_spoolss.c b/librpc/gen_ndr/cli_spoolss.c index 1e94a2a63c..a89c4bb422 100644 --- a/librpc/gen_ndr/cli_spoolss.c +++ b/librpc/gen_ndr/cli_spoolss.c @@ -281,12 +281,21 @@ NTSTATUS rpccli_spoolss_EnumJobs(struct rpc_pipe_client *cli, NTSTATUS rpccli_spoolss_AddPrinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + struct spoolss_SetPrinterInfoCtr *info_ctr /* [in] [ref] */, + struct spoolss_DevmodeContainer *devmode_ctr /* [in] [ref] */, + struct sec_desc_buf *secdesc_ctr /* [in] [ref] */, + struct policy_handle *handle /* [out] [ref] */, WERROR *werror) { struct spoolss_AddPrinter r; NTSTATUS status; /* In parameters */ + r.in.server = server; + r.in.info_ctr = info_ctr; + r.in.devmode_ctr = devmode_ctr; + r.in.secdesc_ctr = secdesc_ctr; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(spoolss_AddPrinter, &r); @@ -311,6 +320,7 @@ NTSTATUS rpccli_spoolss_AddPrinter(struct rpc_pipe_client *cli, } /* Return variables */ + *handle = *r.out.handle; /* Return result */ if (werror) { diff --git a/librpc/gen_ndr/cli_spoolss.h b/librpc/gen_ndr/cli_spoolss.h index eb86e8c6a0..14e818cc54 100644 --- a/librpc/gen_ndr/cli_spoolss.h +++ b/librpc/gen_ndr/cli_spoolss.h @@ -51,6 +51,11 @@ NTSTATUS rpccli_spoolss_EnumJobs(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_spoolss_AddPrinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + struct spoolss_SetPrinterInfoCtr *info_ctr /* [in] [ref] */, + struct spoolss_DevmodeContainer *devmode_ctr /* [in] [ref] */, + struct sec_desc_buf *secdesc_ctr /* [in] [ref] */, + struct policy_handle *handle /* [out] [ref] */, WERROR *werror); NTSTATUS rpccli_spoolss_DeletePrinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/librpc/gen_ndr/ndr_spoolss.c b/librpc/gen_ndr/ndr_spoolss.c index fca622865f..d7d5e354a2 100644 --- a/librpc/gen_ndr/ndr_spoolss.c +++ b/librpc/gen_ndr/ndr_spoolss.c @@ -19593,8 +19593,31 @@ _PUBLIC_ void ndr_print_spoolss_EnumJobs(struct ndr_print *ndr, const char *name static enum ndr_err_code ndr_push_spoolss_AddPrinter(struct ndr_push *ndr, int flags, const struct spoolss_AddPrinter *r) { if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); + if (r->in.server) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server, ndr_charset_length(r->in.server, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->in.info_ctr == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_spoolss_SetPrinterInfoCtr(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info_ctr)); + if (r->in.devmode_ctr == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.devmode_ctr)); + if (r->in.secdesc_ctr == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.secdesc_ctr)); } if (flags & NDR_OUT) { + if (r->out.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -19602,9 +19625,65 @@ static enum ndr_err_code ndr_push_spoolss_AddPrinter(struct ndr_push *ndr, int f static enum ndr_err_code ndr_pull_spoolss_AddPrinter(struct ndr_pull *ndr, int flags, struct spoolss_AddPrinter *r) { + uint32_t _ptr_server; + TALLOC_CTX *_mem_save_server_0; + TALLOC_CTX *_mem_save_info_ctr_0; + TALLOC_CTX *_mem_save_devmode_ctr_0; + TALLOC_CTX *_mem_save_secdesc_ctr_0; + TALLOC_CTX *_mem_save_handle_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server)); + if (_ptr_server) { + NDR_PULL_ALLOC(ndr, r->in.server); + } else { + r->in.server = NULL; + } + if (r->in.server) { + _mem_save_server_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.server, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server)); + if (ndr_get_array_length(ndr, &r->in.server) > ndr_get_array_size(ndr, &r->in.server)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server), ndr_get_array_length(ndr, &r->in.server)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_0, 0); + } + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info_ctr); + } + _mem_save_info_ctr_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info_ctr, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_spoolss_SetPrinterInfoCtr(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info_ctr)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_ctr_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.devmode_ctr); + } + _mem_save_devmode_ctr_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.devmode_ctr, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.devmode_ctr)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_ctr_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.secdesc_ctr); + } + _mem_save_secdesc_ctr_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.secdesc_ctr, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.secdesc_ctr)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_secdesc_ctr_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.handle); + ZERO_STRUCTP(r->out.handle); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -19620,11 +19699,33 @@ _PUBLIC_ void ndr_print_spoolss_AddPrinter(struct ndr_print *ndr, const char *na if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "spoolss_AddPrinter"); ndr->depth++; + ndr_print_ptr(ndr, "server", r->in.server); + ndr->depth++; + if (r->in.server) { + ndr_print_string(ndr, "server", r->in.server); + } + ndr->depth--; + ndr_print_ptr(ndr, "info_ctr", r->in.info_ctr); + ndr->depth++; + ndr_print_spoolss_SetPrinterInfoCtr(ndr, "info_ctr", r->in.info_ctr); + ndr->depth--; + ndr_print_ptr(ndr, "devmode_ctr", r->in.devmode_ctr); + ndr->depth++; + ndr_print_spoolss_DevmodeContainer(ndr, "devmode_ctr", r->in.devmode_ctr); + ndr->depth--; + ndr_print_ptr(ndr, "secdesc_ctr", r->in.secdesc_ctr); + ndr->depth++; + ndr_print_sec_desc_buf(ndr, "secdesc_ctr", r->in.secdesc_ctr); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "spoolss_AddPrinter"); ndr->depth++; + ndr_print_ptr(ndr, "handle", r->out.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->out.handle); + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/librpc/gen_ndr/spoolss.h b/librpc/gen_ndr/spoolss.h index 95734602d4..6bc5cd7d02 100644 --- a/librpc/gen_ndr/spoolss.h +++ b/librpc/gen_ndr/spoolss.h @@ -1786,6 +1786,14 @@ struct spoolss_EnumJobs { struct spoolss_AddPrinter { struct { + const char *server;/* [unique,charset(UTF16)] */ + struct spoolss_SetPrinterInfoCtr *info_ctr;/* [ref] */ + struct spoolss_DevmodeContainer *devmode_ctr;/* [ref] */ + struct sec_desc_buf *secdesc_ctr;/* [ref] */ + } in; + + struct { + struct policy_handle *handle;/* [ref] */ WERROR result; } out; diff --git a/librpc/gen_ndr/srv_spoolss.c b/librpc/gen_ndr/srv_spoolss.c index 79efbb5970..764c805397 100644 --- a/librpc/gen_ndr/srv_spoolss.c +++ b/librpc/gen_ndr/srv_spoolss.c @@ -467,6 +467,13 @@ static bool api_spoolss_AddPrinter(pipes_struct *p) NDR_PRINT_IN_DEBUG(spoolss_AddPrinter, r); } + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(r, struct policy_handle); + if (r->out.handle == NULL) { + talloc_free(r); + return false; + } + r->out.result = _spoolss_AddPrinter(p, r); if (p->rng_fault_state) { @@ -7649,6 +7656,12 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, case NDR_SPOOLSS_ADDPRINTER: { struct spoolss_AddPrinter *r = (struct spoolss_AddPrinter *)_r; + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(mem_ctx, struct policy_handle); + if (r->out.handle == NULL) { + return NT_STATUS_NO_MEMORY; + } + r->out.result = _spoolss_AddPrinter(cli->pipes_struct, r); return NT_STATUS_OK; } diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index 7dad7c92de..91a7cf0d04 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -629,9 +629,12 @@ import "misc.idl", "security.idl", "winreg.idl"; /******************/ /* Function: 0x05 */ - [todo] WERROR spoolss_AddPrinter( - /* This function is not implemented in Samba 3 as no - clients have been observed using it. */ + WERROR spoolss_AddPrinter( + [in,unique] [string,charset(UTF16)] uint16 *server, + [in,ref] spoolss_SetPrinterInfoCtr *info_ctr, + [in,ref] spoolss_DevmodeContainer *devmode_ctr, + [in,ref] sec_desc_buf *secdesc_ctr, + [out,ref] policy_handle *handle ); /******************/ |