diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-05-30 22:44:17 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:17:19 -0500 |
commit | 62480f12529326d174d2c53376765e88ca03754f (patch) | |
tree | c6e81592ee390fa7c597f5838a548a12fa392c11 /source4 | |
parent | 46e5fda0ad956c1b6524d89b9317b8ad35043c69 (diff) | |
download | samba-62480f12529326d174d2c53376765e88ca03754f.tar.gz samba-62480f12529326d174d2c53376765e88ca03754f.tar.bz2 samba-62480f12529326d174d2c53376765e88ca03754f.zip |
r7120: make use of the new 'noopnum' property and get rid of handwritten
parsing code for the spoolss_Enum* functions, there still same handwritten code needed
but just to stack the autogenerated code into the correct way
metze
(This used to be commit 155d18e8b78afebfb4a84e43e3b4d8fc6c9cc4e2)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/librpc/idl/spoolss.idl | 130 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss_buf.c | 1029 | ||||
-rw-r--r-- | source4/rpc_server/spoolss/dcesrv_spoolss.c | 26 | ||||
-rw-r--r-- | source4/torture/rpc/spoolss.c | 36 |
4 files changed, 297 insertions, 924 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl index e496b2b5c6..f3c7e553cc 100644 --- a/source4/librpc/idl/spoolss.idl +++ b/source4/librpc/idl/spoolss.idl @@ -249,13 +249,29 @@ /******************/ /* Function: 0x00 */ - [noprint,nopull,nopush] WERROR spoolss_EnumPrinters( + /* we are using this as internal parsing code */ + [public,noopnum,noprint] WERROR _spoolss_EnumPrinters( + [in] spoolss_EnumPrinterFlags flags, + [in] unistr *server, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count + ); + [public,noopnum,noprint] void __spoolss_EnumPrinters( + [in] uint32 level, + [in] uint32 count, + [out,subcontext(0),switch_is(level)] spoolss_PrinterInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumPrinters( [in] spoolss_EnumPrinterFlags flags, [in] unistr *server, [in] uint32 level, [in] DATA_BLOB *buffer, - /* [out,subcontext(4),switch_is(level)] spoolss_PrinterInfo *info[count],*/ - [out,subcontext(4),switch_is(level)] spoolss_PrinterInfo **info, + /* what we have here is a subcontext containing an array of no discriminant unions + * and the array has no size in front + */ + [out,switch_is(level),size_is(count)] spoolss_PrinterInfo *info, [in,out,ref] uint32 *buf_size, [out] uint32 count ); @@ -324,14 +340,27 @@ /******************/ /* Function: 0x04 */ - [noprint,nopull,nopush] WERROR spoolss_EnumJobs( + [public,noopnum,noprint] WERROR _spoolss_EnumJobs( + [in,ref] policy_handle *handle, + [in] uint32 firstjob, + [in] uint32 numjobs, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count + ); + [public,noopnum,noprint] void __spoolss_EnumJobs( + [in] uint32 level, + [in] uint32 count, + [out,subcontext(0),switch_is(level)] spoolss_JobInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumJobs( [in,ref] policy_handle *handle, [in] uint32 firstjob, [in] uint32 numjobs, [in] uint32 level, [in] DATA_BLOB *buffer, - /* [out,subcontext(4),switch_is(level)] spoolss_JobInfo *info[count],*/ - [out,subcontext(4),switch_is(level)] spoolss_JobInfo **info, + [out,switch_is(level),size_is(count)] spoolss_JobInfo *info, [in,out,ref] uint32 *buf_size, [out] uint32 count ); @@ -473,13 +502,25 @@ /******************/ /* Function: 0x0a */ - [noprint,nopull,nopush] WERROR spoolss_EnumPrinterDrivers( + [public,noopnum,noprint] WERROR _spoolss_EnumPrinterDrivers( + [in] unistr *server, + [in] unistr *environment, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count + ); + [public,noopnum,noprint] void __spoolss_EnumPrinterDrivers( + [in] uint32 level, + [in] uint32 count, + [out,subcontext(0),switch_is(level)] spoolss_DriverInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumPrinterDrivers( [in] unistr *server, [in] unistr *environment, [in] uint32 level, [in] DATA_BLOB *buffer, - /* [out,subcontext(4),switch_is(level)] spoolss_DriverInfo *info[count],*/ - [out,subcontext(4),switch_is(level)] spoolss_DriverInfo **info, + [out,switch_is(level),size_is(count)] spoolss_DriverInfo *info, [in,out,ref] uint32 *buf_size, [out] uint32 count ); @@ -519,14 +560,25 @@ [default]; } spoolss_PrintProcessorInfo; - [noprint,nopull,nopush] WERROR spoolss_EnumPrintProcessors( + [public,noopnum,noprint] WERROR _spoolss_EnumPrintProcessors( + [in] unistr *servername, + [in] unistr *environment, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count + ); + [public,noopnum,noprint] void __spoolss_EnumPrintProcessors( + [in] uint32 level, + [in] uint32 count, + [out,subcontext(0),switch_is(level)] spoolss_PrintProcessorInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumPrintProcessors( [in] unistr *servername, [in] unistr *environment, [in] uint32 level, [in] DATA_BLOB *buffer, - /* [out,subcontext(4),switch_is(level)] spoolss_PrintProcessorInfo *info[count],*/ - [out,subcontext(4),switch_is(level)] spoolss_PrintProcessorInfo **info, - /* [out,subcontext(4),flag(NDR_REMAINING)] DATA_BLOB *info,*/ + [out,switch_is(level),size_is(count)] spoolss_PrintProcessorInfo *info, [in,out,ref] uint32 *buf_size, [out] uint32 count ); @@ -718,12 +770,23 @@ /******************/ /* Function: 0x22 */ - [noprint,nopull,nopush] WERROR spoolss_EnumForms( + [public,noopnum,noprint] WERROR _spoolss_EnumForms( + [in,ref] policy_handle *handle, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count + ); + [public,noopnum,noprint] void __spoolss_EnumForms( + [in] uint32 level, + [in] uint32 count, + [out,subcontext(0),switch_is(level)] spoolss_FormInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumForms( [in,ref] policy_handle *handle, [in] uint32 level, [in] DATA_BLOB *buffer, - /* [out,subcontext(4),switch_is(level)] spoolss_FormInfo *info[count],*/ - [out,subcontext(4),switch_is(level)] spoolss_FormInfo **info, + [out,switch_is(level),size_is(count)] spoolss_FormInfo *info, [in,out,ref] uint32 *buf_size, [out] uint32 count ); @@ -756,12 +819,23 @@ /******************/ /* Function: 0x23 */ - [noprint,nopull,nopush] WERROR spoolss_EnumPorts( + [public,noopnum,noprint] WERROR _spoolss_EnumPorts( + [in] unistr *servername, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count + ); + [public,noopnum,noprint] void __spoolss_EnumPorts( + [in] uint32 level, + [in] uint32 count, + [out,subcontext(0),switch_is(level)] spoolss_PortInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumPorts( [in] unistr *servername, [in] uint32 level, [in] DATA_BLOB *buffer, - /* [out,subcontext(4),switch_is(level)] spoolss_PortInfo *info[count], */ - [out,subcontext(4),switch_is(level)] spoolss_PortInfo **info, + [out,switch_is(level),size_is(count)] spoolss_PortInfo *info, [in,out,ref] uint32 *buf_size, [out] uint32 count ); @@ -784,13 +858,23 @@ [default]; } spoolss_MonitorInfo; - [noprint,nopull,nopush] WERROR spoolss_EnumMonitors( + [public,noopnum,noprint] WERROR _spoolss_EnumMonitors( + [in] unistr *servername, + [in] uint32 level, + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count + ); + [public,noopnum,noprint] void __spoolss_EnumMonitors( + [in] uint32 level, + [in] uint32 count, + [out,subcontext(0),switch_is(level)] spoolss_MonitorInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumMonitors( [in] unistr *servername, [in] uint32 level, [in] DATA_BLOB *buffer, - /* [out,subcontext(4),switch_is(level)] spoolss_MonitorInfo *info[count], */ - [out,subcontext(4),switch_is(level)] spoolss_MonitorInfo **info, - /* [out,subcontext(4),flag(NDR_REMAINING)] DATA_BLOB *info,*/ + [out,switch_is(level),size_is(count)] spoolss_MonitorInfo *info, [in,out,ref] uint32 *buf_size, [out] uint32 count ); diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c index de4a87547d..2ea9f95d45 100644 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ b/source4/librpc/ndr/ndr_spoolss_buf.c @@ -25,116 +25,90 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_spoolss.h" -#define NDR_SPOOLSS_PUSH_ENUM_OUT(fn,type) do { \ - DATA_BLOB buffer;\ - if (r->out.info) {\ - int i;\ - size_t size;\ - uint8_t *data;\ - struct ndr_push *ndr2;\ -\ - ndr2 = ndr_push_init_ctx(ndr);\ - if (!ndr2) {\ - return NT_STATUS_NO_MEMORY;\ - }\ -\ - size = ndr2->offset;\ - data = ndr2->data;\ -\ - for (i=0;i<r->out.count;i++) {\ - ndr2->data += ndr2->offset;\ - ndr2->offset = 0;\ - NDR_CHECK(ndr_push_set_switch_value(ndr2, &(*r->out.info)[i], r->in.level)); \ - NDR_CHECK(ndr_push_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, &(*r->out.info)[i]));\ - size += ndr2->offset;\ - }\ - if (*r->in.buf_size >= size) {\ - buffer = data_blob_const(data, size);\ - } else {\ - r->out.info = NULL;\ - r->out.count = 0;\ - r->out.result = WERR_INSUFFICIENT_BUFFER;\ - }\ - *r->out.buf_size = size;\ - }\ - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info));\ - if (r->out.info) {\ - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, buffer));\ - }\ - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.buf_size));\ - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.count));\ - NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result));\ +#define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \ + _r.in.level = r->in.level;\ + _r.in.buffer = r->in.buffer;\ + _r.in.buf_size = r->in.buf_size;\ + NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ } while(0) -#define NDR_SPOOLSS_PULL_ENUM_OUT(fn,type) do { \ - int i;\ - DATA_BLOB buffer;\ - struct ndr_pull *ndr2;\ -\ - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_info));\ - if (_ptr_info) {\ - NDR_ALLOC(ndr, r->out.info);\ - } else {\ - r->out.info = NULL;\ - }\ +#define NDR_SPOOLSS_PUSH_ENUM_OUT(fn) do { \ + struct ndr_push *_ndr_info;\ + _r.in.level = r->in.level;\ + _r.in.buffer = r->in.buffer;\ + _r.in.buf_size = r->in.buf_size;\ + _r.out.buffer = NULL;\ + _r.out.buf_size = r->out.buf_size;\ + _r.out.count = r->out.count;\ + _r.out.result = r->out.result;\ if (r->out.info) {\ - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, &buffer));\ - *r->out.info = NULL;\ + struct __##fn __r;\ + DATA_BLOB _data_blob_info;\ + _ndr_info = ndr_push_init_ctx(ndr);\ + if (!_ndr_info) return NT_STATUS_NO_MEMORY;\ + __r.in.level = r->in.level;\ + __r.in.count = r->out.count;\ + __r.out.info = r->out.info;\ + NDR_CHECK(ndr_push___##fn(_ndr_info, flags, &__r)); \ + _data_blob_info = ndr_push_blob(_ndr_info);\ + _r.out.buffer = &_data_blob_info;\ }\ - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {\ - NDR_ALLOC(ndr, r->out.buf_size);\ + NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ +} while(0) + +#define NDR_SPOOLSS_PUSH_ENUM(fn,in,out) do { \ + struct _##fn _r;\ + if (flags & NDR_IN) {\ + in;\ + NDR_SPOOLSS_PUSH_ENUM_IN(fn);\ }\ - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.buf_size));\ - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.count));\ - NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result));\ -\ - if (r->out.info == NULL && r->out.count) {\ - return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE,\ - #fn ": r->out.count[%d] but r->out.info == NULL\n",\ - r->out.count);\ + if (flags & NDR_OUT) {\ + out;\ + NDR_SPOOLSS_PUSH_ENUM_OUT(fn);\ }\ -\ - if (r->out.info && r->out.count) {\ - ndr2 = ndr_pull_init_blob(&buffer, ndr);\ - if (!ndr2) return NT_STATUS_NO_MEMORY;\ - NDR_ALLOC_N(ndr2, *r->out.info, r->out.count);\ - for (i=0;i<r->out.count;i++) {\ - ndr2->data += ndr2->offset;\ - ndr2->offset = 0;\ - NDR_CHECK(ndr_pull_set_switch_value(ndr2, &(*r->out.info)[i], r->in.level)); \ - NDR_CHECK(ndr_pull_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, &(*r->out.info)[i]));\ - }\ +} while(0) + +#define NDR_SPOOLSS_PULL_ENUM_IN(fn) do { \ + ZERO_STRUCT(r->out);\ + NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ + r->in.level = _r.in.level;\ + r->in.buffer = _r.in.buffer;\ + r->in.buf_size = _r.in.buf_size;\ +} while(0) + +#define NDR_SPOOLSS_PULL_ENUM_OUT(fn) do { \ + struct ndr_pull *_ndr_info;\ + _r.in.level = r->in.level;\ + _r.in.buffer = r->in.buffer;\ + _r.in.buf_size = r->in.buf_size;\ + _r.out.buf_size = r->out.buf_size;\ + NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ + r->out.info = NULL;\ + r->out.buf_size = _r.out.buf_size;\ + r->out.count = _r.out.count;\ + r->out.result = _r.out.result;\ + if (_r.out.buffer) {\ + struct __##fn __r;\ + _ndr_info = ndr_pull_init_blob(_r.out.buffer, ndr);\ + if (!_ndr_info) return NT_STATUS_NO_MEMORY;\ + __r.in.level = r->in.level;\ + __r.in.count = r->out.count;\ + __r.out.info = NULL;\ + NDR_CHECK(ndr_pull___##fn(_ndr_info, flags, &__r));\ + r->out.info = __r.out.info;\ }\ } while(0) -#define NDR_SPOOLSS_PRINT_ENUM_OUT(fn,type) do { \ - ndr_print_struct(ndr, "out", #fn);\ - ndr->depth++;\ - ndr_print_ptr(ndr, "info", r->out.info);\ - ndr->depth++;\ - if (r->out.info) {\ - int i;\ - ndr->print(ndr, "%s: ARRAY(%d)", "info", r->out.count);\ - ndr->depth++;\ - for (i=0;i<r->out.count;i++) {\ - char *idx=NULL;\ - asprintf(&idx, "[%d]", i);\ - if (idx) {\ - ndr_print_set_switch_value(ndr, &((*r->out.info)[i]), r->in.level); \ - ndr_print_##type(ndr, idx, &((*r->out.info)[i]));\ - free(idx);\ - }\ - }\ - ndr->depth--;\ +#define NDR_SPOOLSS_PULL_ENUM(fn,in,out) do { \ + struct _##fn _r;\ + if (flags & NDR_IN) {\ + in;\ + NDR_SPOOLSS_PULL_ENUM_IN(fn);\ + }\ + if (flags & NDR_OUT) {\ + out;\ + NDR_SPOOLSS_PULL_ENUM_OUT(fn);\ }\ - ndr->depth--;\ - ndr_print_ptr(ndr, "buf_size", r->out.buf_size);\ - ndr->depth++;\ - ndr_print_uint32(ndr, "buf_size", *r->out.buf_size);\ - ndr->depth--;\ - ndr_print_uint32(ndr, "count", r->out.count);\ - ndr_print_WERROR(ndr, "result", r->out.result);\ - ndr->depth--;\ } while(0) /* @@ -142,853 +116,178 @@ */ NTSTATUS ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, struct spoolss_EnumPrinters *r) { - if (!(flags & NDR_IN)) goto ndr_out; - - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.flags)); - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.server) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.server)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); - if (r->in.buffer) { - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size)); - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumPrinters,spoolss_PrinterInfo); - - done: + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinters,{ + _r.in.flags = r->in.flags; + _r.in.server = r->in.server; + },{ + _r.in.flags = r->in.flags; + _r.in.server = r->in.server; + }); return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r) { - uint32_t _ptr_server; - uint32_t _ptr_buffer; - uint32_t _ptr_info; - if (!(flags & NDR_IN)) goto ndr_out; - - ZERO_STRUCT(r->out); - - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.flags)); - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_server)); - if (_ptr_server) { - NDR_ALLOC(ndr, r->in.server); - } else { - r->in.server = NULL; - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.server) { - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.server)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level)); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->in.buffer); - } else { - r->in.buffer = NULL; - } - if (r->in.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); - } - NDR_ALLOC(ndr, r->in.buf_size); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size)); - NDR_ALLOC(ndr, r->out.buf_size); - *r->out.buf_size = *r->in.buf_size; - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumPrinters,spoolss_PrinterInfo); - - done: - + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinters,{ + r->in.flags = _r.in.flags; + r->in.server = _r.in.server; + },{ + _r.in.flags = r->in.flags; + _r.in.server = r->in.server; + }); return NT_STATUS_OK; } -void ndr_print_spoolss_EnumPrinters(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumPrinters *r) -{ - ndr_print_struct(ndr, name, "spoolss_EnumPrinters"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "spoolss_EnumPrinters"); - ndr->depth++; - ndr_print_spoolss_EnumPrinterFlags(ndr, "flags", r->in.flags); - 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_uint32(ndr, "level", r->in.level); - ndr_print_ptr(ndr, "buffer", r->in.buffer); - ndr->depth++; - if (r->in.buffer) { - ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); - } - ndr->depth--; - ndr_print_ptr(ndr, "buf_size", r->in.buf_size); - ndr->depth++; - ndr_print_uint32(ndr, "buf_size", *r->in.buf_size); - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumPrinters,spoolss_PrinterInfo); - } - ndr->depth--; -} - /* spoolss_EnumJobs */ NTSTATUS ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, struct spoolss_EnumJobs *r) { - if (!(flags & NDR_IN)) goto ndr_out; - - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.firstjob)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.numjobs)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); - if (r->in.buffer) { - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size)); - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumJobs,spoolss_JobInfo); - - done: + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumJobs,{ + _r.in.handle = r->in.handle; + _r.in.firstjob = r->in.firstjob; + _r.in.numjobs = r->in.numjobs; + },{ + _r.in.handle = r->in.handle; + _r.in.firstjob = r->in.firstjob; + _r.in.numjobs = r->in.numjobs; + }); return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r) { - uint32_t _ptr_buffer; - uint32_t _ptr_info; - if (!(flags & NDR_IN)) goto ndr_out; - - ZERO_STRUCT(r->out); - - NDR_ALLOC(ndr, r->in.handle); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.firstjob)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.numjobs)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level)); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->in.buffer); - } else { - r->in.buffer = NULL; - } - if (r->in.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); - } - NDR_ALLOC(ndr, r->in.buf_size); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size)); - NDR_ALLOC(ndr, r->out.buf_size); - *r->out.buf_size = *r->in.buf_size; - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumJobs,spoolss_JobInfo); - - done: - + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumJobs,{ + r->in.handle = _r.in.handle; + r->in.firstjob = _r.in.firstjob; + r->in.numjobs = _r.in.numjobs; + },{ + _r.in.handle = r->in.handle; + _r.in.firstjob = r->in.firstjob; + _r.in.numjobs = r->in.numjobs; + }); return NT_STATUS_OK; } -void ndr_print_spoolss_EnumJobs(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumJobs *r) -{ - ndr_print_struct(ndr, name, "spoolss_EnumJobs"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "spoolss_EnumJobs"); - ndr->depth++; - ndr_print_ptr(ndr, "handle", r->in.handle); - ndr->depth++; - ndr_print_policy_handle(ndr, "handle", r->in.handle); - ndr->depth--; - ndr_print_uint32(ndr, "firstjob", r->in.firstjob); - ndr_print_uint32(ndr, "numjobs", r->in.numjobs); - ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_ptr(ndr, "buffer", r->in.buffer); - ndr->depth++; - if (r->in.buffer) { - ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); - } - ndr->depth--; - ndr_print_ptr(ndr, "buf_size", r->in.buf_size); - ndr->depth++; - ndr_print_uint32(ndr, "buf_size", *r->in.buf_size); - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumJobs,spoolss_JobInfo); - } - ndr->depth--; -} - /* spoolss_EnumPrinterDrivers */ NTSTATUS ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, struct spoolss_EnumPrinterDrivers *r) { - if (!(flags & NDR_IN)) goto ndr_out; - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.server) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.server)); - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.environment)); - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.environment) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.environment)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); - if (r->in.buffer) { - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size)); - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumPrinterDrivers,spoolss_DriverInfo); - - done: + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinterDrivers,{ + _r.in.server = r->in.server; + _r.in.environment = r->in.environment; + },{ + _r.in.server = r->in.server; + _r.in.environment = r->in.environment; + }); return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r) { - uint32_t _ptr_server; - uint32_t _ptr_environment; - uint32_t _ptr_buffer; - uint32_t _ptr_info; - if (!(flags & NDR_IN)) goto ndr_out; - - ZERO_STRUCT(r->out); - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_server)); - if (_ptr_server) { - NDR_ALLOC(ndr, r->in.server); - } else { - r->in.server = NULL; - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.server) { - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.server)); - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_environment)); - if (_ptr_environment) { - NDR_ALLOC(ndr, r->in.environment); - } else { - r->in.environment = NULL; - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.environment) { - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.environment)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level)); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->in.buffer); - } else { - r->in.buffer = NULL; - } - if (r->in.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); - } - NDR_ALLOC(ndr, r->in.buf_size); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size)); - NDR_ALLOC(ndr, r->out.buf_size); - *r->out.buf_size = *r->in.buf_size; - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumPrinterDrivers,spoolss_DriverInfo); - - done: - + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinterDrivers,{ + r->in.server = _r.in.server; + r->in.environment = _r.in.environment; + },{ + _r.in.server = r->in.server; + _r.in.environment = r->in.environment; + }); return NT_STATUS_OK; } -void ndr_print_spoolss_EnumPrinterDrivers(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumPrinterDrivers *r) -{ - ndr_print_struct(ndr, name, "spoolss_EnumPrinterDrivers"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "spoolss_EnumPrinterDrivers"); - 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, "environment", r->in.environment); - ndr->depth++; - if (r->in.environment) { - ndr_print_string(ndr, "environment", r->in.environment); - } - ndr->depth--; - ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_ptr(ndr, "buffer", r->in.buffer); - ndr->depth++; - if (r->in.buffer) { - ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); - } - ndr->depth--; - ndr_print_ptr(ndr, "buf_size", r->in.buf_size); - ndr->depth++; - ndr_print_uint32(ndr, "buf_size", *r->in.buf_size); - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumPrinterDrivers,spoolss_DriverInfo); - } - ndr->depth--; -} - /* spoolss_EnumForms */ NTSTATUS ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, struct spoolss_EnumForms *r) { - if (!(flags & NDR_IN)) goto ndr_out; - - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); - if (r->in.buffer) { - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size)); - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumForms,spoolss_FormInfo); - - done: + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumForms,{ + _r.in.handle = r->in.handle; + },{ + _r.in.handle = r->in.handle; + }); return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r) { - uint32_t _ptr_buffer; - uint32_t _ptr_info; - if (!(flags & NDR_IN)) goto ndr_out; - - ZERO_STRUCT(r->out); - - NDR_ALLOC(ndr, r->in.handle); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level)); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->in.buffer); - } else { - r->in.buffer = NULL; - } - if (r->in.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); - } - NDR_ALLOC(ndr, r->in.buf_size); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size)); - NDR_ALLOC(ndr, r->out.buf_size); - *r->out.buf_size = *r->in.buf_size; - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumForms,spoolss_FormInfo); - - done: - + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumForms,{ + r->in.handle = _r.in.handle; + },{ + _r.in.handle = r->in.handle; + }); return NT_STATUS_OK; } -void ndr_print_spoolss_EnumForms(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumForms *r) -{ - ndr_print_struct(ndr, name, "spoolss_EnumForms"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "spoolss_EnumForms"); - ndr->depth++; - ndr_print_ptr(ndr, "handle", r->in.handle); - ndr->depth++; - ndr_print_policy_handle(ndr, "handle", r->in.handle); - ndr->depth--; - ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_ptr(ndr, "buffer", r->in.buffer); - ndr->depth++; - if (r->in.buffer) { - ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); - } - ndr->depth--; - ndr_print_ptr(ndr, "buf_size", r->in.buf_size); - ndr->depth++; - ndr_print_uint32(ndr, "buf_size", *r->in.buf_size); - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumForms,spoolss_FormInfo); - } - ndr->depth--; -} - /* spoolss_EnumPorts */ NTSTATUS ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, struct spoolss_EnumPorts *r) { - if (!(flags & NDR_IN)) goto ndr_out; - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername)); - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.servername) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.servername)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); - if (r->in.buffer) { - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size)); - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumPorts,spoolss_PortInfo); - - done: + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPorts,{ + _r.in.servername= r->in.servername; + },{ + _r.in.servername= r->in.servername; + }); return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r) { - uint32_t _ptr_servername; - uint32_t _ptr_buffer; - uint32_t _ptr_info; - if (!(flags & NDR_IN)) goto ndr_out; - - ZERO_STRUCT(r->out); - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_servername)); - if (_ptr_servername) { - NDR_ALLOC(ndr, r->in.servername); - } else { - r->in.servername = NULL; - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.servername) { - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.servername)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level)); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->in.buffer); - } else { - r->in.buffer = NULL; - } - if (r->in.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); - } - NDR_ALLOC(ndr, r->in.buf_size); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size)); - NDR_ALLOC(ndr, r->out.buf_size); - *r->out.buf_size = *r->in.buf_size; - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumPorts,spoolss_PortInfo); - - done: - + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPorts,{ + r->in.servername= _r.in.servername; + },{ + _r.in.servername= r->in.servername; + }); return NT_STATUS_OK; } -void ndr_print_spoolss_EnumPorts(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumPorts *r) -{ - ndr_print_struct(ndr, name, "spoolss_EnumPorts"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "spoolss_EnumPorts"); - ndr->depth++; - ndr_print_ptr(ndr, "servername", r->in.servername); - ndr->depth++; - if (r->in.servername) { - ndr_print_string(ndr, "servername", r->in.servername); - } - ndr->depth--; - ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_ptr(ndr, "buffer", r->in.buffer); - ndr->depth++; - if (r->in.buffer) { - ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); - } - ndr->depth--; - ndr_print_ptr(ndr, "buf_size", r->in.buf_size); - ndr->depth++; - ndr_print_uint32(ndr, "buf_size", *r->in.buf_size); - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumPorts,spoolss_PortInfo); - } - ndr->depth--; -} - /* spoolss_EnumMonitors */ NTSTATUS ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, struct spoolss_EnumMonitors *r) { - if (!(flags & NDR_IN)) goto ndr_out; - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername)); - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.servername) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.servername)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); - if (r->in.buffer) { - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size)); - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumMonitors,spoolss_MonitorInfo); - - done: + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumMonitors,{ + _r.in.servername= r->in.servername; + },{ + _r.in.servername= r->in.servername; + }); return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r) { - uint32_t _ptr_servername; - uint32_t _ptr_buffer; - uint32_t _ptr_info; - if (!(flags & NDR_IN)) goto ndr_out; - - ZERO_STRUCT(r->out); - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_servername)); - if (_ptr_servername) { - NDR_ALLOC(ndr, r->in.servername); - } else { - r->in.servername = NULL; - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.servername) { - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.servername)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level)); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->in.buffer); - } else { - r->in.buffer = NULL; - } - if (r->in.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); - } - NDR_ALLOC(ndr, r->in.buf_size); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size)); - NDR_ALLOC(ndr, r->out.buf_size); - *r->out.buf_size = *r->in.buf_size; - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumMonitors,spoolss_MonitorInfo); - - done: - + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumMonitors,{ + r->in.servername= _r.in.servername; + },{ + _r.in.servername= r->in.servername; + }); return NT_STATUS_OK; } -void ndr_print_spoolss_EnumMonitors(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumMonitors *r) -{ - ndr_print_struct(ndr, name, "spoolss_EnumMonitors"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "spoolss_EnumMonitors"); - ndr->depth++; - ndr_print_ptr(ndr, "servername", r->in.servername); - ndr->depth++; - if (r->in.servername) { - ndr_print_string(ndr, "servername", r->in.servername); - } - ndr->depth--; - ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_ptr(ndr, "buffer", r->in.buffer); - ndr->depth++; - if (r->in.buffer) { - ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); - } - ndr->depth--; - ndr_print_ptr(ndr, "buf_size", r->in.buf_size); - ndr->depth++; - ndr_print_uint32(ndr, "buf_size", *r->in.buf_size); - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumMonitors,spoolss_MonitorInfo); - } - ndr->depth--; -} - /* spoolss_EnumPrintProcessors */ NTSTATUS ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, struct spoolss_EnumPrintProcessors *r) { - if (!(flags & NDR_IN)) goto ndr_out; - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername)); - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.servername) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.servername)); - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.environment)); - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.environment) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.environment)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); - if (r->in.buffer) { - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size)); - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumPrintProcessors,spoolss_PrintProcessorInfo); - - done: + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrintProcessors,{ + _r.in.servername = r->in.servername; + _r.in.environment = r->in.environment; + },{ + _r.in.servername = r->in.servername; + _r.in.environment = r->in.environment; + }); return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r) { - uint32_t _ptr_servername; - uint32_t _ptr_environment; - uint32_t _ptr_buffer; - uint32_t _ptr_info; - if (!(flags & NDR_IN)) goto ndr_out; - - ZERO_STRUCT(r->out); - - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_servername)); - if (_ptr_servername) { - NDR_ALLOC(ndr, r->in.servername); - } else { - r->in.servername = NULL; - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.servername) { - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.servername)); - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_environment)); - if (_ptr_environment) { - NDR_ALLOC(ndr, r->in.environment); - } else { - r->in.environment = NULL; - } - ndr->flags = _flags_save_string; - } - { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->in.environment) { - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.environment)); - } - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level)); - NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->in.buffer); - } else { - r->in.buffer = NULL; - } - if (r->in.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer)); - } - NDR_ALLOC(ndr, r->in.buf_size); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size)); - NDR_ALLOC(ndr, r->out.buf_size); - *r->out.buf_size = *r->in.buf_size; - ndr_out: - if (!(flags & NDR_OUT)) goto done; - - NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumPrintProcessors,spoolss_PrintProcessorInfo); - - done: - + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrintProcessors,{ + r->in.servername = r->in.servername; + r->in.environment = r->in.environment; + },{ + _r.in.servername = r->in.servername; + _r.in.environment = r->in.environment; + }); return NT_STATUS_OK; } - -void ndr_print_spoolss_EnumPrintProcessors(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumPrintProcessors *r) -{ - ndr_print_struct(ndr, name, "spoolss_EnumPrintProcessors"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "spoolss_EnumPrintProcessors"); - ndr->depth++; - ndr_print_ptr(ndr, "servername", r->in.servername); - ndr->depth++; - if (r->in.servername) { - ndr_print_string(ndr, "servername", r->in.servername); - } - ndr->depth--; - ndr_print_ptr(ndr, "environment", r->in.environment); - ndr->depth++; - if (r->in.environment) { - ndr_print_string(ndr, "environment", r->in.environment); - } - ndr->depth--; - ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_ptr(ndr, "buffer", r->in.buffer); - ndr->depth++; - if (r->in.buffer) { - ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); - } - ndr->depth--; - ndr_print_ptr(ndr, "buf_size", r->in.buf_size); - ndr->depth++; - ndr_print_uint32(ndr, "buf_size", *r->in.buf_size); - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumPrintProcessors,spoolss_PrintProcessorInfo); - } - ndr->depth--; -} diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c index ab70035f28..4e81e5188c 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c @@ -36,7 +36,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT struct ldb_message **msgs; int count; int i; - union spoolss_PrinterInfo *info, **info_ptr; + union spoolss_PrinterInfo *info; r->out.info = NULL; *r->out.buf_size = 0; @@ -52,14 +52,9 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT if (count == 0) return WERR_OK; if (count < 0) return WERR_GENERAL_FAILURE; - info_ptr = talloc(mem_ctx, union spoolss_PrinterInfo *); - W_ERROR_HAVE_NO_MEMORY(info_ptr); - info = talloc_array(mem_ctx, union spoolss_PrinterInfo, count); W_ERROR_HAVE_NO_MEMORY(info); - *info_ptr = info; - switch(r->in.level) { case 1: for (i = 0; i < count; i++) { @@ -73,7 +68,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT info[i].info1.comment = samdb_result_string(msgs[i], "comment", NULL); } - r->out.info = info_ptr; + r->out.info = info; r->out.count = count; return WERR_OK; case 2: @@ -120,7 +115,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT info[i].info2.cjobs = samdb_result_uint(msgs[i], "cjobs", 0); info[i].info2.averageppm = samdb_result_uint(msgs[i], "averageppm", 0); } - r->out.info = info_ptr; + r->out.info = info; r->out.count = count; return WERR_OK; case 4: @@ -133,7 +128,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT info[i].info4.attributes = samdb_result_uint(msgs[i], "attributes", 0); } - r->out.info = info_ptr; + r->out.info = info; r->out.count = count; return WERR_OK; case 5: @@ -148,7 +143,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT info[i].info5.device_not_selected_timeout = samdb_result_uint(msgs[i], "device_not_selected_timeout", 0); info[i].info5.transmission_retry_timeout = samdb_result_uint(msgs[i], "transmission_retry_timeout", 0); } - r->out.info = info_ptr; + r->out.info = info; r->out.count = count; return WERR_OK; } @@ -536,7 +531,7 @@ static WERROR spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLOC_CTX * static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPorts *r) { - union spoolss_PortInfo *info, **info_ptr; + union spoolss_PortInfo *info; int count; int i; @@ -549,21 +544,16 @@ static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX * if (count == 0) return WERR_OK; if (count < 0) return WERR_GENERAL_FAILURE; - info_ptr = talloc(mem_ctx, union spoolss_PortInfo *); - W_ERROR_HAVE_NO_MEMORY(info_ptr); - info = talloc_array(mem_ctx, union spoolss_PortInfo, count); W_ERROR_HAVE_NO_MEMORY(info); - *info_ptr = info; - switch (r->in.level) { case 1: for (i=0; i < count; i++) { info[i].info1.port_name = talloc_strdup(mem_ctx, "Samba Printer Port"); W_ERROR_HAVE_NO_MEMORY(info[i].info1.port_name); } - r->out.info = info_ptr; + r->out.info = info; r->out.count = count; return WERR_OK; case 2: @@ -580,7 +570,7 @@ static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX * info[i].info2.port_type = SPOOLSS_PORT_TYPE_WRITE; info[i].info2.reserved = 0; } - r->out.info = info_ptr; + r->out.info = info; r->out.count = count; return WERR_OK; } diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 4cd3b7a5b3..b9d48a6da4 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -31,23 +31,23 @@ struct test_spoolss_context { /* for EnumPorts */ uint32_t port_count[3]; - union spoolss_PortInfo **ports[3]; + union spoolss_PortInfo *ports[3]; /* for EnumPrinterDrivers */ uint32_t driver_count[7]; - union spoolss_DriverInfo **drivers[7]; + union spoolss_DriverInfo *drivers[7]; /* for EnumMonitors */ uint32_t monitor_count[3]; - union spoolss_MonitorInfo **monitors[3]; + union spoolss_MonitorInfo *monitors[3]; /* for EnumPrintProcessors */ uint32_t print_processor_count[2]; - union spoolss_PrintProcessorInfo **print_processors[2]; + union spoolss_PrintProcessorInfo *print_processors[2]; /* for EnumPrinters */ uint32_t printer_count[6]; - union spoolss_PrinterInfo **printers[6]; + union spoolss_PrinterInfo *printers[6]; }; #define COMPARE_STRING(c,r,e) do {\ @@ -194,8 +194,8 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx) for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; for (j=0;j<ctx->port_count[level];j++) { - union spoolss_PortInfo *cur = &ctx->ports[level][0][j]; - union spoolss_PortInfo *ref = &ctx->ports[2][0][j]; + union spoolss_PortInfo *cur = &ctx->ports[level][j]; + union spoolss_PortInfo *ref = &ctx->ports[2][j]; switch (level) { case 1: COMPARE_STRING(cur->info1, ref->info2, port_name); @@ -284,8 +284,8 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx) for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; for (j=0;j<ctx->driver_count[level];j++) { - union spoolss_DriverInfo *cur = &ctx->drivers[level][0][j]; - union spoolss_DriverInfo *ref = &ctx->drivers[6][0][j]; + union spoolss_DriverInfo *cur = &ctx->drivers[level][j]; + union spoolss_DriverInfo *ref = &ctx->drivers[6][j]; switch (level) { case 1: COMPARE_STRING(cur->info1, ref->info6, driver_name); @@ -417,8 +417,8 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx) for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; for (j=0;j<ctx->monitor_count[level];j++) { - union spoolss_MonitorInfo *cur = &ctx->monitors[level][0][j]; - union spoolss_MonitorInfo *ref = &ctx->monitors[2][0][j]; + union spoolss_MonitorInfo *cur = &ctx->monitors[level][j]; + union spoolss_MonitorInfo *ref = &ctx->monitors[2][j]; switch (level) { case 1: COMPARE_STRING(cur->info1, ref->info2, monitor_name); @@ -508,8 +508,8 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx) int level = levels[i]; for (j=0;j<ctx->print_processor_count[level];j++) { #if 0 - union spoolss_PrintProcessorInfo *cur = &ctx->print_processors[level][0][j]; - union spoolss_PrintProcessorInfo *ref = &ctx->print_processors[1][0][j]; + union spoolss_PrintProcessorInfo *cur = &ctx->print_processors[level][j]; + union spoolss_PrintProcessorInfo *ref = &ctx->print_processors[1][j]; #endif switch (level) { case 1: @@ -593,8 +593,8 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx) for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; for (j=0;j<ctx->printer_count[level];j++) { - union spoolss_PrinterInfo *cur = &ctx->printers[level][0][j]; - union spoolss_PrinterInfo *ref = &ctx->printers[2][0][j]; + union spoolss_PrinterInfo *cur = &ctx->printers[level][j]; + union spoolss_PrinterInfo *ref = &ctx->printers[2][j]; switch (level) { case 0: COMPARE_STRING(cur->info0, ref->info2, printername); @@ -809,7 +809,7 @@ static BOOL test_EnumForms(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return False; } - info = *r.out.info; + info = r.out.info; for (j = 0; j < r.out.count; j++) { test_GetForm(p, mem_ctx, handle, info[j].info1.form_name); @@ -1108,7 +1108,7 @@ static BOOL test_EnumJobs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return True; } - info = *r.out.info; + info = r.out.info; for (j = 0; j < r.out.count; j++) { test_GetJob(p, mem_ctx, handle, info[j].info1.job_id); @@ -1671,7 +1671,7 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) continue; } - info = *r.out.info; + info = r.out.info; for (j=0;j<r.out.count;j++) { if (r.in.level == 1) { |