spoolss: add spoolss_StringArray2.
[ira/wip.git] / librpc / ndr / ndr_spoolss_buf.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    routines for marshalling/unmarshalling spoolss subcontext buffer structures
5
6    Copyright (C) Andrew Tridgell 2003
7    Copyright (C) Tim Potter 2003
8    Copyright (C) Guenther Deschner 2009
9
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 3 of the License, or
13    (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 */
23
24
25 #include "includes.h"
26 #include "librpc/gen_ndr/ndr_spoolss.h"
27 #if (_SAMBA_BUILD_ >= 4)
28 #include "param/param.h"
29 #endif
30
31 #define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \
32         if (!r->in.buffer && r->in.offered != 0) {\
33                 return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\
34                         "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\
35                         (unsigned)r->in.offered);\
36         } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\
37                 return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\
38                         "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\
39                         (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\
40         }\
41         _r.in.level     = r->in.level;\
42         _r.in.buffer    = r->in.buffer;\
43         _r.in.offered   = r->in.offered;\
44         NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\
45 } while(0)
46
47 #define NDR_SPOOLSS_PUSH_ENUM_OUT(fn) do { \
48         struct ndr_push *_ndr_info;\
49         _r.in.level     = r->in.level;\
50         _r.in.buffer    = r->in.buffer;\
51         _r.in.offered   = r->in.offered;\
52         _r.out.info     = NULL;\
53         _r.out.needed   = r->out.needed;\
54         _r.out.count    = r->out.count;\
55         _r.out.result   = r->out.result;\
56         if (r->out.info && *r->out.info && !r->in.buffer) {\
57                 return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\
58                         "SPOOLSS Buffer: *r->out.info but there's no r->in.buffer");\
59         }\
60         if (r->in.buffer) {\
61                 DATA_BLOB _data_blob_info;\
62                 _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);\
63                 NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\
64                 _ndr_info->flags= ndr->flags;\
65                 if (r->out.info) {\
66                         struct __##fn __r;\
67                         __r.in.level    = r->in.level;\
68                         __r.in.count    = *r->out.count;\
69                         __r.out.info    = *r->out.info;\
70                         NDR_CHECK(ndr_push___##fn(_ndr_info, flags, &__r)); \
71                 }\
72                 if (r->in.offered > _ndr_info->offset) {\
73                         uint32_t _padding_len = r->in.offered - _ndr_info->offset;\
74                         NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));\
75                 } else if (r->in.offered < _ndr_info->offset) {\
76                         return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\
77                                 "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]!",\
78                                 (unsigned)r->in.offered, (unsigned)_ndr_info->offset);\
79                 }\
80                 _data_blob_info = ndr_push_blob(_ndr_info);\
81                 _r.out.info     = &_data_blob_info;\
82         }\
83         NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\
84 } while(0)
85
86 #define NDR_SPOOLSS_PUSH_ENUM(fn,in,out) do { \
87         struct _##fn _r;\
88         if (flags & NDR_IN) {\
89                 in;\
90                 NDR_SPOOLSS_PUSH_ENUM_IN(fn);\
91         }\
92         if (flags & NDR_OUT) {\
93                 out;\
94                 NDR_SPOOLSS_PUSH_ENUM_OUT(fn);\
95         }\
96 } while(0)
97
98 #define NDR_SPOOLSS_PULL_ENUM_IN(fn) do { \
99         ZERO_STRUCT(r->out);\
100         NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\
101         r->in.level     = _r.in.level;\
102         r->in.buffer    = _r.in.buffer;\
103         r->in.offered   = _r.in.offered;\
104         r->out.needed   = _r.out.needed;\
105         r->out.count    = _r.out.count;\
106         if (!r->in.buffer && r->in.offered != 0) {\
107                 return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\
108                         "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\
109                         (unsigned)r->in.offered);\
110         } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\
111                 return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\
112                         "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\
113                         (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\
114         }\
115         NDR_PULL_ALLOC(ndr, r->out.info);\
116         ZERO_STRUCTP(r->out.info);\
117 } while(0)
118
119 #define NDR_SPOOLSS_PULL_ENUM_OUT(fn) do { \
120         _r.in.level     = r->in.level;\
121         _r.in.buffer    = r->in.buffer;\
122         _r.in.offered   = r->in.offered;\
123         _r.out.needed   = r->out.needed;\
124         _r.out.count    = r->out.count;\
125         NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\
126         if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {\
127                 NDR_PULL_ALLOC(ndr, r->out.info);\
128         }\
129         *r->out.info = NULL;\
130         r->out.needed   = _r.out.needed;\
131         r->out.count    = _r.out.count;\
132         r->out.result   = _r.out.result;\
133         if (_r.out.info) {\
134                 struct ndr_pull *_ndr_info;\
135                 NDR_PULL_ALLOC(ndr, *r->out.info);\
136                 _ndr_info = ndr_pull_init_blob(_r.out.info, *r->out.info, ndr->iconv_convenience);\
137                 NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\
138                 _ndr_info->flags= ndr->flags;\
139                 if (r->in.offered != _ndr_info->data_size) {\
140                         return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\
141                                 "SPOOLSS Buffer: offered[%u] doesn't match length of buffer[%u]",\
142                                 (unsigned)r->in.offered, (unsigned)_ndr_info->data_size);\
143                 }\
144                 if (*r->out.needed <= _ndr_info->data_size) {\
145                         struct __##fn __r;\
146                         __r.in.level    = r->in.level;\
147                         __r.in.count    = *r->out.count;\
148                         __r.out.info    = NULL;\
149                         NDR_CHECK(ndr_pull___##fn(_ndr_info, flags, &__r));\
150                         *r->out.info    = __r.out.info;\
151                 }\
152         }\
153 } while(0)
154
155 #define NDR_SPOOLSS_PULL_ENUM(fn,in,out) do { \
156         struct _##fn _r;\
157         if (flags & NDR_IN) {\
158                 out;\
159                 NDR_SPOOLSS_PULL_ENUM_IN(fn);\
160                 in;\
161         }\
162         if (flags & NDR_OUT) {\
163                 out;\
164                 NDR_SPOOLSS_PULL_ENUM_OUT(fn);\
165         }\
166 } while(0)
167
168 #define _NDR_CHECK_UINT32(call) do {\
169         enum ndr_err_code _ndr_err; \
170         _ndr_err = call; \
171         if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
172                 return 0; \
173         }\
174 } while (0)
175
176 /* TODO: set _ndr_info->flags correct */
177 #define NDR_SPOOLSS_SIZE_ENUM_LEVEL(fn) do { \
178         struct __##fn __r;\
179         DATA_BLOB _data_blob_info;\
180         struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, iconv_convenience);\
181         if (!_ndr_info) return 0;\
182         _ndr_info->flags|=0;\
183         __r.in.level    = level;\
184         __r.in.count    = count;\
185         __r.out.info    = info;\
186         _NDR_CHECK_UINT32(ndr_push___##fn(_ndr_info, NDR_OUT, &__r)); \
187         _data_blob_info = ndr_push_blob(_ndr_info);\
188         return _data_blob_info.length;\
189 } while(0)
190
191 /* TODO: set _ndr_info->flags correct */
192 #define NDR_SPOOLSS_SIZE_ENUM(fn) do { \
193         struct __##fn __r;\
194         DATA_BLOB _data_blob_info;\
195         struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, iconv_convenience);\
196         if (!_ndr_info) return 0;\
197         _ndr_info->flags|=0;\
198         __r.in.count    = count;\
199         __r.out.info    = info;\
200         _NDR_CHECK_UINT32(ndr_push___##fn(_ndr_info, NDR_OUT, &__r)); \
201         _data_blob_info = ndr_push_blob(_ndr_info);\
202         return _data_blob_info.length;\
203 } while(0)
204
205
206 /*
207   spoolss_EnumPrinters
208 */
209 enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r)
210 {
211         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinters,{
212                 _r.in.flags     = r->in.flags;
213                 _r.in.server    = r->in.server;
214         },{
215                 _r.in.flags     = r->in.flags;
216                 _r.in.server    = r->in.server;
217         });
218         return NDR_ERR_SUCCESS;
219 }
220
221 enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r)
222 {
223         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinters,{
224                 r->in.flags     = _r.in.flags;
225                 r->in.server    = _r.in.server;
226         },{
227                 _r.in.flags     = r->in.flags;
228                 _r.in.server    = r->in.server;
229         });
230         return NDR_ERR_SUCCESS;
231 }
232
233 uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info)
234 {
235         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinters);
236 }
237
238 /*
239   spoolss_EnumJobs
240 */
241 enum ndr_err_code ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct spoolss_EnumJobs *r)
242 {
243         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumJobs,{
244                 _r.in.handle    = r->in.handle;
245                 _r.in.firstjob  = r->in.firstjob;
246                 _r.in.numjobs   = r->in.numjobs;
247         },{
248                 _r.in.handle    = r->in.handle;
249                 _r.in.firstjob  = r->in.firstjob;
250                 _r.in.numjobs   = r->in.numjobs;
251         });
252         return NDR_ERR_SUCCESS;
253 }
254
255 enum ndr_err_code ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r)
256 {
257         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumJobs,{
258                 r->in.handle    = _r.in.handle;
259                 r->in.firstjob  = _r.in.firstjob;
260                 r->in.numjobs   = _r.in.numjobs;
261         },{
262                 _r.in.handle    = r->in.handle;
263                 _r.in.firstjob  = r->in.firstjob;
264                 _r.in.numjobs   = r->in.numjobs;
265         });
266         return NDR_ERR_SUCCESS;
267 }
268
269 uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info)
270 {
271         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumJobs);
272 }
273
274 /*
275   spoolss_EnumPrinterDrivers
276 */
277 enum ndr_err_code ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDrivers *r)
278 {
279         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinterDrivers,{
280                 _r.in.server            = r->in.server;
281                 _r.in.environment       = r->in.environment;
282         },{
283                 _r.in.server            = r->in.server;
284                 _r.in.environment       = r->in.environment;
285         });
286         return NDR_ERR_SUCCESS;
287 }
288
289 enum ndr_err_code ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r)
290 {
291         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinterDrivers,{
292                 r->in.server            = _r.in.server;
293                 r->in.environment       = _r.in.environment;
294         },{
295                 _r.in.server            = r->in.server;
296                 _r.in.environment       = r->in.environment;
297         });
298         return NDR_ERR_SUCCESS;
299 }
300
301 uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_DriverInfo *info)
302 {
303         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinterDrivers);
304 }
305
306 /*
307   spoolss_EnumForms
308 */
309 enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r)
310 {
311         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumForms,{
312                 _r.in.handle    = r->in.handle;
313         },{
314                 _r.in.handle    = r->in.handle;
315         });
316         return NDR_ERR_SUCCESS;
317 }
318
319 enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r)
320 {
321         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumForms,{
322                 r->in.handle    = _r.in.handle;
323         },{
324                 _r.in.handle    = r->in.handle;
325         });
326         return NDR_ERR_SUCCESS;
327 }
328
329 uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_FormInfo *info)
330 {
331         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumForms);
332 }
333
334 /*
335   spoolss_EnumPorts
336 */
337 enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r)
338 {
339         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPorts,{
340                 _r.in.servername= r->in.servername;
341         },{
342                 _r.in.servername= r->in.servername;
343         });
344         return NDR_ERR_SUCCESS;
345 }
346
347 enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r)
348 {
349         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPorts,{
350                 r->in.servername= _r.in.servername;
351         },{
352                 _r.in.servername= r->in.servername;
353         });
354         return NDR_ERR_SUCCESS;
355 }
356
357 uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PortInfo *info)
358 {
359         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPorts);
360 }
361
362 /*
363   spoolss_EnumMonitors
364 */
365 enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r)
366 {
367         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumMonitors,{
368                 _r.in.servername= r->in.servername;
369         },{
370                 _r.in.servername= r->in.servername;
371         });
372         return NDR_ERR_SUCCESS;
373 }
374
375 enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r)
376 {
377         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumMonitors,{
378                 r->in.servername= _r.in.servername;
379         },{
380                 _r.in.servername= r->in.servername;
381         });
382         return NDR_ERR_SUCCESS;
383 }
384
385 uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info)
386 {
387         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumMonitors);
388 }
389
390 /*
391   spoolss_EnumPrintProcessors
392 */
393 enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r)
394 {
395         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrintProcessors,{
396                 _r.in.servername        = r->in.servername;
397                 _r.in.environment       = r->in.environment;
398         },{
399                 _r.in.servername        = r->in.servername;
400                 _r.in.environment       = r->in.environment;
401         });
402         return NDR_ERR_SUCCESS;
403 }
404
405 enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r)
406 {
407         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrintProcessors,{
408                 r->in.servername        = _r.in.servername;
409                 r->in.environment       = _r.in.environment;
410         },{
411                 _r.in.servername        = r->in.servername;
412                 _r.in.environment       = r->in.environment;
413         });
414         return NDR_ERR_SUCCESS;
415 }
416
417 uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
418                                                    uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info)
419 {
420         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrintProcessors);
421 }
422
423 /*
424   spoolss_EnumPrintProcessors
425 */
426 enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r)
427 {
428         NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrintProcDataTypes,{
429                 _r.in.servername                = r->in.servername;
430                 _r.in.print_processor_name      = r->in.print_processor_name;
431         },{
432                 _r.in.servername                = r->in.servername;
433                 _r.in.print_processor_name      = r->in.print_processor_name;
434         });
435         return NDR_ERR_SUCCESS;
436 }
437
438 enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r)
439 {
440         NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrintProcDataTypes,{
441                 r->in.servername                = _r.in.servername;
442                 r->in.print_processor_name      = _r.in.print_processor_name;
443         },{
444                 _r.in.servername                = r->in.servername;
445                 _r.in.print_processor_name      = r->in.print_processor_name;
446         });
447         return NDR_ERR_SUCCESS;
448 }
449
450 uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
451                                                       uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info)
452 {
453         NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrintProcDataTypes);
454 }
455
456 /*
457   spoolss_EnumPrinterDataEx
458 */
459
460 enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDataEx *r)
461 {
462         struct _spoolss_EnumPrinterDataEx _r;
463         if (flags & NDR_IN) {
464                 _r.in.handle    = r->in.handle;
465                 _r.in.key_name  = r->in.key_name;
466                 _r.in.offered   = r->in.offered;
467                 NDR_CHECK(ndr_push__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
468         }
469         if (flags & NDR_OUT) {
470                 struct ndr_push *_ndr_info;
471                 _r.in.handle    = r->in.handle;
472                 _r.in.key_name  = r->in.key_name;
473                 _r.in.offered   = r->in.offered;
474                 _r.out.count    = r->out.count;
475                 _r.out.needed   = r->out.needed;
476                 _r.out.result   = r->out.result;
477                 _r.out.info     = data_blob(NULL, 0);
478                 if (r->in.offered >= *r->out.needed) {
479                         struct __spoolss_EnumPrinterDataEx __r;
480                         _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
481                         NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
482                         _ndr_info->flags= ndr->flags;
483                         __r.in.count    = *r->out.count;
484                         __r.out.info    = *r->out.info;
485                         NDR_CHECK(ndr_push___spoolss_EnumPrinterDataEx(_ndr_info, flags, &__r));
486                         if (r->in.offered > _ndr_info->offset) {
487                                 uint32_t _padding_len = r->in.offered - _ndr_info->offset;
488                                 NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));
489                         }
490                         _r.out.info = ndr_push_blob(_ndr_info);
491                 }
492                 NDR_CHECK(ndr_push__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
493         }
494         return NDR_ERR_SUCCESS;
495 }
496
497 enum ndr_err_code ndr_pull_spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDataEx *r)
498 {
499         struct _spoolss_EnumPrinterDataEx _r;
500         if (flags & NDR_IN) {
501                 _r.in.handle    = r->in.handle;
502                 _r.in.key_name  = r->in.key_name;
503                 ZERO_STRUCT(r->out);
504                 NDR_CHECK(ndr_pull__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
505                 r->in.handle    = _r.in.handle;
506                 r->in.key_name  = _r.in.key_name;
507                 r->in.offered   = _r.in.offered;
508                 r->out.needed   = _r.out.needed;
509                 r->out.count    = _r.out.count;
510                 NDR_PULL_ALLOC(ndr, r->out.info);
511                 ZERO_STRUCTP(r->out.info);
512         }
513         if (flags & NDR_OUT) {
514                 _r.in.handle    = r->in.handle;
515                 _r.in.key_name  = r->in.key_name;
516                 _r.in.offered   = r->in.offered;
517                 _r.out.count    = r->out.count;
518                 _r.out.needed   = r->out.needed;
519                 NDR_CHECK(ndr_pull__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
520                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
521                         NDR_PULL_ALLOC(ndr, r->out.info);
522                 }
523                 *r->out.info    = NULL;
524                 r->out.needed   = _r.out.needed;
525                 r->out.count    = _r.out.count;
526                 r->out.result   = _r.out.result;
527                 if (_r.out.info.length) {
528                         struct ndr_pull *_ndr_info;
529                         NDR_PULL_ALLOC(ndr, *r->out.info);
530                         _ndr_info = ndr_pull_init_blob(&_r.out.info, *r->out.info, ndr->iconv_convenience);
531                         NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
532                         _ndr_info->flags= ndr->flags;
533                         if (r->in.offered != _ndr_info->data_size) {
534                                 return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,
535                                         "SPOOLSS Buffer: offered[%u] doesn't match length of buffer[%u]",
536                                         (unsigned)r->in.offered, (unsigned)_ndr_info->data_size);
537                         }
538                         if (*r->out.needed <= _ndr_info->data_size) {
539                                 struct __spoolss_EnumPrinterDataEx __r;
540                                 __r.in.count    = *r->out.count;
541                                 __r.out.info    = NULL;
542                                 NDR_CHECK(ndr_pull___spoolss_EnumPrinterDataEx(_ndr_info, flags, &__r));
543                                 *r->out.info    = __r.out.info;
544                         }
545                 }
546         }
547         return NDR_ERR_SUCCESS;
548 }
549
550 uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
551                                                  uint32_t count, struct spoolss_PrinterEnumValues *info)
552 {
553         NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrinterDataEx);
554 }
555
556 /*
557   spoolss_GetPrinterData
558 */
559 enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r)
560 {
561         struct _spoolss_GetPrinterData _r;
562         if (flags & NDR_IN) {
563                 _r.in.handle    = r->in.handle;
564                 _r.in.value_name= r->in.value_name;
565                 _r.in.offered   = r->in.offered;
566                 NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r));
567         }
568         if (flags & NDR_OUT) {
569                 struct ndr_push *_ndr_info;
570                 DATA_BLOB blob = data_blob(NULL, 0);
571                 _r.in.handle    = r->in.handle;
572                 _r.in.value_name= r->in.value_name;
573                 _r.in.offered   = r->in.offered;
574                 _r.out.type     = r->out.type;
575                 _r.out.data     = &blob;
576                 _r.out.needed   = r->out.needed;
577                 _r.out.result   = r->out.result;
578                 {
579                         struct __spoolss_GetPrinterData __r;
580                         DATA_BLOB _blob;
581                         _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
582                         NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
583                         _ndr_info->flags= ndr->flags;
584                         __r.in.type     = *r->out.type;
585                         __r.out.data    = r->out.data;
586                         NDR_CHECK(ndr_push___spoolss_GetPrinterData(_ndr_info, flags, &__r));
587                         if (r->in.offered > _ndr_info->offset) {
588                                 uint32_t _padding_len = r->in.offered - _ndr_info->offset;
589                                 NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));
590                         }
591                         _blob = ndr_push_blob(_ndr_info);
592                         _r.out.data = &_blob;
593                 }
594                 NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r));
595         }
596         return NDR_ERR_SUCCESS;
597 }
598
599 enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r)
600 {
601         struct _spoolss_GetPrinterData _r;
602         if (flags & NDR_IN) {
603                 DATA_BLOB blob = data_blob(NULL,0);
604                 ZERO_STRUCT(r->out);
605
606                 _r.in.handle    = r->in.handle;
607                 _r.in.value_name= r->in.value_name;
608                 _r.in.offered   = r->in.offered;
609                 _r.out.type     = r->out.type;
610                 _r.out.data     = &blob;
611                 _r.out.needed   = r->out.needed;
612                 NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
613                 r->in.handle    = _r.in.handle;
614                 r->in.value_name= _r.in.value_name;
615                 r->in.offered   = _r.in.offered;
616                 r->out.needed   = _r.out.needed;
617         }
618         if (flags & NDR_OUT) {
619                 DATA_BLOB blob = data_blob_talloc(ndr,NULL,0);
620                 _r.in.handle    = r->in.handle;
621                 _r.in.value_name= r->in.value_name;
622                 _r.in.offered   = r->in.offered;
623                 _r.out.type     = r->out.type;
624                 _r.out.data     = &blob;
625                 _r.out.needed   = r->out.needed;
626                 _r.out.result   = r->out.result;
627                 NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
628                 r->out.type     = _r.out.type;
629                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
630                         NDR_PULL_ALLOC(ndr, r->out.data);
631                 }
632                 ZERO_STRUCTP(r->out.data);
633                 r->out.needed   = _r.out.needed;
634                 r->out.result   = _r.out.result;
635                 if (_r.out.data && _r.out.data->length != r->in.offered) {
636                         return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,
637                                 "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]",
638                                 (unsigned)r->in.offered, (unsigned)_r.out.data->length);
639                 }
640                 if (_r.out.data && _r.out.data->length > 0 && *r->out.needed <= _r.out.data->length) {
641                         struct __spoolss_GetPrinterData __r;
642                         struct ndr_pull *_ndr_data = ndr_pull_init_blob(_r.out.data, ndr, ndr->iconv_convenience);
643                         NDR_ERR_HAVE_NO_MEMORY(_ndr_data);
644                         _ndr_data->flags= ndr->flags;
645                         __r.in.type     = *r->out.type;
646                         __r.out.data    = r->out.data;
647                         NDR_CHECK(ndr_pull___spoolss_GetPrinterData(_ndr_data, flags, &__r));
648                         r->out.data     = __r.out.data;
649                 } else {
650                         *r->out.type    = REG_NONE;
651                 }
652         }
653         return NDR_ERR_SUCCESS;
654 }
655
656 /*
657   spoolss_SetPrinterData
658 */
659 enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r)
660 {
661         struct _spoolss_SetPrinterData _r;
662         if (flags & NDR_IN) {
663                 struct ndr_push *_ndr_data;
664                 struct __spoolss_SetPrinterData __r;
665                 DATA_BLOB _data_blob_data;
666
667                 _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
668                 NDR_ERR_HAVE_NO_MEMORY(_ndr_data);
669                 _ndr_data->flags= ndr->flags;
670
671                 __r.in.type     = r->in.type;
672                 __r.out.data    = discard_const_p(union spoolss_PrinterData, &r->in.data);
673                 NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r));
674                 _data_blob_data = ndr_push_blob(_ndr_data);
675
676                 _r.in.handle    = r->in.handle;
677                 _r.in.value_name= r->in.value_name;
678                 _r.in.type      = r->in.type;
679                 _r.in.data      = _data_blob_data;
680                 _r.in._offered  = _data_blob_data.length;
681                 _r.out.result   = r->out.result;
682                 NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r));
683         }
684         if (flags & NDR_OUT) {
685                 _r.in.handle    = r->in.handle;
686                 _r.in.value_name= r->in.value_name;
687                 _r.in.type      = r->in.type;
688                 _r.in.data      = data_blob(NULL,0),
689                 _r.in._offered  = r->in._offered;
690                 _r.out.result   = r->out.result;
691                 NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r));
692         }
693         return NDR_ERR_SUCCESS;
694 }
695
696 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags)
697 {
698         if (!devmode) return 0;
699         return ndr_size_spoolss_DeviceMode(devmode,ic,flags);
700 }
701
702 _PUBLIC_ size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags)
703 {
704         if (!r) {
705                 return 4;
706         }
707
708         return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_StringArray, ic);
709 }
710
711 _PUBLIC_ size_t ndr_size_spoolss_StringArray2(const struct spoolss_StringArray2 *r, struct smb_iconv_convenience *ic, int flags)
712 {
713         if (!r) {
714                 return 4;
715         }
716
717         return ndr_size_struct((const struct spoolss_StringArray *)r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_StringArray, ic);
718 }
719
720 /* hand marshall as pidl cannot (yet) generate a relative pointer to a fixed array of
721  * structs */
722
723 _PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r)
724 {
725         uint32_t cntr_file_info_1;
726         if (ndr_flags & NDR_SCALARS) {
727                 NDR_CHECK(ndr_push_align(ndr, 8));
728                 NDR_CHECK(ndr_push_spoolss_DriverOSVersion(ndr, NDR_SCALARS, r->version));
729                 {
730                         uint32_t _flags_save_string = ndr->flags;
731                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
732                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name));
733                         ndr->flags = _flags_save_string;
734                 }
735                 {
736                         uint32_t _flags_save_string = ndr->flags;
737                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
738                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->architecture));
739                         ndr->flags = _flags_save_string;
740                 }
741                 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->file_info));
742                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->file_count));
743                 {
744                         uint32_t _flags_save_string = ndr->flags;
745                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
746                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name));
747                         ndr->flags = _flags_save_string;
748                 }
749                 {
750                         uint32_t _flags_save_string = ndr->flags;
751                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
752                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->default_datatype));
753                         ndr->flags = _flags_save_string;
754                 }
755                 {
756                         uint32_t _flags_save_string_array = ndr->flags;
757                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
758                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous_names));
759                         ndr->flags = _flags_save_string_array;
760                 }
761                 NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_date));
762                 NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->driver_version));
763                 {
764                         uint32_t _flags_save_string = ndr->flags;
765                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
766                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->manufacturer_name));
767                         ndr->flags = _flags_save_string;
768                 }
769                 {
770                         uint32_t _flags_save_string = ndr->flags;
771                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
772                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->manufacturer_url));
773                         ndr->flags = _flags_save_string;
774                 }
775                 {
776                         uint32_t _flags_save_string = ndr->flags;
777                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
778                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->hardware_id));
779                         ndr->flags = _flags_save_string;
780                 }
781                 {
782                         uint32_t _flags_save_string = ndr->flags;
783                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
784                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->provider));
785                         ndr->flags = _flags_save_string;
786                 }
787         }
788         if (ndr_flags & NDR_BUFFERS) {
789                 {
790                         uint32_t _flags_save_string = ndr->flags;
791                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
792                         if (r->driver_name) {
793                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name));
794                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name));
795                         }
796                         ndr->flags = _flags_save_string;
797                 }
798                 {
799                         uint32_t _flags_save_string = ndr->flags;
800                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
801                         if (r->architecture) {
802                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->architecture));
803                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->architecture));
804                         }
805                         ndr->flags = _flags_save_string;
806                 }
807                 if (r->file_info) {
808                         NDR_CHECK(ndr_push_relative_ptr2(ndr, r->file_info));
809 #if 0
810                         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->file_count));
811 #endif
812                         for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
813                                 NDR_CHECK(ndr_push_spoolss_DriverFileInfo(ndr, NDR_SCALARS, &r->file_info[cntr_file_info_1]));
814                         }
815                         for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
816                                 NDR_CHECK(ndr_push_spoolss_DriverFileInfo(ndr, NDR_BUFFERS, &r->file_info[cntr_file_info_1]));
817                         }
818                 }
819                 {
820                         uint32_t _flags_save_string = ndr->flags;
821                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
822                         if (r->monitor_name) {
823                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name));
824                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name));
825                         }
826                         ndr->flags = _flags_save_string;
827                 }
828                 {
829                         uint32_t _flags_save_string = ndr->flags;
830                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
831                         if (r->default_datatype) {
832                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->default_datatype));
833                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->default_datatype));
834                         }
835                         ndr->flags = _flags_save_string;
836                 }
837                 {
838                         uint32_t _flags_save_string_array = ndr->flags;
839                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
840                         if (r->previous_names) {
841                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->previous_names));
842                                 NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->previous_names));
843                         }
844                         ndr->flags = _flags_save_string_array;
845                 }
846                 {
847                         uint32_t _flags_save_string = ndr->flags;
848                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
849                         if (r->manufacturer_name) {
850                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->manufacturer_name));
851                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->manufacturer_name));
852                         }
853                         ndr->flags = _flags_save_string;
854                 }
855                 {
856                         uint32_t _flags_save_string = ndr->flags;
857                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
858                         if (r->manufacturer_url) {
859                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->manufacturer_url));
860                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->manufacturer_url));
861                         }
862                         ndr->flags = _flags_save_string;
863                 }
864                 {
865                         uint32_t _flags_save_string = ndr->flags;
866                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
867                         if (r->hardware_id) {
868                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->hardware_id));
869                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->hardware_id));
870                         }
871                         ndr->flags = _flags_save_string;
872                 }
873                 {
874                         uint32_t _flags_save_string = ndr->flags;
875                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
876                         if (r->provider) {
877                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->provider));
878                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->provider));
879                         }
880                         ndr->flags = _flags_save_string;
881                 }
882         }
883         return NDR_ERR_SUCCESS;
884 }
885
886 _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo101 *r)
887 {
888         uint32_t _ptr_driver_name;
889         TALLOC_CTX *_mem_save_driver_name_0;
890         uint32_t _ptr_architecture;
891         TALLOC_CTX *_mem_save_architecture_0;
892         uint32_t _ptr_file_info;
893         uint32_t cntr_file_info_1;
894         TALLOC_CTX *_mem_save_file_info_0;
895         TALLOC_CTX *_mem_save_file_info_1;
896         uint32_t _ptr_monitor_name;
897         TALLOC_CTX *_mem_save_monitor_name_0;
898         uint32_t _ptr_default_datatype;
899         TALLOC_CTX *_mem_save_default_datatype_0;
900         uint32_t _ptr_previous_names;
901         TALLOC_CTX *_mem_save_previous_names_0;
902         uint32_t _ptr_manufacturer_name;
903         TALLOC_CTX *_mem_save_manufacturer_name_0;
904         uint32_t _ptr_manufacturer_url;
905         TALLOC_CTX *_mem_save_manufacturer_url_0;
906         uint32_t _ptr_hardware_id;
907         TALLOC_CTX *_mem_save_hardware_id_0;
908         uint32_t _ptr_provider;
909         TALLOC_CTX *_mem_save_provider_0;
910         if (ndr_flags & NDR_SCALARS) {
911                 NDR_CHECK(ndr_pull_align(ndr, 8));
912                 NDR_CHECK(ndr_pull_spoolss_DriverOSVersion(ndr, NDR_SCALARS, &r->version));
913                 {
914                         uint32_t _flags_save_string = ndr->flags;
915                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
916                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name));
917                         if (_ptr_driver_name) {
918                                 NDR_PULL_ALLOC(ndr, r->driver_name);
919                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name));
920                         } else {
921                                 r->driver_name = NULL;
922                         }
923                         ndr->flags = _flags_save_string;
924                 }
925                 {
926                         uint32_t _flags_save_string = ndr->flags;
927                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
928                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture));
929                         if (_ptr_architecture) {
930                                 NDR_PULL_ALLOC(ndr, r->architecture);
931                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->architecture, _ptr_architecture));
932                         } else {
933                                 r->architecture = NULL;
934                         }
935                         ndr->flags = _flags_save_string;
936                 }
937                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_file_info));
938                 if (_ptr_file_info) {
939                         NDR_PULL_ALLOC(ndr, r->file_info);
940                         NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->file_info, _ptr_file_info));
941                 } else {
942                         r->file_info = NULL;
943                 }
944                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->file_count));
945                 {
946                         uint32_t _flags_save_string = ndr->flags;
947                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
948                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name));
949                         if (_ptr_monitor_name) {
950                                 NDR_PULL_ALLOC(ndr, r->monitor_name);
951                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name));
952                         } else {
953                                 r->monitor_name = NULL;
954                         }
955                         ndr->flags = _flags_save_string;
956                 }
957                 {
958                         uint32_t _flags_save_string = ndr->flags;
959                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
960                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_default_datatype));
961                         if (_ptr_default_datatype) {
962                                 NDR_PULL_ALLOC(ndr, r->default_datatype);
963                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->default_datatype, _ptr_default_datatype));
964                         } else {
965                                 r->default_datatype = NULL;
966                         }
967                         ndr->flags = _flags_save_string;
968                 }
969                 {
970                         uint32_t _flags_save_string_array = ndr->flags;
971                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
972                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous_names));
973                         if (_ptr_previous_names) {
974                                 NDR_PULL_ALLOC(ndr, r->previous_names);
975                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous_names, _ptr_previous_names));
976                         } else {
977                                 r->previous_names = NULL;
978                         }
979                         ndr->flags = _flags_save_string_array;
980                 }
981                 NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_date));
982                 NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->driver_version));
983                 {
984                         uint32_t _flags_save_string = ndr->flags;
985                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
986                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_name));
987                         if (_ptr_manufacturer_name) {
988                                 NDR_PULL_ALLOC(ndr, r->manufacturer_name);
989                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->manufacturer_name, _ptr_manufacturer_name));
990                         } else {
991                                 r->manufacturer_name = NULL;
992                         }
993                         ndr->flags = _flags_save_string;
994                 }
995                 {
996                         uint32_t _flags_save_string = ndr->flags;
997                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
998                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_url));
999                         if (_ptr_manufacturer_url) {
1000                                 NDR_PULL_ALLOC(ndr, r->manufacturer_url);
1001                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->manufacturer_url, _ptr_manufacturer_url));
1002                         } else {
1003                                 r->manufacturer_url = NULL;
1004                         }
1005                         ndr->flags = _flags_save_string;
1006                 }
1007                 {
1008                         uint32_t _flags_save_string = ndr->flags;
1009                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1010                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_hardware_id));
1011                         if (_ptr_hardware_id) {
1012                                 NDR_PULL_ALLOC(ndr, r->hardware_id);
1013                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->hardware_id, _ptr_hardware_id));
1014                         } else {
1015                                 r->hardware_id = NULL;
1016                         }
1017                         ndr->flags = _flags_save_string;
1018                 }
1019                 {
1020                         uint32_t _flags_save_string = ndr->flags;
1021                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1022                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_provider));
1023                         if (_ptr_provider) {
1024                                 NDR_PULL_ALLOC(ndr, r->provider);
1025                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->provider, _ptr_provider));
1026                         } else {
1027                                 r->provider = NULL;
1028                         }
1029                         ndr->flags = _flags_save_string;
1030                 }
1031         }
1032         if (ndr_flags & NDR_BUFFERS) {
1033                 {
1034                         uint32_t _flags_save_string = ndr->flags;
1035                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1036                         if (r->driver_name) {
1037                                 uint32_t _relative_save_offset;
1038                                 _relative_save_offset = ndr->offset;
1039                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name));
1040                                 _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
1041                                 NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0);
1042                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name));
1043                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_name_0, 0);
1044                                 ndr->offset = _relative_save_offset;
1045                         }
1046                         ndr->flags = _flags_save_string;
1047                 }
1048                 {
1049                         uint32_t _flags_save_string = ndr->flags;
1050                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1051                         if (r->architecture) {
1052                                 uint32_t _relative_save_offset;
1053                                 _relative_save_offset = ndr->offset;
1054                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->architecture));
1055                                 _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr);
1056                                 NDR_PULL_SET_MEM_CTX(ndr, r->architecture, 0);
1057                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture));
1058                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_0, 0);
1059                                 ndr->offset = _relative_save_offset;
1060                         }
1061                         ndr->flags = _flags_save_string;
1062                 }
1063                 if (r->file_info) {
1064                         uint32_t _relative_save_offset;
1065                         _relative_save_offset = ndr->offset;
1066                         NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->file_info));
1067                         _mem_save_file_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
1068                         NDR_PULL_SET_MEM_CTX(ndr, r->file_info, 0);
1069 #if 0
1070                         NDR_CHECK(ndr_pull_array_size(ndr, &r->file_info));
1071 #else
1072                         NDR_CHECK(ndr_token_store(ndr, &ndr->array_size_list, &r->file_info, r->file_count));
1073 #endif
1074                         NDR_PULL_ALLOC_N(ndr, r->file_info, ndr_get_array_size(ndr, &r->file_info));
1075                         _mem_save_file_info_1 = NDR_PULL_GET_MEM_CTX(ndr);
1076                         NDR_PULL_SET_MEM_CTX(ndr, r->file_info, 0);
1077                         for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
1078                                 NDR_CHECK(ndr_pull_spoolss_DriverFileInfo(ndr, NDR_SCALARS, &r->file_info[cntr_file_info_1]));
1079                         }
1080                         for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
1081                                 NDR_CHECK(ndr_pull_spoolss_DriverFileInfo(ndr, NDR_BUFFERS, &r->file_info[cntr_file_info_1]));
1082                         }
1083                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_info_1, 0);
1084                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_info_0, 0);
1085                         ndr->offset = _relative_save_offset;
1086                 }
1087                 {
1088                         uint32_t _flags_save_string = ndr->flags;
1089                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1090                         if (r->monitor_name) {
1091                                 uint32_t _relative_save_offset;
1092                                 _relative_save_offset = ndr->offset;
1093                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name));
1094                                 _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
1095                                 NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0);
1096                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name));
1097                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_name_0, 0);
1098                                 ndr->offset = _relative_save_offset;
1099                         }
1100                         ndr->flags = _flags_save_string;
1101                 }
1102                 {
1103                         uint32_t _flags_save_string = ndr->flags;
1104                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1105                         if (r->default_datatype) {
1106                                 uint32_t _relative_save_offset;
1107                                 _relative_save_offset = ndr->offset;
1108                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->default_datatype));
1109                                 _mem_save_default_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr);
1110                                 NDR_PULL_SET_MEM_CTX(ndr, r->default_datatype, 0);
1111                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->default_datatype));
1112                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_default_datatype_0, 0);
1113                                 ndr->offset = _relative_save_offset;
1114                         }
1115                         ndr->flags = _flags_save_string;
1116                 }
1117                 {
1118                         uint32_t _flags_save_string_array = ndr->flags;
1119                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1120                         if (r->previous_names) {
1121                                 uint32_t _relative_save_offset;
1122                                 _relative_save_offset = ndr->offset;
1123                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous_names));
1124                                 _mem_save_previous_names_0 = NDR_PULL_GET_MEM_CTX(ndr);
1125                                 NDR_PULL_SET_MEM_CTX(ndr, r->previous_names, 0);
1126                                 NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->previous_names));
1127                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_names_0, 0);
1128                                 ndr->offset = _relative_save_offset;
1129                         }
1130                         ndr->flags = _flags_save_string_array;
1131                 }
1132                 {
1133                         uint32_t _flags_save_string = ndr->flags;
1134                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1135                         if (r->manufacturer_name) {
1136                                 uint32_t _relative_save_offset;
1137                                 _relative_save_offset = ndr->offset;
1138                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->manufacturer_name));
1139                                 _mem_save_manufacturer_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
1140                                 NDR_PULL_SET_MEM_CTX(ndr, r->manufacturer_name, 0);
1141                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_name));
1142                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_name_0, 0);
1143                                 ndr->offset = _relative_save_offset;
1144                         }
1145                         ndr->flags = _flags_save_string;
1146                 }
1147                 {
1148                         uint32_t _flags_save_string = ndr->flags;
1149                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1150                         if (r->manufacturer_url) {
1151                                 uint32_t _relative_save_offset;
1152                                 _relative_save_offset = ndr->offset;
1153                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->manufacturer_url));
1154                                 _mem_save_manufacturer_url_0 = NDR_PULL_GET_MEM_CTX(ndr);
1155                                 NDR_PULL_SET_MEM_CTX(ndr, r->manufacturer_url, 0);
1156                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_url));
1157                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_url_0, 0);
1158                                 ndr->offset = _relative_save_offset;
1159                         }
1160                         ndr->flags = _flags_save_string;
1161                 }
1162                 {
1163                         uint32_t _flags_save_string = ndr->flags;
1164                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1165                         if (r->hardware_id) {
1166                                 uint32_t _relative_save_offset;
1167                                 _relative_save_offset = ndr->offset;
1168                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->hardware_id));
1169                                 _mem_save_hardware_id_0 = NDR_PULL_GET_MEM_CTX(ndr);
1170                                 NDR_PULL_SET_MEM_CTX(ndr, r->hardware_id, 0);
1171                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->hardware_id));
1172                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hardware_id_0, 0);
1173                                 ndr->offset = _relative_save_offset;
1174                         }
1175                         ndr->flags = _flags_save_string;
1176                 }
1177                 {
1178                         uint32_t _flags_save_string = ndr->flags;
1179                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
1180                         if (r->provider) {
1181                                 uint32_t _relative_save_offset;
1182                                 _relative_save_offset = ndr->offset;
1183                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->provider));
1184                                 _mem_save_provider_0 = NDR_PULL_GET_MEM_CTX(ndr);
1185                                 NDR_PULL_SET_MEM_CTX(ndr, r->provider, 0);
1186                                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->provider));
1187                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_provider_0, 0);
1188                                 ndr->offset = _relative_save_offset;
1189                         }
1190                         ndr->flags = _flags_save_string;
1191                 }
1192                 if (r->file_info) {
1193                         NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->file_info, r->file_count));
1194                 }
1195         }
1196         return NDR_ERR_SUCCESS;
1197 }
1198
1199 void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, const union spoolss_Field *r)
1200 {
1201         int level;
1202         level = ndr_print_get_switch_value(ndr, r);
1203         ndr_print_union(ndr, name, level, "spoolss_Field");
1204         switch (level) {
1205                 case PRINTER_NOTIFY_TYPE:
1206                         ndr_print_spoolss_PrintNotifyField(ndr, "field", r->field);
1207                 break;
1208
1209                 case JOB_NOTIFY_TYPE:
1210                         ndr_print_spoolss_JobNotifyField(ndr, "field", r->field);
1211                 break;
1212
1213                 default:
1214                         ndr_print_uint16(ndr, "field", r->field);
1215                 break;
1216
1217         }
1218 }
1219