4b1483709aa10db48d06821abb97563c2a1a5c54
[samba.git] / source4 / 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    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24
25 #include "includes.h"
26 #include "librpc/gen_ndr/ndr_spoolss.h"
27
28 #define NDR_SPOOLSS_PUSH_ENUM_OUT(fn,type) do { \
29         DATA_BLOB buffer;\
30         if (r->out.info) {\
31                 int i;\
32                 struct ndr_push *ndr2;\
33 \
34                 ndr2 = ndr_push_init_ctx(ndr);\
35                 if (!ndr2) {\
36                         return NT_STATUS_NO_MEMORY;\
37                 }\
38 \
39                 for (i=0;i<r->out.count;i++) {\
40                         ndr2->data += ndr2->offset;\
41                         ndr2->offset = 0;\
42                         NDR_CHECK(ndr_push_set_switch_value(ndr2, &(*r->out.info)[i], r->in.level)); \
43                         NDR_CHECK(ndr_push_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, &(*r->out.info)[i]));\
44                 }\
45                 if (*r->in.buf_size >= ndr2->offset) {\
46                         buffer = data_blob_const(ndr2->data, ndr2->offset);\
47                 } else {\
48                         r->out.info = NULL;\
49                         r->out.count = 0;\
50                         r->out.result = WERR_INSUFFICIENT_BUFFER;\
51                 }\
52                 *r->out.buf_size = ndr2->offset;\
53         }\
54         NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info));\
55         if (r->out.info) {\
56                 NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, buffer));\
57         }\
58         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.buf_size));\
59         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.count));\
60         NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result));\
61 } while(0)
62
63 #define NDR_SPOOLSS_PULL_ENUM_OUT(fn,type) do { \
64         int i;\
65         DATA_BLOB buffer;\
66         struct ndr_pull *ndr2;\
67 \
68         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_info));\
69         if (_ptr_info) {\
70                 NDR_ALLOC(ndr, r->out.info);\
71         } else {\
72                 r->out.info = NULL;\
73         }\
74         if (r->out.info) {\
75                 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, &buffer));\
76                 *r->out.info = NULL;\
77         }\
78         if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {\
79                 NDR_ALLOC(ndr, r->out.buf_size);\
80         }\
81         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.buf_size));\
82         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.count));\
83         NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result));\
84 \
85         if (r->out.info == NULL && r->out.count) {\
86                 return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE,\
87                                       #fn ": r->out.count[%d] but r->out.info == NULL\n",\
88                                       r->out.count);\
89         }\
90 \
91         if (r->out.info && r->out.count) {\
92                 ndr2 = ndr_pull_init_blob(&buffer, ndr);\
93                 if (!ndr2) return NT_STATUS_NO_MEMORY;\
94                 NDR_ALLOC_N(ndr2, *r->out.info, r->out.count);\
95                 for (i=0;i<r->out.count;i++) {\
96                         ndr2->data += ndr2->offset;\
97                         ndr2->offset = 0;\
98                         NDR_CHECK(ndr_pull_set_switch_value(ndr2, &(*r->out.info)[i], r->in.level)); \
99                         NDR_CHECK(ndr_pull_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, &(*r->out.info)[i]));\
100                 }\
101         }\
102 } while(0)
103
104 #define NDR_SPOOLSS_PRINT_ENUM_OUT(fn,type) do { \
105         ndr_print_struct(ndr, "out", #fn);\
106         ndr->depth++;\
107         ndr_print_ptr(ndr, "info", r->out.info);\
108         ndr->depth++;\
109         if (r->out.info) {\
110                 int i;\
111                 ndr->print(ndr, "%s: ARRAY(%d)", "info", r->out.count);\
112                 ndr->depth++;\
113                 for (i=0;i<r->out.count;i++) {\
114                         char *idx=NULL;\
115                         asprintf(&idx, "[%d]", i);\
116                         if (idx) {\
117                                 ndr_print_##type(ndr, idx, r->in.level, &((*r->out.info)[i]));\
118                                 free(idx);\
119                         }\
120                 }\
121                 ndr->depth--;\
122         }\
123         ndr->depth--;\
124         ndr_print_ptr(ndr, "buf_size", r->out.buf_size);\
125         ndr->depth++;\
126         ndr_print_uint32(ndr, "buf_size", *r->out.buf_size);\
127         ndr->depth--;\
128         ndr_print_uint32(ndr, "count", r->out.count);\
129         ndr_print_WERROR(ndr, "result", r->out.result);\
130         ndr->depth--;\
131 } while(0)
132
133 /*
134   spoolss_EnumPrinters
135 */
136 NTSTATUS ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, struct spoolss_EnumPrinters *r)
137 {
138         if (!(flags & NDR_IN)) goto ndr_out;
139
140         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.flags));
141         { uint32_t _flags_save_string = ndr->flags;
142         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
143         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server));
144         ndr->flags = _flags_save_string;
145         }
146         { uint32_t _flags_save_string = ndr->flags;
147         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
148         if (r->in.server) {
149                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.server));
150         }
151         ndr->flags = _flags_save_string;
152         }
153         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level));
154         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer));
155         if (r->in.buffer) {
156                 NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer));
157         }
158         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size));
159         ndr_out:
160         if (!(flags & NDR_OUT)) goto done;
161
162         NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumPrinters,spoolss_PrinterInfo);
163
164         done:
165         return NT_STATUS_OK;
166 }
167
168 NTSTATUS ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r)
169 {
170         uint32_t _ptr_server;
171         uint32_t _ptr_buffer;
172         uint32_t _ptr_info;
173         if (!(flags & NDR_IN)) goto ndr_out;
174
175         ZERO_STRUCT(r->out);
176
177         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.flags));
178         { uint32_t _flags_save_string = ndr->flags;
179         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
180         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_server));
181         if (_ptr_server) {
182                 NDR_ALLOC(ndr, r->in.server);
183         } else {
184                 r->in.server = NULL;
185         }
186         ndr->flags = _flags_save_string;
187         }
188         { uint32_t _flags_save_string = ndr->flags;
189         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
190         if (r->in.server) {
191                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.server));
192         }
193         ndr->flags = _flags_save_string;
194         }
195         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level));
196         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer));
197         if (_ptr_buffer) {
198                 NDR_ALLOC(ndr, r->in.buffer);
199         } else {
200                 r->in.buffer = NULL;
201         }
202         if (r->in.buffer) {
203                 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer));
204         }
205         NDR_ALLOC(ndr, r->in.buf_size);
206         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size));
207         NDR_ALLOC(ndr, r->out.buf_size);
208         *r->out.buf_size = *r->in.buf_size;
209         ndr_out:
210         if (!(flags & NDR_OUT)) goto done;
211
212         NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumPrinters,spoolss_PrinterInfo);
213
214         done:
215
216         return NT_STATUS_OK;
217 }
218
219 void ndr_print_spoolss_EnumPrinters(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumPrinters *r)
220 {
221         ndr_print_struct(ndr, name, "spoolss_EnumPrinters");
222         ndr->depth++;
223         if (flags & NDR_SET_VALUES) {
224                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
225         }
226         if (flags & NDR_IN) {
227                 ndr_print_struct(ndr, "in", "spoolss_EnumPrinters");
228                 ndr->depth++;
229                 ndr_print_uint32(ndr, "flags", r->in.flags);
230                 ndr_print_ptr(ndr, "server", r->in.server);
231                 ndr->depth++;
232                 if (r->in.server) {
233                         ndr_print_string(ndr, "server", r->in.server);
234                 }
235                 ndr->depth--;
236                 ndr_print_uint32(ndr, "level", r->in.level);
237                 ndr_print_ptr(ndr, "buffer", r->in.buffer);
238                 ndr->depth++;
239                 if (r->in.buffer) {
240                         ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer);
241                 }
242                 ndr->depth--;
243                 ndr_print_ptr(ndr, "buf_size", r->in.buf_size);
244                 ndr->depth++;
245                 ndr_print_uint32(ndr, "buf_size", *r->in.buf_size);
246                 ndr->depth--;
247                 ndr->depth--;
248         }
249         if (flags & NDR_OUT) {
250                 NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumPrinters,spoolss_PrinterInfo);
251         }
252         ndr->depth--;
253 }
254
255 /*
256   spoolss_EnumJobs
257 */
258 NTSTATUS ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, struct spoolss_EnumJobs *r)
259 {
260         if (!(flags & NDR_IN)) goto ndr_out;
261
262         NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
263         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.firstjob));
264         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.numjobs));
265         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level));
266         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer));
267         if (r->in.buffer) {
268                 NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer));
269         }
270         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size));
271         ndr_out:
272         if (!(flags & NDR_OUT)) goto done;
273
274         NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumJobs,spoolss_JobInfo);
275
276         done:
277         return NT_STATUS_OK;
278 }
279
280 NTSTATUS ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r)
281 {
282         uint32_t _ptr_buffer;
283         uint32_t _ptr_info;
284         if (!(flags & NDR_IN)) goto ndr_out;
285
286         ZERO_STRUCT(r->out);
287
288         NDR_ALLOC(ndr, r->in.handle);
289         NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
290         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.firstjob));
291         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.numjobs));
292         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level));
293         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer));
294         if (_ptr_buffer) {
295                 NDR_ALLOC(ndr, r->in.buffer);
296         } else {
297                 r->in.buffer = NULL;
298         }
299         if (r->in.buffer) {
300                 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer));
301         }
302         NDR_ALLOC(ndr, r->in.buf_size);
303         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size));
304         NDR_ALLOC(ndr, r->out.buf_size);
305         *r->out.buf_size = *r->in.buf_size;
306         ndr_out:
307         if (!(flags & NDR_OUT)) goto done;
308
309         NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumJobs,spoolss_JobInfo);
310
311         done:
312
313         return NT_STATUS_OK;
314 }
315
316 void ndr_print_spoolss_EnumJobs(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumJobs *r)
317 {
318         ndr_print_struct(ndr, name, "spoolss_EnumJobs");
319         ndr->depth++;
320         if (flags & NDR_SET_VALUES) {
321                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
322         }
323         if (flags & NDR_IN) {
324                 ndr_print_struct(ndr, "in", "spoolss_EnumJobs");
325                 ndr->depth++;
326                 ndr_print_ptr(ndr, "handle", r->in.handle);
327                 ndr->depth++;
328                 ndr_print_policy_handle(ndr, "handle", r->in.handle);
329                 ndr->depth--;
330                 ndr_print_uint32(ndr, "firstjob", r->in.firstjob);
331                 ndr_print_uint32(ndr, "numjobs", r->in.numjobs);
332                 ndr_print_uint32(ndr, "level", r->in.level);
333                 ndr_print_ptr(ndr, "buffer", r->in.buffer);
334                 ndr->depth++;
335                 if (r->in.buffer) {
336                         ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer);
337                 }
338                 ndr->depth--;
339                 ndr_print_ptr(ndr, "buf_size", r->in.buf_size);
340                 ndr->depth++;
341                 ndr_print_uint32(ndr, "buf_size", *r->in.buf_size);
342                 ndr->depth--;
343                 ndr->depth--;
344         }
345         if (flags & NDR_OUT) {
346                 NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumJobs,spoolss_JobInfo);
347         }
348         ndr->depth--;
349 }
350
351 /*
352   spoolss_EnumPrinterDrivers
353 */
354 NTSTATUS ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, struct spoolss_EnumPrinterDrivers *r)
355 {
356         if (!(flags & NDR_IN)) goto ndr_out;
357
358         { uint32_t _flags_save_string = ndr->flags;
359         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
360         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server));
361         ndr->flags = _flags_save_string;
362         }
363         { uint32_t _flags_save_string = ndr->flags;
364         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
365         if (r->in.server) {
366                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.server));
367         }
368         ndr->flags = _flags_save_string;
369         }
370         { uint32_t _flags_save_string = ndr->flags;
371         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
372         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.environment));
373         ndr->flags = _flags_save_string;
374         }
375         { uint32_t _flags_save_string = ndr->flags;
376         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
377         if (r->in.environment) {
378                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.environment));
379         }
380         ndr->flags = _flags_save_string;
381         }
382         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level));
383         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer));
384         if (r->in.buffer) {
385                 NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer));
386         }
387         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size));
388         ndr_out:
389         if (!(flags & NDR_OUT)) goto done;
390
391         NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumPrinterDrivers,spoolss_DriverInfo);
392
393         done:
394         return NT_STATUS_OK;
395 }
396
397 NTSTATUS ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r)
398 {
399         uint32_t _ptr_server;
400         uint32_t _ptr_environment;
401         uint32_t _ptr_buffer;
402         uint32_t _ptr_info;
403         if (!(flags & NDR_IN)) goto ndr_out;
404
405         ZERO_STRUCT(r->out);
406
407         { uint32_t _flags_save_string = ndr->flags;
408         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
409         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_server));
410         if (_ptr_server) {
411                 NDR_ALLOC(ndr, r->in.server);
412         } else {
413                 r->in.server = NULL;
414         }
415         ndr->flags = _flags_save_string;
416         }
417         { uint32_t _flags_save_string = ndr->flags;
418         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
419         if (r->in.server) {
420                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.server));
421         }
422         ndr->flags = _flags_save_string;
423         }
424         { uint32_t _flags_save_string = ndr->flags;
425         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
426         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_environment));
427         if (_ptr_environment) {
428                 NDR_ALLOC(ndr, r->in.environment);
429         } else {
430                 r->in.environment = NULL;
431         }
432         ndr->flags = _flags_save_string;
433         }
434         { uint32_t _flags_save_string = ndr->flags;
435         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
436         if (r->in.environment) {
437                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.environment));
438         }
439         ndr->flags = _flags_save_string;
440         }
441         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level));
442         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer));
443         if (_ptr_buffer) {
444                 NDR_ALLOC(ndr, r->in.buffer);
445         } else {
446                 r->in.buffer = NULL;
447         }
448         if (r->in.buffer) {
449                 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer));
450         }
451         NDR_ALLOC(ndr, r->in.buf_size);
452         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size));
453         NDR_ALLOC(ndr, r->out.buf_size);
454         *r->out.buf_size = *r->in.buf_size;
455         ndr_out:
456         if (!(flags & NDR_OUT)) goto done;
457
458         NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumPrinterDrivers,spoolss_DriverInfo);
459
460         done:
461
462         return NT_STATUS_OK;
463 }
464
465 void ndr_print_spoolss_EnumPrinterDrivers(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumPrinterDrivers *r)
466 {
467         ndr_print_struct(ndr, name, "spoolss_EnumPrinterDrivers");
468         ndr->depth++;
469         if (flags & NDR_SET_VALUES) {
470                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
471         }
472         if (flags & NDR_IN) {
473                 ndr_print_struct(ndr, "in", "spoolss_EnumPrinterDrivers");
474                 ndr->depth++;
475                 ndr_print_ptr(ndr, "server", r->in.server);
476                 ndr->depth++;
477                 if (r->in.server) {
478                         ndr_print_string(ndr, "server", r->in.server);
479                 }
480                 ndr->depth--;
481                 ndr_print_ptr(ndr, "environment", r->in.environment);
482                 ndr->depth++;
483                 if (r->in.environment) {
484                         ndr_print_string(ndr, "environment", r->in.environment);
485                 }
486                 ndr->depth--;
487                 ndr_print_uint32(ndr, "level", r->in.level);
488                 ndr_print_ptr(ndr, "buffer", r->in.buffer);
489                 ndr->depth++;
490                 if (r->in.buffer) {
491                         ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer);
492                 }
493                 ndr->depth--;
494                 ndr_print_ptr(ndr, "buf_size", r->in.buf_size);
495                 ndr->depth++;
496                 ndr_print_uint32(ndr, "buf_size", *r->in.buf_size);
497                 ndr->depth--;
498                 ndr->depth--;
499         }
500         if (flags & NDR_OUT) {
501                 NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumPrinterDrivers,spoolss_DriverInfo);
502         }
503         ndr->depth--;
504 }
505
506 /*
507   spoolss_EnumForms
508 */
509 NTSTATUS ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, struct spoolss_EnumForms *r)
510 {
511         if (!(flags & NDR_IN)) goto ndr_out;
512
513         NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
514         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level));
515         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer));
516         if (r->in.buffer) {
517                 NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer));
518         }
519         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size));
520         ndr_out:
521         if (!(flags & NDR_OUT)) goto done;
522
523         NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumForms,spoolss_FormInfo);
524
525         done:
526         return NT_STATUS_OK;
527 }
528
529 NTSTATUS ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r)
530 {
531         uint32_t _ptr_buffer;
532         uint32_t _ptr_info;
533         if (!(flags & NDR_IN)) goto ndr_out;
534
535         ZERO_STRUCT(r->out);
536
537         NDR_ALLOC(ndr, r->in.handle);
538         NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
539         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level));
540         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer));
541         if (_ptr_buffer) {
542                 NDR_ALLOC(ndr, r->in.buffer);
543         } else {
544                 r->in.buffer = NULL;
545         }
546         if (r->in.buffer) {
547                 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer));
548         }
549         NDR_ALLOC(ndr, r->in.buf_size);
550         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size));
551         NDR_ALLOC(ndr, r->out.buf_size);
552         *r->out.buf_size = *r->in.buf_size;
553         ndr_out:
554         if (!(flags & NDR_OUT)) goto done;
555
556         NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumForms,spoolss_FormInfo);
557
558         done:
559
560         return NT_STATUS_OK;
561 }
562
563 void ndr_print_spoolss_EnumForms(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumForms *r)
564 {
565         ndr_print_struct(ndr, name, "spoolss_EnumForms");
566         ndr->depth++;
567         if (flags & NDR_SET_VALUES) {
568                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
569         }
570         if (flags & NDR_IN) {
571                 ndr_print_struct(ndr, "in", "spoolss_EnumForms");
572                 ndr->depth++;
573                 ndr_print_ptr(ndr, "handle", r->in.handle);
574                 ndr->depth++;
575                 ndr_print_policy_handle(ndr, "handle", r->in.handle);
576                 ndr->depth--;
577                 ndr_print_uint32(ndr, "level", r->in.level);
578                 ndr_print_ptr(ndr, "buffer", r->in.buffer);
579                 ndr->depth++;
580                 if (r->in.buffer) {
581                         ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer);
582                 }
583                 ndr->depth--;
584                 ndr_print_ptr(ndr, "buf_size", r->in.buf_size);
585                 ndr->depth++;
586                 ndr_print_uint32(ndr, "buf_size", *r->in.buf_size);
587                 ndr->depth--;
588                 ndr->depth--;
589         }
590         if (flags & NDR_OUT) {
591                 NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumForms,spoolss_FormInfo);
592         }
593         ndr->depth--;
594 }
595
596 /*
597   spoolss_EnumPorts
598 */
599 NTSTATUS ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, struct spoolss_EnumPorts *r)
600 {
601         if (!(flags & NDR_IN)) goto ndr_out;
602
603         { uint32_t _flags_save_string = ndr->flags;
604         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
605         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername));
606         ndr->flags = _flags_save_string;
607         }
608         { uint32_t _flags_save_string = ndr->flags;
609         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
610         if (r->in.servername) {
611                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.servername));
612         }
613         ndr->flags = _flags_save_string;
614         }
615         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.level));
616         NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer));
617         if (r->in.buffer) {
618                 NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buffer));
619         }
620         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.buf_size));
621         ndr_out:
622         if (!(flags & NDR_OUT)) goto done;
623
624         NDR_SPOOLSS_PUSH_ENUM_OUT(spoolss_EnumPorts,spoolss_PortInfo);
625
626         done:
627         return NT_STATUS_OK;
628 }
629
630 NTSTATUS ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r)
631 {
632         uint32_t _ptr_servername;
633         uint32_t _ptr_buffer;
634         uint32_t _ptr_info;
635         if (!(flags & NDR_IN)) goto ndr_out;
636
637         ZERO_STRUCT(r->out);
638
639         { uint32_t _flags_save_string = ndr->flags;
640         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
641         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_servername));
642         if (_ptr_servername) {
643                 NDR_ALLOC(ndr, r->in.servername);
644         } else {
645                 r->in.servername = NULL;
646         }
647         ndr->flags = _flags_save_string;
648         }
649         { uint32_t _flags_save_string = ndr->flags;
650         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4);
651         if (r->in.servername) {
652                 NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.servername));
653         }
654         ndr->flags = _flags_save_string;
655         }
656         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.level));
657         NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_buffer));
658         if (_ptr_buffer) {
659                 NDR_ALLOC(ndr, r->in.buffer);
660         } else {
661                 r->in.buffer = NULL;
662         }
663         if (r->in.buffer) {
664                 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buffer));
665         }
666         NDR_ALLOC(ndr, r->in.buf_size);
667         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.buf_size));
668         NDR_ALLOC(ndr, r->out.buf_size);
669         *r->out.buf_size = *r->in.buf_size;
670         ndr_out:
671         if (!(flags & NDR_OUT)) goto done;
672
673         NDR_SPOOLSS_PULL_ENUM_OUT(spoolss_EnumPorts,spoolss_PortInfo);
674
675         done:
676
677         return NT_STATUS_OK;
678 }
679
680 void ndr_print_spoolss_EnumPorts(struct ndr_print *ndr, const char *name, int flags, struct spoolss_EnumPorts *r)
681 {
682         ndr_print_struct(ndr, name, "spoolss_EnumPorts");
683         ndr->depth++;
684         if (flags & NDR_SET_VALUES) {
685                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
686         }
687         if (flags & NDR_IN) {
688                 ndr_print_struct(ndr, "in", "spoolss_EnumPorts");
689                 ndr->depth++;
690                 ndr_print_ptr(ndr, "servername", r->in.servername);
691                 ndr->depth++;
692                 if (r->in.servername) {
693                         ndr_print_string(ndr, "servername", r->in.servername);
694                 }
695                 ndr->depth--;
696                 ndr_print_uint32(ndr, "level", r->in.level);
697                 ndr_print_ptr(ndr, "buffer", r->in.buffer);
698                 ndr->depth++;
699                 if (r->in.buffer) {
700                         ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer);
701                 }
702                 ndr->depth--;
703                 ndr_print_ptr(ndr, "buf_size", r->in.buf_size);
704                 ndr->depth++;
705                 ndr_print_uint32(ndr, "buf_size", *r->in.buf_size);
706                 ndr->depth--;
707                 ndr->depth--;
708         }
709         if (flags & NDR_OUT) {
710                 NDR_SPOOLSS_PRINT_ENUM_OUT(spoolss_EnumPorts,spoolss_PortInfo);
711         }
712         ndr->depth--;
713 }