diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-17 04:56:59 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-17 04:56:59 +0000 |
commit | d1feb4c6d56b37d045a329fab98857fb36bd42c1 (patch) | |
tree | c2f7b2022f3cda522104769de7b88c9bbe18ec38 /source4/librpc | |
parent | bf48b6e69a638dc78ab119424e27adc0ccc6c610 (diff) | |
download | samba-d1feb4c6d56b37d045a329fab98857fb36bd42c1.tar.gz samba-d1feb4c6d56b37d045a329fab98857fb36bd42c1.tar.bz2 samba-d1feb4c6d56b37d045a329fab98857fb36bd42c1.zip |
call OpenPrinterEx on each printer on the server, and then call
GetPrinter with all info levels on each printer
(This used to be commit 136b3cfc0460315e924c3d9c8328c1850fc21fba)
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/idl/spoolss.idl | 20 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 29 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.c | 23 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.h | 17 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss_buf.c | 6 | ||||
-rw-r--r-- | source4/librpc/rpc/rpc_spoolss.c | 42 |
6 files changed, 72 insertions, 65 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl index be6f9a8f51..7abf3effde 100644 --- a/source4/librpc/idl/spoolss.idl +++ b/source4/librpc/idl/spoolss.idl @@ -115,7 +115,7 @@ case(5) spoolss_PrinterInfo5 info5; case(6) spoolss_PrinterInfo6 info6; case(7) spoolss_PrinterInfo7 info7; - } spoolss_PrinterEnum; + } spoolss_PrinterInfo; WERROR spoolss_EnumPrinters( [in] uint32 flags, @@ -176,13 +176,11 @@ /******************/ /* Function: 0x08 */ - NTSTATUS spoolss_GetPrinter( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,out] uint8_buf *buffer, - [in] uint32 offered, - [out] uint32 needed, - [out] uint32 returned + WERROR spoolss_GetPrinter( + [in,ref] policy_handle *handle, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size ); /******************/ @@ -289,8 +287,8 @@ /******************/ /* Function: 0x1d */ - NTSTATUS spoolss_ClosePrinter( - [in,out,ref] policy_handle *handle + WERROR spoolss_ClosePrinter( + [in,out,ref] policy_handle *handle ); /******************/ @@ -513,7 +511,7 @@ /******************/ /* Function: 0x45 */ - NTSTATUS spoolss_OpenPrinterEx( + WERROR spoolss_OpenPrinterEx( [in] unistr *printername, [in] unistr *datatype, [in] spoolss_DevmodeContainer devmode_ctr, diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 97eee70dfe..5f941c703d 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -533,3 +533,32 @@ NTSTATUS ndr_push_relative(struct ndr_push *ndr, int ndr_flags, const void *p, } return NT_STATUS_OK; } + + +/* + pull a union from a blob using NDR +*/ +NTSTATUS ndr_pull_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, uint16 level, void *p, + NTSTATUS (*fn)(struct ndr_pull *, int ndr_flags, uint16 *, void *)) +{ + struct ndr_pull *ndr; + ndr = ndr_pull_init_blob(blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + return fn(ndr, NDR_SCALARS|NDR_BUFFERS, &level, p); +} + +/* + pull a struct from a blob using NDR +*/ +NTSTATUS ndr_pull_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, + NTSTATUS (*fn)(struct ndr_pull *, int ndr_flags, void *)) +{ + struct ndr_pull *ndr; + ndr = ndr_pull_init_blob(blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + return fn(ndr, NDR_SCALARS|NDR_BUFFERS, p); +} diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index 5b64f9067a..2e2e911311 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -200,7 +200,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_push_spoolss_PrinterEnum(struct ndr_push *ndr, int ndr_flags, uint16 level, union spoolss_PrinterEnum *r) +NTSTATUS ndr_push_spoolss_PrinterInfo(struct ndr_push *ndr, int ndr_flags, uint16 level, union spoolss_PrinterInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_push_struct_start(ndr)); @@ -362,9 +362,9 @@ NTSTATUS ndr_push_spoolss_GetPrinter(struct ndr_push *ndr, struct spoolss_GetPri NDR_CHECK(ndr_push_uint32(ndr, r->in.level)); NDR_CHECK(ndr_push_ptr(ndr, r->in.buffer)); if (r->in.buffer) { - NDR_CHECK(ndr_push_uint8_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, *r->in.buffer)); } - NDR_CHECK(ndr_push_uint32(ndr, r->in.offered)); + NDR_CHECK(ndr_push_uint32(ndr, *r->in.buf_size)); return NT_STATUS_OK; } @@ -1168,7 +1168,7 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_pull_spoolss_PrinterEnum(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union spoolss_PrinterEnum *r) +NTSTATUS ndr_pull_spoolss_PrinterInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union spoolss_PrinterInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_struct_start(ndr)); @@ -1334,11 +1334,10 @@ NTSTATUS ndr_pull_spoolss_GetPrinter(struct ndr_pull *ndr, struct spoolss_GetPri r->out.buffer = NULL; } if (r->out.buffer) { - NDR_CHECK(ndr_pull_uint8_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.buffer)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, r->out.buffer)); } - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.needed)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.returned)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); + NDR_CHECK(ndr_pull_uint32(ndr, r->out.buf_size)); + NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); return NT_STATUS_OK; } @@ -1486,7 +1485,7 @@ NTSTATUS ndr_pull_spoolss_1c(struct ndr_pull *ndr, struct spoolss_1c *r) NTSTATUS ndr_pull_spoolss_ClosePrinter(struct ndr_pull *ndr, struct spoolss_ClosePrinter *r) { NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.handle)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); + NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); return NT_STATUS_OK; } @@ -1767,7 +1766,7 @@ NTSTATUS ndr_pull_spoolss_44(struct ndr_pull *ndr, struct spoolss_44 *r) NTSTATUS ndr_pull_spoolss_OpenPrinterEx(struct ndr_pull *ndr, struct spoolss_OpenPrinterEx *r) { NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.handle)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); + NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); return NT_STATUS_OK; } @@ -2112,9 +2111,9 @@ void ndr_print_spoolss_PrinterInfo7(struct ndr_print *ndr, const char *name, str ndr->depth--; } -void ndr_print_spoolss_PrinterEnum(struct ndr_print *ndr, const char *name, uint16 level, union spoolss_PrinterEnum *r) +void ndr_print_spoolss_PrinterInfo(struct ndr_print *ndr, const char *name, uint16 level, union spoolss_PrinterInfo *r) { - ndr_print_union(ndr, name, level, "spoolss_PrinterEnum"); + ndr_print_union(ndr, name, level, "spoolss_PrinterInfo"); switch (level) { case 1: ndr_print_spoolss_PrinterInfo1(ndr, "info1", &r->info1); diff --git a/source4/librpc/ndr/ndr_spoolss.h b/source4/librpc/ndr/ndr_spoolss.h index 60738b494a..61aac510d9 100644 --- a/source4/librpc/ndr/ndr_spoolss.h +++ b/source4/librpc/ndr/ndr_spoolss.h @@ -96,7 +96,7 @@ struct spoolss_PrinterInfo7 { uint32 action; }; -union spoolss_PrinterEnum { +union spoolss_PrinterInfo { /* [case(1)] */ struct spoolss_PrinterInfo1 info1; /* [case(2)] */ struct spoolss_PrinterInfo2 info2; /* [case(3)] */ struct spoolss_PrinterInfo3 info3; @@ -212,15 +212,14 @@ struct spoolss_GetPrinter { struct { struct policy_handle *handle; uint32 level; - struct uint8_buf *buffer; - uint32 offered; + DATA_BLOB *buffer; + uint32 *buf_size; } in; struct { - struct uint8_buf *buffer; - uint32 needed; - uint32 returned; - NTSTATUS result; + DATA_BLOB *buffer; + uint32 *buf_size; + WERROR result; } out; }; @@ -434,7 +433,7 @@ struct spoolss_ClosePrinter { struct { struct policy_handle *handle; - NTSTATUS result; + WERROR result; } out; }; @@ -864,7 +863,7 @@ struct spoolss_OpenPrinterEx { struct { struct policy_handle *handle; - NTSTATUS result; + WERROR result; } out; }; diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c index c53a691417..c06d6704b2 100644 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ b/source4/librpc/ndr/ndr_spoolss_buf.c @@ -24,9 +24,9 @@ #include "includes.h" -NTSTATUS pull_spoolss_PrinterEnumArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, +NTSTATUS pull_spoolss_PrinterInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, uint16 level, uint32 count, - union spoolss_PrinterEnum **info) + union spoolss_PrinterInfo **info) { int i; struct ndr_pull *ndr; @@ -36,7 +36,7 @@ NTSTATUS pull_spoolss_PrinterEnumArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, } NDR_ALLOC_N(ndr, *info, count); for (i=0;i<count;i++) { - NDR_CHECK(ndr_pull_spoolss_PrinterEnum(ndr, NDR_SCALARS|NDR_BUFFERS, &level, &(*info)[i])); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &level, &(*info)[i])); } return NT_STATUS_OK; } diff --git a/source4/librpc/rpc/rpc_spoolss.c b/source4/librpc/rpc/rpc_spoolss.c index e2d3a1ae35..026798df70 100644 --- a/source4/librpc/rpc/rpc_spoolss.c +++ b/source4/librpc/rpc/rpc_spoolss.c @@ -105,16 +105,10 @@ NTSTATUS dcerpc_spoolss_07(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct sp NTSTATUS dcerpc_spoolss_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinter *r) { - NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SPOOLSS_GETPRINTER, mem_ctx, - (ndr_push_fn_t) ndr_push_spoolss_GetPrinter, - (ndr_pull_fn_t) ndr_pull_spoolss_GetPrinter, - r); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return r->out.result; + return dcerpc_ndr_request(p, DCERPC_SPOOLSS_GETPRINTER, mem_ctx, + (ndr_push_fn_t) ndr_push_spoolss_GetPrinter, + (ndr_pull_fn_t) ndr_pull_spoolss_GetPrinter, + r); } NTSTATUS dcerpc_spoolss_09(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_09 *r) @@ -399,16 +393,10 @@ NTSTATUS dcerpc_spoolss_1c(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct sp NTSTATUS dcerpc_spoolss_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ClosePrinter *r) { - NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SPOOLSS_CLOSEPRINTER, mem_ctx, - (ndr_push_fn_t) ndr_push_spoolss_ClosePrinter, - (ndr_pull_fn_t) ndr_pull_spoolss_ClosePrinter, - r); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return r->out.result; + return dcerpc_ndr_request(p, DCERPC_SPOOLSS_CLOSEPRINTER, mem_ctx, + (ndr_push_fn_t) ndr_push_spoolss_ClosePrinter, + (ndr_pull_fn_t) ndr_pull_spoolss_ClosePrinter, + r); } NTSTATUS dcerpc_spoolss_1e(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_1e *r) @@ -959,16 +947,10 @@ NTSTATUS dcerpc_spoolss_44(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct sp NTSTATUS dcerpc_spoolss_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r) { - NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SPOOLSS_OPENPRINTEREX, mem_ctx, - (ndr_push_fn_t) ndr_push_spoolss_OpenPrinterEx, - (ndr_pull_fn_t) ndr_pull_spoolss_OpenPrinterEx, - r); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - return r->out.result; + return dcerpc_ndr_request(p, DCERPC_SPOOLSS_OPENPRINTEREX, mem_ctx, + (ndr_push_fn_t) ndr_push_spoolss_OpenPrinterEx, + (ndr_pull_fn_t) ndr_pull_spoolss_OpenPrinterEx, + r); } NTSTATUS dcerpc_spoolss_46(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_46 *r) |