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