librpc/gen_ndr
[metze/samba/wip.git] / source3 / librpc / gen_ndr / ndr_spoolss_c.c
1 /* client functions auto-generated by pidl */
2
3 #include "includes.h"
4 #include <tevent.h>
5 #include "lib/util/tevent_ntstatus.h"
6 #include "librpc/gen_ndr/ndr_spoolss.h"
7 #include "librpc/gen_ndr/ndr_spoolss_c.h"
8
9 /* spoolss - client functions generated by pidl */
10
11 struct dcerpc_spoolss_EnumPrinters_r_state {
12         TALLOC_CTX *out_mem_ctx;
13 };
14
15 static void dcerpc_spoolss_EnumPrinters_r_done(struct tevent_req *subreq);
16
17 struct tevent_req *dcerpc_spoolss_EnumPrinters_r_send(TALLOC_CTX *mem_ctx,
18         struct tevent_context *ev,
19         struct dcerpc_binding_handle *h,
20         struct spoolss_EnumPrinters *r)
21 {
22         struct tevent_req *req;
23         struct dcerpc_spoolss_EnumPrinters_r_state *state;
24         struct tevent_req *subreq;
25
26         req = tevent_req_create(mem_ctx, &state,
27                                 struct dcerpc_spoolss_EnumPrinters_r_state);
28         if (req == NULL) {
29                 return NULL;
30         }
31
32         state->out_mem_ctx = talloc_new(state);
33         if (tevent_req_nomem(state->out_mem_ctx, req)) {
34                 return tevent_req_post(req, ev);
35         }
36
37         subreq = dcerpc_binding_handle_call_send(state, ev, h,
38                         NULL, &ndr_table_spoolss,
39                         NDR_SPOOLSS_ENUMPRINTERS, state->out_mem_ctx, r);
40         if (tevent_req_nomem(subreq, req)) {
41                 return tevent_req_post(req, ev);
42         }
43         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinters_r_done, req);
44
45         return req;
46 }
47
48 static void dcerpc_spoolss_EnumPrinters_r_done(struct tevent_req *subreq)
49 {
50         struct tevent_req *req =
51                 tevent_req_callback_data(subreq,
52                 struct tevent_req);
53         NTSTATUS status;
54
55         status = dcerpc_binding_handle_call_recv(subreq);
56         if (!NT_STATUS_IS_OK(status)) {
57                 tevent_req_nterror(req, status);
58                 return;
59         }
60
61         tevent_req_done(req);
62 }
63
64 NTSTATUS dcerpc_spoolss_EnumPrinters_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
65 {
66         struct dcerpc_spoolss_EnumPrinters_r_state *state =
67                 tevent_req_data(req,
68                 struct dcerpc_spoolss_EnumPrinters_r_state);
69         NTSTATUS status;
70
71         if (tevent_req_is_nterror(req, &status)) {
72                 tevent_req_received(req);
73                 return status;
74         }
75
76         talloc_steal(mem_ctx, state->out_mem_ctx);
77
78         tevent_req_received(req);
79         return NT_STATUS_OK;
80 }
81
82 NTSTATUS dcerpc_spoolss_EnumPrinters_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinters *r)
83 {
84         NTSTATUS status;
85
86         status = dcerpc_binding_handle_call(h,
87                         NULL, &ndr_table_spoolss,
88                         NDR_SPOOLSS_ENUMPRINTERS, mem_ctx, r);
89
90         return status;
91 }
92
93 NTSTATUS dcerpc_spoolss_EnumPrinters_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinters *r)
94 {
95         NTSTATUS status;
96
97         status = dcerpc_spoolss_EnumPrinters_r(p->binding_handle, mem_ctx, r);
98
99         if (NT_STATUS_IS_RPC(status)) {
100                 status = NT_STATUS_NET_WRITE_FAULT;
101         }
102
103         return status;
104 }
105
106 struct dcerpc_spoolss_EnumPrinters_state {
107         struct spoolss_EnumPrinters orig;
108         struct spoolss_EnumPrinters tmp;
109         TALLOC_CTX *out_mem_ctx;
110 };
111
112 static void dcerpc_spoolss_EnumPrinters_done(struct tevent_req *subreq);
113
114 struct tevent_req *dcerpc_spoolss_EnumPrinters_send(TALLOC_CTX *mem_ctx,
115                                                     struct tevent_context *ev,
116                                                     struct dcerpc_binding_handle *h,
117                                                     uint32_t _flags /* [in]  */,
118                                                     const char *_server /* [in] [unique,charset(UTF16)] */,
119                                                     uint32_t _level /* [in]  */,
120                                                     DATA_BLOB *_buffer /* [in] [unique] */,
121                                                     uint32_t _offered /* [in]  */,
122                                                     uint32_t *_count /* [out] [ref] */,
123                                                     union spoolss_PrinterInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
124                                                     uint32_t *_needed /* [out] [ref] */)
125 {
126         struct tevent_req *req;
127         struct dcerpc_spoolss_EnumPrinters_state *state;
128         struct tevent_req *subreq;
129
130         req = tevent_req_create(mem_ctx, &state,
131                                 struct dcerpc_spoolss_EnumPrinters_state);
132         if (req == NULL) {
133                 return NULL;
134         }
135         state->out_mem_ctx = NULL;
136
137         /* In parameters */
138         state->orig.in.flags = _flags;
139         state->orig.in.server = _server;
140         state->orig.in.level = _level;
141         state->orig.in.buffer = _buffer;
142         state->orig.in.offered = _offered;
143
144         /* Out parameters */
145         state->orig.out.count = _count;
146         state->orig.out.info = _info;
147         state->orig.out.needed = _needed;
148
149         /* Result */
150         ZERO_STRUCT(state->orig.out.result);
151
152         state->out_mem_ctx = talloc_named_const(state, 0,
153                              "dcerpc_spoolss_EnumPrinters_out_memory");
154         if (tevent_req_nomem(state->out_mem_ctx, req)) {
155                 return tevent_req_post(req, ev);
156         }
157
158         /* make a temporary copy, that we pass to the dispatch function */
159         state->tmp = state->orig;
160
161         subreq = dcerpc_spoolss_EnumPrinters_r_send(state, ev, h, &state->tmp);
162         if (tevent_req_nomem(subreq, req)) {
163                 return tevent_req_post(req, ev);
164         }
165         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinters_done, req);
166         return req;
167 }
168
169 static void dcerpc_spoolss_EnumPrinters_done(struct tevent_req *subreq)
170 {
171         struct tevent_req *req = tevent_req_callback_data(
172                 subreq, struct tevent_req);
173         struct dcerpc_spoolss_EnumPrinters_state *state = tevent_req_data(
174                 req, struct dcerpc_spoolss_EnumPrinters_state);
175         NTSTATUS status;
176         TALLOC_CTX *mem_ctx;
177
178         if (state->out_mem_ctx) {
179                 mem_ctx = state->out_mem_ctx;
180         } else {
181                 mem_ctx = state;
182         }
183
184         status = dcerpc_spoolss_EnumPrinters_r_recv(subreq, mem_ctx);
185         TALLOC_FREE(subreq);
186         if (!NT_STATUS_IS_OK(status)) {
187                 tevent_req_nterror(req, status);
188                 return;
189         }
190
191         /* Copy out parameters */
192         *state->orig.out.count = *state->tmp.out.count;
193         *state->orig.out.info = *state->tmp.out.info;
194         *state->orig.out.needed = *state->tmp.out.needed;
195
196         /* Copy result */
197         state->orig.out.result = state->tmp.out.result;
198
199         /* Reset temporary structure */
200         ZERO_STRUCT(state->tmp);
201
202         tevent_req_done(req);
203 }
204
205 NTSTATUS dcerpc_spoolss_EnumPrinters_recv(struct tevent_req *req,
206                                           TALLOC_CTX *mem_ctx,
207                                           WERROR *result)
208 {
209         struct dcerpc_spoolss_EnumPrinters_state *state = tevent_req_data(
210                 req, struct dcerpc_spoolss_EnumPrinters_state);
211         NTSTATUS status;
212
213         if (tevent_req_is_nterror(req, &status)) {
214                 tevent_req_received(req);
215                 return status;
216         }
217
218         /* Steal possible out parameters to the callers context */
219         talloc_steal(mem_ctx, state->out_mem_ctx);
220
221         /* Return result */
222         *result = state->orig.out.result;
223
224         tevent_req_received(req);
225         return NT_STATUS_OK;
226 }
227
228 NTSTATUS dcerpc_spoolss_EnumPrinters(struct dcerpc_binding_handle *h,
229                                      TALLOC_CTX *mem_ctx,
230                                      uint32_t _flags /* [in]  */,
231                                      const char *_server /* [in] [unique,charset(UTF16)] */,
232                                      uint32_t _level /* [in]  */,
233                                      DATA_BLOB *_buffer /* [in] [unique] */,
234                                      uint32_t _offered /* [in]  */,
235                                      uint32_t *_count /* [out] [ref] */,
236                                      union spoolss_PrinterInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
237                                      uint32_t *_needed /* [out] [ref] */,
238                                      WERROR *result)
239 {
240         struct spoolss_EnumPrinters r;
241         NTSTATUS status;
242
243         /* In parameters */
244         r.in.flags = _flags;
245         r.in.server = _server;
246         r.in.level = _level;
247         r.in.buffer = _buffer;
248         r.in.offered = _offered;
249
250         status = dcerpc_spoolss_EnumPrinters_r(h, mem_ctx, &r);
251         if (!NT_STATUS_IS_OK(status)) {
252                 return status;
253         }
254
255         /* Return variables */
256         *_count = *r.out.count;
257         *_info = *r.out.info;
258         *_needed = *r.out.needed;
259
260         /* Return result */
261         *result = r.out.result;
262
263         return NT_STATUS_OK;
264 }
265
266 struct dcerpc_spoolss_OpenPrinter_r_state {
267         TALLOC_CTX *out_mem_ctx;
268 };
269
270 static void dcerpc_spoolss_OpenPrinter_r_done(struct tevent_req *subreq);
271
272 struct tevent_req *dcerpc_spoolss_OpenPrinter_r_send(TALLOC_CTX *mem_ctx,
273         struct tevent_context *ev,
274         struct dcerpc_binding_handle *h,
275         struct spoolss_OpenPrinter *r)
276 {
277         struct tevent_req *req;
278         struct dcerpc_spoolss_OpenPrinter_r_state *state;
279         struct tevent_req *subreq;
280
281         req = tevent_req_create(mem_ctx, &state,
282                                 struct dcerpc_spoolss_OpenPrinter_r_state);
283         if (req == NULL) {
284                 return NULL;
285         }
286
287         state->out_mem_ctx = talloc_new(state);
288         if (tevent_req_nomem(state->out_mem_ctx, req)) {
289                 return tevent_req_post(req, ev);
290         }
291
292         subreq = dcerpc_binding_handle_call_send(state, ev, h,
293                         NULL, &ndr_table_spoolss,
294                         NDR_SPOOLSS_OPENPRINTER, state->out_mem_ctx, r);
295         if (tevent_req_nomem(subreq, req)) {
296                 return tevent_req_post(req, ev);
297         }
298         tevent_req_set_callback(subreq, dcerpc_spoolss_OpenPrinter_r_done, req);
299
300         return req;
301 }
302
303 static void dcerpc_spoolss_OpenPrinter_r_done(struct tevent_req *subreq)
304 {
305         struct tevent_req *req =
306                 tevent_req_callback_data(subreq,
307                 struct tevent_req);
308         NTSTATUS status;
309
310         status = dcerpc_binding_handle_call_recv(subreq);
311         if (!NT_STATUS_IS_OK(status)) {
312                 tevent_req_nterror(req, status);
313                 return;
314         }
315
316         tevent_req_done(req);
317 }
318
319 NTSTATUS dcerpc_spoolss_OpenPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
320 {
321         struct dcerpc_spoolss_OpenPrinter_r_state *state =
322                 tevent_req_data(req,
323                 struct dcerpc_spoolss_OpenPrinter_r_state);
324         NTSTATUS status;
325
326         if (tevent_req_is_nterror(req, &status)) {
327                 tevent_req_received(req);
328                 return status;
329         }
330
331         talloc_steal(mem_ctx, state->out_mem_ctx);
332
333         tevent_req_received(req);
334         return NT_STATUS_OK;
335 }
336
337 NTSTATUS dcerpc_spoolss_OpenPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinter *r)
338 {
339         NTSTATUS status;
340
341         status = dcerpc_binding_handle_call(h,
342                         NULL, &ndr_table_spoolss,
343                         NDR_SPOOLSS_OPENPRINTER, mem_ctx, r);
344
345         return status;
346 }
347
348 NTSTATUS dcerpc_spoolss_OpenPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinter *r)
349 {
350         NTSTATUS status;
351
352         status = dcerpc_spoolss_OpenPrinter_r(p->binding_handle, mem_ctx, r);
353
354         if (NT_STATUS_IS_RPC(status)) {
355                 status = NT_STATUS_NET_WRITE_FAULT;
356         }
357
358         return status;
359 }
360
361 struct dcerpc_spoolss_OpenPrinter_state {
362         struct spoolss_OpenPrinter orig;
363         struct spoolss_OpenPrinter tmp;
364         TALLOC_CTX *out_mem_ctx;
365 };
366
367 static void dcerpc_spoolss_OpenPrinter_done(struct tevent_req *subreq);
368
369 struct tevent_req *dcerpc_spoolss_OpenPrinter_send(TALLOC_CTX *mem_ctx,
370                                                    struct tevent_context *ev,
371                                                    struct dcerpc_binding_handle *h,
372                                                    const char *_printername /* [in] [unique,charset(UTF16)] */,
373                                                    const char *_datatype /* [in] [unique,charset(UTF16)] */,
374                                                    struct spoolss_DevmodeContainer _devmode_ctr /* [in]  */,
375                                                    uint32_t _access_mask /* [in]  */,
376                                                    struct policy_handle *_handle /* [out] [ref] */)
377 {
378         struct tevent_req *req;
379         struct dcerpc_spoolss_OpenPrinter_state *state;
380         struct tevent_req *subreq;
381
382         req = tevent_req_create(mem_ctx, &state,
383                                 struct dcerpc_spoolss_OpenPrinter_state);
384         if (req == NULL) {
385                 return NULL;
386         }
387         state->out_mem_ctx = NULL;
388
389         /* In parameters */
390         state->orig.in.printername = _printername;
391         state->orig.in.datatype = _datatype;
392         state->orig.in.devmode_ctr = _devmode_ctr;
393         state->orig.in.access_mask = _access_mask;
394
395         /* Out parameters */
396         state->orig.out.handle = _handle;
397
398         /* Result */
399         ZERO_STRUCT(state->orig.out.result);
400
401         state->out_mem_ctx = talloc_named_const(state, 0,
402                              "dcerpc_spoolss_OpenPrinter_out_memory");
403         if (tevent_req_nomem(state->out_mem_ctx, req)) {
404                 return tevent_req_post(req, ev);
405         }
406
407         /* make a temporary copy, that we pass to the dispatch function */
408         state->tmp = state->orig;
409
410         subreq = dcerpc_spoolss_OpenPrinter_r_send(state, ev, h, &state->tmp);
411         if (tevent_req_nomem(subreq, req)) {
412                 return tevent_req_post(req, ev);
413         }
414         tevent_req_set_callback(subreq, dcerpc_spoolss_OpenPrinter_done, req);
415         return req;
416 }
417
418 static void dcerpc_spoolss_OpenPrinter_done(struct tevent_req *subreq)
419 {
420         struct tevent_req *req = tevent_req_callback_data(
421                 subreq, struct tevent_req);
422         struct dcerpc_spoolss_OpenPrinter_state *state = tevent_req_data(
423                 req, struct dcerpc_spoolss_OpenPrinter_state);
424         NTSTATUS status;
425         TALLOC_CTX *mem_ctx;
426
427         if (state->out_mem_ctx) {
428                 mem_ctx = state->out_mem_ctx;
429         } else {
430                 mem_ctx = state;
431         }
432
433         status = dcerpc_spoolss_OpenPrinter_r_recv(subreq, mem_ctx);
434         TALLOC_FREE(subreq);
435         if (!NT_STATUS_IS_OK(status)) {
436                 tevent_req_nterror(req, status);
437                 return;
438         }
439
440         /* Copy out parameters */
441         *state->orig.out.handle = *state->tmp.out.handle;
442
443         /* Copy result */
444         state->orig.out.result = state->tmp.out.result;
445
446         /* Reset temporary structure */
447         ZERO_STRUCT(state->tmp);
448
449         tevent_req_done(req);
450 }
451
452 NTSTATUS dcerpc_spoolss_OpenPrinter_recv(struct tevent_req *req,
453                                          TALLOC_CTX *mem_ctx,
454                                          WERROR *result)
455 {
456         struct dcerpc_spoolss_OpenPrinter_state *state = tevent_req_data(
457                 req, struct dcerpc_spoolss_OpenPrinter_state);
458         NTSTATUS status;
459
460         if (tevent_req_is_nterror(req, &status)) {
461                 tevent_req_received(req);
462                 return status;
463         }
464
465         /* Steal possible out parameters to the callers context */
466         talloc_steal(mem_ctx, state->out_mem_ctx);
467
468         /* Return result */
469         *result = state->orig.out.result;
470
471         tevent_req_received(req);
472         return NT_STATUS_OK;
473 }
474
475 NTSTATUS dcerpc_spoolss_OpenPrinter(struct dcerpc_binding_handle *h,
476                                     TALLOC_CTX *mem_ctx,
477                                     const char *_printername /* [in] [unique,charset(UTF16)] */,
478                                     const char *_datatype /* [in] [unique,charset(UTF16)] */,
479                                     struct spoolss_DevmodeContainer _devmode_ctr /* [in]  */,
480                                     uint32_t _access_mask /* [in]  */,
481                                     struct policy_handle *_handle /* [out] [ref] */,
482                                     WERROR *result)
483 {
484         struct spoolss_OpenPrinter r;
485         NTSTATUS status;
486
487         /* In parameters */
488         r.in.printername = _printername;
489         r.in.datatype = _datatype;
490         r.in.devmode_ctr = _devmode_ctr;
491         r.in.access_mask = _access_mask;
492
493         status = dcerpc_spoolss_OpenPrinter_r(h, mem_ctx, &r);
494         if (!NT_STATUS_IS_OK(status)) {
495                 return status;
496         }
497
498         /* Return variables */
499         *_handle = *r.out.handle;
500
501         /* Return result */
502         *result = r.out.result;
503
504         return NT_STATUS_OK;
505 }
506
507 struct dcerpc_spoolss_SetJob_r_state {
508         TALLOC_CTX *out_mem_ctx;
509 };
510
511 static void dcerpc_spoolss_SetJob_r_done(struct tevent_req *subreq);
512
513 struct tevent_req *dcerpc_spoolss_SetJob_r_send(TALLOC_CTX *mem_ctx,
514         struct tevent_context *ev,
515         struct dcerpc_binding_handle *h,
516         struct spoolss_SetJob *r)
517 {
518         struct tevent_req *req;
519         struct dcerpc_spoolss_SetJob_r_state *state;
520         struct tevent_req *subreq;
521
522         req = tevent_req_create(mem_ctx, &state,
523                                 struct dcerpc_spoolss_SetJob_r_state);
524         if (req == NULL) {
525                 return NULL;
526         }
527
528         state->out_mem_ctx = NULL;
529         subreq = dcerpc_binding_handle_call_send(state, ev, h,
530                         NULL, &ndr_table_spoolss,
531                         NDR_SPOOLSS_SETJOB, state, r);
532         if (tevent_req_nomem(subreq, req)) {
533                 return tevent_req_post(req, ev);
534         }
535         tevent_req_set_callback(subreq, dcerpc_spoolss_SetJob_r_done, req);
536
537         return req;
538 }
539
540 static void dcerpc_spoolss_SetJob_r_done(struct tevent_req *subreq)
541 {
542         struct tevent_req *req =
543                 tevent_req_callback_data(subreq,
544                 struct tevent_req);
545         NTSTATUS status;
546
547         status = dcerpc_binding_handle_call_recv(subreq);
548         if (!NT_STATUS_IS_OK(status)) {
549                 tevent_req_nterror(req, status);
550                 return;
551         }
552
553         tevent_req_done(req);
554 }
555
556 NTSTATUS dcerpc_spoolss_SetJob_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
557 {
558         struct dcerpc_spoolss_SetJob_r_state *state =
559                 tevent_req_data(req,
560                 struct dcerpc_spoolss_SetJob_r_state);
561         NTSTATUS status;
562
563         if (tevent_req_is_nterror(req, &status)) {
564                 tevent_req_received(req);
565                 return status;
566         }
567
568         talloc_steal(mem_ctx, state->out_mem_ctx);
569
570         tevent_req_received(req);
571         return NT_STATUS_OK;
572 }
573
574 NTSTATUS dcerpc_spoolss_SetJob_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetJob *r)
575 {
576         NTSTATUS status;
577
578         status = dcerpc_binding_handle_call(h,
579                         NULL, &ndr_table_spoolss,
580                         NDR_SPOOLSS_SETJOB, mem_ctx, r);
581
582         return status;
583 }
584
585 NTSTATUS dcerpc_spoolss_SetJob_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetJob *r)
586 {
587         NTSTATUS status;
588
589         status = dcerpc_spoolss_SetJob_r(p->binding_handle, mem_ctx, r);
590
591         if (NT_STATUS_IS_RPC(status)) {
592                 status = NT_STATUS_NET_WRITE_FAULT;
593         }
594
595         return status;
596 }
597
598 struct dcerpc_spoolss_SetJob_state {
599         struct spoolss_SetJob orig;
600         struct spoolss_SetJob tmp;
601         TALLOC_CTX *out_mem_ctx;
602 };
603
604 static void dcerpc_spoolss_SetJob_done(struct tevent_req *subreq);
605
606 struct tevent_req *dcerpc_spoolss_SetJob_send(TALLOC_CTX *mem_ctx,
607                                               struct tevent_context *ev,
608                                               struct dcerpc_binding_handle *h,
609                                               struct policy_handle *_handle /* [in] [ref] */,
610                                               uint32_t _job_id /* [in]  */,
611                                               struct spoolss_JobInfoContainer *_ctr /* [in] [unique] */,
612                                               enum spoolss_JobControl _command /* [in]  */)
613 {
614         struct tevent_req *req;
615         struct dcerpc_spoolss_SetJob_state *state;
616         struct tevent_req *subreq;
617
618         req = tevent_req_create(mem_ctx, &state,
619                                 struct dcerpc_spoolss_SetJob_state);
620         if (req == NULL) {
621                 return NULL;
622         }
623         state->out_mem_ctx = NULL;
624
625         /* In parameters */
626         state->orig.in.handle = _handle;
627         state->orig.in.job_id = _job_id;
628         state->orig.in.ctr = _ctr;
629         state->orig.in.command = _command;
630
631         /* Out parameters */
632
633         /* Result */
634         ZERO_STRUCT(state->orig.out.result);
635
636         /* make a temporary copy, that we pass to the dispatch function */
637         state->tmp = state->orig;
638
639         subreq = dcerpc_spoolss_SetJob_r_send(state, ev, h, &state->tmp);
640         if (tevent_req_nomem(subreq, req)) {
641                 return tevent_req_post(req, ev);
642         }
643         tevent_req_set_callback(subreq, dcerpc_spoolss_SetJob_done, req);
644         return req;
645 }
646
647 static void dcerpc_spoolss_SetJob_done(struct tevent_req *subreq)
648 {
649         struct tevent_req *req = tevent_req_callback_data(
650                 subreq, struct tevent_req);
651         struct dcerpc_spoolss_SetJob_state *state = tevent_req_data(
652                 req, struct dcerpc_spoolss_SetJob_state);
653         NTSTATUS status;
654         TALLOC_CTX *mem_ctx;
655
656         if (state->out_mem_ctx) {
657                 mem_ctx = state->out_mem_ctx;
658         } else {
659                 mem_ctx = state;
660         }
661
662         status = dcerpc_spoolss_SetJob_r_recv(subreq, mem_ctx);
663         TALLOC_FREE(subreq);
664         if (!NT_STATUS_IS_OK(status)) {
665                 tevent_req_nterror(req, status);
666                 return;
667         }
668
669         /* Copy out parameters */
670
671         /* Copy result */
672         state->orig.out.result = state->tmp.out.result;
673
674         /* Reset temporary structure */
675         ZERO_STRUCT(state->tmp);
676
677         tevent_req_done(req);
678 }
679
680 NTSTATUS dcerpc_spoolss_SetJob_recv(struct tevent_req *req,
681                                     TALLOC_CTX *mem_ctx,
682                                     WERROR *result)
683 {
684         struct dcerpc_spoolss_SetJob_state *state = tevent_req_data(
685                 req, struct dcerpc_spoolss_SetJob_state);
686         NTSTATUS status;
687
688         if (tevent_req_is_nterror(req, &status)) {
689                 tevent_req_received(req);
690                 return status;
691         }
692
693         /* Steal possible out parameters to the callers context */
694         talloc_steal(mem_ctx, state->out_mem_ctx);
695
696         /* Return result */
697         *result = state->orig.out.result;
698
699         tevent_req_received(req);
700         return NT_STATUS_OK;
701 }
702
703 NTSTATUS dcerpc_spoolss_SetJob(struct dcerpc_binding_handle *h,
704                                TALLOC_CTX *mem_ctx,
705                                struct policy_handle *_handle /* [in] [ref] */,
706                                uint32_t _job_id /* [in]  */,
707                                struct spoolss_JobInfoContainer *_ctr /* [in] [unique] */,
708                                enum spoolss_JobControl _command /* [in]  */,
709                                WERROR *result)
710 {
711         struct spoolss_SetJob r;
712         NTSTATUS status;
713
714         /* In parameters */
715         r.in.handle = _handle;
716         r.in.job_id = _job_id;
717         r.in.ctr = _ctr;
718         r.in.command = _command;
719
720         status = dcerpc_spoolss_SetJob_r(h, mem_ctx, &r);
721         if (!NT_STATUS_IS_OK(status)) {
722                 return status;
723         }
724
725         /* Return variables */
726
727         /* Return result */
728         *result = r.out.result;
729
730         return NT_STATUS_OK;
731 }
732
733 struct dcerpc_spoolss_GetJob_r_state {
734         TALLOC_CTX *out_mem_ctx;
735 };
736
737 static void dcerpc_spoolss_GetJob_r_done(struct tevent_req *subreq);
738
739 struct tevent_req *dcerpc_spoolss_GetJob_r_send(TALLOC_CTX *mem_ctx,
740         struct tevent_context *ev,
741         struct dcerpc_binding_handle *h,
742         struct spoolss_GetJob *r)
743 {
744         struct tevent_req *req;
745         struct dcerpc_spoolss_GetJob_r_state *state;
746         struct tevent_req *subreq;
747
748         req = tevent_req_create(mem_ctx, &state,
749                                 struct dcerpc_spoolss_GetJob_r_state);
750         if (req == NULL) {
751                 return NULL;
752         }
753
754         state->out_mem_ctx = talloc_new(state);
755         if (tevent_req_nomem(state->out_mem_ctx, req)) {
756                 return tevent_req_post(req, ev);
757         }
758
759         subreq = dcerpc_binding_handle_call_send(state, ev, h,
760                         NULL, &ndr_table_spoolss,
761                         NDR_SPOOLSS_GETJOB, state->out_mem_ctx, r);
762         if (tevent_req_nomem(subreq, req)) {
763                 return tevent_req_post(req, ev);
764         }
765         tevent_req_set_callback(subreq, dcerpc_spoolss_GetJob_r_done, req);
766
767         return req;
768 }
769
770 static void dcerpc_spoolss_GetJob_r_done(struct tevent_req *subreq)
771 {
772         struct tevent_req *req =
773                 tevent_req_callback_data(subreq,
774                 struct tevent_req);
775         NTSTATUS status;
776
777         status = dcerpc_binding_handle_call_recv(subreq);
778         if (!NT_STATUS_IS_OK(status)) {
779                 tevent_req_nterror(req, status);
780                 return;
781         }
782
783         tevent_req_done(req);
784 }
785
786 NTSTATUS dcerpc_spoolss_GetJob_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
787 {
788         struct dcerpc_spoolss_GetJob_r_state *state =
789                 tevent_req_data(req,
790                 struct dcerpc_spoolss_GetJob_r_state);
791         NTSTATUS status;
792
793         if (tevent_req_is_nterror(req, &status)) {
794                 tevent_req_received(req);
795                 return status;
796         }
797
798         talloc_steal(mem_ctx, state->out_mem_ctx);
799
800         tevent_req_received(req);
801         return NT_STATUS_OK;
802 }
803
804 NTSTATUS dcerpc_spoolss_GetJob_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetJob *r)
805 {
806         NTSTATUS status;
807
808         status = dcerpc_binding_handle_call(h,
809                         NULL, &ndr_table_spoolss,
810                         NDR_SPOOLSS_GETJOB, mem_ctx, r);
811
812         return status;
813 }
814
815 NTSTATUS dcerpc_spoolss_GetJob_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetJob *r)
816 {
817         NTSTATUS status;
818
819         status = dcerpc_spoolss_GetJob_r(p->binding_handle, mem_ctx, r);
820
821         if (NT_STATUS_IS_RPC(status)) {
822                 status = NT_STATUS_NET_WRITE_FAULT;
823         }
824
825         return status;
826 }
827
828 struct dcerpc_spoolss_GetJob_state {
829         struct spoolss_GetJob orig;
830         struct spoolss_GetJob tmp;
831         TALLOC_CTX *out_mem_ctx;
832 };
833
834 static void dcerpc_spoolss_GetJob_done(struct tevent_req *subreq);
835
836 struct tevent_req *dcerpc_spoolss_GetJob_send(TALLOC_CTX *mem_ctx,
837                                               struct tevent_context *ev,
838                                               struct dcerpc_binding_handle *h,
839                                               struct policy_handle *_handle /* [in] [ref] */,
840                                               uint32_t _job_id /* [in]  */,
841                                               uint32_t _level /* [in]  */,
842                                               DATA_BLOB *_buffer /* [in] [unique] */,
843                                               uint32_t _offered /* [in]  */,
844                                               union spoolss_JobInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
845                                               uint32_t *_needed /* [out] [ref] */)
846 {
847         struct tevent_req *req;
848         struct dcerpc_spoolss_GetJob_state *state;
849         struct tevent_req *subreq;
850
851         req = tevent_req_create(mem_ctx, &state,
852                                 struct dcerpc_spoolss_GetJob_state);
853         if (req == NULL) {
854                 return NULL;
855         }
856         state->out_mem_ctx = NULL;
857
858         /* In parameters */
859         state->orig.in.handle = _handle;
860         state->orig.in.job_id = _job_id;
861         state->orig.in.level = _level;
862         state->orig.in.buffer = _buffer;
863         state->orig.in.offered = _offered;
864
865         /* Out parameters */
866         state->orig.out.info = _info;
867         state->orig.out.needed = _needed;
868
869         /* Result */
870         ZERO_STRUCT(state->orig.out.result);
871
872         state->out_mem_ctx = talloc_named_const(state, 0,
873                              "dcerpc_spoolss_GetJob_out_memory");
874         if (tevent_req_nomem(state->out_mem_ctx, req)) {
875                 return tevent_req_post(req, ev);
876         }
877
878         /* make a temporary copy, that we pass to the dispatch function */
879         state->tmp = state->orig;
880
881         subreq = dcerpc_spoolss_GetJob_r_send(state, ev, h, &state->tmp);
882         if (tevent_req_nomem(subreq, req)) {
883                 return tevent_req_post(req, ev);
884         }
885         tevent_req_set_callback(subreq, dcerpc_spoolss_GetJob_done, req);
886         return req;
887 }
888
889 static void dcerpc_spoolss_GetJob_done(struct tevent_req *subreq)
890 {
891         struct tevent_req *req = tevent_req_callback_data(
892                 subreq, struct tevent_req);
893         struct dcerpc_spoolss_GetJob_state *state = tevent_req_data(
894                 req, struct dcerpc_spoolss_GetJob_state);
895         NTSTATUS status;
896         TALLOC_CTX *mem_ctx;
897
898         if (state->out_mem_ctx) {
899                 mem_ctx = state->out_mem_ctx;
900         } else {
901                 mem_ctx = state;
902         }
903
904         status = dcerpc_spoolss_GetJob_r_recv(subreq, mem_ctx);
905         TALLOC_FREE(subreq);
906         if (!NT_STATUS_IS_OK(status)) {
907                 tevent_req_nterror(req, status);
908                 return;
909         }
910
911         /* Copy out parameters */
912         if (state->orig.out.info && state->tmp.out.info) {
913                 *state->orig.out.info = *state->tmp.out.info;
914         }
915         *state->orig.out.needed = *state->tmp.out.needed;
916
917         /* Copy result */
918         state->orig.out.result = state->tmp.out.result;
919
920         /* Reset temporary structure */
921         ZERO_STRUCT(state->tmp);
922
923         tevent_req_done(req);
924 }
925
926 NTSTATUS dcerpc_spoolss_GetJob_recv(struct tevent_req *req,
927                                     TALLOC_CTX *mem_ctx,
928                                     WERROR *result)
929 {
930         struct dcerpc_spoolss_GetJob_state *state = tevent_req_data(
931                 req, struct dcerpc_spoolss_GetJob_state);
932         NTSTATUS status;
933
934         if (tevent_req_is_nterror(req, &status)) {
935                 tevent_req_received(req);
936                 return status;
937         }
938
939         /* Steal possible out parameters to the callers context */
940         talloc_steal(mem_ctx, state->out_mem_ctx);
941
942         /* Return result */
943         *result = state->orig.out.result;
944
945         tevent_req_received(req);
946         return NT_STATUS_OK;
947 }
948
949 NTSTATUS dcerpc_spoolss_GetJob(struct dcerpc_binding_handle *h,
950                                TALLOC_CTX *mem_ctx,
951                                struct policy_handle *_handle /* [in] [ref] */,
952                                uint32_t _job_id /* [in]  */,
953                                uint32_t _level /* [in]  */,
954                                DATA_BLOB *_buffer /* [in] [unique] */,
955                                uint32_t _offered /* [in]  */,
956                                union spoolss_JobInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
957                                uint32_t *_needed /* [out] [ref] */,
958                                WERROR *result)
959 {
960         struct spoolss_GetJob r;
961         NTSTATUS status;
962
963         /* In parameters */
964         r.in.handle = _handle;
965         r.in.job_id = _job_id;
966         r.in.level = _level;
967         r.in.buffer = _buffer;
968         r.in.offered = _offered;
969
970         status = dcerpc_spoolss_GetJob_r(h, mem_ctx, &r);
971         if (!NT_STATUS_IS_OK(status)) {
972                 return status;
973         }
974
975         /* Return variables */
976         if (_info && r.out.info) {
977                 *_info = *r.out.info;
978         }
979         *_needed = *r.out.needed;
980
981         /* Return result */
982         *result = r.out.result;
983
984         return NT_STATUS_OK;
985 }
986
987 struct dcerpc_spoolss_EnumJobs_r_state {
988         TALLOC_CTX *out_mem_ctx;
989 };
990
991 static void dcerpc_spoolss_EnumJobs_r_done(struct tevent_req *subreq);
992
993 struct tevent_req *dcerpc_spoolss_EnumJobs_r_send(TALLOC_CTX *mem_ctx,
994         struct tevent_context *ev,
995         struct dcerpc_binding_handle *h,
996         struct spoolss_EnumJobs *r)
997 {
998         struct tevent_req *req;
999         struct dcerpc_spoolss_EnumJobs_r_state *state;
1000         struct tevent_req *subreq;
1001
1002         req = tevent_req_create(mem_ctx, &state,
1003                                 struct dcerpc_spoolss_EnumJobs_r_state);
1004         if (req == NULL) {
1005                 return NULL;
1006         }
1007
1008         state->out_mem_ctx = talloc_new(state);
1009         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1010                 return tevent_req_post(req, ev);
1011         }
1012
1013         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1014                         NULL, &ndr_table_spoolss,
1015                         NDR_SPOOLSS_ENUMJOBS, state->out_mem_ctx, r);
1016         if (tevent_req_nomem(subreq, req)) {
1017                 return tevent_req_post(req, ev);
1018         }
1019         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumJobs_r_done, req);
1020
1021         return req;
1022 }
1023
1024 static void dcerpc_spoolss_EnumJobs_r_done(struct tevent_req *subreq)
1025 {
1026         struct tevent_req *req =
1027                 tevent_req_callback_data(subreq,
1028                 struct tevent_req);
1029         NTSTATUS status;
1030
1031         status = dcerpc_binding_handle_call_recv(subreq);
1032         if (!NT_STATUS_IS_OK(status)) {
1033                 tevent_req_nterror(req, status);
1034                 return;
1035         }
1036
1037         tevent_req_done(req);
1038 }
1039
1040 NTSTATUS dcerpc_spoolss_EnumJobs_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1041 {
1042         struct dcerpc_spoolss_EnumJobs_r_state *state =
1043                 tevent_req_data(req,
1044                 struct dcerpc_spoolss_EnumJobs_r_state);
1045         NTSTATUS status;
1046
1047         if (tevent_req_is_nterror(req, &status)) {
1048                 tevent_req_received(req);
1049                 return status;
1050         }
1051
1052         talloc_steal(mem_ctx, state->out_mem_ctx);
1053
1054         tevent_req_received(req);
1055         return NT_STATUS_OK;
1056 }
1057
1058 NTSTATUS dcerpc_spoolss_EnumJobs_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumJobs *r)
1059 {
1060         NTSTATUS status;
1061
1062         status = dcerpc_binding_handle_call(h,
1063                         NULL, &ndr_table_spoolss,
1064                         NDR_SPOOLSS_ENUMJOBS, mem_ctx, r);
1065
1066         return status;
1067 }
1068
1069 NTSTATUS dcerpc_spoolss_EnumJobs_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumJobs *r)
1070 {
1071         NTSTATUS status;
1072
1073         status = dcerpc_spoolss_EnumJobs_r(p->binding_handle, mem_ctx, r);
1074
1075         if (NT_STATUS_IS_RPC(status)) {
1076                 status = NT_STATUS_NET_WRITE_FAULT;
1077         }
1078
1079         return status;
1080 }
1081
1082 struct dcerpc_spoolss_EnumJobs_state {
1083         struct spoolss_EnumJobs orig;
1084         struct spoolss_EnumJobs tmp;
1085         TALLOC_CTX *out_mem_ctx;
1086 };
1087
1088 static void dcerpc_spoolss_EnumJobs_done(struct tevent_req *subreq);
1089
1090 struct tevent_req *dcerpc_spoolss_EnumJobs_send(TALLOC_CTX *mem_ctx,
1091                                                 struct tevent_context *ev,
1092                                                 struct dcerpc_binding_handle *h,
1093                                                 struct policy_handle *_handle /* [in] [ref] */,
1094                                                 uint32_t _firstjob /* [in]  */,
1095                                                 uint32_t _numjobs /* [in]  */,
1096                                                 uint32_t _level /* [in]  */,
1097                                                 DATA_BLOB *_buffer /* [in] [unique] */,
1098                                                 uint32_t _offered /* [in]  */,
1099                                                 uint32_t *_count /* [out] [ref] */,
1100                                                 union spoolss_JobInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
1101                                                 uint32_t *_needed /* [out] [ref] */)
1102 {
1103         struct tevent_req *req;
1104         struct dcerpc_spoolss_EnumJobs_state *state;
1105         struct tevent_req *subreq;
1106
1107         req = tevent_req_create(mem_ctx, &state,
1108                                 struct dcerpc_spoolss_EnumJobs_state);
1109         if (req == NULL) {
1110                 return NULL;
1111         }
1112         state->out_mem_ctx = NULL;
1113
1114         /* In parameters */
1115         state->orig.in.handle = _handle;
1116         state->orig.in.firstjob = _firstjob;
1117         state->orig.in.numjobs = _numjobs;
1118         state->orig.in.level = _level;
1119         state->orig.in.buffer = _buffer;
1120         state->orig.in.offered = _offered;
1121
1122         /* Out parameters */
1123         state->orig.out.count = _count;
1124         state->orig.out.info = _info;
1125         state->orig.out.needed = _needed;
1126
1127         /* Result */
1128         ZERO_STRUCT(state->orig.out.result);
1129
1130         state->out_mem_ctx = talloc_named_const(state, 0,
1131                              "dcerpc_spoolss_EnumJobs_out_memory");
1132         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1133                 return tevent_req_post(req, ev);
1134         }
1135
1136         /* make a temporary copy, that we pass to the dispatch function */
1137         state->tmp = state->orig;
1138
1139         subreq = dcerpc_spoolss_EnumJobs_r_send(state, ev, h, &state->tmp);
1140         if (tevent_req_nomem(subreq, req)) {
1141                 return tevent_req_post(req, ev);
1142         }
1143         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumJobs_done, req);
1144         return req;
1145 }
1146
1147 static void dcerpc_spoolss_EnumJobs_done(struct tevent_req *subreq)
1148 {
1149         struct tevent_req *req = tevent_req_callback_data(
1150                 subreq, struct tevent_req);
1151         struct dcerpc_spoolss_EnumJobs_state *state = tevent_req_data(
1152                 req, struct dcerpc_spoolss_EnumJobs_state);
1153         NTSTATUS status;
1154         TALLOC_CTX *mem_ctx;
1155
1156         if (state->out_mem_ctx) {
1157                 mem_ctx = state->out_mem_ctx;
1158         } else {
1159                 mem_ctx = state;
1160         }
1161
1162         status = dcerpc_spoolss_EnumJobs_r_recv(subreq, mem_ctx);
1163         TALLOC_FREE(subreq);
1164         if (!NT_STATUS_IS_OK(status)) {
1165                 tevent_req_nterror(req, status);
1166                 return;
1167         }
1168
1169         /* Copy out parameters */
1170         *state->orig.out.count = *state->tmp.out.count;
1171         *state->orig.out.info = *state->tmp.out.info;
1172         *state->orig.out.needed = *state->tmp.out.needed;
1173
1174         /* Copy result */
1175         state->orig.out.result = state->tmp.out.result;
1176
1177         /* Reset temporary structure */
1178         ZERO_STRUCT(state->tmp);
1179
1180         tevent_req_done(req);
1181 }
1182
1183 NTSTATUS dcerpc_spoolss_EnumJobs_recv(struct tevent_req *req,
1184                                       TALLOC_CTX *mem_ctx,
1185                                       WERROR *result)
1186 {
1187         struct dcerpc_spoolss_EnumJobs_state *state = tevent_req_data(
1188                 req, struct dcerpc_spoolss_EnumJobs_state);
1189         NTSTATUS status;
1190
1191         if (tevent_req_is_nterror(req, &status)) {
1192                 tevent_req_received(req);
1193                 return status;
1194         }
1195
1196         /* Steal possible out parameters to the callers context */
1197         talloc_steal(mem_ctx, state->out_mem_ctx);
1198
1199         /* Return result */
1200         *result = state->orig.out.result;
1201
1202         tevent_req_received(req);
1203         return NT_STATUS_OK;
1204 }
1205
1206 NTSTATUS dcerpc_spoolss_EnumJobs(struct dcerpc_binding_handle *h,
1207                                  TALLOC_CTX *mem_ctx,
1208                                  struct policy_handle *_handle /* [in] [ref] */,
1209                                  uint32_t _firstjob /* [in]  */,
1210                                  uint32_t _numjobs /* [in]  */,
1211                                  uint32_t _level /* [in]  */,
1212                                  DATA_BLOB *_buffer /* [in] [unique] */,
1213                                  uint32_t _offered /* [in]  */,
1214                                  uint32_t *_count /* [out] [ref] */,
1215                                  union spoolss_JobInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
1216                                  uint32_t *_needed /* [out] [ref] */,
1217                                  WERROR *result)
1218 {
1219         struct spoolss_EnumJobs r;
1220         NTSTATUS status;
1221
1222         /* In parameters */
1223         r.in.handle = _handle;
1224         r.in.firstjob = _firstjob;
1225         r.in.numjobs = _numjobs;
1226         r.in.level = _level;
1227         r.in.buffer = _buffer;
1228         r.in.offered = _offered;
1229
1230         status = dcerpc_spoolss_EnumJobs_r(h, mem_ctx, &r);
1231         if (!NT_STATUS_IS_OK(status)) {
1232                 return status;
1233         }
1234
1235         /* Return variables */
1236         *_count = *r.out.count;
1237         *_info = *r.out.info;
1238         *_needed = *r.out.needed;
1239
1240         /* Return result */
1241         *result = r.out.result;
1242
1243         return NT_STATUS_OK;
1244 }
1245
1246 struct dcerpc_spoolss_AddPrinter_r_state {
1247         TALLOC_CTX *out_mem_ctx;
1248 };
1249
1250 static void dcerpc_spoolss_AddPrinter_r_done(struct tevent_req *subreq);
1251
1252 struct tevent_req *dcerpc_spoolss_AddPrinter_r_send(TALLOC_CTX *mem_ctx,
1253         struct tevent_context *ev,
1254         struct dcerpc_binding_handle *h,
1255         struct spoolss_AddPrinter *r)
1256 {
1257         struct tevent_req *req;
1258         struct dcerpc_spoolss_AddPrinter_r_state *state;
1259         struct tevent_req *subreq;
1260
1261         req = tevent_req_create(mem_ctx, &state,
1262                                 struct dcerpc_spoolss_AddPrinter_r_state);
1263         if (req == NULL) {
1264                 return NULL;
1265         }
1266
1267         state->out_mem_ctx = talloc_new(state);
1268         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1269                 return tevent_req_post(req, ev);
1270         }
1271
1272         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1273                         NULL, &ndr_table_spoolss,
1274                         NDR_SPOOLSS_ADDPRINTER, state->out_mem_ctx, r);
1275         if (tevent_req_nomem(subreq, req)) {
1276                 return tevent_req_post(req, ev);
1277         }
1278         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinter_r_done, req);
1279
1280         return req;
1281 }
1282
1283 static void dcerpc_spoolss_AddPrinter_r_done(struct tevent_req *subreq)
1284 {
1285         struct tevent_req *req =
1286                 tevent_req_callback_data(subreq,
1287                 struct tevent_req);
1288         NTSTATUS status;
1289
1290         status = dcerpc_binding_handle_call_recv(subreq);
1291         if (!NT_STATUS_IS_OK(status)) {
1292                 tevent_req_nterror(req, status);
1293                 return;
1294         }
1295
1296         tevent_req_done(req);
1297 }
1298
1299 NTSTATUS dcerpc_spoolss_AddPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1300 {
1301         struct dcerpc_spoolss_AddPrinter_r_state *state =
1302                 tevent_req_data(req,
1303                 struct dcerpc_spoolss_AddPrinter_r_state);
1304         NTSTATUS status;
1305
1306         if (tevent_req_is_nterror(req, &status)) {
1307                 tevent_req_received(req);
1308                 return status;
1309         }
1310
1311         talloc_steal(mem_ctx, state->out_mem_ctx);
1312
1313         tevent_req_received(req);
1314         return NT_STATUS_OK;
1315 }
1316
1317 NTSTATUS dcerpc_spoolss_AddPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinter *r)
1318 {
1319         NTSTATUS status;
1320
1321         status = dcerpc_binding_handle_call(h,
1322                         NULL, &ndr_table_spoolss,
1323                         NDR_SPOOLSS_ADDPRINTER, mem_ctx, r);
1324
1325         return status;
1326 }
1327
1328 NTSTATUS dcerpc_spoolss_AddPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinter *r)
1329 {
1330         NTSTATUS status;
1331
1332         status = dcerpc_spoolss_AddPrinter_r(p->binding_handle, mem_ctx, r);
1333
1334         if (NT_STATUS_IS_RPC(status)) {
1335                 status = NT_STATUS_NET_WRITE_FAULT;
1336         }
1337
1338         return status;
1339 }
1340
1341 struct dcerpc_spoolss_AddPrinter_state {
1342         struct spoolss_AddPrinter orig;
1343         struct spoolss_AddPrinter tmp;
1344         TALLOC_CTX *out_mem_ctx;
1345 };
1346
1347 static void dcerpc_spoolss_AddPrinter_done(struct tevent_req *subreq);
1348
1349 struct tevent_req *dcerpc_spoolss_AddPrinter_send(TALLOC_CTX *mem_ctx,
1350                                                   struct tevent_context *ev,
1351                                                   struct dcerpc_binding_handle *h,
1352                                                   const char *_server /* [in] [unique,charset(UTF16)] */,
1353                                                   struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
1354                                                   struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
1355                                                   struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
1356                                                   struct policy_handle *_handle /* [out] [ref] */)
1357 {
1358         struct tevent_req *req;
1359         struct dcerpc_spoolss_AddPrinter_state *state;
1360         struct tevent_req *subreq;
1361
1362         req = tevent_req_create(mem_ctx, &state,
1363                                 struct dcerpc_spoolss_AddPrinter_state);
1364         if (req == NULL) {
1365                 return NULL;
1366         }
1367         state->out_mem_ctx = NULL;
1368
1369         /* In parameters */
1370         state->orig.in.server = _server;
1371         state->orig.in.info_ctr = _info_ctr;
1372         state->orig.in.devmode_ctr = _devmode_ctr;
1373         state->orig.in.secdesc_ctr = _secdesc_ctr;
1374
1375         /* Out parameters */
1376         state->orig.out.handle = _handle;
1377
1378         /* Result */
1379         ZERO_STRUCT(state->orig.out.result);
1380
1381         state->out_mem_ctx = talloc_named_const(state, 0,
1382                              "dcerpc_spoolss_AddPrinter_out_memory");
1383         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1384                 return tevent_req_post(req, ev);
1385         }
1386
1387         /* make a temporary copy, that we pass to the dispatch function */
1388         state->tmp = state->orig;
1389
1390         subreq = dcerpc_spoolss_AddPrinter_r_send(state, ev, h, &state->tmp);
1391         if (tevent_req_nomem(subreq, req)) {
1392                 return tevent_req_post(req, ev);
1393         }
1394         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinter_done, req);
1395         return req;
1396 }
1397
1398 static void dcerpc_spoolss_AddPrinter_done(struct tevent_req *subreq)
1399 {
1400         struct tevent_req *req = tevent_req_callback_data(
1401                 subreq, struct tevent_req);
1402         struct dcerpc_spoolss_AddPrinter_state *state = tevent_req_data(
1403                 req, struct dcerpc_spoolss_AddPrinter_state);
1404         NTSTATUS status;
1405         TALLOC_CTX *mem_ctx;
1406
1407         if (state->out_mem_ctx) {
1408                 mem_ctx = state->out_mem_ctx;
1409         } else {
1410                 mem_ctx = state;
1411         }
1412
1413         status = dcerpc_spoolss_AddPrinter_r_recv(subreq, mem_ctx);
1414         TALLOC_FREE(subreq);
1415         if (!NT_STATUS_IS_OK(status)) {
1416                 tevent_req_nterror(req, status);
1417                 return;
1418         }
1419
1420         /* Copy out parameters */
1421         *state->orig.out.handle = *state->tmp.out.handle;
1422
1423         /* Copy result */
1424         state->orig.out.result = state->tmp.out.result;
1425
1426         /* Reset temporary structure */
1427         ZERO_STRUCT(state->tmp);
1428
1429         tevent_req_done(req);
1430 }
1431
1432 NTSTATUS dcerpc_spoolss_AddPrinter_recv(struct tevent_req *req,
1433                                         TALLOC_CTX *mem_ctx,
1434                                         WERROR *result)
1435 {
1436         struct dcerpc_spoolss_AddPrinter_state *state = tevent_req_data(
1437                 req, struct dcerpc_spoolss_AddPrinter_state);
1438         NTSTATUS status;
1439
1440         if (tevent_req_is_nterror(req, &status)) {
1441                 tevent_req_received(req);
1442                 return status;
1443         }
1444
1445         /* Steal possible out parameters to the callers context */
1446         talloc_steal(mem_ctx, state->out_mem_ctx);
1447
1448         /* Return result */
1449         *result = state->orig.out.result;
1450
1451         tevent_req_received(req);
1452         return NT_STATUS_OK;
1453 }
1454
1455 NTSTATUS dcerpc_spoolss_AddPrinter(struct dcerpc_binding_handle *h,
1456                                    TALLOC_CTX *mem_ctx,
1457                                    const char *_server /* [in] [unique,charset(UTF16)] */,
1458                                    struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
1459                                    struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
1460                                    struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
1461                                    struct policy_handle *_handle /* [out] [ref] */,
1462                                    WERROR *result)
1463 {
1464         struct spoolss_AddPrinter r;
1465         NTSTATUS status;
1466
1467         /* In parameters */
1468         r.in.server = _server;
1469         r.in.info_ctr = _info_ctr;
1470         r.in.devmode_ctr = _devmode_ctr;
1471         r.in.secdesc_ctr = _secdesc_ctr;
1472
1473         status = dcerpc_spoolss_AddPrinter_r(h, mem_ctx, &r);
1474         if (!NT_STATUS_IS_OK(status)) {
1475                 return status;
1476         }
1477
1478         /* Return variables */
1479         *_handle = *r.out.handle;
1480
1481         /* Return result */
1482         *result = r.out.result;
1483
1484         return NT_STATUS_OK;
1485 }
1486
1487 struct dcerpc_spoolss_DeletePrinter_r_state {
1488         TALLOC_CTX *out_mem_ctx;
1489 };
1490
1491 static void dcerpc_spoolss_DeletePrinter_r_done(struct tevent_req *subreq);
1492
1493 struct tevent_req *dcerpc_spoolss_DeletePrinter_r_send(TALLOC_CTX *mem_ctx,
1494         struct tevent_context *ev,
1495         struct dcerpc_binding_handle *h,
1496         struct spoolss_DeletePrinter *r)
1497 {
1498         struct tevent_req *req;
1499         struct dcerpc_spoolss_DeletePrinter_r_state *state;
1500         struct tevent_req *subreq;
1501
1502         req = tevent_req_create(mem_ctx, &state,
1503                                 struct dcerpc_spoolss_DeletePrinter_r_state);
1504         if (req == NULL) {
1505                 return NULL;
1506         }
1507
1508         state->out_mem_ctx = NULL;
1509         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1510                         NULL, &ndr_table_spoolss,
1511                         NDR_SPOOLSS_DELETEPRINTER, state, r);
1512         if (tevent_req_nomem(subreq, req)) {
1513                 return tevent_req_post(req, ev);
1514         }
1515         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinter_r_done, req);
1516
1517         return req;
1518 }
1519
1520 static void dcerpc_spoolss_DeletePrinter_r_done(struct tevent_req *subreq)
1521 {
1522         struct tevent_req *req =
1523                 tevent_req_callback_data(subreq,
1524                 struct tevent_req);
1525         NTSTATUS status;
1526
1527         status = dcerpc_binding_handle_call_recv(subreq);
1528         if (!NT_STATUS_IS_OK(status)) {
1529                 tevent_req_nterror(req, status);
1530                 return;
1531         }
1532
1533         tevent_req_done(req);
1534 }
1535
1536 NTSTATUS dcerpc_spoolss_DeletePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1537 {
1538         struct dcerpc_spoolss_DeletePrinter_r_state *state =
1539                 tevent_req_data(req,
1540                 struct dcerpc_spoolss_DeletePrinter_r_state);
1541         NTSTATUS status;
1542
1543         if (tevent_req_is_nterror(req, &status)) {
1544                 tevent_req_received(req);
1545                 return status;
1546         }
1547
1548         talloc_steal(mem_ctx, state->out_mem_ctx);
1549
1550         tevent_req_received(req);
1551         return NT_STATUS_OK;
1552 }
1553
1554 NTSTATUS dcerpc_spoolss_DeletePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinter *r)
1555 {
1556         NTSTATUS status;
1557
1558         status = dcerpc_binding_handle_call(h,
1559                         NULL, &ndr_table_spoolss,
1560                         NDR_SPOOLSS_DELETEPRINTER, mem_ctx, r);
1561
1562         return status;
1563 }
1564
1565 NTSTATUS dcerpc_spoolss_DeletePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinter *r)
1566 {
1567         NTSTATUS status;
1568
1569         status = dcerpc_spoolss_DeletePrinter_r(p->binding_handle, mem_ctx, r);
1570
1571         if (NT_STATUS_IS_RPC(status)) {
1572                 status = NT_STATUS_NET_WRITE_FAULT;
1573         }
1574
1575         return status;
1576 }
1577
1578 struct dcerpc_spoolss_DeletePrinter_state {
1579         struct spoolss_DeletePrinter orig;
1580         struct spoolss_DeletePrinter tmp;
1581         TALLOC_CTX *out_mem_ctx;
1582 };
1583
1584 static void dcerpc_spoolss_DeletePrinter_done(struct tevent_req *subreq);
1585
1586 struct tevent_req *dcerpc_spoolss_DeletePrinter_send(TALLOC_CTX *mem_ctx,
1587                                                      struct tevent_context *ev,
1588                                                      struct dcerpc_binding_handle *h,
1589                                                      struct policy_handle *_handle /* [in] [ref] */)
1590 {
1591         struct tevent_req *req;
1592         struct dcerpc_spoolss_DeletePrinter_state *state;
1593         struct tevent_req *subreq;
1594
1595         req = tevent_req_create(mem_ctx, &state,
1596                                 struct dcerpc_spoolss_DeletePrinter_state);
1597         if (req == NULL) {
1598                 return NULL;
1599         }
1600         state->out_mem_ctx = NULL;
1601
1602         /* In parameters */
1603         state->orig.in.handle = _handle;
1604
1605         /* Out parameters */
1606
1607         /* Result */
1608         ZERO_STRUCT(state->orig.out.result);
1609
1610         /* make a temporary copy, that we pass to the dispatch function */
1611         state->tmp = state->orig;
1612
1613         subreq = dcerpc_spoolss_DeletePrinter_r_send(state, ev, h, &state->tmp);
1614         if (tevent_req_nomem(subreq, req)) {
1615                 return tevent_req_post(req, ev);
1616         }
1617         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinter_done, req);
1618         return req;
1619 }
1620
1621 static void dcerpc_spoolss_DeletePrinter_done(struct tevent_req *subreq)
1622 {
1623         struct tevent_req *req = tevent_req_callback_data(
1624                 subreq, struct tevent_req);
1625         struct dcerpc_spoolss_DeletePrinter_state *state = tevent_req_data(
1626                 req, struct dcerpc_spoolss_DeletePrinter_state);
1627         NTSTATUS status;
1628         TALLOC_CTX *mem_ctx;
1629
1630         if (state->out_mem_ctx) {
1631                 mem_ctx = state->out_mem_ctx;
1632         } else {
1633                 mem_ctx = state;
1634         }
1635
1636         status = dcerpc_spoolss_DeletePrinter_r_recv(subreq, mem_ctx);
1637         TALLOC_FREE(subreq);
1638         if (!NT_STATUS_IS_OK(status)) {
1639                 tevent_req_nterror(req, status);
1640                 return;
1641         }
1642
1643         /* Copy out parameters */
1644
1645         /* Copy result */
1646         state->orig.out.result = state->tmp.out.result;
1647
1648         /* Reset temporary structure */
1649         ZERO_STRUCT(state->tmp);
1650
1651         tevent_req_done(req);
1652 }
1653
1654 NTSTATUS dcerpc_spoolss_DeletePrinter_recv(struct tevent_req *req,
1655                                            TALLOC_CTX *mem_ctx,
1656                                            WERROR *result)
1657 {
1658         struct dcerpc_spoolss_DeletePrinter_state *state = tevent_req_data(
1659                 req, struct dcerpc_spoolss_DeletePrinter_state);
1660         NTSTATUS status;
1661
1662         if (tevent_req_is_nterror(req, &status)) {
1663                 tevent_req_received(req);
1664                 return status;
1665         }
1666
1667         /* Steal possible out parameters to the callers context */
1668         talloc_steal(mem_ctx, state->out_mem_ctx);
1669
1670         /* Return result */
1671         *result = state->orig.out.result;
1672
1673         tevent_req_received(req);
1674         return NT_STATUS_OK;
1675 }
1676
1677 NTSTATUS dcerpc_spoolss_DeletePrinter(struct dcerpc_binding_handle *h,
1678                                       TALLOC_CTX *mem_ctx,
1679                                       struct policy_handle *_handle /* [in] [ref] */,
1680                                       WERROR *result)
1681 {
1682         struct spoolss_DeletePrinter r;
1683         NTSTATUS status;
1684
1685         /* In parameters */
1686         r.in.handle = _handle;
1687
1688         status = dcerpc_spoolss_DeletePrinter_r(h, mem_ctx, &r);
1689         if (!NT_STATUS_IS_OK(status)) {
1690                 return status;
1691         }
1692
1693         /* Return variables */
1694
1695         /* Return result */
1696         *result = r.out.result;
1697
1698         return NT_STATUS_OK;
1699 }
1700
1701 struct dcerpc_spoolss_SetPrinter_r_state {
1702         TALLOC_CTX *out_mem_ctx;
1703 };
1704
1705 static void dcerpc_spoolss_SetPrinter_r_done(struct tevent_req *subreq);
1706
1707 struct tevent_req *dcerpc_spoolss_SetPrinter_r_send(TALLOC_CTX *mem_ctx,
1708         struct tevent_context *ev,
1709         struct dcerpc_binding_handle *h,
1710         struct spoolss_SetPrinter *r)
1711 {
1712         struct tevent_req *req;
1713         struct dcerpc_spoolss_SetPrinter_r_state *state;
1714         struct tevent_req *subreq;
1715
1716         req = tevent_req_create(mem_ctx, &state,
1717                                 struct dcerpc_spoolss_SetPrinter_r_state);
1718         if (req == NULL) {
1719                 return NULL;
1720         }
1721
1722         state->out_mem_ctx = NULL;
1723         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1724                         NULL, &ndr_table_spoolss,
1725                         NDR_SPOOLSS_SETPRINTER, state, r);
1726         if (tevent_req_nomem(subreq, req)) {
1727                 return tevent_req_post(req, ev);
1728         }
1729         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinter_r_done, req);
1730
1731         return req;
1732 }
1733
1734 static void dcerpc_spoolss_SetPrinter_r_done(struct tevent_req *subreq)
1735 {
1736         struct tevent_req *req =
1737                 tevent_req_callback_data(subreq,
1738                 struct tevent_req);
1739         NTSTATUS status;
1740
1741         status = dcerpc_binding_handle_call_recv(subreq);
1742         if (!NT_STATUS_IS_OK(status)) {
1743                 tevent_req_nterror(req, status);
1744                 return;
1745         }
1746
1747         tevent_req_done(req);
1748 }
1749
1750 NTSTATUS dcerpc_spoolss_SetPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1751 {
1752         struct dcerpc_spoolss_SetPrinter_r_state *state =
1753                 tevent_req_data(req,
1754                 struct dcerpc_spoolss_SetPrinter_r_state);
1755         NTSTATUS status;
1756
1757         if (tevent_req_is_nterror(req, &status)) {
1758                 tevent_req_received(req);
1759                 return status;
1760         }
1761
1762         talloc_steal(mem_ctx, state->out_mem_ctx);
1763
1764         tevent_req_received(req);
1765         return NT_STATUS_OK;
1766 }
1767
1768 NTSTATUS dcerpc_spoolss_SetPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinter *r)
1769 {
1770         NTSTATUS status;
1771
1772         status = dcerpc_binding_handle_call(h,
1773                         NULL, &ndr_table_spoolss,
1774                         NDR_SPOOLSS_SETPRINTER, mem_ctx, r);
1775
1776         return status;
1777 }
1778
1779 NTSTATUS dcerpc_spoolss_SetPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinter *r)
1780 {
1781         NTSTATUS status;
1782
1783         status = dcerpc_spoolss_SetPrinter_r(p->binding_handle, mem_ctx, r);
1784
1785         if (NT_STATUS_IS_RPC(status)) {
1786                 status = NT_STATUS_NET_WRITE_FAULT;
1787         }
1788
1789         return status;
1790 }
1791
1792 struct dcerpc_spoolss_SetPrinter_state {
1793         struct spoolss_SetPrinter orig;
1794         struct spoolss_SetPrinter tmp;
1795         TALLOC_CTX *out_mem_ctx;
1796 };
1797
1798 static void dcerpc_spoolss_SetPrinter_done(struct tevent_req *subreq);
1799
1800 struct tevent_req *dcerpc_spoolss_SetPrinter_send(TALLOC_CTX *mem_ctx,
1801                                                   struct tevent_context *ev,
1802                                                   struct dcerpc_binding_handle *h,
1803                                                   struct policy_handle *_handle /* [in] [ref] */,
1804                                                   struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
1805                                                   struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
1806                                                   struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
1807                                                   enum spoolss_PrinterControl _command /* [in]  */)
1808 {
1809         struct tevent_req *req;
1810         struct dcerpc_spoolss_SetPrinter_state *state;
1811         struct tevent_req *subreq;
1812
1813         req = tevent_req_create(mem_ctx, &state,
1814                                 struct dcerpc_spoolss_SetPrinter_state);
1815         if (req == NULL) {
1816                 return NULL;
1817         }
1818         state->out_mem_ctx = NULL;
1819
1820         /* In parameters */
1821         state->orig.in.handle = _handle;
1822         state->orig.in.info_ctr = _info_ctr;
1823         state->orig.in.devmode_ctr = _devmode_ctr;
1824         state->orig.in.secdesc_ctr = _secdesc_ctr;
1825         state->orig.in.command = _command;
1826
1827         /* Out parameters */
1828
1829         /* Result */
1830         ZERO_STRUCT(state->orig.out.result);
1831
1832         /* make a temporary copy, that we pass to the dispatch function */
1833         state->tmp = state->orig;
1834
1835         subreq = dcerpc_spoolss_SetPrinter_r_send(state, ev, h, &state->tmp);
1836         if (tevent_req_nomem(subreq, req)) {
1837                 return tevent_req_post(req, ev);
1838         }
1839         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinter_done, req);
1840         return req;
1841 }
1842
1843 static void dcerpc_spoolss_SetPrinter_done(struct tevent_req *subreq)
1844 {
1845         struct tevent_req *req = tevent_req_callback_data(
1846                 subreq, struct tevent_req);
1847         struct dcerpc_spoolss_SetPrinter_state *state = tevent_req_data(
1848                 req, struct dcerpc_spoolss_SetPrinter_state);
1849         NTSTATUS status;
1850         TALLOC_CTX *mem_ctx;
1851
1852         if (state->out_mem_ctx) {
1853                 mem_ctx = state->out_mem_ctx;
1854         } else {
1855                 mem_ctx = state;
1856         }
1857
1858         status = dcerpc_spoolss_SetPrinter_r_recv(subreq, mem_ctx);
1859         TALLOC_FREE(subreq);
1860         if (!NT_STATUS_IS_OK(status)) {
1861                 tevent_req_nterror(req, status);
1862                 return;
1863         }
1864
1865         /* Copy out parameters */
1866
1867         /* Copy result */
1868         state->orig.out.result = state->tmp.out.result;
1869
1870         /* Reset temporary structure */
1871         ZERO_STRUCT(state->tmp);
1872
1873         tevent_req_done(req);
1874 }
1875
1876 NTSTATUS dcerpc_spoolss_SetPrinter_recv(struct tevent_req *req,
1877                                         TALLOC_CTX *mem_ctx,
1878                                         WERROR *result)
1879 {
1880         struct dcerpc_spoolss_SetPrinter_state *state = tevent_req_data(
1881                 req, struct dcerpc_spoolss_SetPrinter_state);
1882         NTSTATUS status;
1883
1884         if (tevent_req_is_nterror(req, &status)) {
1885                 tevent_req_received(req);
1886                 return status;
1887         }
1888
1889         /* Steal possible out parameters to the callers context */
1890         talloc_steal(mem_ctx, state->out_mem_ctx);
1891
1892         /* Return result */
1893         *result = state->orig.out.result;
1894
1895         tevent_req_received(req);
1896         return NT_STATUS_OK;
1897 }
1898
1899 NTSTATUS dcerpc_spoolss_SetPrinter(struct dcerpc_binding_handle *h,
1900                                    TALLOC_CTX *mem_ctx,
1901                                    struct policy_handle *_handle /* [in] [ref] */,
1902                                    struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
1903                                    struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
1904                                    struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
1905                                    enum spoolss_PrinterControl _command /* [in]  */,
1906                                    WERROR *result)
1907 {
1908         struct spoolss_SetPrinter r;
1909         NTSTATUS status;
1910
1911         /* In parameters */
1912         r.in.handle = _handle;
1913         r.in.info_ctr = _info_ctr;
1914         r.in.devmode_ctr = _devmode_ctr;
1915         r.in.secdesc_ctr = _secdesc_ctr;
1916         r.in.command = _command;
1917
1918         status = dcerpc_spoolss_SetPrinter_r(h, mem_ctx, &r);
1919         if (!NT_STATUS_IS_OK(status)) {
1920                 return status;
1921         }
1922
1923         /* Return variables */
1924
1925         /* Return result */
1926         *result = r.out.result;
1927
1928         return NT_STATUS_OK;
1929 }
1930
1931 struct dcerpc_spoolss_GetPrinter_r_state {
1932         TALLOC_CTX *out_mem_ctx;
1933 };
1934
1935 static void dcerpc_spoolss_GetPrinter_r_done(struct tevent_req *subreq);
1936
1937 struct tevent_req *dcerpc_spoolss_GetPrinter_r_send(TALLOC_CTX *mem_ctx,
1938         struct tevent_context *ev,
1939         struct dcerpc_binding_handle *h,
1940         struct spoolss_GetPrinter *r)
1941 {
1942         struct tevent_req *req;
1943         struct dcerpc_spoolss_GetPrinter_r_state *state;
1944         struct tevent_req *subreq;
1945
1946         req = tevent_req_create(mem_ctx, &state,
1947                                 struct dcerpc_spoolss_GetPrinter_r_state);
1948         if (req == NULL) {
1949                 return NULL;
1950         }
1951
1952         state->out_mem_ctx = talloc_new(state);
1953         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1954                 return tevent_req_post(req, ev);
1955         }
1956
1957         subreq = dcerpc_binding_handle_call_send(state, ev, h,
1958                         NULL, &ndr_table_spoolss,
1959                         NDR_SPOOLSS_GETPRINTER, state->out_mem_ctx, r);
1960         if (tevent_req_nomem(subreq, req)) {
1961                 return tevent_req_post(req, ev);
1962         }
1963         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinter_r_done, req);
1964
1965         return req;
1966 }
1967
1968 static void dcerpc_spoolss_GetPrinter_r_done(struct tevent_req *subreq)
1969 {
1970         struct tevent_req *req =
1971                 tevent_req_callback_data(subreq,
1972                 struct tevent_req);
1973         NTSTATUS status;
1974
1975         status = dcerpc_binding_handle_call_recv(subreq);
1976         if (!NT_STATUS_IS_OK(status)) {
1977                 tevent_req_nterror(req, status);
1978                 return;
1979         }
1980
1981         tevent_req_done(req);
1982 }
1983
1984 NTSTATUS dcerpc_spoolss_GetPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
1985 {
1986         struct dcerpc_spoolss_GetPrinter_r_state *state =
1987                 tevent_req_data(req,
1988                 struct dcerpc_spoolss_GetPrinter_r_state);
1989         NTSTATUS status;
1990
1991         if (tevent_req_is_nterror(req, &status)) {
1992                 tevent_req_received(req);
1993                 return status;
1994         }
1995
1996         talloc_steal(mem_ctx, state->out_mem_ctx);
1997
1998         tevent_req_received(req);
1999         return NT_STATUS_OK;
2000 }
2001
2002 NTSTATUS dcerpc_spoolss_GetPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinter *r)
2003 {
2004         NTSTATUS status;
2005
2006         status = dcerpc_binding_handle_call(h,
2007                         NULL, &ndr_table_spoolss,
2008                         NDR_SPOOLSS_GETPRINTER, mem_ctx, r);
2009
2010         return status;
2011 }
2012
2013 NTSTATUS dcerpc_spoolss_GetPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinter *r)
2014 {
2015         NTSTATUS status;
2016
2017         status = dcerpc_spoolss_GetPrinter_r(p->binding_handle, mem_ctx, r);
2018
2019         if (NT_STATUS_IS_RPC(status)) {
2020                 status = NT_STATUS_NET_WRITE_FAULT;
2021         }
2022
2023         return status;
2024 }
2025
2026 struct dcerpc_spoolss_GetPrinter_state {
2027         struct spoolss_GetPrinter orig;
2028         struct spoolss_GetPrinter tmp;
2029         TALLOC_CTX *out_mem_ctx;
2030 };
2031
2032 static void dcerpc_spoolss_GetPrinter_done(struct tevent_req *subreq);
2033
2034 struct tevent_req *dcerpc_spoolss_GetPrinter_send(TALLOC_CTX *mem_ctx,
2035                                                   struct tevent_context *ev,
2036                                                   struct dcerpc_binding_handle *h,
2037                                                   struct policy_handle *_handle /* [in] [ref] */,
2038                                                   uint32_t _level /* [in]  */,
2039                                                   DATA_BLOB *_buffer /* [in] [unique] */,
2040                                                   uint32_t _offered /* [in]  */,
2041                                                   union spoolss_PrinterInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
2042                                                   uint32_t *_needed /* [out] [ref] */)
2043 {
2044         struct tevent_req *req;
2045         struct dcerpc_spoolss_GetPrinter_state *state;
2046         struct tevent_req *subreq;
2047
2048         req = tevent_req_create(mem_ctx, &state,
2049                                 struct dcerpc_spoolss_GetPrinter_state);
2050         if (req == NULL) {
2051                 return NULL;
2052         }
2053         state->out_mem_ctx = NULL;
2054
2055         /* In parameters */
2056         state->orig.in.handle = _handle;
2057         state->orig.in.level = _level;
2058         state->orig.in.buffer = _buffer;
2059         state->orig.in.offered = _offered;
2060
2061         /* Out parameters */
2062         state->orig.out.info = _info;
2063         state->orig.out.needed = _needed;
2064
2065         /* Result */
2066         ZERO_STRUCT(state->orig.out.result);
2067
2068         state->out_mem_ctx = talloc_named_const(state, 0,
2069                              "dcerpc_spoolss_GetPrinter_out_memory");
2070         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2071                 return tevent_req_post(req, ev);
2072         }
2073
2074         /* make a temporary copy, that we pass to the dispatch function */
2075         state->tmp = state->orig;
2076
2077         subreq = dcerpc_spoolss_GetPrinter_r_send(state, ev, h, &state->tmp);
2078         if (tevent_req_nomem(subreq, req)) {
2079                 return tevent_req_post(req, ev);
2080         }
2081         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinter_done, req);
2082         return req;
2083 }
2084
2085 static void dcerpc_spoolss_GetPrinter_done(struct tevent_req *subreq)
2086 {
2087         struct tevent_req *req = tevent_req_callback_data(
2088                 subreq, struct tevent_req);
2089         struct dcerpc_spoolss_GetPrinter_state *state = tevent_req_data(
2090                 req, struct dcerpc_spoolss_GetPrinter_state);
2091         NTSTATUS status;
2092         TALLOC_CTX *mem_ctx;
2093
2094         if (state->out_mem_ctx) {
2095                 mem_ctx = state->out_mem_ctx;
2096         } else {
2097                 mem_ctx = state;
2098         }
2099
2100         status = dcerpc_spoolss_GetPrinter_r_recv(subreq, mem_ctx);
2101         TALLOC_FREE(subreq);
2102         if (!NT_STATUS_IS_OK(status)) {
2103                 tevent_req_nterror(req, status);
2104                 return;
2105         }
2106
2107         /* Copy out parameters */
2108         if (state->orig.out.info && state->tmp.out.info) {
2109                 *state->orig.out.info = *state->tmp.out.info;
2110         }
2111         *state->orig.out.needed = *state->tmp.out.needed;
2112
2113         /* Copy result */
2114         state->orig.out.result = state->tmp.out.result;
2115
2116         /* Reset temporary structure */
2117         ZERO_STRUCT(state->tmp);
2118
2119         tevent_req_done(req);
2120 }
2121
2122 NTSTATUS dcerpc_spoolss_GetPrinter_recv(struct tevent_req *req,
2123                                         TALLOC_CTX *mem_ctx,
2124                                         WERROR *result)
2125 {
2126         struct dcerpc_spoolss_GetPrinter_state *state = tevent_req_data(
2127                 req, struct dcerpc_spoolss_GetPrinter_state);
2128         NTSTATUS status;
2129
2130         if (tevent_req_is_nterror(req, &status)) {
2131                 tevent_req_received(req);
2132                 return status;
2133         }
2134
2135         /* Steal possible out parameters to the callers context */
2136         talloc_steal(mem_ctx, state->out_mem_ctx);
2137
2138         /* Return result */
2139         *result = state->orig.out.result;
2140
2141         tevent_req_received(req);
2142         return NT_STATUS_OK;
2143 }
2144
2145 NTSTATUS dcerpc_spoolss_GetPrinter(struct dcerpc_binding_handle *h,
2146                                    TALLOC_CTX *mem_ctx,
2147                                    struct policy_handle *_handle /* [in] [ref] */,
2148                                    uint32_t _level /* [in]  */,
2149                                    DATA_BLOB *_buffer /* [in] [unique] */,
2150                                    uint32_t _offered /* [in]  */,
2151                                    union spoolss_PrinterInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
2152                                    uint32_t *_needed /* [out] [ref] */,
2153                                    WERROR *result)
2154 {
2155         struct spoolss_GetPrinter r;
2156         NTSTATUS status;
2157
2158         /* In parameters */
2159         r.in.handle = _handle;
2160         r.in.level = _level;
2161         r.in.buffer = _buffer;
2162         r.in.offered = _offered;
2163
2164         status = dcerpc_spoolss_GetPrinter_r(h, mem_ctx, &r);
2165         if (!NT_STATUS_IS_OK(status)) {
2166                 return status;
2167         }
2168
2169         /* Return variables */
2170         if (_info && r.out.info) {
2171                 *_info = *r.out.info;
2172         }
2173         *_needed = *r.out.needed;
2174
2175         /* Return result */
2176         *result = r.out.result;
2177
2178         return NT_STATUS_OK;
2179 }
2180
2181 struct dcerpc_spoolss_AddPrinterDriver_r_state {
2182         TALLOC_CTX *out_mem_ctx;
2183 };
2184
2185 static void dcerpc_spoolss_AddPrinterDriver_r_done(struct tevent_req *subreq);
2186
2187 struct tevent_req *dcerpc_spoolss_AddPrinterDriver_r_send(TALLOC_CTX *mem_ctx,
2188         struct tevent_context *ev,
2189         struct dcerpc_binding_handle *h,
2190         struct spoolss_AddPrinterDriver *r)
2191 {
2192         struct tevent_req *req;
2193         struct dcerpc_spoolss_AddPrinterDriver_r_state *state;
2194         struct tevent_req *subreq;
2195
2196         req = tevent_req_create(mem_ctx, &state,
2197                                 struct dcerpc_spoolss_AddPrinterDriver_r_state);
2198         if (req == NULL) {
2199                 return NULL;
2200         }
2201
2202         state->out_mem_ctx = NULL;
2203         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2204                         NULL, &ndr_table_spoolss,
2205                         NDR_SPOOLSS_ADDPRINTERDRIVER, state, r);
2206         if (tevent_req_nomem(subreq, req)) {
2207                 return tevent_req_post(req, ev);
2208         }
2209         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterDriver_r_done, req);
2210
2211         return req;
2212 }
2213
2214 static void dcerpc_spoolss_AddPrinterDriver_r_done(struct tevent_req *subreq)
2215 {
2216         struct tevent_req *req =
2217                 tevent_req_callback_data(subreq,
2218                 struct tevent_req);
2219         NTSTATUS status;
2220
2221         status = dcerpc_binding_handle_call_recv(subreq);
2222         if (!NT_STATUS_IS_OK(status)) {
2223                 tevent_req_nterror(req, status);
2224                 return;
2225         }
2226
2227         tevent_req_done(req);
2228 }
2229
2230 NTSTATUS dcerpc_spoolss_AddPrinterDriver_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2231 {
2232         struct dcerpc_spoolss_AddPrinterDriver_r_state *state =
2233                 tevent_req_data(req,
2234                 struct dcerpc_spoolss_AddPrinterDriver_r_state);
2235         NTSTATUS status;
2236
2237         if (tevent_req_is_nterror(req, &status)) {
2238                 tevent_req_received(req);
2239                 return status;
2240         }
2241
2242         talloc_steal(mem_ctx, state->out_mem_ctx);
2243
2244         tevent_req_received(req);
2245         return NT_STATUS_OK;
2246 }
2247
2248 NTSTATUS dcerpc_spoolss_AddPrinterDriver_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterDriver *r)
2249 {
2250         NTSTATUS status;
2251
2252         status = dcerpc_binding_handle_call(h,
2253                         NULL, &ndr_table_spoolss,
2254                         NDR_SPOOLSS_ADDPRINTERDRIVER, mem_ctx, r);
2255
2256         return status;
2257 }
2258
2259 NTSTATUS dcerpc_spoolss_AddPrinterDriver_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterDriver *r)
2260 {
2261         NTSTATUS status;
2262
2263         status = dcerpc_spoolss_AddPrinterDriver_r(p->binding_handle, mem_ctx, r);
2264
2265         if (NT_STATUS_IS_RPC(status)) {
2266                 status = NT_STATUS_NET_WRITE_FAULT;
2267         }
2268
2269         return status;
2270 }
2271
2272 struct dcerpc_spoolss_AddPrinterDriver_state {
2273         struct spoolss_AddPrinterDriver orig;
2274         struct spoolss_AddPrinterDriver tmp;
2275         TALLOC_CTX *out_mem_ctx;
2276 };
2277
2278 static void dcerpc_spoolss_AddPrinterDriver_done(struct tevent_req *subreq);
2279
2280 struct tevent_req *dcerpc_spoolss_AddPrinterDriver_send(TALLOC_CTX *mem_ctx,
2281                                                         struct tevent_context *ev,
2282                                                         struct dcerpc_binding_handle *h,
2283                                                         const char *_servername /* [in] [unique,charset(UTF16)] */,
2284                                                         struct spoolss_AddDriverInfoCtr *_info_ctr /* [in] [ref] */)
2285 {
2286         struct tevent_req *req;
2287         struct dcerpc_spoolss_AddPrinterDriver_state *state;
2288         struct tevent_req *subreq;
2289
2290         req = tevent_req_create(mem_ctx, &state,
2291                                 struct dcerpc_spoolss_AddPrinterDriver_state);
2292         if (req == NULL) {
2293                 return NULL;
2294         }
2295         state->out_mem_ctx = NULL;
2296
2297         /* In parameters */
2298         state->orig.in.servername = _servername;
2299         state->orig.in.info_ctr = _info_ctr;
2300
2301         /* Out parameters */
2302
2303         /* Result */
2304         ZERO_STRUCT(state->orig.out.result);
2305
2306         /* make a temporary copy, that we pass to the dispatch function */
2307         state->tmp = state->orig;
2308
2309         subreq = dcerpc_spoolss_AddPrinterDriver_r_send(state, ev, h, &state->tmp);
2310         if (tevent_req_nomem(subreq, req)) {
2311                 return tevent_req_post(req, ev);
2312         }
2313         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterDriver_done, req);
2314         return req;
2315 }
2316
2317 static void dcerpc_spoolss_AddPrinterDriver_done(struct tevent_req *subreq)
2318 {
2319         struct tevent_req *req = tevent_req_callback_data(
2320                 subreq, struct tevent_req);
2321         struct dcerpc_spoolss_AddPrinterDriver_state *state = tevent_req_data(
2322                 req, struct dcerpc_spoolss_AddPrinterDriver_state);
2323         NTSTATUS status;
2324         TALLOC_CTX *mem_ctx;
2325
2326         if (state->out_mem_ctx) {
2327                 mem_ctx = state->out_mem_ctx;
2328         } else {
2329                 mem_ctx = state;
2330         }
2331
2332         status = dcerpc_spoolss_AddPrinterDriver_r_recv(subreq, mem_ctx);
2333         TALLOC_FREE(subreq);
2334         if (!NT_STATUS_IS_OK(status)) {
2335                 tevent_req_nterror(req, status);
2336                 return;
2337         }
2338
2339         /* Copy out parameters */
2340
2341         /* Copy result */
2342         state->orig.out.result = state->tmp.out.result;
2343
2344         /* Reset temporary structure */
2345         ZERO_STRUCT(state->tmp);
2346
2347         tevent_req_done(req);
2348 }
2349
2350 NTSTATUS dcerpc_spoolss_AddPrinterDriver_recv(struct tevent_req *req,
2351                                               TALLOC_CTX *mem_ctx,
2352                                               WERROR *result)
2353 {
2354         struct dcerpc_spoolss_AddPrinterDriver_state *state = tevent_req_data(
2355                 req, struct dcerpc_spoolss_AddPrinterDriver_state);
2356         NTSTATUS status;
2357
2358         if (tevent_req_is_nterror(req, &status)) {
2359                 tevent_req_received(req);
2360                 return status;
2361         }
2362
2363         /* Steal possible out parameters to the callers context */
2364         talloc_steal(mem_ctx, state->out_mem_ctx);
2365
2366         /* Return result */
2367         *result = state->orig.out.result;
2368
2369         tevent_req_received(req);
2370         return NT_STATUS_OK;
2371 }
2372
2373 NTSTATUS dcerpc_spoolss_AddPrinterDriver(struct dcerpc_binding_handle *h,
2374                                          TALLOC_CTX *mem_ctx,
2375                                          const char *_servername /* [in] [unique,charset(UTF16)] */,
2376                                          struct spoolss_AddDriverInfoCtr *_info_ctr /* [in] [ref] */,
2377                                          WERROR *result)
2378 {
2379         struct spoolss_AddPrinterDriver r;
2380         NTSTATUS status;
2381
2382         /* In parameters */
2383         r.in.servername = _servername;
2384         r.in.info_ctr = _info_ctr;
2385
2386         status = dcerpc_spoolss_AddPrinterDriver_r(h, mem_ctx, &r);
2387         if (!NT_STATUS_IS_OK(status)) {
2388                 return status;
2389         }
2390
2391         /* Return variables */
2392
2393         /* Return result */
2394         *result = r.out.result;
2395
2396         return NT_STATUS_OK;
2397 }
2398
2399 struct dcerpc_spoolss_EnumPrinterDrivers_r_state {
2400         TALLOC_CTX *out_mem_ctx;
2401 };
2402
2403 static void dcerpc_spoolss_EnumPrinterDrivers_r_done(struct tevent_req *subreq);
2404
2405 struct tevent_req *dcerpc_spoolss_EnumPrinterDrivers_r_send(TALLOC_CTX *mem_ctx,
2406         struct tevent_context *ev,
2407         struct dcerpc_binding_handle *h,
2408         struct spoolss_EnumPrinterDrivers *r)
2409 {
2410         struct tevent_req *req;
2411         struct dcerpc_spoolss_EnumPrinterDrivers_r_state *state;
2412         struct tevent_req *subreq;
2413
2414         req = tevent_req_create(mem_ctx, &state,
2415                                 struct dcerpc_spoolss_EnumPrinterDrivers_r_state);
2416         if (req == NULL) {
2417                 return NULL;
2418         }
2419
2420         state->out_mem_ctx = talloc_new(state);
2421         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2422                 return tevent_req_post(req, ev);
2423         }
2424
2425         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2426                         NULL, &ndr_table_spoolss,
2427                         NDR_SPOOLSS_ENUMPRINTERDRIVERS, state->out_mem_ctx, r);
2428         if (tevent_req_nomem(subreq, req)) {
2429                 return tevent_req_post(req, ev);
2430         }
2431         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterDrivers_r_done, req);
2432
2433         return req;
2434 }
2435
2436 static void dcerpc_spoolss_EnumPrinterDrivers_r_done(struct tevent_req *subreq)
2437 {
2438         struct tevent_req *req =
2439                 tevent_req_callback_data(subreq,
2440                 struct tevent_req);
2441         NTSTATUS status;
2442
2443         status = dcerpc_binding_handle_call_recv(subreq);
2444         if (!NT_STATUS_IS_OK(status)) {
2445                 tevent_req_nterror(req, status);
2446                 return;
2447         }
2448
2449         tevent_req_done(req);
2450 }
2451
2452 NTSTATUS dcerpc_spoolss_EnumPrinterDrivers_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2453 {
2454         struct dcerpc_spoolss_EnumPrinterDrivers_r_state *state =
2455                 tevent_req_data(req,
2456                 struct dcerpc_spoolss_EnumPrinterDrivers_r_state);
2457         NTSTATUS status;
2458
2459         if (tevent_req_is_nterror(req, &status)) {
2460                 tevent_req_received(req);
2461                 return status;
2462         }
2463
2464         talloc_steal(mem_ctx, state->out_mem_ctx);
2465
2466         tevent_req_received(req);
2467         return NT_STATUS_OK;
2468 }
2469
2470 NTSTATUS dcerpc_spoolss_EnumPrinterDrivers_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDrivers *r)
2471 {
2472         NTSTATUS status;
2473
2474         status = dcerpc_binding_handle_call(h,
2475                         NULL, &ndr_table_spoolss,
2476                         NDR_SPOOLSS_ENUMPRINTERDRIVERS, mem_ctx, r);
2477
2478         return status;
2479 }
2480
2481 NTSTATUS dcerpc_spoolss_EnumPrinterDrivers_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDrivers *r)
2482 {
2483         NTSTATUS status;
2484
2485         status = dcerpc_spoolss_EnumPrinterDrivers_r(p->binding_handle, mem_ctx, r);
2486
2487         if (NT_STATUS_IS_RPC(status)) {
2488                 status = NT_STATUS_NET_WRITE_FAULT;
2489         }
2490
2491         return status;
2492 }
2493
2494 struct dcerpc_spoolss_EnumPrinterDrivers_state {
2495         struct spoolss_EnumPrinterDrivers orig;
2496         struct spoolss_EnumPrinterDrivers tmp;
2497         TALLOC_CTX *out_mem_ctx;
2498 };
2499
2500 static void dcerpc_spoolss_EnumPrinterDrivers_done(struct tevent_req *subreq);
2501
2502 struct tevent_req *dcerpc_spoolss_EnumPrinterDrivers_send(TALLOC_CTX *mem_ctx,
2503                                                           struct tevent_context *ev,
2504                                                           struct dcerpc_binding_handle *h,
2505                                                           const char *_server /* [in] [unique,charset(UTF16)] */,
2506                                                           const char *_environment /* [in] [unique,charset(UTF16)] */,
2507                                                           uint32_t _level /* [in]  */,
2508                                                           DATA_BLOB *_buffer /* [in] [unique] */,
2509                                                           uint32_t _offered /* [in]  */,
2510                                                           uint32_t *_count /* [out] [ref] */,
2511                                                           union spoolss_DriverInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
2512                                                           uint32_t *_needed /* [out] [ref] */)
2513 {
2514         struct tevent_req *req;
2515         struct dcerpc_spoolss_EnumPrinterDrivers_state *state;
2516         struct tevent_req *subreq;
2517
2518         req = tevent_req_create(mem_ctx, &state,
2519                                 struct dcerpc_spoolss_EnumPrinterDrivers_state);
2520         if (req == NULL) {
2521                 return NULL;
2522         }
2523         state->out_mem_ctx = NULL;
2524
2525         /* In parameters */
2526         state->orig.in.server = _server;
2527         state->orig.in.environment = _environment;
2528         state->orig.in.level = _level;
2529         state->orig.in.buffer = _buffer;
2530         state->orig.in.offered = _offered;
2531
2532         /* Out parameters */
2533         state->orig.out.count = _count;
2534         state->orig.out.info = _info;
2535         state->orig.out.needed = _needed;
2536
2537         /* Result */
2538         ZERO_STRUCT(state->orig.out.result);
2539
2540         state->out_mem_ctx = talloc_named_const(state, 0,
2541                              "dcerpc_spoolss_EnumPrinterDrivers_out_memory");
2542         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2543                 return tevent_req_post(req, ev);
2544         }
2545
2546         /* make a temporary copy, that we pass to the dispatch function */
2547         state->tmp = state->orig;
2548
2549         subreq = dcerpc_spoolss_EnumPrinterDrivers_r_send(state, ev, h, &state->tmp);
2550         if (tevent_req_nomem(subreq, req)) {
2551                 return tevent_req_post(req, ev);
2552         }
2553         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterDrivers_done, req);
2554         return req;
2555 }
2556
2557 static void dcerpc_spoolss_EnumPrinterDrivers_done(struct tevent_req *subreq)
2558 {
2559         struct tevent_req *req = tevent_req_callback_data(
2560                 subreq, struct tevent_req);
2561         struct dcerpc_spoolss_EnumPrinterDrivers_state *state = tevent_req_data(
2562                 req, struct dcerpc_spoolss_EnumPrinterDrivers_state);
2563         NTSTATUS status;
2564         TALLOC_CTX *mem_ctx;
2565
2566         if (state->out_mem_ctx) {
2567                 mem_ctx = state->out_mem_ctx;
2568         } else {
2569                 mem_ctx = state;
2570         }
2571
2572         status = dcerpc_spoolss_EnumPrinterDrivers_r_recv(subreq, mem_ctx);
2573         TALLOC_FREE(subreq);
2574         if (!NT_STATUS_IS_OK(status)) {
2575                 tevent_req_nterror(req, status);
2576                 return;
2577         }
2578
2579         /* Copy out parameters */
2580         *state->orig.out.count = *state->tmp.out.count;
2581         *state->orig.out.info = *state->tmp.out.info;
2582         *state->orig.out.needed = *state->tmp.out.needed;
2583
2584         /* Copy result */
2585         state->orig.out.result = state->tmp.out.result;
2586
2587         /* Reset temporary structure */
2588         ZERO_STRUCT(state->tmp);
2589
2590         tevent_req_done(req);
2591 }
2592
2593 NTSTATUS dcerpc_spoolss_EnumPrinterDrivers_recv(struct tevent_req *req,
2594                                                 TALLOC_CTX *mem_ctx,
2595                                                 WERROR *result)
2596 {
2597         struct dcerpc_spoolss_EnumPrinterDrivers_state *state = tevent_req_data(
2598                 req, struct dcerpc_spoolss_EnumPrinterDrivers_state);
2599         NTSTATUS status;
2600
2601         if (tevent_req_is_nterror(req, &status)) {
2602                 tevent_req_received(req);
2603                 return status;
2604         }
2605
2606         /* Steal possible out parameters to the callers context */
2607         talloc_steal(mem_ctx, state->out_mem_ctx);
2608
2609         /* Return result */
2610         *result = state->orig.out.result;
2611
2612         tevent_req_received(req);
2613         return NT_STATUS_OK;
2614 }
2615
2616 NTSTATUS dcerpc_spoolss_EnumPrinterDrivers(struct dcerpc_binding_handle *h,
2617                                            TALLOC_CTX *mem_ctx,
2618                                            const char *_server /* [in] [unique,charset(UTF16)] */,
2619                                            const char *_environment /* [in] [unique,charset(UTF16)] */,
2620                                            uint32_t _level /* [in]  */,
2621                                            DATA_BLOB *_buffer /* [in] [unique] */,
2622                                            uint32_t _offered /* [in]  */,
2623                                            uint32_t *_count /* [out] [ref] */,
2624                                            union spoolss_DriverInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
2625                                            uint32_t *_needed /* [out] [ref] */,
2626                                            WERROR *result)
2627 {
2628         struct spoolss_EnumPrinterDrivers r;
2629         NTSTATUS status;
2630
2631         /* In parameters */
2632         r.in.server = _server;
2633         r.in.environment = _environment;
2634         r.in.level = _level;
2635         r.in.buffer = _buffer;
2636         r.in.offered = _offered;
2637
2638         status = dcerpc_spoolss_EnumPrinterDrivers_r(h, mem_ctx, &r);
2639         if (!NT_STATUS_IS_OK(status)) {
2640                 return status;
2641         }
2642
2643         /* Return variables */
2644         *_count = *r.out.count;
2645         *_info = *r.out.info;
2646         *_needed = *r.out.needed;
2647
2648         /* Return result */
2649         *result = r.out.result;
2650
2651         return NT_STATUS_OK;
2652 }
2653
2654 struct dcerpc_spoolss_GetPrinterDriver_r_state {
2655         TALLOC_CTX *out_mem_ctx;
2656 };
2657
2658 static void dcerpc_spoolss_GetPrinterDriver_r_done(struct tevent_req *subreq);
2659
2660 struct tevent_req *dcerpc_spoolss_GetPrinterDriver_r_send(TALLOC_CTX *mem_ctx,
2661         struct tevent_context *ev,
2662         struct dcerpc_binding_handle *h,
2663         struct spoolss_GetPrinterDriver *r)
2664 {
2665         struct tevent_req *req;
2666         struct dcerpc_spoolss_GetPrinterDriver_r_state *state;
2667         struct tevent_req *subreq;
2668
2669         req = tevent_req_create(mem_ctx, &state,
2670                                 struct dcerpc_spoolss_GetPrinterDriver_r_state);
2671         if (req == NULL) {
2672                 return NULL;
2673         }
2674
2675         state->out_mem_ctx = talloc_new(state);
2676         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2677                 return tevent_req_post(req, ev);
2678         }
2679
2680         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2681                         NULL, &ndr_table_spoolss,
2682                         NDR_SPOOLSS_GETPRINTERDRIVER, state->out_mem_ctx, r);
2683         if (tevent_req_nomem(subreq, req)) {
2684                 return tevent_req_post(req, ev);
2685         }
2686         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriver_r_done, req);
2687
2688         return req;
2689 }
2690
2691 static void dcerpc_spoolss_GetPrinterDriver_r_done(struct tevent_req *subreq)
2692 {
2693         struct tevent_req *req =
2694                 tevent_req_callback_data(subreq,
2695                 struct tevent_req);
2696         NTSTATUS status;
2697
2698         status = dcerpc_binding_handle_call_recv(subreq);
2699         if (!NT_STATUS_IS_OK(status)) {
2700                 tevent_req_nterror(req, status);
2701                 return;
2702         }
2703
2704         tevent_req_done(req);
2705 }
2706
2707 NTSTATUS dcerpc_spoolss_GetPrinterDriver_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2708 {
2709         struct dcerpc_spoolss_GetPrinterDriver_r_state *state =
2710                 tevent_req_data(req,
2711                 struct dcerpc_spoolss_GetPrinterDriver_r_state);
2712         NTSTATUS status;
2713
2714         if (tevent_req_is_nterror(req, &status)) {
2715                 tevent_req_received(req);
2716                 return status;
2717         }
2718
2719         talloc_steal(mem_ctx, state->out_mem_ctx);
2720
2721         tevent_req_received(req);
2722         return NT_STATUS_OK;
2723 }
2724
2725 NTSTATUS dcerpc_spoolss_GetPrinterDriver_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriver *r)
2726 {
2727         NTSTATUS status;
2728
2729         status = dcerpc_binding_handle_call(h,
2730                         NULL, &ndr_table_spoolss,
2731                         NDR_SPOOLSS_GETPRINTERDRIVER, mem_ctx, r);
2732
2733         return status;
2734 }
2735
2736 NTSTATUS dcerpc_spoolss_GetPrinterDriver_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriver *r)
2737 {
2738         NTSTATUS status;
2739
2740         status = dcerpc_spoolss_GetPrinterDriver_r(p->binding_handle, mem_ctx, r);
2741
2742         if (NT_STATUS_IS_RPC(status)) {
2743                 status = NT_STATUS_NET_WRITE_FAULT;
2744         }
2745
2746         return status;
2747 }
2748
2749 struct dcerpc_spoolss_GetPrinterDriver_state {
2750         struct spoolss_GetPrinterDriver orig;
2751         struct spoolss_GetPrinterDriver tmp;
2752         TALLOC_CTX *out_mem_ctx;
2753 };
2754
2755 static void dcerpc_spoolss_GetPrinterDriver_done(struct tevent_req *subreq);
2756
2757 struct tevent_req *dcerpc_spoolss_GetPrinterDriver_send(TALLOC_CTX *mem_ctx,
2758                                                         struct tevent_context *ev,
2759                                                         struct dcerpc_binding_handle *h,
2760                                                         struct policy_handle *_handle /* [in] [ref] */,
2761                                                         const char *_architecture /* [in] [unique,charset(UTF16)] */,
2762                                                         uint32_t _level /* [in]  */,
2763                                                         DATA_BLOB *_buffer /* [in] [unique] */,
2764                                                         uint32_t _offered /* [in]  */,
2765                                                         union spoolss_DriverInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
2766                                                         uint32_t *_needed /* [out] [ref] */)
2767 {
2768         struct tevent_req *req;
2769         struct dcerpc_spoolss_GetPrinterDriver_state *state;
2770         struct tevent_req *subreq;
2771
2772         req = tevent_req_create(mem_ctx, &state,
2773                                 struct dcerpc_spoolss_GetPrinterDriver_state);
2774         if (req == NULL) {
2775                 return NULL;
2776         }
2777         state->out_mem_ctx = NULL;
2778
2779         /* In parameters */
2780         state->orig.in.handle = _handle;
2781         state->orig.in.architecture = _architecture;
2782         state->orig.in.level = _level;
2783         state->orig.in.buffer = _buffer;
2784         state->orig.in.offered = _offered;
2785
2786         /* Out parameters */
2787         state->orig.out.info = _info;
2788         state->orig.out.needed = _needed;
2789
2790         /* Result */
2791         ZERO_STRUCT(state->orig.out.result);
2792
2793         state->out_mem_ctx = talloc_named_const(state, 0,
2794                              "dcerpc_spoolss_GetPrinterDriver_out_memory");
2795         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2796                 return tevent_req_post(req, ev);
2797         }
2798
2799         /* make a temporary copy, that we pass to the dispatch function */
2800         state->tmp = state->orig;
2801
2802         subreq = dcerpc_spoolss_GetPrinterDriver_r_send(state, ev, h, &state->tmp);
2803         if (tevent_req_nomem(subreq, req)) {
2804                 return tevent_req_post(req, ev);
2805         }
2806         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriver_done, req);
2807         return req;
2808 }
2809
2810 static void dcerpc_spoolss_GetPrinterDriver_done(struct tevent_req *subreq)
2811 {
2812         struct tevent_req *req = tevent_req_callback_data(
2813                 subreq, struct tevent_req);
2814         struct dcerpc_spoolss_GetPrinterDriver_state *state = tevent_req_data(
2815                 req, struct dcerpc_spoolss_GetPrinterDriver_state);
2816         NTSTATUS status;
2817         TALLOC_CTX *mem_ctx;
2818
2819         if (state->out_mem_ctx) {
2820                 mem_ctx = state->out_mem_ctx;
2821         } else {
2822                 mem_ctx = state;
2823         }
2824
2825         status = dcerpc_spoolss_GetPrinterDriver_r_recv(subreq, mem_ctx);
2826         TALLOC_FREE(subreq);
2827         if (!NT_STATUS_IS_OK(status)) {
2828                 tevent_req_nterror(req, status);
2829                 return;
2830         }
2831
2832         /* Copy out parameters */
2833         if (state->orig.out.info && state->tmp.out.info) {
2834                 *state->orig.out.info = *state->tmp.out.info;
2835         }
2836         *state->orig.out.needed = *state->tmp.out.needed;
2837
2838         /* Copy result */
2839         state->orig.out.result = state->tmp.out.result;
2840
2841         /* Reset temporary structure */
2842         ZERO_STRUCT(state->tmp);
2843
2844         tevent_req_done(req);
2845 }
2846
2847 NTSTATUS dcerpc_spoolss_GetPrinterDriver_recv(struct tevent_req *req,
2848                                               TALLOC_CTX *mem_ctx,
2849                                               WERROR *result)
2850 {
2851         struct dcerpc_spoolss_GetPrinterDriver_state *state = tevent_req_data(
2852                 req, struct dcerpc_spoolss_GetPrinterDriver_state);
2853         NTSTATUS status;
2854
2855         if (tevent_req_is_nterror(req, &status)) {
2856                 tevent_req_received(req);
2857                 return status;
2858         }
2859
2860         /* Steal possible out parameters to the callers context */
2861         talloc_steal(mem_ctx, state->out_mem_ctx);
2862
2863         /* Return result */
2864         *result = state->orig.out.result;
2865
2866         tevent_req_received(req);
2867         return NT_STATUS_OK;
2868 }
2869
2870 NTSTATUS dcerpc_spoolss_GetPrinterDriver(struct dcerpc_binding_handle *h,
2871                                          TALLOC_CTX *mem_ctx,
2872                                          struct policy_handle *_handle /* [in] [ref] */,
2873                                          const char *_architecture /* [in] [unique,charset(UTF16)] */,
2874                                          uint32_t _level /* [in]  */,
2875                                          DATA_BLOB *_buffer /* [in] [unique] */,
2876                                          uint32_t _offered /* [in]  */,
2877                                          union spoolss_DriverInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
2878                                          uint32_t *_needed /* [out] [ref] */,
2879                                          WERROR *result)
2880 {
2881         struct spoolss_GetPrinterDriver r;
2882         NTSTATUS status;
2883
2884         /* In parameters */
2885         r.in.handle = _handle;
2886         r.in.architecture = _architecture;
2887         r.in.level = _level;
2888         r.in.buffer = _buffer;
2889         r.in.offered = _offered;
2890
2891         status = dcerpc_spoolss_GetPrinterDriver_r(h, mem_ctx, &r);
2892         if (!NT_STATUS_IS_OK(status)) {
2893                 return status;
2894         }
2895
2896         /* Return variables */
2897         if (_info && r.out.info) {
2898                 *_info = *r.out.info;
2899         }
2900         *_needed = *r.out.needed;
2901
2902         /* Return result */
2903         *result = r.out.result;
2904
2905         return NT_STATUS_OK;
2906 }
2907
2908 struct dcerpc_spoolss_GetPrinterDriverDirectory_r_state {
2909         TALLOC_CTX *out_mem_ctx;
2910 };
2911
2912 static void dcerpc_spoolss_GetPrinterDriverDirectory_r_done(struct tevent_req *subreq);
2913
2914 struct tevent_req *dcerpc_spoolss_GetPrinterDriverDirectory_r_send(TALLOC_CTX *mem_ctx,
2915         struct tevent_context *ev,
2916         struct dcerpc_binding_handle *h,
2917         struct spoolss_GetPrinterDriverDirectory *r)
2918 {
2919         struct tevent_req *req;
2920         struct dcerpc_spoolss_GetPrinterDriverDirectory_r_state *state;
2921         struct tevent_req *subreq;
2922
2923         req = tevent_req_create(mem_ctx, &state,
2924                                 struct dcerpc_spoolss_GetPrinterDriverDirectory_r_state);
2925         if (req == NULL) {
2926                 return NULL;
2927         }
2928
2929         state->out_mem_ctx = talloc_new(state);
2930         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2931                 return tevent_req_post(req, ev);
2932         }
2933
2934         subreq = dcerpc_binding_handle_call_send(state, ev, h,
2935                         NULL, &ndr_table_spoolss,
2936                         NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY, state->out_mem_ctx, r);
2937         if (tevent_req_nomem(subreq, req)) {
2938                 return tevent_req_post(req, ev);
2939         }
2940         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriverDirectory_r_done, req);
2941
2942         return req;
2943 }
2944
2945 static void dcerpc_spoolss_GetPrinterDriverDirectory_r_done(struct tevent_req *subreq)
2946 {
2947         struct tevent_req *req =
2948                 tevent_req_callback_data(subreq,
2949                 struct tevent_req);
2950         NTSTATUS status;
2951
2952         status = dcerpc_binding_handle_call_recv(subreq);
2953         if (!NT_STATUS_IS_OK(status)) {
2954                 tevent_req_nterror(req, status);
2955                 return;
2956         }
2957
2958         tevent_req_done(req);
2959 }
2960
2961 NTSTATUS dcerpc_spoolss_GetPrinterDriverDirectory_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
2962 {
2963         struct dcerpc_spoolss_GetPrinterDriverDirectory_r_state *state =
2964                 tevent_req_data(req,
2965                 struct dcerpc_spoolss_GetPrinterDriverDirectory_r_state);
2966         NTSTATUS status;
2967
2968         if (tevent_req_is_nterror(req, &status)) {
2969                 tevent_req_received(req);
2970                 return status;
2971         }
2972
2973         talloc_steal(mem_ctx, state->out_mem_ctx);
2974
2975         tevent_req_received(req);
2976         return NT_STATUS_OK;
2977 }
2978
2979 NTSTATUS dcerpc_spoolss_GetPrinterDriverDirectory_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverDirectory *r)
2980 {
2981         NTSTATUS status;
2982
2983         status = dcerpc_binding_handle_call(h,
2984                         NULL, &ndr_table_spoolss,
2985                         NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY, mem_ctx, r);
2986
2987         return status;
2988 }
2989
2990 NTSTATUS dcerpc_spoolss_GetPrinterDriverDirectory_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverDirectory *r)
2991 {
2992         NTSTATUS status;
2993
2994         status = dcerpc_spoolss_GetPrinterDriverDirectory_r(p->binding_handle, mem_ctx, r);
2995
2996         if (NT_STATUS_IS_RPC(status)) {
2997                 status = NT_STATUS_NET_WRITE_FAULT;
2998         }
2999
3000         return status;
3001 }
3002
3003 struct dcerpc_spoolss_GetPrinterDriverDirectory_state {
3004         struct spoolss_GetPrinterDriverDirectory orig;
3005         struct spoolss_GetPrinterDriverDirectory tmp;
3006         TALLOC_CTX *out_mem_ctx;
3007 };
3008
3009 static void dcerpc_spoolss_GetPrinterDriverDirectory_done(struct tevent_req *subreq);
3010
3011 struct tevent_req *dcerpc_spoolss_GetPrinterDriverDirectory_send(TALLOC_CTX *mem_ctx,
3012                                                                  struct tevent_context *ev,
3013                                                                  struct dcerpc_binding_handle *h,
3014                                                                  const char *_server /* [in] [unique,charset(UTF16)] */,
3015                                                                  const char *_environment /* [in] [unique,charset(UTF16)] */,
3016                                                                  uint32_t _level /* [in]  */,
3017                                                                  DATA_BLOB *_buffer /* [in] [unique] */,
3018                                                                  uint32_t _offered /* [in]  */,
3019                                                                  union spoolss_DriverDirectoryInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
3020                                                                  uint32_t *_needed /* [out] [ref] */)
3021 {
3022         struct tevent_req *req;
3023         struct dcerpc_spoolss_GetPrinterDriverDirectory_state *state;
3024         struct tevent_req *subreq;
3025
3026         req = tevent_req_create(mem_ctx, &state,
3027                                 struct dcerpc_spoolss_GetPrinterDriverDirectory_state);
3028         if (req == NULL) {
3029                 return NULL;
3030         }
3031         state->out_mem_ctx = NULL;
3032
3033         /* In parameters */
3034         state->orig.in.server = _server;
3035         state->orig.in.environment = _environment;
3036         state->orig.in.level = _level;
3037         state->orig.in.buffer = _buffer;
3038         state->orig.in.offered = _offered;
3039
3040         /* Out parameters */
3041         state->orig.out.info = _info;
3042         state->orig.out.needed = _needed;
3043
3044         /* Result */
3045         ZERO_STRUCT(state->orig.out.result);
3046
3047         state->out_mem_ctx = talloc_named_const(state, 0,
3048                              "dcerpc_spoolss_GetPrinterDriverDirectory_out_memory");
3049         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3050                 return tevent_req_post(req, ev);
3051         }
3052
3053         /* make a temporary copy, that we pass to the dispatch function */
3054         state->tmp = state->orig;
3055
3056         subreq = dcerpc_spoolss_GetPrinterDriverDirectory_r_send(state, ev, h, &state->tmp);
3057         if (tevent_req_nomem(subreq, req)) {
3058                 return tevent_req_post(req, ev);
3059         }
3060         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriverDirectory_done, req);
3061         return req;
3062 }
3063
3064 static void dcerpc_spoolss_GetPrinterDriverDirectory_done(struct tevent_req *subreq)
3065 {
3066         struct tevent_req *req = tevent_req_callback_data(
3067                 subreq, struct tevent_req);
3068         struct dcerpc_spoolss_GetPrinterDriverDirectory_state *state = tevent_req_data(
3069                 req, struct dcerpc_spoolss_GetPrinterDriverDirectory_state);
3070         NTSTATUS status;
3071         TALLOC_CTX *mem_ctx;
3072
3073         if (state->out_mem_ctx) {
3074                 mem_ctx = state->out_mem_ctx;
3075         } else {
3076                 mem_ctx = state;
3077         }
3078
3079         status = dcerpc_spoolss_GetPrinterDriverDirectory_r_recv(subreq, mem_ctx);
3080         TALLOC_FREE(subreq);
3081         if (!NT_STATUS_IS_OK(status)) {
3082                 tevent_req_nterror(req, status);
3083                 return;
3084         }
3085
3086         /* Copy out parameters */
3087         if (state->orig.out.info && state->tmp.out.info) {
3088                 *state->orig.out.info = *state->tmp.out.info;
3089         }
3090         *state->orig.out.needed = *state->tmp.out.needed;
3091
3092         /* Copy result */
3093         state->orig.out.result = state->tmp.out.result;
3094
3095         /* Reset temporary structure */
3096         ZERO_STRUCT(state->tmp);
3097
3098         tevent_req_done(req);
3099 }
3100
3101 NTSTATUS dcerpc_spoolss_GetPrinterDriverDirectory_recv(struct tevent_req *req,
3102                                                        TALLOC_CTX *mem_ctx,
3103                                                        WERROR *result)
3104 {
3105         struct dcerpc_spoolss_GetPrinterDriverDirectory_state *state = tevent_req_data(
3106                 req, struct dcerpc_spoolss_GetPrinterDriverDirectory_state);
3107         NTSTATUS status;
3108
3109         if (tevent_req_is_nterror(req, &status)) {
3110                 tevent_req_received(req);
3111                 return status;
3112         }
3113
3114         /* Steal possible out parameters to the callers context */
3115         talloc_steal(mem_ctx, state->out_mem_ctx);
3116
3117         /* Return result */
3118         *result = state->orig.out.result;
3119
3120         tevent_req_received(req);
3121         return NT_STATUS_OK;
3122 }
3123
3124 NTSTATUS dcerpc_spoolss_GetPrinterDriverDirectory(struct dcerpc_binding_handle *h,
3125                                                   TALLOC_CTX *mem_ctx,
3126                                                   const char *_server /* [in] [unique,charset(UTF16)] */,
3127                                                   const char *_environment /* [in] [unique,charset(UTF16)] */,
3128                                                   uint32_t _level /* [in]  */,
3129                                                   DATA_BLOB *_buffer /* [in] [unique] */,
3130                                                   uint32_t _offered /* [in]  */,
3131                                                   union spoolss_DriverDirectoryInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
3132                                                   uint32_t *_needed /* [out] [ref] */,
3133                                                   WERROR *result)
3134 {
3135         struct spoolss_GetPrinterDriverDirectory r;
3136         NTSTATUS status;
3137
3138         /* In parameters */
3139         r.in.server = _server;
3140         r.in.environment = _environment;
3141         r.in.level = _level;
3142         r.in.buffer = _buffer;
3143         r.in.offered = _offered;
3144
3145         status = dcerpc_spoolss_GetPrinterDriverDirectory_r(h, mem_ctx, &r);
3146         if (!NT_STATUS_IS_OK(status)) {
3147                 return status;
3148         }
3149
3150         /* Return variables */
3151         if (_info && r.out.info) {
3152                 *_info = *r.out.info;
3153         }
3154         *_needed = *r.out.needed;
3155
3156         /* Return result */
3157         *result = r.out.result;
3158
3159         return NT_STATUS_OK;
3160 }
3161
3162 struct dcerpc_spoolss_DeletePrinterDriver_r_state {
3163         TALLOC_CTX *out_mem_ctx;
3164 };
3165
3166 static void dcerpc_spoolss_DeletePrinterDriver_r_done(struct tevent_req *subreq);
3167
3168 struct tevent_req *dcerpc_spoolss_DeletePrinterDriver_r_send(TALLOC_CTX *mem_ctx,
3169         struct tevent_context *ev,
3170         struct dcerpc_binding_handle *h,
3171         struct spoolss_DeletePrinterDriver *r)
3172 {
3173         struct tevent_req *req;
3174         struct dcerpc_spoolss_DeletePrinterDriver_r_state *state;
3175         struct tevent_req *subreq;
3176
3177         req = tevent_req_create(mem_ctx, &state,
3178                                 struct dcerpc_spoolss_DeletePrinterDriver_r_state);
3179         if (req == NULL) {
3180                 return NULL;
3181         }
3182
3183         state->out_mem_ctx = NULL;
3184         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3185                         NULL, &ndr_table_spoolss,
3186                         NDR_SPOOLSS_DELETEPRINTERDRIVER, state, r);
3187         if (tevent_req_nomem(subreq, req)) {
3188                 return tevent_req_post(req, ev);
3189         }
3190         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDriver_r_done, req);
3191
3192         return req;
3193 }
3194
3195 static void dcerpc_spoolss_DeletePrinterDriver_r_done(struct tevent_req *subreq)
3196 {
3197         struct tevent_req *req =
3198                 tevent_req_callback_data(subreq,
3199                 struct tevent_req);
3200         NTSTATUS status;
3201
3202         status = dcerpc_binding_handle_call_recv(subreq);
3203         if (!NT_STATUS_IS_OK(status)) {
3204                 tevent_req_nterror(req, status);
3205                 return;
3206         }
3207
3208         tevent_req_done(req);
3209 }
3210
3211 NTSTATUS dcerpc_spoolss_DeletePrinterDriver_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3212 {
3213         struct dcerpc_spoolss_DeletePrinterDriver_r_state *state =
3214                 tevent_req_data(req,
3215                 struct dcerpc_spoolss_DeletePrinterDriver_r_state);
3216         NTSTATUS status;
3217
3218         if (tevent_req_is_nterror(req, &status)) {
3219                 tevent_req_received(req);
3220                 return status;
3221         }
3222
3223         talloc_steal(mem_ctx, state->out_mem_ctx);
3224
3225         tevent_req_received(req);
3226         return NT_STATUS_OK;
3227 }
3228
3229 NTSTATUS dcerpc_spoolss_DeletePrinterDriver_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDriver *r)
3230 {
3231         NTSTATUS status;
3232
3233         status = dcerpc_binding_handle_call(h,
3234                         NULL, &ndr_table_spoolss,
3235                         NDR_SPOOLSS_DELETEPRINTERDRIVER, mem_ctx, r);
3236
3237         return status;
3238 }
3239
3240 NTSTATUS dcerpc_spoolss_DeletePrinterDriver_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDriver *r)
3241 {
3242         NTSTATUS status;
3243
3244         status = dcerpc_spoolss_DeletePrinterDriver_r(p->binding_handle, mem_ctx, r);
3245
3246         if (NT_STATUS_IS_RPC(status)) {
3247                 status = NT_STATUS_NET_WRITE_FAULT;
3248         }
3249
3250         return status;
3251 }
3252
3253 struct dcerpc_spoolss_DeletePrinterDriver_state {
3254         struct spoolss_DeletePrinterDriver orig;
3255         struct spoolss_DeletePrinterDriver tmp;
3256         TALLOC_CTX *out_mem_ctx;
3257 };
3258
3259 static void dcerpc_spoolss_DeletePrinterDriver_done(struct tevent_req *subreq);
3260
3261 struct tevent_req *dcerpc_spoolss_DeletePrinterDriver_send(TALLOC_CTX *mem_ctx,
3262                                                            struct tevent_context *ev,
3263                                                            struct dcerpc_binding_handle *h,
3264                                                            const char *_server /* [in] [unique,charset(UTF16)] */,
3265                                                            const char *_architecture /* [in] [charset(UTF16)] */,
3266                                                            const char *_driver /* [in] [charset(UTF16)] */)
3267 {
3268         struct tevent_req *req;
3269         struct dcerpc_spoolss_DeletePrinterDriver_state *state;
3270         struct tevent_req *subreq;
3271
3272         req = tevent_req_create(mem_ctx, &state,
3273                                 struct dcerpc_spoolss_DeletePrinterDriver_state);
3274         if (req == NULL) {
3275                 return NULL;
3276         }
3277         state->out_mem_ctx = NULL;
3278
3279         /* In parameters */
3280         state->orig.in.server = _server;
3281         state->orig.in.architecture = _architecture;
3282         state->orig.in.driver = _driver;
3283
3284         /* Out parameters */
3285
3286         /* Result */
3287         ZERO_STRUCT(state->orig.out.result);
3288
3289         /* make a temporary copy, that we pass to the dispatch function */
3290         state->tmp = state->orig;
3291
3292         subreq = dcerpc_spoolss_DeletePrinterDriver_r_send(state, ev, h, &state->tmp);
3293         if (tevent_req_nomem(subreq, req)) {
3294                 return tevent_req_post(req, ev);
3295         }
3296         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDriver_done, req);
3297         return req;
3298 }
3299
3300 static void dcerpc_spoolss_DeletePrinterDriver_done(struct tevent_req *subreq)
3301 {
3302         struct tevent_req *req = tevent_req_callback_data(
3303                 subreq, struct tevent_req);
3304         struct dcerpc_spoolss_DeletePrinterDriver_state *state = tevent_req_data(
3305                 req, struct dcerpc_spoolss_DeletePrinterDriver_state);
3306         NTSTATUS status;
3307         TALLOC_CTX *mem_ctx;
3308
3309         if (state->out_mem_ctx) {
3310                 mem_ctx = state->out_mem_ctx;
3311         } else {
3312                 mem_ctx = state;
3313         }
3314
3315         status = dcerpc_spoolss_DeletePrinterDriver_r_recv(subreq, mem_ctx);
3316         TALLOC_FREE(subreq);
3317         if (!NT_STATUS_IS_OK(status)) {
3318                 tevent_req_nterror(req, status);
3319                 return;
3320         }
3321
3322         /* Copy out parameters */
3323
3324         /* Copy result */
3325         state->orig.out.result = state->tmp.out.result;
3326
3327         /* Reset temporary structure */
3328         ZERO_STRUCT(state->tmp);
3329
3330         tevent_req_done(req);
3331 }
3332
3333 NTSTATUS dcerpc_spoolss_DeletePrinterDriver_recv(struct tevent_req *req,
3334                                                  TALLOC_CTX *mem_ctx,
3335                                                  WERROR *result)
3336 {
3337         struct dcerpc_spoolss_DeletePrinterDriver_state *state = tevent_req_data(
3338                 req, struct dcerpc_spoolss_DeletePrinterDriver_state);
3339         NTSTATUS status;
3340
3341         if (tevent_req_is_nterror(req, &status)) {
3342                 tevent_req_received(req);
3343                 return status;
3344         }
3345
3346         /* Steal possible out parameters to the callers context */
3347         talloc_steal(mem_ctx, state->out_mem_ctx);
3348
3349         /* Return result */
3350         *result = state->orig.out.result;
3351
3352         tevent_req_received(req);
3353         return NT_STATUS_OK;
3354 }
3355
3356 NTSTATUS dcerpc_spoolss_DeletePrinterDriver(struct dcerpc_binding_handle *h,
3357                                             TALLOC_CTX *mem_ctx,
3358                                             const char *_server /* [in] [unique,charset(UTF16)] */,
3359                                             const char *_architecture /* [in] [charset(UTF16)] */,
3360                                             const char *_driver /* [in] [charset(UTF16)] */,
3361                                             WERROR *result)
3362 {
3363         struct spoolss_DeletePrinterDriver r;
3364         NTSTATUS status;
3365
3366         /* In parameters */
3367         r.in.server = _server;
3368         r.in.architecture = _architecture;
3369         r.in.driver = _driver;
3370
3371         status = dcerpc_spoolss_DeletePrinterDriver_r(h, mem_ctx, &r);
3372         if (!NT_STATUS_IS_OK(status)) {
3373                 return status;
3374         }
3375
3376         /* Return variables */
3377
3378         /* Return result */
3379         *result = r.out.result;
3380
3381         return NT_STATUS_OK;
3382 }
3383
3384 struct dcerpc_spoolss_AddPrintProcessor_r_state {
3385         TALLOC_CTX *out_mem_ctx;
3386 };
3387
3388 static void dcerpc_spoolss_AddPrintProcessor_r_done(struct tevent_req *subreq);
3389
3390 struct tevent_req *dcerpc_spoolss_AddPrintProcessor_r_send(TALLOC_CTX *mem_ctx,
3391         struct tevent_context *ev,
3392         struct dcerpc_binding_handle *h,
3393         struct spoolss_AddPrintProcessor *r)
3394 {
3395         struct tevent_req *req;
3396         struct dcerpc_spoolss_AddPrintProcessor_r_state *state;
3397         struct tevent_req *subreq;
3398
3399         req = tevent_req_create(mem_ctx, &state,
3400                                 struct dcerpc_spoolss_AddPrintProcessor_r_state);
3401         if (req == NULL) {
3402                 return NULL;
3403         }
3404
3405         state->out_mem_ctx = NULL;
3406         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3407                         NULL, &ndr_table_spoolss,
3408                         NDR_SPOOLSS_ADDPRINTPROCESSOR, state, r);
3409         if (tevent_req_nomem(subreq, req)) {
3410                 return tevent_req_post(req, ev);
3411         }
3412         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrintProcessor_r_done, req);
3413
3414         return req;
3415 }
3416
3417 static void dcerpc_spoolss_AddPrintProcessor_r_done(struct tevent_req *subreq)
3418 {
3419         struct tevent_req *req =
3420                 tevent_req_callback_data(subreq,
3421                 struct tevent_req);
3422         NTSTATUS status;
3423
3424         status = dcerpc_binding_handle_call_recv(subreq);
3425         if (!NT_STATUS_IS_OK(status)) {
3426                 tevent_req_nterror(req, status);
3427                 return;
3428         }
3429
3430         tevent_req_done(req);
3431 }
3432
3433 NTSTATUS dcerpc_spoolss_AddPrintProcessor_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3434 {
3435         struct dcerpc_spoolss_AddPrintProcessor_r_state *state =
3436                 tevent_req_data(req,
3437                 struct dcerpc_spoolss_AddPrintProcessor_r_state);
3438         NTSTATUS status;
3439
3440         if (tevent_req_is_nterror(req, &status)) {
3441                 tevent_req_received(req);
3442                 return status;
3443         }
3444
3445         talloc_steal(mem_ctx, state->out_mem_ctx);
3446
3447         tevent_req_received(req);
3448         return NT_STATUS_OK;
3449 }
3450
3451 NTSTATUS dcerpc_spoolss_AddPrintProcessor_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPrintProcessor *r)
3452 {
3453         NTSTATUS status;
3454
3455         status = dcerpc_binding_handle_call(h,
3456                         NULL, &ndr_table_spoolss,
3457                         NDR_SPOOLSS_ADDPRINTPROCESSOR, mem_ctx, r);
3458
3459         return status;
3460 }
3461
3462 NTSTATUS dcerpc_spoolss_AddPrintProcessor_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPrintProcessor *r)
3463 {
3464         NTSTATUS status;
3465
3466         status = dcerpc_spoolss_AddPrintProcessor_r(p->binding_handle, mem_ctx, r);
3467
3468         if (NT_STATUS_IS_RPC(status)) {
3469                 status = NT_STATUS_NET_WRITE_FAULT;
3470         }
3471
3472         return status;
3473 }
3474
3475 struct dcerpc_spoolss_AddPrintProcessor_state {
3476         struct spoolss_AddPrintProcessor orig;
3477         struct spoolss_AddPrintProcessor tmp;
3478         TALLOC_CTX *out_mem_ctx;
3479 };
3480
3481 static void dcerpc_spoolss_AddPrintProcessor_done(struct tevent_req *subreq);
3482
3483 struct tevent_req *dcerpc_spoolss_AddPrintProcessor_send(TALLOC_CTX *mem_ctx,
3484                                                          struct tevent_context *ev,
3485                                                          struct dcerpc_binding_handle *h,
3486                                                          const char *_server /* [in] [unique,charset(UTF16)] */,
3487                                                          const char *_architecture /* [in] [charset(UTF16)] */,
3488                                                          const char *_path_name /* [in] [charset(UTF16)] */,
3489                                                          const char *_print_processor_name /* [in] [charset(UTF16)] */)
3490 {
3491         struct tevent_req *req;
3492         struct dcerpc_spoolss_AddPrintProcessor_state *state;
3493         struct tevent_req *subreq;
3494
3495         req = tevent_req_create(mem_ctx, &state,
3496                                 struct dcerpc_spoolss_AddPrintProcessor_state);
3497         if (req == NULL) {
3498                 return NULL;
3499         }
3500         state->out_mem_ctx = NULL;
3501
3502         /* In parameters */
3503         state->orig.in.server = _server;
3504         state->orig.in.architecture = _architecture;
3505         state->orig.in.path_name = _path_name;
3506         state->orig.in.print_processor_name = _print_processor_name;
3507
3508         /* Out parameters */
3509
3510         /* Result */
3511         ZERO_STRUCT(state->orig.out.result);
3512
3513         /* make a temporary copy, that we pass to the dispatch function */
3514         state->tmp = state->orig;
3515
3516         subreq = dcerpc_spoolss_AddPrintProcessor_r_send(state, ev, h, &state->tmp);
3517         if (tevent_req_nomem(subreq, req)) {
3518                 return tevent_req_post(req, ev);
3519         }
3520         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrintProcessor_done, req);
3521         return req;
3522 }
3523
3524 static void dcerpc_spoolss_AddPrintProcessor_done(struct tevent_req *subreq)
3525 {
3526         struct tevent_req *req = tevent_req_callback_data(
3527                 subreq, struct tevent_req);
3528         struct dcerpc_spoolss_AddPrintProcessor_state *state = tevent_req_data(
3529                 req, struct dcerpc_spoolss_AddPrintProcessor_state);
3530         NTSTATUS status;
3531         TALLOC_CTX *mem_ctx;
3532
3533         if (state->out_mem_ctx) {
3534                 mem_ctx = state->out_mem_ctx;
3535         } else {
3536                 mem_ctx = state;
3537         }
3538
3539         status = dcerpc_spoolss_AddPrintProcessor_r_recv(subreq, mem_ctx);
3540         TALLOC_FREE(subreq);
3541         if (!NT_STATUS_IS_OK(status)) {
3542                 tevent_req_nterror(req, status);
3543                 return;
3544         }
3545
3546         /* Copy out parameters */
3547
3548         /* Copy result */
3549         state->orig.out.result = state->tmp.out.result;
3550
3551         /* Reset temporary structure */
3552         ZERO_STRUCT(state->tmp);
3553
3554         tevent_req_done(req);
3555 }
3556
3557 NTSTATUS dcerpc_spoolss_AddPrintProcessor_recv(struct tevent_req *req,
3558                                                TALLOC_CTX *mem_ctx,
3559                                                WERROR *result)
3560 {
3561         struct dcerpc_spoolss_AddPrintProcessor_state *state = tevent_req_data(
3562                 req, struct dcerpc_spoolss_AddPrintProcessor_state);
3563         NTSTATUS status;
3564
3565         if (tevent_req_is_nterror(req, &status)) {
3566                 tevent_req_received(req);
3567                 return status;
3568         }
3569
3570         /* Steal possible out parameters to the callers context */
3571         talloc_steal(mem_ctx, state->out_mem_ctx);
3572
3573         /* Return result */
3574         *result = state->orig.out.result;
3575
3576         tevent_req_received(req);
3577         return NT_STATUS_OK;
3578 }
3579
3580 NTSTATUS dcerpc_spoolss_AddPrintProcessor(struct dcerpc_binding_handle *h,
3581                                           TALLOC_CTX *mem_ctx,
3582                                           const char *_server /* [in] [unique,charset(UTF16)] */,
3583                                           const char *_architecture /* [in] [charset(UTF16)] */,
3584                                           const char *_path_name /* [in] [charset(UTF16)] */,
3585                                           const char *_print_processor_name /* [in] [charset(UTF16)] */,
3586                                           WERROR *result)
3587 {
3588         struct spoolss_AddPrintProcessor r;
3589         NTSTATUS status;
3590
3591         /* In parameters */
3592         r.in.server = _server;
3593         r.in.architecture = _architecture;
3594         r.in.path_name = _path_name;
3595         r.in.print_processor_name = _print_processor_name;
3596
3597         status = dcerpc_spoolss_AddPrintProcessor_r(h, mem_ctx, &r);
3598         if (!NT_STATUS_IS_OK(status)) {
3599                 return status;
3600         }
3601
3602         /* Return variables */
3603
3604         /* Return result */
3605         *result = r.out.result;
3606
3607         return NT_STATUS_OK;
3608 }
3609
3610 struct dcerpc_spoolss_EnumPrintProcessors_r_state {
3611         TALLOC_CTX *out_mem_ctx;
3612 };
3613
3614 static void dcerpc_spoolss_EnumPrintProcessors_r_done(struct tevent_req *subreq);
3615
3616 struct tevent_req *dcerpc_spoolss_EnumPrintProcessors_r_send(TALLOC_CTX *mem_ctx,
3617         struct tevent_context *ev,
3618         struct dcerpc_binding_handle *h,
3619         struct spoolss_EnumPrintProcessors *r)
3620 {
3621         struct tevent_req *req;
3622         struct dcerpc_spoolss_EnumPrintProcessors_r_state *state;
3623         struct tevent_req *subreq;
3624
3625         req = tevent_req_create(mem_ctx, &state,
3626                                 struct dcerpc_spoolss_EnumPrintProcessors_r_state);
3627         if (req == NULL) {
3628                 return NULL;
3629         }
3630
3631         state->out_mem_ctx = talloc_new(state);
3632         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3633                 return tevent_req_post(req, ev);
3634         }
3635
3636         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3637                         NULL, &ndr_table_spoolss,
3638                         NDR_SPOOLSS_ENUMPRINTPROCESSORS, state->out_mem_ctx, r);
3639         if (tevent_req_nomem(subreq, req)) {
3640                 return tevent_req_post(req, ev);
3641         }
3642         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrintProcessors_r_done, req);
3643
3644         return req;
3645 }
3646
3647 static void dcerpc_spoolss_EnumPrintProcessors_r_done(struct tevent_req *subreq)
3648 {
3649         struct tevent_req *req =
3650                 tevent_req_callback_data(subreq,
3651                 struct tevent_req);
3652         NTSTATUS status;
3653
3654         status = dcerpc_binding_handle_call_recv(subreq);
3655         if (!NT_STATUS_IS_OK(status)) {
3656                 tevent_req_nterror(req, status);
3657                 return;
3658         }
3659
3660         tevent_req_done(req);
3661 }
3662
3663 NTSTATUS dcerpc_spoolss_EnumPrintProcessors_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3664 {
3665         struct dcerpc_spoolss_EnumPrintProcessors_r_state *state =
3666                 tevent_req_data(req,
3667                 struct dcerpc_spoolss_EnumPrintProcessors_r_state);
3668         NTSTATUS status;
3669
3670         if (tevent_req_is_nterror(req, &status)) {
3671                 tevent_req_received(req);
3672                 return status;
3673         }
3674
3675         talloc_steal(mem_ctx, state->out_mem_ctx);
3676
3677         tevent_req_received(req);
3678         return NT_STATUS_OK;
3679 }
3680
3681 NTSTATUS dcerpc_spoolss_EnumPrintProcessors_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrintProcessors *r)
3682 {
3683         NTSTATUS status;
3684
3685         status = dcerpc_binding_handle_call(h,
3686                         NULL, &ndr_table_spoolss,
3687                         NDR_SPOOLSS_ENUMPRINTPROCESSORS, mem_ctx, r);
3688
3689         return status;
3690 }
3691
3692 NTSTATUS dcerpc_spoolss_EnumPrintProcessors_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrintProcessors *r)
3693 {
3694         NTSTATUS status;
3695
3696         status = dcerpc_spoolss_EnumPrintProcessors_r(p->binding_handle, mem_ctx, r);
3697
3698         if (NT_STATUS_IS_RPC(status)) {
3699                 status = NT_STATUS_NET_WRITE_FAULT;
3700         }
3701
3702         return status;
3703 }
3704
3705 struct dcerpc_spoolss_EnumPrintProcessors_state {
3706         struct spoolss_EnumPrintProcessors orig;
3707         struct spoolss_EnumPrintProcessors tmp;
3708         TALLOC_CTX *out_mem_ctx;
3709 };
3710
3711 static void dcerpc_spoolss_EnumPrintProcessors_done(struct tevent_req *subreq);
3712
3713 struct tevent_req *dcerpc_spoolss_EnumPrintProcessors_send(TALLOC_CTX *mem_ctx,
3714                                                            struct tevent_context *ev,
3715                                                            struct dcerpc_binding_handle *h,
3716                                                            const char *_servername /* [in] [unique,charset(UTF16)] */,
3717                                                            const char *_environment /* [in] [unique,charset(UTF16)] */,
3718                                                            uint32_t _level /* [in]  */,
3719                                                            DATA_BLOB *_buffer /* [in] [unique] */,
3720                                                            uint32_t _offered /* [in]  */,
3721                                                            uint32_t *_count /* [out] [ref] */,
3722                                                            union spoolss_PrintProcessorInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
3723                                                            uint32_t *_needed /* [out] [ref] */)
3724 {
3725         struct tevent_req *req;
3726         struct dcerpc_spoolss_EnumPrintProcessors_state *state;
3727         struct tevent_req *subreq;
3728
3729         req = tevent_req_create(mem_ctx, &state,
3730                                 struct dcerpc_spoolss_EnumPrintProcessors_state);
3731         if (req == NULL) {
3732                 return NULL;
3733         }
3734         state->out_mem_ctx = NULL;
3735
3736         /* In parameters */
3737         state->orig.in.servername = _servername;
3738         state->orig.in.environment = _environment;
3739         state->orig.in.level = _level;
3740         state->orig.in.buffer = _buffer;
3741         state->orig.in.offered = _offered;
3742
3743         /* Out parameters */
3744         state->orig.out.count = _count;
3745         state->orig.out.info = _info;
3746         state->orig.out.needed = _needed;
3747
3748         /* Result */
3749         ZERO_STRUCT(state->orig.out.result);
3750
3751         state->out_mem_ctx = talloc_named_const(state, 0,
3752                              "dcerpc_spoolss_EnumPrintProcessors_out_memory");
3753         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3754                 return tevent_req_post(req, ev);
3755         }
3756
3757         /* make a temporary copy, that we pass to the dispatch function */
3758         state->tmp = state->orig;
3759
3760         subreq = dcerpc_spoolss_EnumPrintProcessors_r_send(state, ev, h, &state->tmp);
3761         if (tevent_req_nomem(subreq, req)) {
3762                 return tevent_req_post(req, ev);
3763         }
3764         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrintProcessors_done, req);
3765         return req;
3766 }
3767
3768 static void dcerpc_spoolss_EnumPrintProcessors_done(struct tevent_req *subreq)
3769 {
3770         struct tevent_req *req = tevent_req_callback_data(
3771                 subreq, struct tevent_req);
3772         struct dcerpc_spoolss_EnumPrintProcessors_state *state = tevent_req_data(
3773                 req, struct dcerpc_spoolss_EnumPrintProcessors_state);
3774         NTSTATUS status;
3775         TALLOC_CTX *mem_ctx;
3776
3777         if (state->out_mem_ctx) {
3778                 mem_ctx = state->out_mem_ctx;
3779         } else {
3780                 mem_ctx = state;
3781         }
3782
3783         status = dcerpc_spoolss_EnumPrintProcessors_r_recv(subreq, mem_ctx);
3784         TALLOC_FREE(subreq);
3785         if (!NT_STATUS_IS_OK(status)) {
3786                 tevent_req_nterror(req, status);
3787                 return;
3788         }
3789
3790         /* Copy out parameters */
3791         *state->orig.out.count = *state->tmp.out.count;
3792         *state->orig.out.info = *state->tmp.out.info;
3793         *state->orig.out.needed = *state->tmp.out.needed;
3794
3795         /* Copy result */
3796         state->orig.out.result = state->tmp.out.result;
3797
3798         /* Reset temporary structure */
3799         ZERO_STRUCT(state->tmp);
3800
3801         tevent_req_done(req);
3802 }
3803
3804 NTSTATUS dcerpc_spoolss_EnumPrintProcessors_recv(struct tevent_req *req,
3805                                                  TALLOC_CTX *mem_ctx,
3806                                                  WERROR *result)
3807 {
3808         struct dcerpc_spoolss_EnumPrintProcessors_state *state = tevent_req_data(
3809                 req, struct dcerpc_spoolss_EnumPrintProcessors_state);
3810         NTSTATUS status;
3811
3812         if (tevent_req_is_nterror(req, &status)) {
3813                 tevent_req_received(req);
3814                 return status;
3815         }
3816
3817         /* Steal possible out parameters to the callers context */
3818         talloc_steal(mem_ctx, state->out_mem_ctx);
3819
3820         /* Return result */
3821         *result = state->orig.out.result;
3822
3823         tevent_req_received(req);
3824         return NT_STATUS_OK;
3825 }
3826
3827 NTSTATUS dcerpc_spoolss_EnumPrintProcessors(struct dcerpc_binding_handle *h,
3828                                             TALLOC_CTX *mem_ctx,
3829                                             const char *_servername /* [in] [unique,charset(UTF16)] */,
3830                                             const char *_environment /* [in] [unique,charset(UTF16)] */,
3831                                             uint32_t _level /* [in]  */,
3832                                             DATA_BLOB *_buffer /* [in] [unique] */,
3833                                             uint32_t _offered /* [in]  */,
3834                                             uint32_t *_count /* [out] [ref] */,
3835                                             union spoolss_PrintProcessorInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
3836                                             uint32_t *_needed /* [out] [ref] */,
3837                                             WERROR *result)
3838 {
3839         struct spoolss_EnumPrintProcessors r;
3840         NTSTATUS status;
3841
3842         /* In parameters */
3843         r.in.servername = _servername;
3844         r.in.environment = _environment;
3845         r.in.level = _level;
3846         r.in.buffer = _buffer;
3847         r.in.offered = _offered;
3848
3849         status = dcerpc_spoolss_EnumPrintProcessors_r(h, mem_ctx, &r);
3850         if (!NT_STATUS_IS_OK(status)) {
3851                 return status;
3852         }
3853
3854         /* Return variables */
3855         *_count = *r.out.count;
3856         *_info = *r.out.info;
3857         *_needed = *r.out.needed;
3858
3859         /* Return result */
3860         *result = r.out.result;
3861
3862         return NT_STATUS_OK;
3863 }
3864
3865 struct dcerpc_spoolss_GetPrintProcessorDirectory_r_state {
3866         TALLOC_CTX *out_mem_ctx;
3867 };
3868
3869 static void dcerpc_spoolss_GetPrintProcessorDirectory_r_done(struct tevent_req *subreq);
3870
3871 struct tevent_req *dcerpc_spoolss_GetPrintProcessorDirectory_r_send(TALLOC_CTX *mem_ctx,
3872         struct tevent_context *ev,
3873         struct dcerpc_binding_handle *h,
3874         struct spoolss_GetPrintProcessorDirectory *r)
3875 {
3876         struct tevent_req *req;
3877         struct dcerpc_spoolss_GetPrintProcessorDirectory_r_state *state;
3878         struct tevent_req *subreq;
3879
3880         req = tevent_req_create(mem_ctx, &state,
3881                                 struct dcerpc_spoolss_GetPrintProcessorDirectory_r_state);
3882         if (req == NULL) {
3883                 return NULL;
3884         }
3885
3886         state->out_mem_ctx = talloc_new(state);
3887         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3888                 return tevent_req_post(req, ev);
3889         }
3890
3891         subreq = dcerpc_binding_handle_call_send(state, ev, h,
3892                         NULL, &ndr_table_spoolss,
3893                         NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY, state->out_mem_ctx, r);
3894         if (tevent_req_nomem(subreq, req)) {
3895                 return tevent_req_post(req, ev);
3896         }
3897         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrintProcessorDirectory_r_done, req);
3898
3899         return req;
3900 }
3901
3902 static void dcerpc_spoolss_GetPrintProcessorDirectory_r_done(struct tevent_req *subreq)
3903 {
3904         struct tevent_req *req =
3905                 tevent_req_callback_data(subreq,
3906                 struct tevent_req);
3907         NTSTATUS status;
3908
3909         status = dcerpc_binding_handle_call_recv(subreq);
3910         if (!NT_STATUS_IS_OK(status)) {
3911                 tevent_req_nterror(req, status);
3912                 return;
3913         }
3914
3915         tevent_req_done(req);
3916 }
3917
3918 NTSTATUS dcerpc_spoolss_GetPrintProcessorDirectory_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
3919 {
3920         struct dcerpc_spoolss_GetPrintProcessorDirectory_r_state *state =
3921                 tevent_req_data(req,
3922                 struct dcerpc_spoolss_GetPrintProcessorDirectory_r_state);
3923         NTSTATUS status;
3924
3925         if (tevent_req_is_nterror(req, &status)) {
3926                 tevent_req_received(req);
3927                 return status;
3928         }
3929
3930         talloc_steal(mem_ctx, state->out_mem_ctx);
3931
3932         tevent_req_received(req);
3933         return NT_STATUS_OK;
3934 }
3935
3936 NTSTATUS dcerpc_spoolss_GetPrintProcessorDirectory_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrintProcessorDirectory *r)
3937 {
3938         NTSTATUS status;
3939
3940         status = dcerpc_binding_handle_call(h,
3941                         NULL, &ndr_table_spoolss,
3942                         NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY, mem_ctx, r);
3943
3944         return status;
3945 }
3946
3947 NTSTATUS dcerpc_spoolss_GetPrintProcessorDirectory_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrintProcessorDirectory *r)
3948 {
3949         NTSTATUS status;
3950
3951         status = dcerpc_spoolss_GetPrintProcessorDirectory_r(p->binding_handle, mem_ctx, r);
3952
3953         if (NT_STATUS_IS_RPC(status)) {
3954                 status = NT_STATUS_NET_WRITE_FAULT;
3955         }
3956
3957         return status;
3958 }
3959
3960 struct dcerpc_spoolss_GetPrintProcessorDirectory_state {
3961         struct spoolss_GetPrintProcessorDirectory orig;
3962         struct spoolss_GetPrintProcessorDirectory tmp;
3963         TALLOC_CTX *out_mem_ctx;
3964 };
3965
3966 static void dcerpc_spoolss_GetPrintProcessorDirectory_done(struct tevent_req *subreq);
3967
3968 struct tevent_req *dcerpc_spoolss_GetPrintProcessorDirectory_send(TALLOC_CTX *mem_ctx,
3969                                                                   struct tevent_context *ev,
3970                                                                   struct dcerpc_binding_handle *h,
3971                                                                   const char *_server /* [in] [unique,charset(UTF16)] */,
3972                                                                   const char *_environment /* [in] [unique,charset(UTF16)] */,
3973                                                                   uint32_t _level /* [in]  */,
3974                                                                   DATA_BLOB *_buffer /* [in] [unique] */,
3975                                                                   uint32_t _offered /* [in]  */,
3976                                                                   union spoolss_PrintProcessorDirectoryInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
3977                                                                   uint32_t *_needed /* [out] [ref] */)
3978 {
3979         struct tevent_req *req;
3980         struct dcerpc_spoolss_GetPrintProcessorDirectory_state *state;
3981         struct tevent_req *subreq;
3982
3983         req = tevent_req_create(mem_ctx, &state,
3984                                 struct dcerpc_spoolss_GetPrintProcessorDirectory_state);
3985         if (req == NULL) {
3986                 return NULL;
3987         }
3988         state->out_mem_ctx = NULL;
3989
3990         /* In parameters */
3991         state->orig.in.server = _server;
3992         state->orig.in.environment = _environment;
3993         state->orig.in.level = _level;
3994         state->orig.in.buffer = _buffer;
3995         state->orig.in.offered = _offered;
3996
3997         /* Out parameters */
3998         state->orig.out.info = _info;
3999         state->orig.out.needed = _needed;
4000
4001         /* Result */
4002         ZERO_STRUCT(state->orig.out.result);
4003
4004         state->out_mem_ctx = talloc_named_const(state, 0,
4005                              "dcerpc_spoolss_GetPrintProcessorDirectory_out_memory");
4006         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4007                 return tevent_req_post(req, ev);
4008         }
4009
4010         /* make a temporary copy, that we pass to the dispatch function */
4011         state->tmp = state->orig;
4012
4013         subreq = dcerpc_spoolss_GetPrintProcessorDirectory_r_send(state, ev, h, &state->tmp);
4014         if (tevent_req_nomem(subreq, req)) {
4015                 return tevent_req_post(req, ev);
4016         }
4017         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrintProcessorDirectory_done, req);
4018         return req;
4019 }
4020
4021 static void dcerpc_spoolss_GetPrintProcessorDirectory_done(struct tevent_req *subreq)
4022 {
4023         struct tevent_req *req = tevent_req_callback_data(
4024                 subreq, struct tevent_req);
4025         struct dcerpc_spoolss_GetPrintProcessorDirectory_state *state = tevent_req_data(
4026                 req, struct dcerpc_spoolss_GetPrintProcessorDirectory_state);
4027         NTSTATUS status;
4028         TALLOC_CTX *mem_ctx;
4029
4030         if (state->out_mem_ctx) {
4031                 mem_ctx = state->out_mem_ctx;
4032         } else {
4033                 mem_ctx = state;
4034         }
4035
4036         status = dcerpc_spoolss_GetPrintProcessorDirectory_r_recv(subreq, mem_ctx);
4037         TALLOC_FREE(subreq);
4038         if (!NT_STATUS_IS_OK(status)) {
4039                 tevent_req_nterror(req, status);
4040                 return;
4041         }
4042
4043         /* Copy out parameters */
4044         if (state->orig.out.info && state->tmp.out.info) {
4045                 *state->orig.out.info = *state->tmp.out.info;
4046         }
4047         *state->orig.out.needed = *state->tmp.out.needed;
4048
4049         /* Copy result */
4050         state->orig.out.result = state->tmp.out.result;
4051
4052         /* Reset temporary structure */
4053         ZERO_STRUCT(state->tmp);
4054
4055         tevent_req_done(req);
4056 }
4057
4058 NTSTATUS dcerpc_spoolss_GetPrintProcessorDirectory_recv(struct tevent_req *req,
4059                                                         TALLOC_CTX *mem_ctx,
4060                                                         WERROR *result)
4061 {
4062         struct dcerpc_spoolss_GetPrintProcessorDirectory_state *state = tevent_req_data(
4063                 req, struct dcerpc_spoolss_GetPrintProcessorDirectory_state);
4064         NTSTATUS status;
4065
4066         if (tevent_req_is_nterror(req, &status)) {
4067                 tevent_req_received(req);
4068                 return status;
4069         }
4070
4071         /* Steal possible out parameters to the callers context */
4072         talloc_steal(mem_ctx, state->out_mem_ctx);
4073
4074         /* Return result */
4075         *result = state->orig.out.result;
4076
4077         tevent_req_received(req);
4078         return NT_STATUS_OK;
4079 }
4080
4081 NTSTATUS dcerpc_spoolss_GetPrintProcessorDirectory(struct dcerpc_binding_handle *h,
4082                                                    TALLOC_CTX *mem_ctx,
4083                                                    const char *_server /* [in] [unique,charset(UTF16)] */,
4084                                                    const char *_environment /* [in] [unique,charset(UTF16)] */,
4085                                                    uint32_t _level /* [in]  */,
4086                                                    DATA_BLOB *_buffer /* [in] [unique] */,
4087                                                    uint32_t _offered /* [in]  */,
4088                                                    union spoolss_PrintProcessorDirectoryInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
4089                                                    uint32_t *_needed /* [out] [ref] */,
4090                                                    WERROR *result)
4091 {
4092         struct spoolss_GetPrintProcessorDirectory r;
4093         NTSTATUS status;
4094
4095         /* In parameters */
4096         r.in.server = _server;
4097         r.in.environment = _environment;
4098         r.in.level = _level;
4099         r.in.buffer = _buffer;
4100         r.in.offered = _offered;
4101
4102         status = dcerpc_spoolss_GetPrintProcessorDirectory_r(h, mem_ctx, &r);
4103         if (!NT_STATUS_IS_OK(status)) {
4104                 return status;
4105         }
4106
4107         /* Return variables */
4108         if (_info && r.out.info) {
4109                 *_info = *r.out.info;
4110         }
4111         *_needed = *r.out.needed;
4112
4113         /* Return result */
4114         *result = r.out.result;
4115
4116         return NT_STATUS_OK;
4117 }
4118
4119 struct dcerpc_spoolss_StartDocPrinter_r_state {
4120         TALLOC_CTX *out_mem_ctx;
4121 };
4122
4123 static void dcerpc_spoolss_StartDocPrinter_r_done(struct tevent_req *subreq);
4124
4125 struct tevent_req *dcerpc_spoolss_StartDocPrinter_r_send(TALLOC_CTX *mem_ctx,
4126         struct tevent_context *ev,
4127         struct dcerpc_binding_handle *h,
4128         struct spoolss_StartDocPrinter *r)
4129 {
4130         struct tevent_req *req;
4131         struct dcerpc_spoolss_StartDocPrinter_r_state *state;
4132         struct tevent_req *subreq;
4133
4134         req = tevent_req_create(mem_ctx, &state,
4135                                 struct dcerpc_spoolss_StartDocPrinter_r_state);
4136         if (req == NULL) {
4137                 return NULL;
4138         }
4139
4140         state->out_mem_ctx = talloc_new(state);
4141         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4142                 return tevent_req_post(req, ev);
4143         }
4144
4145         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4146                         NULL, &ndr_table_spoolss,
4147                         NDR_SPOOLSS_STARTDOCPRINTER, state->out_mem_ctx, r);
4148         if (tevent_req_nomem(subreq, req)) {
4149                 return tevent_req_post(req, ev);
4150         }
4151         tevent_req_set_callback(subreq, dcerpc_spoolss_StartDocPrinter_r_done, req);
4152
4153         return req;
4154 }
4155
4156 static void dcerpc_spoolss_StartDocPrinter_r_done(struct tevent_req *subreq)
4157 {
4158         struct tevent_req *req =
4159                 tevent_req_callback_data(subreq,
4160                 struct tevent_req);
4161         NTSTATUS status;
4162
4163         status = dcerpc_binding_handle_call_recv(subreq);
4164         if (!NT_STATUS_IS_OK(status)) {
4165                 tevent_req_nterror(req, status);
4166                 return;
4167         }
4168
4169         tevent_req_done(req);
4170 }
4171
4172 NTSTATUS dcerpc_spoolss_StartDocPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4173 {
4174         struct dcerpc_spoolss_StartDocPrinter_r_state *state =
4175                 tevent_req_data(req,
4176                 struct dcerpc_spoolss_StartDocPrinter_r_state);
4177         NTSTATUS status;
4178
4179         if (tevent_req_is_nterror(req, &status)) {
4180                 tevent_req_received(req);
4181                 return status;
4182         }
4183
4184         talloc_steal(mem_ctx, state->out_mem_ctx);
4185
4186         tevent_req_received(req);
4187         return NT_STATUS_OK;
4188 }
4189
4190 NTSTATUS dcerpc_spoolss_StartDocPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_StartDocPrinter *r)
4191 {
4192         NTSTATUS status;
4193
4194         status = dcerpc_binding_handle_call(h,
4195                         NULL, &ndr_table_spoolss,
4196                         NDR_SPOOLSS_STARTDOCPRINTER, mem_ctx, r);
4197
4198         return status;
4199 }
4200
4201 NTSTATUS dcerpc_spoolss_StartDocPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_StartDocPrinter *r)
4202 {
4203         NTSTATUS status;
4204
4205         status = dcerpc_spoolss_StartDocPrinter_r(p->binding_handle, mem_ctx, r);
4206
4207         if (NT_STATUS_IS_RPC(status)) {
4208                 status = NT_STATUS_NET_WRITE_FAULT;
4209         }
4210
4211         return status;
4212 }
4213
4214 struct dcerpc_spoolss_StartDocPrinter_state {
4215         struct spoolss_StartDocPrinter orig;
4216         struct spoolss_StartDocPrinter tmp;
4217         TALLOC_CTX *out_mem_ctx;
4218 };
4219
4220 static void dcerpc_spoolss_StartDocPrinter_done(struct tevent_req *subreq);
4221
4222 struct tevent_req *dcerpc_spoolss_StartDocPrinter_send(TALLOC_CTX *mem_ctx,
4223                                                        struct tevent_context *ev,
4224                                                        struct dcerpc_binding_handle *h,
4225                                                        struct policy_handle *_handle /* [in] [ref] */,
4226                                                        uint32_t _level /* [in]  */,
4227                                                        union spoolss_DocumentInfo _info /* [in] [switch_is(level)] */,
4228                                                        uint32_t *_job_id /* [out] [ref] */)
4229 {
4230         struct tevent_req *req;
4231         struct dcerpc_spoolss_StartDocPrinter_state *state;
4232         struct tevent_req *subreq;
4233
4234         req = tevent_req_create(mem_ctx, &state,
4235                                 struct dcerpc_spoolss_StartDocPrinter_state);
4236         if (req == NULL) {
4237                 return NULL;
4238         }
4239         state->out_mem_ctx = NULL;
4240
4241         /* In parameters */
4242         state->orig.in.handle = _handle;
4243         state->orig.in.level = _level;
4244         state->orig.in.info = _info;
4245
4246         /* Out parameters */
4247         state->orig.out.job_id = _job_id;
4248
4249         /* Result */
4250         ZERO_STRUCT(state->orig.out.result);
4251
4252         state->out_mem_ctx = talloc_named_const(state, 0,
4253                              "dcerpc_spoolss_StartDocPrinter_out_memory");
4254         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4255                 return tevent_req_post(req, ev);
4256         }
4257
4258         /* make a temporary copy, that we pass to the dispatch function */
4259         state->tmp = state->orig;
4260
4261         subreq = dcerpc_spoolss_StartDocPrinter_r_send(state, ev, h, &state->tmp);
4262         if (tevent_req_nomem(subreq, req)) {
4263                 return tevent_req_post(req, ev);
4264         }
4265         tevent_req_set_callback(subreq, dcerpc_spoolss_StartDocPrinter_done, req);
4266         return req;
4267 }
4268
4269 static void dcerpc_spoolss_StartDocPrinter_done(struct tevent_req *subreq)
4270 {
4271         struct tevent_req *req = tevent_req_callback_data(
4272                 subreq, struct tevent_req);
4273         struct dcerpc_spoolss_StartDocPrinter_state *state = tevent_req_data(
4274                 req, struct dcerpc_spoolss_StartDocPrinter_state);
4275         NTSTATUS status;
4276         TALLOC_CTX *mem_ctx;
4277
4278         if (state->out_mem_ctx) {
4279                 mem_ctx = state->out_mem_ctx;
4280         } else {
4281                 mem_ctx = state;
4282         }
4283
4284         status = dcerpc_spoolss_StartDocPrinter_r_recv(subreq, mem_ctx);
4285         TALLOC_FREE(subreq);
4286         if (!NT_STATUS_IS_OK(status)) {
4287                 tevent_req_nterror(req, status);
4288                 return;
4289         }
4290
4291         /* Copy out parameters */
4292         *state->orig.out.job_id = *state->tmp.out.job_id;
4293
4294         /* Copy result */
4295         state->orig.out.result = state->tmp.out.result;
4296
4297         /* Reset temporary structure */
4298         ZERO_STRUCT(state->tmp);
4299
4300         tevent_req_done(req);
4301 }
4302
4303 NTSTATUS dcerpc_spoolss_StartDocPrinter_recv(struct tevent_req *req,
4304                                              TALLOC_CTX *mem_ctx,
4305                                              WERROR *result)
4306 {
4307         struct dcerpc_spoolss_StartDocPrinter_state *state = tevent_req_data(
4308                 req, struct dcerpc_spoolss_StartDocPrinter_state);
4309         NTSTATUS status;
4310
4311         if (tevent_req_is_nterror(req, &status)) {
4312                 tevent_req_received(req);
4313                 return status;
4314         }
4315
4316         /* Steal possible out parameters to the callers context */
4317         talloc_steal(mem_ctx, state->out_mem_ctx);
4318
4319         /* Return result */
4320         *result = state->orig.out.result;
4321
4322         tevent_req_received(req);
4323         return NT_STATUS_OK;
4324 }
4325
4326 NTSTATUS dcerpc_spoolss_StartDocPrinter(struct dcerpc_binding_handle *h,
4327                                         TALLOC_CTX *mem_ctx,
4328                                         struct policy_handle *_handle /* [in] [ref] */,
4329                                         uint32_t _level /* [in]  */,
4330                                         union spoolss_DocumentInfo _info /* [in] [switch_is(level)] */,
4331                                         uint32_t *_job_id /* [out] [ref] */,
4332                                         WERROR *result)
4333 {
4334         struct spoolss_StartDocPrinter r;
4335         NTSTATUS status;
4336
4337         /* In parameters */
4338         r.in.handle = _handle;
4339         r.in.level = _level;
4340         r.in.info = _info;
4341
4342         status = dcerpc_spoolss_StartDocPrinter_r(h, mem_ctx, &r);
4343         if (!NT_STATUS_IS_OK(status)) {
4344                 return status;
4345         }
4346
4347         /* Return variables */
4348         *_job_id = *r.out.job_id;
4349
4350         /* Return result */
4351         *result = r.out.result;
4352
4353         return NT_STATUS_OK;
4354 }
4355
4356 struct dcerpc_spoolss_StartPagePrinter_r_state {
4357         TALLOC_CTX *out_mem_ctx;
4358 };
4359
4360 static void dcerpc_spoolss_StartPagePrinter_r_done(struct tevent_req *subreq);
4361
4362 struct tevent_req *dcerpc_spoolss_StartPagePrinter_r_send(TALLOC_CTX *mem_ctx,
4363         struct tevent_context *ev,
4364         struct dcerpc_binding_handle *h,
4365         struct spoolss_StartPagePrinter *r)
4366 {
4367         struct tevent_req *req;
4368         struct dcerpc_spoolss_StartPagePrinter_r_state *state;
4369         struct tevent_req *subreq;
4370
4371         req = tevent_req_create(mem_ctx, &state,
4372                                 struct dcerpc_spoolss_StartPagePrinter_r_state);
4373         if (req == NULL) {
4374                 return NULL;
4375         }
4376
4377         state->out_mem_ctx = NULL;
4378         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4379                         NULL, &ndr_table_spoolss,
4380                         NDR_SPOOLSS_STARTPAGEPRINTER, state, r);
4381         if (tevent_req_nomem(subreq, req)) {
4382                 return tevent_req_post(req, ev);
4383         }
4384         tevent_req_set_callback(subreq, dcerpc_spoolss_StartPagePrinter_r_done, req);
4385
4386         return req;
4387 }
4388
4389 static void dcerpc_spoolss_StartPagePrinter_r_done(struct tevent_req *subreq)
4390 {
4391         struct tevent_req *req =
4392                 tevent_req_callback_data(subreq,
4393                 struct tevent_req);
4394         NTSTATUS status;
4395
4396         status = dcerpc_binding_handle_call_recv(subreq);
4397         if (!NT_STATUS_IS_OK(status)) {
4398                 tevent_req_nterror(req, status);
4399                 return;
4400         }
4401
4402         tevent_req_done(req);
4403 }
4404
4405 NTSTATUS dcerpc_spoolss_StartPagePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4406 {
4407         struct dcerpc_spoolss_StartPagePrinter_r_state *state =
4408                 tevent_req_data(req,
4409                 struct dcerpc_spoolss_StartPagePrinter_r_state);
4410         NTSTATUS status;
4411
4412         if (tevent_req_is_nterror(req, &status)) {
4413                 tevent_req_received(req);
4414                 return status;
4415         }
4416
4417         talloc_steal(mem_ctx, state->out_mem_ctx);
4418
4419         tevent_req_received(req);
4420         return NT_STATUS_OK;
4421 }
4422
4423 NTSTATUS dcerpc_spoolss_StartPagePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_StartPagePrinter *r)
4424 {
4425         NTSTATUS status;
4426
4427         status = dcerpc_binding_handle_call(h,
4428                         NULL, &ndr_table_spoolss,
4429                         NDR_SPOOLSS_STARTPAGEPRINTER, mem_ctx, r);
4430
4431         return status;
4432 }
4433
4434 NTSTATUS dcerpc_spoolss_StartPagePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_StartPagePrinter *r)
4435 {
4436         NTSTATUS status;
4437
4438         status = dcerpc_spoolss_StartPagePrinter_r(p->binding_handle, mem_ctx, r);
4439
4440         if (NT_STATUS_IS_RPC(status)) {
4441                 status = NT_STATUS_NET_WRITE_FAULT;
4442         }
4443
4444         return status;
4445 }
4446
4447 struct dcerpc_spoolss_StartPagePrinter_state {
4448         struct spoolss_StartPagePrinter orig;
4449         struct spoolss_StartPagePrinter tmp;
4450         TALLOC_CTX *out_mem_ctx;
4451 };
4452
4453 static void dcerpc_spoolss_StartPagePrinter_done(struct tevent_req *subreq);
4454
4455 struct tevent_req *dcerpc_spoolss_StartPagePrinter_send(TALLOC_CTX *mem_ctx,
4456                                                         struct tevent_context *ev,
4457                                                         struct dcerpc_binding_handle *h,
4458                                                         struct policy_handle *_handle /* [in] [ref] */)
4459 {
4460         struct tevent_req *req;
4461         struct dcerpc_spoolss_StartPagePrinter_state *state;
4462         struct tevent_req *subreq;
4463
4464         req = tevent_req_create(mem_ctx, &state,
4465                                 struct dcerpc_spoolss_StartPagePrinter_state);
4466         if (req == NULL) {
4467                 return NULL;
4468         }
4469         state->out_mem_ctx = NULL;
4470
4471         /* In parameters */
4472         state->orig.in.handle = _handle;
4473
4474         /* Out parameters */
4475
4476         /* Result */
4477         ZERO_STRUCT(state->orig.out.result);
4478
4479         /* make a temporary copy, that we pass to the dispatch function */
4480         state->tmp = state->orig;
4481
4482         subreq = dcerpc_spoolss_StartPagePrinter_r_send(state, ev, h, &state->tmp);
4483         if (tevent_req_nomem(subreq, req)) {
4484                 return tevent_req_post(req, ev);
4485         }
4486         tevent_req_set_callback(subreq, dcerpc_spoolss_StartPagePrinter_done, req);
4487         return req;
4488 }
4489
4490 static void dcerpc_spoolss_StartPagePrinter_done(struct tevent_req *subreq)
4491 {
4492         struct tevent_req *req = tevent_req_callback_data(
4493                 subreq, struct tevent_req);
4494         struct dcerpc_spoolss_StartPagePrinter_state *state = tevent_req_data(
4495                 req, struct dcerpc_spoolss_StartPagePrinter_state);
4496         NTSTATUS status;
4497         TALLOC_CTX *mem_ctx;
4498
4499         if (state->out_mem_ctx) {
4500                 mem_ctx = state->out_mem_ctx;
4501         } else {
4502                 mem_ctx = state;
4503         }
4504
4505         status = dcerpc_spoolss_StartPagePrinter_r_recv(subreq, mem_ctx);
4506         TALLOC_FREE(subreq);
4507         if (!NT_STATUS_IS_OK(status)) {
4508                 tevent_req_nterror(req, status);
4509                 return;
4510         }
4511
4512         /* Copy out parameters */
4513
4514         /* Copy result */
4515         state->orig.out.result = state->tmp.out.result;
4516
4517         /* Reset temporary structure */
4518         ZERO_STRUCT(state->tmp);
4519
4520         tevent_req_done(req);
4521 }
4522
4523 NTSTATUS dcerpc_spoolss_StartPagePrinter_recv(struct tevent_req *req,
4524                                               TALLOC_CTX *mem_ctx,
4525                                               WERROR *result)
4526 {
4527         struct dcerpc_spoolss_StartPagePrinter_state *state = tevent_req_data(
4528                 req, struct dcerpc_spoolss_StartPagePrinter_state);
4529         NTSTATUS status;
4530
4531         if (tevent_req_is_nterror(req, &status)) {
4532                 tevent_req_received(req);
4533                 return status;
4534         }
4535
4536         /* Steal possible out parameters to the callers context */
4537         talloc_steal(mem_ctx, state->out_mem_ctx);
4538
4539         /* Return result */
4540         *result = state->orig.out.result;
4541
4542         tevent_req_received(req);
4543         return NT_STATUS_OK;
4544 }
4545
4546 NTSTATUS dcerpc_spoolss_StartPagePrinter(struct dcerpc_binding_handle *h,
4547                                          TALLOC_CTX *mem_ctx,
4548                                          struct policy_handle *_handle /* [in] [ref] */,
4549                                          WERROR *result)
4550 {
4551         struct spoolss_StartPagePrinter r;
4552         NTSTATUS status;
4553
4554         /* In parameters */
4555         r.in.handle = _handle;
4556
4557         status = dcerpc_spoolss_StartPagePrinter_r(h, mem_ctx, &r);
4558         if (!NT_STATUS_IS_OK(status)) {
4559                 return status;
4560         }
4561
4562         /* Return variables */
4563
4564         /* Return result */
4565         *result = r.out.result;
4566
4567         return NT_STATUS_OK;
4568 }
4569
4570 struct dcerpc_spoolss_WritePrinter_r_state {
4571         TALLOC_CTX *out_mem_ctx;
4572 };
4573
4574 static void dcerpc_spoolss_WritePrinter_r_done(struct tevent_req *subreq);
4575
4576 struct tevent_req *dcerpc_spoolss_WritePrinter_r_send(TALLOC_CTX *mem_ctx,
4577         struct tevent_context *ev,
4578         struct dcerpc_binding_handle *h,
4579         struct spoolss_WritePrinter *r)
4580 {
4581         struct tevent_req *req;
4582         struct dcerpc_spoolss_WritePrinter_r_state *state;
4583         struct tevent_req *subreq;
4584
4585         req = tevent_req_create(mem_ctx, &state,
4586                                 struct dcerpc_spoolss_WritePrinter_r_state);
4587         if (req == NULL) {
4588                 return NULL;
4589         }
4590
4591         state->out_mem_ctx = talloc_new(state);
4592         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4593                 return tevent_req_post(req, ev);
4594         }
4595
4596         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4597                         NULL, &ndr_table_spoolss,
4598                         NDR_SPOOLSS_WRITEPRINTER, state->out_mem_ctx, r);
4599         if (tevent_req_nomem(subreq, req)) {
4600                 return tevent_req_post(req, ev);
4601         }
4602         tevent_req_set_callback(subreq, dcerpc_spoolss_WritePrinter_r_done, req);
4603
4604         return req;
4605 }
4606
4607 static void dcerpc_spoolss_WritePrinter_r_done(struct tevent_req *subreq)
4608 {
4609         struct tevent_req *req =
4610                 tevent_req_callback_data(subreq,
4611                 struct tevent_req);
4612         NTSTATUS status;
4613
4614         status = dcerpc_binding_handle_call_recv(subreq);
4615         if (!NT_STATUS_IS_OK(status)) {
4616                 tevent_req_nterror(req, status);
4617                 return;
4618         }
4619
4620         tevent_req_done(req);
4621 }
4622
4623 NTSTATUS dcerpc_spoolss_WritePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4624 {
4625         struct dcerpc_spoolss_WritePrinter_r_state *state =
4626                 tevent_req_data(req,
4627                 struct dcerpc_spoolss_WritePrinter_r_state);
4628         NTSTATUS status;
4629
4630         if (tevent_req_is_nterror(req, &status)) {
4631                 tevent_req_received(req);
4632                 return status;
4633         }
4634
4635         talloc_steal(mem_ctx, state->out_mem_ctx);
4636
4637         tevent_req_received(req);
4638         return NT_STATUS_OK;
4639 }
4640
4641 NTSTATUS dcerpc_spoolss_WritePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_WritePrinter *r)
4642 {
4643         NTSTATUS status;
4644
4645         status = dcerpc_binding_handle_call(h,
4646                         NULL, &ndr_table_spoolss,
4647                         NDR_SPOOLSS_WRITEPRINTER, mem_ctx, r);
4648
4649         return status;
4650 }
4651
4652 NTSTATUS dcerpc_spoolss_WritePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_WritePrinter *r)
4653 {
4654         NTSTATUS status;
4655
4656         status = dcerpc_spoolss_WritePrinter_r(p->binding_handle, mem_ctx, r);
4657
4658         if (NT_STATUS_IS_RPC(status)) {
4659                 status = NT_STATUS_NET_WRITE_FAULT;
4660         }
4661
4662         return status;
4663 }
4664
4665 struct dcerpc_spoolss_WritePrinter_state {
4666         struct spoolss_WritePrinter orig;
4667         struct spoolss_WritePrinter tmp;
4668         TALLOC_CTX *out_mem_ctx;
4669 };
4670
4671 static void dcerpc_spoolss_WritePrinter_done(struct tevent_req *subreq);
4672
4673 struct tevent_req *dcerpc_spoolss_WritePrinter_send(TALLOC_CTX *mem_ctx,
4674                                                     struct tevent_context *ev,
4675                                                     struct dcerpc_binding_handle *h,
4676                                                     struct policy_handle *_handle /* [in] [ref] */,
4677                                                     DATA_BLOB _data /* [in]  */,
4678                                                     uint32_t __data_size /* [in] [value(r->in.data.length)] */,
4679                                                     uint32_t *_num_written /* [out] [ref] */)
4680 {
4681         struct tevent_req *req;
4682         struct dcerpc_spoolss_WritePrinter_state *state;
4683         struct tevent_req *subreq;
4684
4685         req = tevent_req_create(mem_ctx, &state,
4686                                 struct dcerpc_spoolss_WritePrinter_state);
4687         if (req == NULL) {
4688                 return NULL;
4689         }
4690         state->out_mem_ctx = NULL;
4691
4692         /* In parameters */
4693         state->orig.in.handle = _handle;
4694         state->orig.in.data = _data;
4695         state->orig.in._data_size = __data_size;
4696
4697         /* Out parameters */
4698         state->orig.out.num_written = _num_written;
4699
4700         /* Result */
4701         ZERO_STRUCT(state->orig.out.result);
4702
4703         state->out_mem_ctx = talloc_named_const(state, 0,
4704                              "dcerpc_spoolss_WritePrinter_out_memory");
4705         if (tevent_req_nomem(state->out_mem_ctx, req)) {
4706                 return tevent_req_post(req, ev);
4707         }
4708
4709         /* make a temporary copy, that we pass to the dispatch function */
4710         state->tmp = state->orig;
4711
4712         subreq = dcerpc_spoolss_WritePrinter_r_send(state, ev, h, &state->tmp);
4713         if (tevent_req_nomem(subreq, req)) {
4714                 return tevent_req_post(req, ev);
4715         }
4716         tevent_req_set_callback(subreq, dcerpc_spoolss_WritePrinter_done, req);
4717         return req;
4718 }
4719
4720 static void dcerpc_spoolss_WritePrinter_done(struct tevent_req *subreq)
4721 {
4722         struct tevent_req *req = tevent_req_callback_data(
4723                 subreq, struct tevent_req);
4724         struct dcerpc_spoolss_WritePrinter_state *state = tevent_req_data(
4725                 req, struct dcerpc_spoolss_WritePrinter_state);
4726         NTSTATUS status;
4727         TALLOC_CTX *mem_ctx;
4728
4729         if (state->out_mem_ctx) {
4730                 mem_ctx = state->out_mem_ctx;
4731         } else {
4732                 mem_ctx = state;
4733         }
4734
4735         status = dcerpc_spoolss_WritePrinter_r_recv(subreq, mem_ctx);
4736         TALLOC_FREE(subreq);
4737         if (!NT_STATUS_IS_OK(status)) {
4738                 tevent_req_nterror(req, status);
4739                 return;
4740         }
4741
4742         /* Copy out parameters */
4743         *state->orig.out.num_written = *state->tmp.out.num_written;
4744
4745         /* Copy result */
4746         state->orig.out.result = state->tmp.out.result;
4747
4748         /* Reset temporary structure */
4749         ZERO_STRUCT(state->tmp);
4750
4751         tevent_req_done(req);
4752 }
4753
4754 NTSTATUS dcerpc_spoolss_WritePrinter_recv(struct tevent_req *req,
4755                                           TALLOC_CTX *mem_ctx,
4756                                           WERROR *result)
4757 {
4758         struct dcerpc_spoolss_WritePrinter_state *state = tevent_req_data(
4759                 req, struct dcerpc_spoolss_WritePrinter_state);
4760         NTSTATUS status;
4761
4762         if (tevent_req_is_nterror(req, &status)) {
4763                 tevent_req_received(req);
4764                 return status;
4765         }
4766
4767         /* Steal possible out parameters to the callers context */
4768         talloc_steal(mem_ctx, state->out_mem_ctx);
4769
4770         /* Return result */
4771         *result = state->orig.out.result;
4772
4773         tevent_req_received(req);
4774         return NT_STATUS_OK;
4775 }
4776
4777 NTSTATUS dcerpc_spoolss_WritePrinter(struct dcerpc_binding_handle *h,
4778                                      TALLOC_CTX *mem_ctx,
4779                                      struct policy_handle *_handle /* [in] [ref] */,
4780                                      DATA_BLOB _data /* [in]  */,
4781                                      uint32_t __data_size /* [in] [value(r->in.data.length)] */,
4782                                      uint32_t *_num_written /* [out] [ref] */,
4783                                      WERROR *result)
4784 {
4785         struct spoolss_WritePrinter r;
4786         NTSTATUS status;
4787
4788         /* In parameters */
4789         r.in.handle = _handle;
4790         r.in.data = _data;
4791         r.in._data_size = __data_size;
4792
4793         status = dcerpc_spoolss_WritePrinter_r(h, mem_ctx, &r);
4794         if (!NT_STATUS_IS_OK(status)) {
4795                 return status;
4796         }
4797
4798         /* Return variables */
4799         *_num_written = *r.out.num_written;
4800
4801         /* Return result */
4802         *result = r.out.result;
4803
4804         return NT_STATUS_OK;
4805 }
4806
4807 struct dcerpc_spoolss_EndPagePrinter_r_state {
4808         TALLOC_CTX *out_mem_ctx;
4809 };
4810
4811 static void dcerpc_spoolss_EndPagePrinter_r_done(struct tevent_req *subreq);
4812
4813 struct tevent_req *dcerpc_spoolss_EndPagePrinter_r_send(TALLOC_CTX *mem_ctx,
4814         struct tevent_context *ev,
4815         struct dcerpc_binding_handle *h,
4816         struct spoolss_EndPagePrinter *r)
4817 {
4818         struct tevent_req *req;
4819         struct dcerpc_spoolss_EndPagePrinter_r_state *state;
4820         struct tevent_req *subreq;
4821
4822         req = tevent_req_create(mem_ctx, &state,
4823                                 struct dcerpc_spoolss_EndPagePrinter_r_state);
4824         if (req == NULL) {
4825                 return NULL;
4826         }
4827
4828         state->out_mem_ctx = NULL;
4829         subreq = dcerpc_binding_handle_call_send(state, ev, h,
4830                         NULL, &ndr_table_spoolss,
4831                         NDR_SPOOLSS_ENDPAGEPRINTER, state, r);
4832         if (tevent_req_nomem(subreq, req)) {
4833                 return tevent_req_post(req, ev);
4834         }
4835         tevent_req_set_callback(subreq, dcerpc_spoolss_EndPagePrinter_r_done, req);
4836
4837         return req;
4838 }
4839
4840 static void dcerpc_spoolss_EndPagePrinter_r_done(struct tevent_req *subreq)
4841 {
4842         struct tevent_req *req =
4843                 tevent_req_callback_data(subreq,
4844                 struct tevent_req);
4845         NTSTATUS status;
4846
4847         status = dcerpc_binding_handle_call_recv(subreq);
4848         if (!NT_STATUS_IS_OK(status)) {
4849                 tevent_req_nterror(req, status);
4850                 return;
4851         }
4852
4853         tevent_req_done(req);
4854 }
4855
4856 NTSTATUS dcerpc_spoolss_EndPagePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
4857 {
4858         struct dcerpc_spoolss_EndPagePrinter_r_state *state =
4859                 tevent_req_data(req,
4860                 struct dcerpc_spoolss_EndPagePrinter_r_state);
4861         NTSTATUS status;
4862
4863         if (tevent_req_is_nterror(req, &status)) {
4864                 tevent_req_received(req);
4865                 return status;
4866         }
4867
4868         talloc_steal(mem_ctx, state->out_mem_ctx);
4869
4870         tevent_req_received(req);
4871         return NT_STATUS_OK;
4872 }
4873
4874 NTSTATUS dcerpc_spoolss_EndPagePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EndPagePrinter *r)
4875 {
4876         NTSTATUS status;
4877
4878         status = dcerpc_binding_handle_call(h,
4879                         NULL, &ndr_table_spoolss,
4880                         NDR_SPOOLSS_ENDPAGEPRINTER, mem_ctx, r);
4881
4882         return status;
4883 }
4884
4885 NTSTATUS dcerpc_spoolss_EndPagePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EndPagePrinter *r)
4886 {
4887         NTSTATUS status;
4888
4889         status = dcerpc_spoolss_EndPagePrinter_r(p->binding_handle, mem_ctx, r);
4890
4891         if (NT_STATUS_IS_RPC(status)) {
4892                 status = NT_STATUS_NET_WRITE_FAULT;
4893         }
4894
4895         return status;
4896 }
4897
4898 struct dcerpc_spoolss_EndPagePrinter_state {
4899         struct spoolss_EndPagePrinter orig;
4900         struct spoolss_EndPagePrinter tmp;
4901         TALLOC_CTX *out_mem_ctx;
4902 };
4903
4904 static void dcerpc_spoolss_EndPagePrinter_done(struct tevent_req *subreq);
4905
4906 struct tevent_req *dcerpc_spoolss_EndPagePrinter_send(TALLOC_CTX *mem_ctx,
4907                                                       struct tevent_context *ev,
4908                                                       struct dcerpc_binding_handle *h,
4909                                                       struct policy_handle *_handle /* [in] [ref] */)
4910 {
4911         struct tevent_req *req;
4912         struct dcerpc_spoolss_EndPagePrinter_state *state;
4913         struct tevent_req *subreq;
4914
4915         req = tevent_req_create(mem_ctx, &state,
4916                                 struct dcerpc_spoolss_EndPagePrinter_state);
4917         if (req == NULL) {
4918                 return NULL;
4919         }
4920         state->out_mem_ctx = NULL;
4921
4922         /* In parameters */
4923         state->orig.in.handle = _handle;
4924
4925         /* Out parameters */
4926
4927         /* Result */
4928         ZERO_STRUCT(state->orig.out.result);
4929
4930         /* make a temporary copy, that we pass to the dispatch function */
4931         state->tmp = state->orig;
4932
4933         subreq = dcerpc_spoolss_EndPagePrinter_r_send(state, ev, h, &state->tmp);
4934         if (tevent_req_nomem(subreq, req)) {
4935                 return tevent_req_post(req, ev);
4936         }
4937         tevent_req_set_callback(subreq, dcerpc_spoolss_EndPagePrinter_done, req);
4938         return req;
4939 }
4940
4941 static void dcerpc_spoolss_EndPagePrinter_done(struct tevent_req *subreq)
4942 {
4943         struct tevent_req *req = tevent_req_callback_data(
4944                 subreq, struct tevent_req);
4945         struct dcerpc_spoolss_EndPagePrinter_state *state = tevent_req_data(
4946                 req, struct dcerpc_spoolss_EndPagePrinter_state);
4947         NTSTATUS status;
4948         TALLOC_CTX *mem_ctx;
4949
4950         if (state->out_mem_ctx) {
4951                 mem_ctx = state->out_mem_ctx;
4952         } else {
4953                 mem_ctx = state;
4954         }
4955
4956         status = dcerpc_spoolss_EndPagePrinter_r_recv(subreq, mem_ctx);
4957         TALLOC_FREE(subreq);
4958         if (!NT_STATUS_IS_OK(status)) {
4959                 tevent_req_nterror(req, status);
4960                 return;
4961         }
4962
4963         /* Copy out parameters */
4964
4965         /* Copy result */
4966         state->orig.out.result = state->tmp.out.result;
4967
4968         /* Reset temporary structure */
4969         ZERO_STRUCT(state->tmp);
4970
4971         tevent_req_done(req);
4972 }
4973
4974 NTSTATUS dcerpc_spoolss_EndPagePrinter_recv(struct tevent_req *req,
4975                                             TALLOC_CTX *mem_ctx,
4976                                             WERROR *result)
4977 {
4978         struct dcerpc_spoolss_EndPagePrinter_state *state = tevent_req_data(
4979                 req, struct dcerpc_spoolss_EndPagePrinter_state);
4980         NTSTATUS status;
4981
4982         if (tevent_req_is_nterror(req, &status)) {
4983                 tevent_req_received(req);
4984                 return status;
4985         }
4986
4987         /* Steal possible out parameters to the callers context */
4988         talloc_steal(mem_ctx, state->out_mem_ctx);
4989
4990         /* Return result */
4991         *result = state->orig.out.result;
4992
4993         tevent_req_received(req);
4994         return NT_STATUS_OK;
4995 }
4996
4997 NTSTATUS dcerpc_spoolss_EndPagePrinter(struct dcerpc_binding_handle *h,
4998                                        TALLOC_CTX *mem_ctx,
4999                                        struct policy_handle *_handle /* [in] [ref] */,
5000                                        WERROR *result)
5001 {
5002         struct spoolss_EndPagePrinter r;
5003         NTSTATUS status;
5004
5005         /* In parameters */
5006         r.in.handle = _handle;
5007
5008         status = dcerpc_spoolss_EndPagePrinter_r(h, mem_ctx, &r);
5009         if (!NT_STATUS_IS_OK(status)) {
5010                 return status;
5011         }
5012
5013         /* Return variables */
5014
5015         /* Return result */
5016         *result = r.out.result;
5017
5018         return NT_STATUS_OK;
5019 }
5020
5021 struct dcerpc_spoolss_AbortPrinter_r_state {
5022         TALLOC_CTX *out_mem_ctx;
5023 };
5024
5025 static void dcerpc_spoolss_AbortPrinter_r_done(struct tevent_req *subreq);
5026
5027 struct tevent_req *dcerpc_spoolss_AbortPrinter_r_send(TALLOC_CTX *mem_ctx,
5028         struct tevent_context *ev,
5029         struct dcerpc_binding_handle *h,
5030         struct spoolss_AbortPrinter *r)
5031 {
5032         struct tevent_req *req;
5033         struct dcerpc_spoolss_AbortPrinter_r_state *state;
5034         struct tevent_req *subreq;
5035
5036         req = tevent_req_create(mem_ctx, &state,
5037                                 struct dcerpc_spoolss_AbortPrinter_r_state);
5038         if (req == NULL) {
5039                 return NULL;
5040         }
5041
5042         state->out_mem_ctx = NULL;
5043         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5044                         NULL, &ndr_table_spoolss,
5045                         NDR_SPOOLSS_ABORTPRINTER, state, r);
5046         if (tevent_req_nomem(subreq, req)) {
5047                 return tevent_req_post(req, ev);
5048         }
5049         tevent_req_set_callback(subreq, dcerpc_spoolss_AbortPrinter_r_done, req);
5050
5051         return req;
5052 }
5053
5054 static void dcerpc_spoolss_AbortPrinter_r_done(struct tevent_req *subreq)
5055 {
5056         struct tevent_req *req =
5057                 tevent_req_callback_data(subreq,
5058                 struct tevent_req);
5059         NTSTATUS status;
5060
5061         status = dcerpc_binding_handle_call_recv(subreq);
5062         if (!NT_STATUS_IS_OK(status)) {
5063                 tevent_req_nterror(req, status);
5064                 return;
5065         }
5066
5067         tevent_req_done(req);
5068 }
5069
5070 NTSTATUS dcerpc_spoolss_AbortPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5071 {
5072         struct dcerpc_spoolss_AbortPrinter_r_state *state =
5073                 tevent_req_data(req,
5074                 struct dcerpc_spoolss_AbortPrinter_r_state);
5075         NTSTATUS status;
5076
5077         if (tevent_req_is_nterror(req, &status)) {
5078                 tevent_req_received(req);
5079                 return status;
5080         }
5081
5082         talloc_steal(mem_ctx, state->out_mem_ctx);
5083
5084         tevent_req_received(req);
5085         return NT_STATUS_OK;
5086 }
5087
5088 NTSTATUS dcerpc_spoolss_AbortPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AbortPrinter *r)
5089 {
5090         NTSTATUS status;
5091
5092         status = dcerpc_binding_handle_call(h,
5093                         NULL, &ndr_table_spoolss,
5094                         NDR_SPOOLSS_ABORTPRINTER, mem_ctx, r);
5095
5096         return status;
5097 }
5098
5099 NTSTATUS dcerpc_spoolss_AbortPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AbortPrinter *r)
5100 {
5101         NTSTATUS status;
5102
5103         status = dcerpc_spoolss_AbortPrinter_r(p->binding_handle, mem_ctx, r);
5104
5105         if (NT_STATUS_IS_RPC(status)) {
5106                 status = NT_STATUS_NET_WRITE_FAULT;
5107         }
5108
5109         return status;
5110 }
5111
5112 struct dcerpc_spoolss_AbortPrinter_state {
5113         struct spoolss_AbortPrinter orig;
5114         struct spoolss_AbortPrinter tmp;
5115         TALLOC_CTX *out_mem_ctx;
5116 };
5117
5118 static void dcerpc_spoolss_AbortPrinter_done(struct tevent_req *subreq);
5119
5120 struct tevent_req *dcerpc_spoolss_AbortPrinter_send(TALLOC_CTX *mem_ctx,
5121                                                     struct tevent_context *ev,
5122                                                     struct dcerpc_binding_handle *h,
5123                                                     struct policy_handle *_handle /* [in] [ref] */)
5124 {
5125         struct tevent_req *req;
5126         struct dcerpc_spoolss_AbortPrinter_state *state;
5127         struct tevent_req *subreq;
5128
5129         req = tevent_req_create(mem_ctx, &state,
5130                                 struct dcerpc_spoolss_AbortPrinter_state);
5131         if (req == NULL) {
5132                 return NULL;
5133         }
5134         state->out_mem_ctx = NULL;
5135
5136         /* In parameters */
5137         state->orig.in.handle = _handle;
5138
5139         /* Out parameters */
5140
5141         /* Result */
5142         ZERO_STRUCT(state->orig.out.result);
5143
5144         /* make a temporary copy, that we pass to the dispatch function */
5145         state->tmp = state->orig;
5146
5147         subreq = dcerpc_spoolss_AbortPrinter_r_send(state, ev, h, &state->tmp);
5148         if (tevent_req_nomem(subreq, req)) {
5149                 return tevent_req_post(req, ev);
5150         }
5151         tevent_req_set_callback(subreq, dcerpc_spoolss_AbortPrinter_done, req);
5152         return req;
5153 }
5154
5155 static void dcerpc_spoolss_AbortPrinter_done(struct tevent_req *subreq)
5156 {
5157         struct tevent_req *req = tevent_req_callback_data(
5158                 subreq, struct tevent_req);
5159         struct dcerpc_spoolss_AbortPrinter_state *state = tevent_req_data(
5160                 req, struct dcerpc_spoolss_AbortPrinter_state);
5161         NTSTATUS status;
5162         TALLOC_CTX *mem_ctx;
5163
5164         if (state->out_mem_ctx) {
5165                 mem_ctx = state->out_mem_ctx;
5166         } else {
5167                 mem_ctx = state;
5168         }
5169
5170         status = dcerpc_spoolss_AbortPrinter_r_recv(subreq, mem_ctx);
5171         TALLOC_FREE(subreq);
5172         if (!NT_STATUS_IS_OK(status)) {
5173                 tevent_req_nterror(req, status);
5174                 return;
5175         }
5176
5177         /* Copy out parameters */
5178
5179         /* Copy result */
5180         state->orig.out.result = state->tmp.out.result;
5181
5182         /* Reset temporary structure */
5183         ZERO_STRUCT(state->tmp);
5184
5185         tevent_req_done(req);
5186 }
5187
5188 NTSTATUS dcerpc_spoolss_AbortPrinter_recv(struct tevent_req *req,
5189                                           TALLOC_CTX *mem_ctx,
5190                                           WERROR *result)
5191 {
5192         struct dcerpc_spoolss_AbortPrinter_state *state = tevent_req_data(
5193                 req, struct dcerpc_spoolss_AbortPrinter_state);
5194         NTSTATUS status;
5195
5196         if (tevent_req_is_nterror(req, &status)) {
5197                 tevent_req_received(req);
5198                 return status;
5199         }
5200
5201         /* Steal possible out parameters to the callers context */
5202         talloc_steal(mem_ctx, state->out_mem_ctx);
5203
5204         /* Return result */
5205         *result = state->orig.out.result;
5206
5207         tevent_req_received(req);
5208         return NT_STATUS_OK;
5209 }
5210
5211 NTSTATUS dcerpc_spoolss_AbortPrinter(struct dcerpc_binding_handle *h,
5212                                      TALLOC_CTX *mem_ctx,
5213                                      struct policy_handle *_handle /* [in] [ref] */,
5214                                      WERROR *result)
5215 {
5216         struct spoolss_AbortPrinter r;
5217         NTSTATUS status;
5218
5219         /* In parameters */
5220         r.in.handle = _handle;
5221
5222         status = dcerpc_spoolss_AbortPrinter_r(h, mem_ctx, &r);
5223         if (!NT_STATUS_IS_OK(status)) {
5224                 return status;
5225         }
5226
5227         /* Return variables */
5228
5229         /* Return result */
5230         *result = r.out.result;
5231
5232         return NT_STATUS_OK;
5233 }
5234
5235 struct dcerpc_spoolss_ReadPrinter_r_state {
5236         TALLOC_CTX *out_mem_ctx;
5237 };
5238
5239 static void dcerpc_spoolss_ReadPrinter_r_done(struct tevent_req *subreq);
5240
5241 struct tevent_req *dcerpc_spoolss_ReadPrinter_r_send(TALLOC_CTX *mem_ctx,
5242         struct tevent_context *ev,
5243         struct dcerpc_binding_handle *h,
5244         struct spoolss_ReadPrinter *r)
5245 {
5246         struct tevent_req *req;
5247         struct dcerpc_spoolss_ReadPrinter_r_state *state;
5248         struct tevent_req *subreq;
5249
5250         req = tevent_req_create(mem_ctx, &state,
5251                                 struct dcerpc_spoolss_ReadPrinter_r_state);
5252         if (req == NULL) {
5253                 return NULL;
5254         }
5255
5256         state->out_mem_ctx = talloc_new(state);
5257         if (tevent_req_nomem(state->out_mem_ctx, req)) {
5258                 return tevent_req_post(req, ev);
5259         }
5260
5261         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5262                         NULL, &ndr_table_spoolss,
5263                         NDR_SPOOLSS_READPRINTER, state->out_mem_ctx, r);
5264         if (tevent_req_nomem(subreq, req)) {
5265                 return tevent_req_post(req, ev);
5266         }
5267         tevent_req_set_callback(subreq, dcerpc_spoolss_ReadPrinter_r_done, req);
5268
5269         return req;
5270 }
5271
5272 static void dcerpc_spoolss_ReadPrinter_r_done(struct tevent_req *subreq)
5273 {
5274         struct tevent_req *req =
5275                 tevent_req_callback_data(subreq,
5276                 struct tevent_req);
5277         NTSTATUS status;
5278
5279         status = dcerpc_binding_handle_call_recv(subreq);
5280         if (!NT_STATUS_IS_OK(status)) {
5281                 tevent_req_nterror(req, status);
5282                 return;
5283         }
5284
5285         tevent_req_done(req);
5286 }
5287
5288 NTSTATUS dcerpc_spoolss_ReadPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5289 {
5290         struct dcerpc_spoolss_ReadPrinter_r_state *state =
5291                 tevent_req_data(req,
5292                 struct dcerpc_spoolss_ReadPrinter_r_state);
5293         NTSTATUS status;
5294
5295         if (tevent_req_is_nterror(req, &status)) {
5296                 tevent_req_received(req);
5297                 return status;
5298         }
5299
5300         talloc_steal(mem_ctx, state->out_mem_ctx);
5301
5302         tevent_req_received(req);
5303         return NT_STATUS_OK;
5304 }
5305
5306 NTSTATUS dcerpc_spoolss_ReadPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ReadPrinter *r)
5307 {
5308         NTSTATUS status;
5309
5310         status = dcerpc_binding_handle_call(h,
5311                         NULL, &ndr_table_spoolss,
5312                         NDR_SPOOLSS_READPRINTER, mem_ctx, r);
5313
5314         return status;
5315 }
5316
5317 NTSTATUS dcerpc_spoolss_ReadPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ReadPrinter *r)
5318 {
5319         NTSTATUS status;
5320
5321         status = dcerpc_spoolss_ReadPrinter_r(p->binding_handle, mem_ctx, r);
5322
5323         if (NT_STATUS_IS_RPC(status)) {
5324                 status = NT_STATUS_NET_WRITE_FAULT;
5325         }
5326
5327         return status;
5328 }
5329
5330 struct dcerpc_spoolss_ReadPrinter_state {
5331         struct spoolss_ReadPrinter orig;
5332         struct spoolss_ReadPrinter tmp;
5333         TALLOC_CTX *out_mem_ctx;
5334 };
5335
5336 static void dcerpc_spoolss_ReadPrinter_done(struct tevent_req *subreq);
5337
5338 struct tevent_req *dcerpc_spoolss_ReadPrinter_send(TALLOC_CTX *mem_ctx,
5339                                                    struct tevent_context *ev,
5340                                                    struct dcerpc_binding_handle *h,
5341                                                    struct policy_handle *_handle /* [in] [ref] */,
5342                                                    uint8_t *_data /* [out] [ref,size_is(data_size)] */,
5343                                                    uint32_t _data_size /* [in]  */,
5344                                                    uint32_t *__data_size /* [out] [ref] */)
5345 {
5346         struct tevent_req *req;
5347         struct dcerpc_spoolss_ReadPrinter_state *state;
5348         struct tevent_req *subreq;
5349
5350         req = tevent_req_create(mem_ctx, &state,
5351                                 struct dcerpc_spoolss_ReadPrinter_state);
5352         if (req == NULL) {
5353                 return NULL;
5354         }
5355         state->out_mem_ctx = NULL;
5356
5357         /* In parameters */
5358         state->orig.in.handle = _handle;
5359         state->orig.in.data_size = _data_size;
5360
5361         /* Out parameters */
5362         state->orig.out.data = _data;
5363         state->orig.out._data_size = __data_size;
5364
5365         /* Result */
5366         ZERO_STRUCT(state->orig.out.result);
5367
5368         state->out_mem_ctx = talloc_named_const(state, 0,
5369                              "dcerpc_spoolss_ReadPrinter_out_memory");
5370         if (tevent_req_nomem(state->out_mem_ctx, req)) {
5371                 return tevent_req_post(req, ev);
5372         }
5373
5374         /* make a temporary copy, that we pass to the dispatch function */
5375         state->tmp = state->orig;
5376
5377         subreq = dcerpc_spoolss_ReadPrinter_r_send(state, ev, h, &state->tmp);
5378         if (tevent_req_nomem(subreq, req)) {
5379                 return tevent_req_post(req, ev);
5380         }
5381         tevent_req_set_callback(subreq, dcerpc_spoolss_ReadPrinter_done, req);
5382         return req;
5383 }
5384
5385 static void dcerpc_spoolss_ReadPrinter_done(struct tevent_req *subreq)
5386 {
5387         struct tevent_req *req = tevent_req_callback_data(
5388                 subreq, struct tevent_req);
5389         struct dcerpc_spoolss_ReadPrinter_state *state = tevent_req_data(
5390                 req, struct dcerpc_spoolss_ReadPrinter_state);
5391         NTSTATUS status;
5392         TALLOC_CTX *mem_ctx;
5393
5394         if (state->out_mem_ctx) {
5395                 mem_ctx = state->out_mem_ctx;
5396         } else {
5397                 mem_ctx = state;
5398         }
5399
5400         status = dcerpc_spoolss_ReadPrinter_r_recv(subreq, mem_ctx);
5401         TALLOC_FREE(subreq);
5402         if (!NT_STATUS_IS_OK(status)) {
5403                 tevent_req_nterror(req, status);
5404                 return;
5405         }
5406
5407         /* Copy out parameters */
5408         {
5409                 size_t _copy_len_data;
5410                 _copy_len_data = state->tmp.in.data_size;
5411                 memcpy(state->orig.out.data, state->tmp.out.data, _copy_len_data * sizeof(*state->orig.out.data));
5412         }
5413         *state->orig.out._data_size = *state->tmp.out._data_size;
5414
5415         /* Copy result */
5416         state->orig.out.result = state->tmp.out.result;
5417
5418         /* Reset temporary structure */
5419         ZERO_STRUCT(state->tmp);
5420
5421         tevent_req_done(req);
5422 }
5423
5424 NTSTATUS dcerpc_spoolss_ReadPrinter_recv(struct tevent_req *req,
5425                                          TALLOC_CTX *mem_ctx,
5426                                          WERROR *result)
5427 {
5428         struct dcerpc_spoolss_ReadPrinter_state *state = tevent_req_data(
5429                 req, struct dcerpc_spoolss_ReadPrinter_state);
5430         NTSTATUS status;
5431
5432         if (tevent_req_is_nterror(req, &status)) {
5433                 tevent_req_received(req);
5434                 return status;
5435         }
5436
5437         /* Steal possible out parameters to the callers context */
5438         talloc_steal(mem_ctx, state->out_mem_ctx);
5439
5440         /* Return result */
5441         *result = state->orig.out.result;
5442
5443         tevent_req_received(req);
5444         return NT_STATUS_OK;
5445 }
5446
5447 NTSTATUS dcerpc_spoolss_ReadPrinter(struct dcerpc_binding_handle *h,
5448                                     TALLOC_CTX *mem_ctx,
5449                                     struct policy_handle *_handle /* [in] [ref] */,
5450                                     uint8_t *_data /* [out] [ref,size_is(data_size)] */,
5451                                     uint32_t _data_size /* [in]  */,
5452                                     uint32_t *__data_size /* [out] [ref] */,
5453                                     WERROR *result)
5454 {
5455         struct spoolss_ReadPrinter r;
5456         NTSTATUS status;
5457
5458         /* In parameters */
5459         r.in.handle = _handle;
5460         r.in.data_size = _data_size;
5461
5462         status = dcerpc_spoolss_ReadPrinter_r(h, mem_ctx, &r);
5463         if (!NT_STATUS_IS_OK(status)) {
5464                 return status;
5465         }
5466
5467         /* Return variables */
5468         {
5469                 size_t _copy_len_data;
5470                 _copy_len_data = r.in.data_size;
5471                 memcpy(_data, r.out.data, _copy_len_data * sizeof(*_data));
5472         }
5473         *__data_size = *r.out._data_size;
5474
5475         /* Return result */
5476         *result = r.out.result;
5477
5478         return NT_STATUS_OK;
5479 }
5480
5481 struct dcerpc_spoolss_EndDocPrinter_r_state {
5482         TALLOC_CTX *out_mem_ctx;
5483 };
5484
5485 static void dcerpc_spoolss_EndDocPrinter_r_done(struct tevent_req *subreq);
5486
5487 struct tevent_req *dcerpc_spoolss_EndDocPrinter_r_send(TALLOC_CTX *mem_ctx,
5488         struct tevent_context *ev,
5489         struct dcerpc_binding_handle *h,
5490         struct spoolss_EndDocPrinter *r)
5491 {
5492         struct tevent_req *req;
5493         struct dcerpc_spoolss_EndDocPrinter_r_state *state;
5494         struct tevent_req *subreq;
5495
5496         req = tevent_req_create(mem_ctx, &state,
5497                                 struct dcerpc_spoolss_EndDocPrinter_r_state);
5498         if (req == NULL) {
5499                 return NULL;
5500         }
5501
5502         state->out_mem_ctx = NULL;
5503         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5504                         NULL, &ndr_table_spoolss,
5505                         NDR_SPOOLSS_ENDDOCPRINTER, state, r);
5506         if (tevent_req_nomem(subreq, req)) {
5507                 return tevent_req_post(req, ev);
5508         }
5509         tevent_req_set_callback(subreq, dcerpc_spoolss_EndDocPrinter_r_done, req);
5510
5511         return req;
5512 }
5513
5514 static void dcerpc_spoolss_EndDocPrinter_r_done(struct tevent_req *subreq)
5515 {
5516         struct tevent_req *req =
5517                 tevent_req_callback_data(subreq,
5518                 struct tevent_req);
5519         NTSTATUS status;
5520
5521         status = dcerpc_binding_handle_call_recv(subreq);
5522         if (!NT_STATUS_IS_OK(status)) {
5523                 tevent_req_nterror(req, status);
5524                 return;
5525         }
5526
5527         tevent_req_done(req);
5528 }
5529
5530 NTSTATUS dcerpc_spoolss_EndDocPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5531 {
5532         struct dcerpc_spoolss_EndDocPrinter_r_state *state =
5533                 tevent_req_data(req,
5534                 struct dcerpc_spoolss_EndDocPrinter_r_state);
5535         NTSTATUS status;
5536
5537         if (tevent_req_is_nterror(req, &status)) {
5538                 tevent_req_received(req);
5539                 return status;
5540         }
5541
5542         talloc_steal(mem_ctx, state->out_mem_ctx);
5543
5544         tevent_req_received(req);
5545         return NT_STATUS_OK;
5546 }
5547
5548 NTSTATUS dcerpc_spoolss_EndDocPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EndDocPrinter *r)
5549 {
5550         NTSTATUS status;
5551
5552         status = dcerpc_binding_handle_call(h,
5553                         NULL, &ndr_table_spoolss,
5554                         NDR_SPOOLSS_ENDDOCPRINTER, mem_ctx, r);
5555
5556         return status;
5557 }
5558
5559 NTSTATUS dcerpc_spoolss_EndDocPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EndDocPrinter *r)
5560 {
5561         NTSTATUS status;
5562
5563         status = dcerpc_spoolss_EndDocPrinter_r(p->binding_handle, mem_ctx, r);
5564
5565         if (NT_STATUS_IS_RPC(status)) {
5566                 status = NT_STATUS_NET_WRITE_FAULT;
5567         }
5568
5569         return status;
5570 }
5571
5572 struct dcerpc_spoolss_EndDocPrinter_state {
5573         struct spoolss_EndDocPrinter orig;
5574         struct spoolss_EndDocPrinter tmp;
5575         TALLOC_CTX *out_mem_ctx;
5576 };
5577
5578 static void dcerpc_spoolss_EndDocPrinter_done(struct tevent_req *subreq);
5579
5580 struct tevent_req *dcerpc_spoolss_EndDocPrinter_send(TALLOC_CTX *mem_ctx,
5581                                                      struct tevent_context *ev,
5582                                                      struct dcerpc_binding_handle *h,
5583                                                      struct policy_handle *_handle /* [in] [ref] */)
5584 {
5585         struct tevent_req *req;
5586         struct dcerpc_spoolss_EndDocPrinter_state *state;
5587         struct tevent_req *subreq;
5588
5589         req = tevent_req_create(mem_ctx, &state,
5590                                 struct dcerpc_spoolss_EndDocPrinter_state);
5591         if (req == NULL) {
5592                 return NULL;
5593         }
5594         state->out_mem_ctx = NULL;
5595
5596         /* In parameters */
5597         state->orig.in.handle = _handle;
5598
5599         /* Out parameters */
5600
5601         /* Result */
5602         ZERO_STRUCT(state->orig.out.result);
5603
5604         /* make a temporary copy, that we pass to the dispatch function */
5605         state->tmp = state->orig;
5606
5607         subreq = dcerpc_spoolss_EndDocPrinter_r_send(state, ev, h, &state->tmp);
5608         if (tevent_req_nomem(subreq, req)) {
5609                 return tevent_req_post(req, ev);
5610         }
5611         tevent_req_set_callback(subreq, dcerpc_spoolss_EndDocPrinter_done, req);
5612         return req;
5613 }
5614
5615 static void dcerpc_spoolss_EndDocPrinter_done(struct tevent_req *subreq)
5616 {
5617         struct tevent_req *req = tevent_req_callback_data(
5618                 subreq, struct tevent_req);
5619         struct dcerpc_spoolss_EndDocPrinter_state *state = tevent_req_data(
5620                 req, struct dcerpc_spoolss_EndDocPrinter_state);
5621         NTSTATUS status;
5622         TALLOC_CTX *mem_ctx;
5623
5624         if (state->out_mem_ctx) {
5625                 mem_ctx = state->out_mem_ctx;
5626         } else {
5627                 mem_ctx = state;
5628         }
5629
5630         status = dcerpc_spoolss_EndDocPrinter_r_recv(subreq, mem_ctx);
5631         TALLOC_FREE(subreq);
5632         if (!NT_STATUS_IS_OK(status)) {
5633                 tevent_req_nterror(req, status);
5634                 return;
5635         }
5636
5637         /* Copy out parameters */
5638
5639         /* Copy result */
5640         state->orig.out.result = state->tmp.out.result;
5641
5642         /* Reset temporary structure */
5643         ZERO_STRUCT(state->tmp);
5644
5645         tevent_req_done(req);
5646 }
5647
5648 NTSTATUS dcerpc_spoolss_EndDocPrinter_recv(struct tevent_req *req,
5649                                            TALLOC_CTX *mem_ctx,
5650                                            WERROR *result)
5651 {
5652         struct dcerpc_spoolss_EndDocPrinter_state *state = tevent_req_data(
5653                 req, struct dcerpc_spoolss_EndDocPrinter_state);
5654         NTSTATUS status;
5655
5656         if (tevent_req_is_nterror(req, &status)) {
5657                 tevent_req_received(req);
5658                 return status;
5659         }
5660
5661         /* Steal possible out parameters to the callers context */
5662         talloc_steal(mem_ctx, state->out_mem_ctx);
5663
5664         /* Return result */
5665         *result = state->orig.out.result;
5666
5667         tevent_req_received(req);
5668         return NT_STATUS_OK;
5669 }
5670
5671 NTSTATUS dcerpc_spoolss_EndDocPrinter(struct dcerpc_binding_handle *h,
5672                                       TALLOC_CTX *mem_ctx,
5673                                       struct policy_handle *_handle /* [in] [ref] */,
5674                                       WERROR *result)
5675 {
5676         struct spoolss_EndDocPrinter r;
5677         NTSTATUS status;
5678
5679         /* In parameters */
5680         r.in.handle = _handle;
5681
5682         status = dcerpc_spoolss_EndDocPrinter_r(h, mem_ctx, &r);
5683         if (!NT_STATUS_IS_OK(status)) {
5684                 return status;
5685         }
5686
5687         /* Return variables */
5688
5689         /* Return result */
5690         *result = r.out.result;
5691
5692         return NT_STATUS_OK;
5693 }
5694
5695 struct dcerpc_spoolss_AddJob_r_state {
5696         TALLOC_CTX *out_mem_ctx;
5697 };
5698
5699 static void dcerpc_spoolss_AddJob_r_done(struct tevent_req *subreq);
5700
5701 struct tevent_req *dcerpc_spoolss_AddJob_r_send(TALLOC_CTX *mem_ctx,
5702         struct tevent_context *ev,
5703         struct dcerpc_binding_handle *h,
5704         struct spoolss_AddJob *r)
5705 {
5706         struct tevent_req *req;
5707         struct dcerpc_spoolss_AddJob_r_state *state;
5708         struct tevent_req *subreq;
5709
5710         req = tevent_req_create(mem_ctx, &state,
5711                                 struct dcerpc_spoolss_AddJob_r_state);
5712         if (req == NULL) {
5713                 return NULL;
5714         }
5715
5716         state->out_mem_ctx = talloc_new(state);
5717         if (tevent_req_nomem(state->out_mem_ctx, req)) {
5718                 return tevent_req_post(req, ev);
5719         }
5720
5721         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5722                         NULL, &ndr_table_spoolss,
5723                         NDR_SPOOLSS_ADDJOB, state->out_mem_ctx, r);
5724         if (tevent_req_nomem(subreq, req)) {
5725                 return tevent_req_post(req, ev);
5726         }
5727         tevent_req_set_callback(subreq, dcerpc_spoolss_AddJob_r_done, req);
5728
5729         return req;
5730 }
5731
5732 static void dcerpc_spoolss_AddJob_r_done(struct tevent_req *subreq)
5733 {
5734         struct tevent_req *req =
5735                 tevent_req_callback_data(subreq,
5736                 struct tevent_req);
5737         NTSTATUS status;
5738
5739         status = dcerpc_binding_handle_call_recv(subreq);
5740         if (!NT_STATUS_IS_OK(status)) {
5741                 tevent_req_nterror(req, status);
5742                 return;
5743         }
5744
5745         tevent_req_done(req);
5746 }
5747
5748 NTSTATUS dcerpc_spoolss_AddJob_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5749 {
5750         struct dcerpc_spoolss_AddJob_r_state *state =
5751                 tevent_req_data(req,
5752                 struct dcerpc_spoolss_AddJob_r_state);
5753         NTSTATUS status;
5754
5755         if (tevent_req_is_nterror(req, &status)) {
5756                 tevent_req_received(req);
5757                 return status;
5758         }
5759
5760         talloc_steal(mem_ctx, state->out_mem_ctx);
5761
5762         tevent_req_received(req);
5763         return NT_STATUS_OK;
5764 }
5765
5766 NTSTATUS dcerpc_spoolss_AddJob_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddJob *r)
5767 {
5768         NTSTATUS status;
5769
5770         status = dcerpc_binding_handle_call(h,
5771                         NULL, &ndr_table_spoolss,
5772                         NDR_SPOOLSS_ADDJOB, mem_ctx, r);
5773
5774         return status;
5775 }
5776
5777 NTSTATUS dcerpc_spoolss_AddJob_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddJob *r)
5778 {
5779         NTSTATUS status;
5780
5781         status = dcerpc_spoolss_AddJob_r(p->binding_handle, mem_ctx, r);
5782
5783         if (NT_STATUS_IS_RPC(status)) {
5784                 status = NT_STATUS_NET_WRITE_FAULT;
5785         }
5786
5787         return status;
5788 }
5789
5790 struct dcerpc_spoolss_AddJob_state {
5791         struct spoolss_AddJob orig;
5792         struct spoolss_AddJob tmp;
5793         TALLOC_CTX *out_mem_ctx;
5794 };
5795
5796 static void dcerpc_spoolss_AddJob_done(struct tevent_req *subreq);
5797
5798 struct tevent_req *dcerpc_spoolss_AddJob_send(TALLOC_CTX *mem_ctx,
5799                                               struct tevent_context *ev,
5800                                               struct dcerpc_binding_handle *h,
5801                                               struct policy_handle *_handle /* [in] [ref] */,
5802                                               uint32_t _level /* [in]  */,
5803                                               uint8_t *_buffer /* [in,out] [unique,size_is(offered)] */,
5804                                               uint32_t _offered /* [in]  */,
5805                                               uint32_t *_needed /* [out] [ref] */)
5806 {
5807         struct tevent_req *req;
5808         struct dcerpc_spoolss_AddJob_state *state;
5809         struct tevent_req *subreq;
5810
5811         req = tevent_req_create(mem_ctx, &state,
5812                                 struct dcerpc_spoolss_AddJob_state);
5813         if (req == NULL) {
5814                 return NULL;
5815         }
5816         state->out_mem_ctx = NULL;
5817
5818         /* In parameters */
5819         state->orig.in.handle = _handle;
5820         state->orig.in.level = _level;
5821         state->orig.in.buffer = _buffer;
5822         state->orig.in.offered = _offered;
5823
5824         /* Out parameters */
5825         state->orig.out.buffer = _buffer;
5826         state->orig.out.needed = _needed;
5827
5828         /* Result */
5829         ZERO_STRUCT(state->orig.out.result);
5830
5831         state->out_mem_ctx = talloc_named_const(state, 0,
5832                              "dcerpc_spoolss_AddJob_out_memory");
5833         if (tevent_req_nomem(state->out_mem_ctx, req)) {
5834                 return tevent_req_post(req, ev);
5835         }
5836
5837         /* make a temporary copy, that we pass to the dispatch function */
5838         state->tmp = state->orig;
5839
5840         subreq = dcerpc_spoolss_AddJob_r_send(state, ev, h, &state->tmp);
5841         if (tevent_req_nomem(subreq, req)) {
5842                 return tevent_req_post(req, ev);
5843         }
5844         tevent_req_set_callback(subreq, dcerpc_spoolss_AddJob_done, req);
5845         return req;
5846 }
5847
5848 static void dcerpc_spoolss_AddJob_done(struct tevent_req *subreq)
5849 {
5850         struct tevent_req *req = tevent_req_callback_data(
5851                 subreq, struct tevent_req);
5852         struct dcerpc_spoolss_AddJob_state *state = tevent_req_data(
5853                 req, struct dcerpc_spoolss_AddJob_state);
5854         NTSTATUS status;
5855         TALLOC_CTX *mem_ctx;
5856
5857         if (state->out_mem_ctx) {
5858                 mem_ctx = state->out_mem_ctx;
5859         } else {
5860                 mem_ctx = state;
5861         }
5862
5863         status = dcerpc_spoolss_AddJob_r_recv(subreq, mem_ctx);
5864         TALLOC_FREE(subreq);
5865         if (!NT_STATUS_IS_OK(status)) {
5866                 tevent_req_nterror(req, status);
5867                 return;
5868         }
5869
5870         /* Copy out parameters */
5871         if (state->orig.out.buffer && state->tmp.out.buffer) {
5872                 {
5873                         size_t _copy_len_buffer;
5874                         _copy_len_buffer = state->tmp.in.offered;
5875                         memcpy(state->orig.out.buffer, state->tmp.out.buffer, _copy_len_buffer * sizeof(*state->orig.out.buffer));
5876                 }
5877         }
5878         *state->orig.out.needed = *state->tmp.out.needed;
5879
5880         /* Copy result */
5881         state->orig.out.result = state->tmp.out.result;
5882
5883         /* Reset temporary structure */
5884         ZERO_STRUCT(state->tmp);
5885
5886         tevent_req_done(req);
5887 }
5888
5889 NTSTATUS dcerpc_spoolss_AddJob_recv(struct tevent_req *req,
5890                                     TALLOC_CTX *mem_ctx,
5891                                     WERROR *result)
5892 {
5893         struct dcerpc_spoolss_AddJob_state *state = tevent_req_data(
5894                 req, struct dcerpc_spoolss_AddJob_state);
5895         NTSTATUS status;
5896
5897         if (tevent_req_is_nterror(req, &status)) {
5898                 tevent_req_received(req);
5899                 return status;
5900         }
5901
5902         /* Steal possible out parameters to the callers context */
5903         talloc_steal(mem_ctx, state->out_mem_ctx);
5904
5905         /* Return result */
5906         *result = state->orig.out.result;
5907
5908         tevent_req_received(req);
5909         return NT_STATUS_OK;
5910 }
5911
5912 NTSTATUS dcerpc_spoolss_AddJob(struct dcerpc_binding_handle *h,
5913                                TALLOC_CTX *mem_ctx,
5914                                struct policy_handle *_handle /* [in] [ref] */,
5915                                uint32_t _level /* [in]  */,
5916                                uint8_t *_buffer /* [in,out] [unique,size_is(offered)] */,
5917                                uint32_t _offered /* [in]  */,
5918                                uint32_t *_needed /* [out] [ref] */,
5919                                WERROR *result)
5920 {
5921         struct spoolss_AddJob r;
5922         NTSTATUS status;
5923
5924         /* In parameters */
5925         r.in.handle = _handle;
5926         r.in.level = _level;
5927         r.in.buffer = _buffer;
5928         r.in.offered = _offered;
5929
5930         status = dcerpc_spoolss_AddJob_r(h, mem_ctx, &r);
5931         if (!NT_STATUS_IS_OK(status)) {
5932                 return status;
5933         }
5934
5935         /* Return variables */
5936         if (_buffer && r.out.buffer) {
5937                 {
5938                         size_t _copy_len_buffer;
5939                         _copy_len_buffer = r.in.offered;
5940                         memcpy(_buffer, r.out.buffer, _copy_len_buffer * sizeof(*_buffer));
5941                 }
5942         }
5943         *_needed = *r.out.needed;
5944
5945         /* Return result */
5946         *result = r.out.result;
5947
5948         return NT_STATUS_OK;
5949 }
5950
5951 struct dcerpc_spoolss_ScheduleJob_r_state {
5952         TALLOC_CTX *out_mem_ctx;
5953 };
5954
5955 static void dcerpc_spoolss_ScheduleJob_r_done(struct tevent_req *subreq);
5956
5957 struct tevent_req *dcerpc_spoolss_ScheduleJob_r_send(TALLOC_CTX *mem_ctx,
5958         struct tevent_context *ev,
5959         struct dcerpc_binding_handle *h,
5960         struct spoolss_ScheduleJob *r)
5961 {
5962         struct tevent_req *req;
5963         struct dcerpc_spoolss_ScheduleJob_r_state *state;
5964         struct tevent_req *subreq;
5965
5966         req = tevent_req_create(mem_ctx, &state,
5967                                 struct dcerpc_spoolss_ScheduleJob_r_state);
5968         if (req == NULL) {
5969                 return NULL;
5970         }
5971
5972         state->out_mem_ctx = NULL;
5973         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5974                         NULL, &ndr_table_spoolss,
5975                         NDR_SPOOLSS_SCHEDULEJOB, state, r);
5976         if (tevent_req_nomem(subreq, req)) {
5977                 return tevent_req_post(req, ev);
5978         }
5979         tevent_req_set_callback(subreq, dcerpc_spoolss_ScheduleJob_r_done, req);
5980
5981         return req;
5982 }
5983
5984 static void dcerpc_spoolss_ScheduleJob_r_done(struct tevent_req *subreq)
5985 {
5986         struct tevent_req *req =
5987                 tevent_req_callback_data(subreq,
5988                 struct tevent_req);
5989         NTSTATUS status;
5990
5991         status = dcerpc_binding_handle_call_recv(subreq);
5992         if (!NT_STATUS_IS_OK(status)) {
5993                 tevent_req_nterror(req, status);
5994                 return;
5995         }
5996
5997         tevent_req_done(req);
5998 }
5999
6000 NTSTATUS dcerpc_spoolss_ScheduleJob_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6001 {
6002         struct dcerpc_spoolss_ScheduleJob_r_state *state =
6003                 tevent_req_data(req,
6004                 struct dcerpc_spoolss_ScheduleJob_r_state);
6005         NTSTATUS status;
6006
6007         if (tevent_req_is_nterror(req, &status)) {
6008                 tevent_req_received(req);
6009                 return status;
6010         }
6011
6012         talloc_steal(mem_ctx, state->out_mem_ctx);
6013
6014         tevent_req_received(req);
6015         return NT_STATUS_OK;
6016 }
6017
6018 NTSTATUS dcerpc_spoolss_ScheduleJob_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ScheduleJob *r)
6019 {
6020         NTSTATUS status;
6021
6022         status = dcerpc_binding_handle_call(h,
6023                         NULL, &ndr_table_spoolss,
6024                         NDR_SPOOLSS_SCHEDULEJOB, mem_ctx, r);
6025
6026         return status;
6027 }
6028
6029 NTSTATUS dcerpc_spoolss_ScheduleJob_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ScheduleJob *r)
6030 {
6031         NTSTATUS status;
6032
6033         status = dcerpc_spoolss_ScheduleJob_r(p->binding_handle, mem_ctx, r);
6034
6035         if (NT_STATUS_IS_RPC(status)) {
6036                 status = NT_STATUS_NET_WRITE_FAULT;
6037         }
6038
6039         return status;
6040 }
6041
6042 struct dcerpc_spoolss_ScheduleJob_state {
6043         struct spoolss_ScheduleJob orig;
6044         struct spoolss_ScheduleJob tmp;
6045         TALLOC_CTX *out_mem_ctx;
6046 };
6047
6048 static void dcerpc_spoolss_ScheduleJob_done(struct tevent_req *subreq);
6049
6050 struct tevent_req *dcerpc_spoolss_ScheduleJob_send(TALLOC_CTX *mem_ctx,
6051                                                    struct tevent_context *ev,
6052                                                    struct dcerpc_binding_handle *h,
6053                                                    struct policy_handle *_handle /* [in] [ref] */,
6054                                                    uint32_t _jobid /* [in]  */)
6055 {
6056         struct tevent_req *req;
6057         struct dcerpc_spoolss_ScheduleJob_state *state;
6058         struct tevent_req *subreq;
6059
6060         req = tevent_req_create(mem_ctx, &state,
6061                                 struct dcerpc_spoolss_ScheduleJob_state);
6062         if (req == NULL) {
6063                 return NULL;
6064         }
6065         state->out_mem_ctx = NULL;
6066
6067         /* In parameters */
6068         state->orig.in.handle = _handle;
6069         state->orig.in.jobid = _jobid;
6070
6071         /* Out parameters */
6072
6073         /* Result */
6074         ZERO_STRUCT(state->orig.out.result);
6075
6076         /* make a temporary copy, that we pass to the dispatch function */
6077         state->tmp = state->orig;
6078
6079         subreq = dcerpc_spoolss_ScheduleJob_r_send(state, ev, h, &state->tmp);
6080         if (tevent_req_nomem(subreq, req)) {
6081                 return tevent_req_post(req, ev);
6082         }
6083         tevent_req_set_callback(subreq, dcerpc_spoolss_ScheduleJob_done, req);
6084         return req;
6085 }
6086
6087 static void dcerpc_spoolss_ScheduleJob_done(struct tevent_req *subreq)
6088 {
6089         struct tevent_req *req = tevent_req_callback_data(
6090                 subreq, struct tevent_req);
6091         struct dcerpc_spoolss_ScheduleJob_state *state = tevent_req_data(
6092                 req, struct dcerpc_spoolss_ScheduleJob_state);
6093         NTSTATUS status;
6094         TALLOC_CTX *mem_ctx;
6095
6096         if (state->out_mem_ctx) {
6097                 mem_ctx = state->out_mem_ctx;
6098         } else {
6099                 mem_ctx = state;
6100         }
6101
6102         status = dcerpc_spoolss_ScheduleJob_r_recv(subreq, mem_ctx);
6103         TALLOC_FREE(subreq);
6104         if (!NT_STATUS_IS_OK(status)) {
6105                 tevent_req_nterror(req, status);
6106                 return;
6107         }
6108
6109         /* Copy out parameters */
6110
6111         /* Copy result */
6112         state->orig.out.result = state->tmp.out.result;
6113
6114         /* Reset temporary structure */
6115         ZERO_STRUCT(state->tmp);
6116
6117         tevent_req_done(req);
6118 }
6119
6120 NTSTATUS dcerpc_spoolss_ScheduleJob_recv(struct tevent_req *req,
6121                                          TALLOC_CTX *mem_ctx,
6122                                          WERROR *result)
6123 {
6124         struct dcerpc_spoolss_ScheduleJob_state *state = tevent_req_data(
6125                 req, struct dcerpc_spoolss_ScheduleJob_state);
6126         NTSTATUS status;
6127
6128         if (tevent_req_is_nterror(req, &status)) {
6129                 tevent_req_received(req);
6130                 return status;
6131         }
6132
6133         /* Steal possible out parameters to the callers context */
6134         talloc_steal(mem_ctx, state->out_mem_ctx);
6135
6136         /* Return result */
6137         *result = state->orig.out.result;
6138
6139         tevent_req_received(req);
6140         return NT_STATUS_OK;
6141 }
6142
6143 NTSTATUS dcerpc_spoolss_ScheduleJob(struct dcerpc_binding_handle *h,
6144                                     TALLOC_CTX *mem_ctx,
6145                                     struct policy_handle *_handle /* [in] [ref] */,
6146                                     uint32_t _jobid /* [in]  */,
6147                                     WERROR *result)
6148 {
6149         struct spoolss_ScheduleJob r;
6150         NTSTATUS status;
6151
6152         /* In parameters */
6153         r.in.handle = _handle;
6154         r.in.jobid = _jobid;
6155
6156         status = dcerpc_spoolss_ScheduleJob_r(h, mem_ctx, &r);
6157         if (!NT_STATUS_IS_OK(status)) {
6158                 return status;
6159         }
6160
6161         /* Return variables */
6162
6163         /* Return result */
6164         *result = r.out.result;
6165
6166         return NT_STATUS_OK;
6167 }
6168
6169 struct dcerpc_spoolss_GetPrinterData_r_state {
6170         TALLOC_CTX *out_mem_ctx;
6171 };
6172
6173 static void dcerpc_spoolss_GetPrinterData_r_done(struct tevent_req *subreq);
6174
6175 struct tevent_req *dcerpc_spoolss_GetPrinterData_r_send(TALLOC_CTX *mem_ctx,
6176         struct tevent_context *ev,
6177         struct dcerpc_binding_handle *h,
6178         struct spoolss_GetPrinterData *r)
6179 {
6180         struct tevent_req *req;
6181         struct dcerpc_spoolss_GetPrinterData_r_state *state;
6182         struct tevent_req *subreq;
6183
6184         req = tevent_req_create(mem_ctx, &state,
6185                                 struct dcerpc_spoolss_GetPrinterData_r_state);
6186         if (req == NULL) {
6187                 return NULL;
6188         }
6189
6190         state->out_mem_ctx = talloc_new(state);
6191         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6192                 return tevent_req_post(req, ev);
6193         }
6194
6195         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6196                         NULL, &ndr_table_spoolss,
6197                         NDR_SPOOLSS_GETPRINTERDATA, state->out_mem_ctx, r);
6198         if (tevent_req_nomem(subreq, req)) {
6199                 return tevent_req_post(req, ev);
6200         }
6201         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterData_r_done, req);
6202
6203         return req;
6204 }
6205
6206 static void dcerpc_spoolss_GetPrinterData_r_done(struct tevent_req *subreq)
6207 {
6208         struct tevent_req *req =
6209                 tevent_req_callback_data(subreq,
6210                 struct tevent_req);
6211         NTSTATUS status;
6212
6213         status = dcerpc_binding_handle_call_recv(subreq);
6214         if (!NT_STATUS_IS_OK(status)) {
6215                 tevent_req_nterror(req, status);
6216                 return;
6217         }
6218
6219         tevent_req_done(req);
6220 }
6221
6222 NTSTATUS dcerpc_spoolss_GetPrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6223 {
6224         struct dcerpc_spoolss_GetPrinterData_r_state *state =
6225                 tevent_req_data(req,
6226                 struct dcerpc_spoolss_GetPrinterData_r_state);
6227         NTSTATUS status;
6228
6229         if (tevent_req_is_nterror(req, &status)) {
6230                 tevent_req_received(req);
6231                 return status;
6232         }
6233
6234         talloc_steal(mem_ctx, state->out_mem_ctx);
6235
6236         tevent_req_received(req);
6237         return NT_STATUS_OK;
6238 }
6239
6240 NTSTATUS dcerpc_spoolss_GetPrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterData *r)
6241 {
6242         NTSTATUS status;
6243
6244         status = dcerpc_binding_handle_call(h,
6245                         NULL, &ndr_table_spoolss,
6246                         NDR_SPOOLSS_GETPRINTERDATA, mem_ctx, r);
6247
6248         return status;
6249 }
6250
6251 NTSTATUS dcerpc_spoolss_GetPrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterData *r)
6252 {
6253         NTSTATUS status;
6254
6255         status = dcerpc_spoolss_GetPrinterData_r(p->binding_handle, mem_ctx, r);
6256
6257         if (NT_STATUS_IS_RPC(status)) {
6258                 status = NT_STATUS_NET_WRITE_FAULT;
6259         }
6260
6261         return status;
6262 }
6263
6264 struct dcerpc_spoolss_GetPrinterData_state {
6265         struct spoolss_GetPrinterData orig;
6266         struct spoolss_GetPrinterData tmp;
6267         TALLOC_CTX *out_mem_ctx;
6268 };
6269
6270 static void dcerpc_spoolss_GetPrinterData_done(struct tevent_req *subreq);
6271
6272 struct tevent_req *dcerpc_spoolss_GetPrinterData_send(TALLOC_CTX *mem_ctx,
6273                                                       struct tevent_context *ev,
6274                                                       struct dcerpc_binding_handle *h,
6275                                                       struct policy_handle *_handle /* [in] [ref] */,
6276                                                       const char *_value_name /* [in] [charset(UTF16)] */,
6277                                                       enum winreg_Type *_type /* [out] [ref] */,
6278                                                       uint8_t *_data /* [out] [ref,size_is(offered)] */,
6279                                                       uint32_t _offered /* [in]  */,
6280                                                       uint32_t *_needed /* [out] [ref] */)
6281 {
6282         struct tevent_req *req;
6283         struct dcerpc_spoolss_GetPrinterData_state *state;
6284         struct tevent_req *subreq;
6285
6286         req = tevent_req_create(mem_ctx, &state,
6287                                 struct dcerpc_spoolss_GetPrinterData_state);
6288         if (req == NULL) {
6289                 return NULL;
6290         }
6291         state->out_mem_ctx = NULL;
6292
6293         /* In parameters */
6294         state->orig.in.handle = _handle;
6295         state->orig.in.value_name = _value_name;
6296         state->orig.in.offered = _offered;
6297
6298         /* Out parameters */
6299         state->orig.out.type = _type;
6300         state->orig.out.data = _data;
6301         state->orig.out.needed = _needed;
6302
6303         /* Result */
6304         ZERO_STRUCT(state->orig.out.result);
6305
6306         state->out_mem_ctx = talloc_named_const(state, 0,
6307                              "dcerpc_spoolss_GetPrinterData_out_memory");
6308         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6309                 return tevent_req_post(req, ev);
6310         }
6311
6312         /* make a temporary copy, that we pass to the dispatch function */
6313         state->tmp = state->orig;
6314
6315         subreq = dcerpc_spoolss_GetPrinterData_r_send(state, ev, h, &state->tmp);
6316         if (tevent_req_nomem(subreq, req)) {
6317                 return tevent_req_post(req, ev);
6318         }
6319         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterData_done, req);
6320         return req;
6321 }
6322
6323 static void dcerpc_spoolss_GetPrinterData_done(struct tevent_req *subreq)
6324 {
6325         struct tevent_req *req = tevent_req_callback_data(
6326                 subreq, struct tevent_req);
6327         struct dcerpc_spoolss_GetPrinterData_state *state = tevent_req_data(
6328                 req, struct dcerpc_spoolss_GetPrinterData_state);
6329         NTSTATUS status;
6330         TALLOC_CTX *mem_ctx;
6331
6332         if (state->out_mem_ctx) {
6333                 mem_ctx = state->out_mem_ctx;
6334         } else {
6335                 mem_ctx = state;
6336         }
6337
6338         status = dcerpc_spoolss_GetPrinterData_r_recv(subreq, mem_ctx);
6339         TALLOC_FREE(subreq);
6340         if (!NT_STATUS_IS_OK(status)) {
6341                 tevent_req_nterror(req, status);
6342                 return;
6343         }
6344
6345         /* Copy out parameters */
6346         *state->orig.out.type = *state->tmp.out.type;
6347         {
6348                 size_t _copy_len_data;
6349                 _copy_len_data = state->tmp.in.offered;
6350                 memcpy(state->orig.out.data, state->tmp.out.data, _copy_len_data * sizeof(*state->orig.out.data));
6351         }
6352         *state->orig.out.needed = *state->tmp.out.needed;
6353
6354         /* Copy result */
6355         state->orig.out.result = state->tmp.out.result;
6356
6357         /* Reset temporary structure */
6358         ZERO_STRUCT(state->tmp);
6359
6360         tevent_req_done(req);
6361 }
6362
6363 NTSTATUS dcerpc_spoolss_GetPrinterData_recv(struct tevent_req *req,
6364                                             TALLOC_CTX *mem_ctx,
6365                                             WERROR *result)
6366 {
6367         struct dcerpc_spoolss_GetPrinterData_state *state = tevent_req_data(
6368                 req, struct dcerpc_spoolss_GetPrinterData_state);
6369         NTSTATUS status;
6370
6371         if (tevent_req_is_nterror(req, &status)) {
6372                 tevent_req_received(req);
6373                 return status;
6374         }
6375
6376         /* Steal possible out parameters to the callers context */
6377         talloc_steal(mem_ctx, state->out_mem_ctx);
6378
6379         /* Return result */
6380         *result = state->orig.out.result;
6381
6382         tevent_req_received(req);
6383         return NT_STATUS_OK;
6384 }
6385
6386 NTSTATUS dcerpc_spoolss_GetPrinterData(struct dcerpc_binding_handle *h,
6387                                        TALLOC_CTX *mem_ctx,
6388                                        struct policy_handle *_handle /* [in] [ref] */,
6389                                        const char *_value_name /* [in] [charset(UTF16)] */,
6390                                        enum winreg_Type *_type /* [out] [ref] */,
6391                                        uint8_t *_data /* [out] [ref,size_is(offered)] */,
6392                                        uint32_t _offered /* [in]  */,
6393                                        uint32_t *_needed /* [out] [ref] */,
6394                                        WERROR *result)
6395 {
6396         struct spoolss_GetPrinterData r;
6397         NTSTATUS status;
6398
6399         /* In parameters */
6400         r.in.handle = _handle;
6401         r.in.value_name = _value_name;
6402         r.in.offered = _offered;
6403
6404         status = dcerpc_spoolss_GetPrinterData_r(h, mem_ctx, &r);
6405         if (!NT_STATUS_IS_OK(status)) {
6406                 return status;
6407         }
6408
6409         /* Return variables */
6410         *_type = *r.out.type;
6411         {
6412                 size_t _copy_len_data;
6413                 _copy_len_data = r.in.offered;
6414                 memcpy(_data, r.out.data, _copy_len_data * sizeof(*_data));
6415         }
6416         *_needed = *r.out.needed;
6417
6418         /* Return result */
6419         *result = r.out.result;
6420
6421         return NT_STATUS_OK;
6422 }
6423
6424 struct dcerpc_spoolss_SetPrinterData_r_state {
6425         TALLOC_CTX *out_mem_ctx;
6426 };
6427
6428 static void dcerpc_spoolss_SetPrinterData_r_done(struct tevent_req *subreq);
6429
6430 struct tevent_req *dcerpc_spoolss_SetPrinterData_r_send(TALLOC_CTX *mem_ctx,
6431         struct tevent_context *ev,
6432         struct dcerpc_binding_handle *h,
6433         struct spoolss_SetPrinterData *r)
6434 {
6435         struct tevent_req *req;
6436         struct dcerpc_spoolss_SetPrinterData_r_state *state;
6437         struct tevent_req *subreq;
6438
6439         req = tevent_req_create(mem_ctx, &state,
6440                                 struct dcerpc_spoolss_SetPrinterData_r_state);
6441         if (req == NULL) {
6442                 return NULL;
6443         }
6444
6445         state->out_mem_ctx = NULL;
6446         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6447                         NULL, &ndr_table_spoolss,
6448                         NDR_SPOOLSS_SETPRINTERDATA, state, r);
6449         if (tevent_req_nomem(subreq, req)) {
6450                 return tevent_req_post(req, ev);
6451         }
6452         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterData_r_done, req);
6453
6454         return req;
6455 }
6456
6457 static void dcerpc_spoolss_SetPrinterData_r_done(struct tevent_req *subreq)
6458 {
6459         struct tevent_req *req =
6460                 tevent_req_callback_data(subreq,
6461                 struct tevent_req);
6462         NTSTATUS status;
6463
6464         status = dcerpc_binding_handle_call_recv(subreq);
6465         if (!NT_STATUS_IS_OK(status)) {
6466                 tevent_req_nterror(req, status);
6467                 return;
6468         }
6469
6470         tevent_req_done(req);
6471 }
6472
6473 NTSTATUS dcerpc_spoolss_SetPrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6474 {
6475         struct dcerpc_spoolss_SetPrinterData_r_state *state =
6476                 tevent_req_data(req,
6477                 struct dcerpc_spoolss_SetPrinterData_r_state);
6478         NTSTATUS status;
6479
6480         if (tevent_req_is_nterror(req, &status)) {
6481                 tevent_req_received(req);
6482                 return status;
6483         }
6484
6485         talloc_steal(mem_ctx, state->out_mem_ctx);
6486
6487         tevent_req_received(req);
6488         return NT_STATUS_OK;
6489 }
6490
6491 NTSTATUS dcerpc_spoolss_SetPrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterData *r)
6492 {
6493         NTSTATUS status;
6494
6495         status = dcerpc_binding_handle_call(h,
6496                         NULL, &ndr_table_spoolss,
6497                         NDR_SPOOLSS_SETPRINTERDATA, mem_ctx, r);
6498
6499         return status;
6500 }
6501
6502 NTSTATUS dcerpc_spoolss_SetPrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterData *r)
6503 {
6504         NTSTATUS status;
6505
6506         status = dcerpc_spoolss_SetPrinterData_r(p->binding_handle, mem_ctx, r);
6507
6508         if (NT_STATUS_IS_RPC(status)) {
6509                 status = NT_STATUS_NET_WRITE_FAULT;
6510         }
6511
6512         return status;
6513 }
6514
6515 struct dcerpc_spoolss_SetPrinterData_state {
6516         struct spoolss_SetPrinterData orig;
6517         struct spoolss_SetPrinterData tmp;
6518         TALLOC_CTX *out_mem_ctx;
6519 };
6520
6521 static void dcerpc_spoolss_SetPrinterData_done(struct tevent_req *subreq);
6522
6523 struct tevent_req *dcerpc_spoolss_SetPrinterData_send(TALLOC_CTX *mem_ctx,
6524                                                       struct tevent_context *ev,
6525                                                       struct dcerpc_binding_handle *h,
6526                                                       struct policy_handle *_handle /* [in] [ref] */,
6527                                                       const char *_value_name /* [in] [charset(UTF16)] */,
6528                                                       enum winreg_Type _type /* [in]  */,
6529                                                       uint8_t *_data /* [in] [ref,size_is(offered)] */,
6530                                                       uint32_t _offered /* [in]  */)
6531 {
6532         struct tevent_req *req;
6533         struct dcerpc_spoolss_SetPrinterData_state *state;
6534         struct tevent_req *subreq;
6535
6536         req = tevent_req_create(mem_ctx, &state,
6537                                 struct dcerpc_spoolss_SetPrinterData_state);
6538         if (req == NULL) {
6539                 return NULL;
6540         }
6541         state->out_mem_ctx = NULL;
6542
6543         /* In parameters */
6544         state->orig.in.handle = _handle;
6545         state->orig.in.value_name = _value_name;
6546         state->orig.in.type = _type;
6547         state->orig.in.data = _data;
6548         state->orig.in.offered = _offered;
6549
6550         /* Out parameters */
6551
6552         /* Result */
6553         ZERO_STRUCT(state->orig.out.result);
6554
6555         /* make a temporary copy, that we pass to the dispatch function */
6556         state->tmp = state->orig;
6557
6558         subreq = dcerpc_spoolss_SetPrinterData_r_send(state, ev, h, &state->tmp);
6559         if (tevent_req_nomem(subreq, req)) {
6560                 return tevent_req_post(req, ev);
6561         }
6562         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterData_done, req);
6563         return req;
6564 }
6565
6566 static void dcerpc_spoolss_SetPrinterData_done(struct tevent_req *subreq)
6567 {
6568         struct tevent_req *req = tevent_req_callback_data(
6569                 subreq, struct tevent_req);
6570         struct dcerpc_spoolss_SetPrinterData_state *state = tevent_req_data(
6571                 req, struct dcerpc_spoolss_SetPrinterData_state);
6572         NTSTATUS status;
6573         TALLOC_CTX *mem_ctx;
6574
6575         if (state->out_mem_ctx) {
6576                 mem_ctx = state->out_mem_ctx;
6577         } else {
6578                 mem_ctx = state;
6579         }
6580
6581         status = dcerpc_spoolss_SetPrinterData_r_recv(subreq, mem_ctx);
6582         TALLOC_FREE(subreq);
6583         if (!NT_STATUS_IS_OK(status)) {
6584                 tevent_req_nterror(req, status);
6585                 return;
6586         }
6587
6588         /* Copy out parameters */
6589
6590         /* Copy result */
6591         state->orig.out.result = state->tmp.out.result;
6592
6593         /* Reset temporary structure */
6594         ZERO_STRUCT(state->tmp);
6595
6596         tevent_req_done(req);
6597 }
6598
6599 NTSTATUS dcerpc_spoolss_SetPrinterData_recv(struct tevent_req *req,
6600                                             TALLOC_CTX *mem_ctx,
6601                                             WERROR *result)
6602 {
6603         struct dcerpc_spoolss_SetPrinterData_state *state = tevent_req_data(
6604                 req, struct dcerpc_spoolss_SetPrinterData_state);
6605         NTSTATUS status;
6606
6607         if (tevent_req_is_nterror(req, &status)) {
6608                 tevent_req_received(req);
6609                 return status;
6610         }
6611
6612         /* Steal possible out parameters to the callers context */
6613         talloc_steal(mem_ctx, state->out_mem_ctx);
6614
6615         /* Return result */
6616         *result = state->orig.out.result;
6617
6618         tevent_req_received(req);
6619         return NT_STATUS_OK;
6620 }
6621
6622 NTSTATUS dcerpc_spoolss_SetPrinterData(struct dcerpc_binding_handle *h,
6623                                        TALLOC_CTX *mem_ctx,
6624                                        struct policy_handle *_handle /* [in] [ref] */,
6625                                        const char *_value_name /* [in] [charset(UTF16)] */,
6626                                        enum winreg_Type _type /* [in]  */,
6627                                        uint8_t *_data /* [in] [ref,size_is(offered)] */,
6628                                        uint32_t _offered /* [in]  */,
6629                                        WERROR *result)
6630 {
6631         struct spoolss_SetPrinterData r;
6632         NTSTATUS status;
6633
6634         /* In parameters */
6635         r.in.handle = _handle;
6636         r.in.value_name = _value_name;
6637         r.in.type = _type;
6638         r.in.data = _data;
6639         r.in.offered = _offered;
6640
6641         status = dcerpc_spoolss_SetPrinterData_r(h, mem_ctx, &r);
6642         if (!NT_STATUS_IS_OK(status)) {
6643                 return status;
6644         }
6645
6646         /* Return variables */
6647
6648         /* Return result */
6649         *result = r.out.result;
6650
6651         return NT_STATUS_OK;
6652 }
6653
6654 struct dcerpc_spoolss_ClosePrinter_r_state {
6655         TALLOC_CTX *out_mem_ctx;
6656 };
6657
6658 static void dcerpc_spoolss_ClosePrinter_r_done(struct tevent_req *subreq);
6659
6660 struct tevent_req *dcerpc_spoolss_ClosePrinter_r_send(TALLOC_CTX *mem_ctx,
6661         struct tevent_context *ev,
6662         struct dcerpc_binding_handle *h,
6663         struct spoolss_ClosePrinter *r)
6664 {
6665         struct tevent_req *req;
6666         struct dcerpc_spoolss_ClosePrinter_r_state *state;
6667         struct tevent_req *subreq;
6668
6669         req = tevent_req_create(mem_ctx, &state,
6670                                 struct dcerpc_spoolss_ClosePrinter_r_state);
6671         if (req == NULL) {
6672                 return NULL;
6673         }
6674
6675         state->out_mem_ctx = talloc_new(state);
6676         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6677                 return tevent_req_post(req, ev);
6678         }
6679
6680         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6681                         NULL, &ndr_table_spoolss,
6682                         NDR_SPOOLSS_CLOSEPRINTER, state->out_mem_ctx, r);
6683         if (tevent_req_nomem(subreq, req)) {
6684                 return tevent_req_post(req, ev);
6685         }
6686         tevent_req_set_callback(subreq, dcerpc_spoolss_ClosePrinter_r_done, req);
6687
6688         return req;
6689 }
6690
6691 static void dcerpc_spoolss_ClosePrinter_r_done(struct tevent_req *subreq)
6692 {
6693         struct tevent_req *req =
6694                 tevent_req_callback_data(subreq,
6695                 struct tevent_req);
6696         NTSTATUS status;
6697
6698         status = dcerpc_binding_handle_call_recv(subreq);
6699         if (!NT_STATUS_IS_OK(status)) {
6700                 tevent_req_nterror(req, status);
6701                 return;
6702         }
6703
6704         tevent_req_done(req);
6705 }
6706
6707 NTSTATUS dcerpc_spoolss_ClosePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6708 {
6709         struct dcerpc_spoolss_ClosePrinter_r_state *state =
6710                 tevent_req_data(req,
6711                 struct dcerpc_spoolss_ClosePrinter_r_state);
6712         NTSTATUS status;
6713
6714         if (tevent_req_is_nterror(req, &status)) {
6715                 tevent_req_received(req);
6716                 return status;
6717         }
6718
6719         talloc_steal(mem_ctx, state->out_mem_ctx);
6720
6721         tevent_req_received(req);
6722         return NT_STATUS_OK;
6723 }
6724
6725 NTSTATUS dcerpc_spoolss_ClosePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ClosePrinter *r)
6726 {
6727         NTSTATUS status;
6728
6729         status = dcerpc_binding_handle_call(h,
6730                         NULL, &ndr_table_spoolss,
6731                         NDR_SPOOLSS_CLOSEPRINTER, mem_ctx, r);
6732
6733         return status;
6734 }
6735
6736 NTSTATUS dcerpc_spoolss_ClosePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ClosePrinter *r)
6737 {
6738         NTSTATUS status;
6739
6740         status = dcerpc_spoolss_ClosePrinter_r(p->binding_handle, mem_ctx, r);
6741
6742         if (NT_STATUS_IS_RPC(status)) {
6743                 status = NT_STATUS_NET_WRITE_FAULT;
6744         }
6745
6746         return status;
6747 }
6748
6749 struct dcerpc_spoolss_ClosePrinter_state {
6750         struct spoolss_ClosePrinter orig;
6751         struct spoolss_ClosePrinter tmp;
6752         TALLOC_CTX *out_mem_ctx;
6753 };
6754
6755 static void dcerpc_spoolss_ClosePrinter_done(struct tevent_req *subreq);
6756
6757 struct tevent_req *dcerpc_spoolss_ClosePrinter_send(TALLOC_CTX *mem_ctx,
6758                                                     struct tevent_context *ev,
6759                                                     struct dcerpc_binding_handle *h,
6760                                                     struct policy_handle *_handle /* [in,out] [ref] */)
6761 {
6762         struct tevent_req *req;
6763         struct dcerpc_spoolss_ClosePrinter_state *state;
6764         struct tevent_req *subreq;
6765
6766         req = tevent_req_create(mem_ctx, &state,
6767                                 struct dcerpc_spoolss_ClosePrinter_state);
6768         if (req == NULL) {
6769                 return NULL;
6770         }
6771         state->out_mem_ctx = NULL;
6772
6773         /* In parameters */
6774         state->orig.in.handle = _handle;
6775
6776         /* Out parameters */
6777         state->orig.out.handle = _handle;
6778
6779         /* Result */
6780         ZERO_STRUCT(state->orig.out.result);
6781
6782         state->out_mem_ctx = talloc_named_const(state, 0,
6783                              "dcerpc_spoolss_ClosePrinter_out_memory");
6784         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6785                 return tevent_req_post(req, ev);
6786         }
6787
6788         /* make a temporary copy, that we pass to the dispatch function */
6789         state->tmp = state->orig;
6790
6791         subreq = dcerpc_spoolss_ClosePrinter_r_send(state, ev, h, &state->tmp);
6792         if (tevent_req_nomem(subreq, req)) {
6793                 return tevent_req_post(req, ev);
6794         }
6795         tevent_req_set_callback(subreq, dcerpc_spoolss_ClosePrinter_done, req);
6796         return req;
6797 }
6798
6799 static void dcerpc_spoolss_ClosePrinter_done(struct tevent_req *subreq)
6800 {
6801         struct tevent_req *req = tevent_req_callback_data(
6802                 subreq, struct tevent_req);
6803         struct dcerpc_spoolss_ClosePrinter_state *state = tevent_req_data(
6804                 req, struct dcerpc_spoolss_ClosePrinter_state);
6805         NTSTATUS status;
6806         TALLOC_CTX *mem_ctx;
6807
6808         if (state->out_mem_ctx) {
6809                 mem_ctx = state->out_mem_ctx;
6810         } else {
6811                 mem_ctx = state;
6812         }
6813
6814         status = dcerpc_spoolss_ClosePrinter_r_recv(subreq, mem_ctx);
6815         TALLOC_FREE(subreq);
6816         if (!NT_STATUS_IS_OK(status)) {
6817                 tevent_req_nterror(req, status);
6818                 return;
6819         }
6820
6821         /* Copy out parameters */
6822         *state->orig.out.handle = *state->tmp.out.handle;
6823
6824         /* Copy result */
6825         state->orig.out.result = state->tmp.out.result;
6826
6827         /* Reset temporary structure */
6828         ZERO_STRUCT(state->tmp);
6829
6830         tevent_req_done(req);
6831 }
6832
6833 NTSTATUS dcerpc_spoolss_ClosePrinter_recv(struct tevent_req *req,
6834                                           TALLOC_CTX *mem_ctx,
6835                                           WERROR *result)
6836 {
6837         struct dcerpc_spoolss_ClosePrinter_state *state = tevent_req_data(
6838                 req, struct dcerpc_spoolss_ClosePrinter_state);
6839         NTSTATUS status;
6840
6841         if (tevent_req_is_nterror(req, &status)) {
6842                 tevent_req_received(req);
6843                 return status;
6844         }
6845
6846         /* Steal possible out parameters to the callers context */
6847         talloc_steal(mem_ctx, state->out_mem_ctx);
6848
6849         /* Return result */
6850         *result = state->orig.out.result;
6851
6852         tevent_req_received(req);
6853         return NT_STATUS_OK;
6854 }
6855
6856 NTSTATUS dcerpc_spoolss_ClosePrinter(struct dcerpc_binding_handle *h,
6857                                      TALLOC_CTX *mem_ctx,
6858                                      struct policy_handle *_handle /* [in,out] [ref] */,
6859                                      WERROR *result)
6860 {
6861         struct spoolss_ClosePrinter r;
6862         NTSTATUS status;
6863
6864         /* In parameters */
6865         r.in.handle = _handle;
6866
6867         status = dcerpc_spoolss_ClosePrinter_r(h, mem_ctx, &r);
6868         if (!NT_STATUS_IS_OK(status)) {
6869                 return status;
6870         }
6871
6872         /* Return variables */
6873         *_handle = *r.out.handle;
6874
6875         /* Return result */
6876         *result = r.out.result;
6877
6878         return NT_STATUS_OK;
6879 }
6880
6881 struct dcerpc_spoolss_AddForm_r_state {
6882         TALLOC_CTX *out_mem_ctx;
6883 };
6884
6885 static void dcerpc_spoolss_AddForm_r_done(struct tevent_req *subreq);
6886
6887 struct tevent_req *dcerpc_spoolss_AddForm_r_send(TALLOC_CTX *mem_ctx,
6888         struct tevent_context *ev,
6889         struct dcerpc_binding_handle *h,
6890         struct spoolss_AddForm *r)
6891 {
6892         struct tevent_req *req;
6893         struct dcerpc_spoolss_AddForm_r_state *state;
6894         struct tevent_req *subreq;
6895
6896         req = tevent_req_create(mem_ctx, &state,
6897                                 struct dcerpc_spoolss_AddForm_r_state);
6898         if (req == NULL) {
6899                 return NULL;
6900         }
6901
6902         state->out_mem_ctx = NULL;
6903         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6904                         NULL, &ndr_table_spoolss,
6905                         NDR_SPOOLSS_ADDFORM, state, r);
6906         if (tevent_req_nomem(subreq, req)) {
6907                 return tevent_req_post(req, ev);
6908         }
6909         tevent_req_set_callback(subreq, dcerpc_spoolss_AddForm_r_done, req);
6910
6911         return req;
6912 }
6913
6914 static void dcerpc_spoolss_AddForm_r_done(struct tevent_req *subreq)
6915 {
6916         struct tevent_req *req =
6917                 tevent_req_callback_data(subreq,
6918                 struct tevent_req);
6919         NTSTATUS status;
6920
6921         status = dcerpc_binding_handle_call_recv(subreq);
6922         if (!NT_STATUS_IS_OK(status)) {
6923                 tevent_req_nterror(req, status);
6924                 return;
6925         }
6926
6927         tevent_req_done(req);
6928 }
6929
6930 NTSTATUS dcerpc_spoolss_AddForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6931 {
6932         struct dcerpc_spoolss_AddForm_r_state *state =
6933                 tevent_req_data(req,
6934                 struct dcerpc_spoolss_AddForm_r_state);
6935         NTSTATUS status;
6936
6937         if (tevent_req_is_nterror(req, &status)) {
6938                 tevent_req_received(req);
6939                 return status;
6940         }
6941
6942         talloc_steal(mem_ctx, state->out_mem_ctx);
6943
6944         tevent_req_received(req);
6945         return NT_STATUS_OK;
6946 }
6947
6948 NTSTATUS dcerpc_spoolss_AddForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddForm *r)
6949 {
6950         NTSTATUS status;
6951
6952         status = dcerpc_binding_handle_call(h,
6953                         NULL, &ndr_table_spoolss,
6954                         NDR_SPOOLSS_ADDFORM, mem_ctx, r);
6955
6956         return status;
6957 }
6958
6959 NTSTATUS dcerpc_spoolss_AddForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddForm *r)
6960 {
6961         NTSTATUS status;
6962
6963         status = dcerpc_spoolss_AddForm_r(p->binding_handle, mem_ctx, r);
6964
6965         if (NT_STATUS_IS_RPC(status)) {
6966                 status = NT_STATUS_NET_WRITE_FAULT;
6967         }
6968
6969         return status;
6970 }
6971
6972 struct dcerpc_spoolss_AddForm_state {
6973         struct spoolss_AddForm orig;
6974         struct spoolss_AddForm tmp;
6975         TALLOC_CTX *out_mem_ctx;
6976 };
6977
6978 static void dcerpc_spoolss_AddForm_done(struct tevent_req *subreq);
6979
6980 struct tevent_req *dcerpc_spoolss_AddForm_send(TALLOC_CTX *mem_ctx,
6981                                                struct tevent_context *ev,
6982                                                struct dcerpc_binding_handle *h,
6983                                                struct policy_handle *_handle /* [in] [ref] */,
6984                                                uint32_t _level /* [in]  */,
6985                                                union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */)
6986 {
6987         struct tevent_req *req;
6988         struct dcerpc_spoolss_AddForm_state *state;
6989         struct tevent_req *subreq;
6990
6991         req = tevent_req_create(mem_ctx, &state,
6992                                 struct dcerpc_spoolss_AddForm_state);
6993         if (req == NULL) {
6994                 return NULL;
6995         }
6996         state->out_mem_ctx = NULL;
6997
6998         /* In parameters */
6999         state->orig.in.handle = _handle;
7000         state->orig.in.level = _level;
7001         state->orig.in.info = _info;
7002
7003         /* Out parameters */
7004
7005         /* Result */
7006         ZERO_STRUCT(state->orig.out.result);
7007
7008         /* make a temporary copy, that we pass to the dispatch function */
7009         state->tmp = state->orig;
7010
7011         subreq = dcerpc_spoolss_AddForm_r_send(state, ev, h, &state->tmp);
7012         if (tevent_req_nomem(subreq, req)) {
7013                 return tevent_req_post(req, ev);
7014         }
7015         tevent_req_set_callback(subreq, dcerpc_spoolss_AddForm_done, req);
7016         return req;
7017 }
7018
7019 static void dcerpc_spoolss_AddForm_done(struct tevent_req *subreq)
7020 {
7021         struct tevent_req *req = tevent_req_callback_data(
7022                 subreq, struct tevent_req);
7023         struct dcerpc_spoolss_AddForm_state *state = tevent_req_data(
7024                 req, struct dcerpc_spoolss_AddForm_state);
7025         NTSTATUS status;
7026         TALLOC_CTX *mem_ctx;
7027
7028         if (state->out_mem_ctx) {
7029                 mem_ctx = state->out_mem_ctx;
7030         } else {
7031                 mem_ctx = state;
7032         }
7033
7034         status = dcerpc_spoolss_AddForm_r_recv(subreq, mem_ctx);
7035         TALLOC_FREE(subreq);
7036         if (!NT_STATUS_IS_OK(status)) {
7037                 tevent_req_nterror(req, status);
7038                 return;
7039         }
7040
7041         /* Copy out parameters */
7042
7043         /* Copy result */
7044         state->orig.out.result = state->tmp.out.result;
7045
7046         /* Reset temporary structure */
7047         ZERO_STRUCT(state->tmp);
7048
7049         tevent_req_done(req);
7050 }
7051
7052 NTSTATUS dcerpc_spoolss_AddForm_recv(struct tevent_req *req,
7053                                      TALLOC_CTX *mem_ctx,
7054                                      WERROR *result)
7055 {
7056         struct dcerpc_spoolss_AddForm_state *state = tevent_req_data(
7057                 req, struct dcerpc_spoolss_AddForm_state);
7058         NTSTATUS status;
7059
7060         if (tevent_req_is_nterror(req, &status)) {
7061                 tevent_req_received(req);
7062                 return status;
7063         }
7064
7065         /* Steal possible out parameters to the callers context */
7066         talloc_steal(mem_ctx, state->out_mem_ctx);
7067
7068         /* Return result */
7069         *result = state->orig.out.result;
7070
7071         tevent_req_received(req);
7072         return NT_STATUS_OK;
7073 }
7074
7075 NTSTATUS dcerpc_spoolss_AddForm(struct dcerpc_binding_handle *h,
7076                                 TALLOC_CTX *mem_ctx,
7077                                 struct policy_handle *_handle /* [in] [ref] */,
7078                                 uint32_t _level /* [in]  */,
7079                                 union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */,
7080                                 WERROR *result)
7081 {
7082         struct spoolss_AddForm r;
7083         NTSTATUS status;
7084
7085         /* In parameters */
7086         r.in.handle = _handle;
7087         r.in.level = _level;
7088         r.in.info = _info;
7089
7090         status = dcerpc_spoolss_AddForm_r(h, mem_ctx, &r);
7091         if (!NT_STATUS_IS_OK(status)) {
7092                 return status;
7093         }
7094
7095         /* Return variables */
7096
7097         /* Return result */
7098         *result = r.out.result;
7099
7100         return NT_STATUS_OK;
7101 }
7102
7103 struct dcerpc_spoolss_DeleteForm_r_state {
7104         TALLOC_CTX *out_mem_ctx;
7105 };
7106
7107 static void dcerpc_spoolss_DeleteForm_r_done(struct tevent_req *subreq);
7108
7109 struct tevent_req *dcerpc_spoolss_DeleteForm_r_send(TALLOC_CTX *mem_ctx,
7110         struct tevent_context *ev,
7111         struct dcerpc_binding_handle *h,
7112         struct spoolss_DeleteForm *r)
7113 {
7114         struct tevent_req *req;
7115         struct dcerpc_spoolss_DeleteForm_r_state *state;
7116         struct tevent_req *subreq;
7117
7118         req = tevent_req_create(mem_ctx, &state,
7119                                 struct dcerpc_spoolss_DeleteForm_r_state);
7120         if (req == NULL) {
7121                 return NULL;
7122         }
7123
7124         state->out_mem_ctx = NULL;
7125         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7126                         NULL, &ndr_table_spoolss,
7127                         NDR_SPOOLSS_DELETEFORM, state, r);
7128         if (tevent_req_nomem(subreq, req)) {
7129                 return tevent_req_post(req, ev);
7130         }
7131         tevent_req_set_callback(subreq, dcerpc_spoolss_DeleteForm_r_done, req);
7132
7133         return req;
7134 }
7135
7136 static void dcerpc_spoolss_DeleteForm_r_done(struct tevent_req *subreq)
7137 {
7138         struct tevent_req *req =
7139                 tevent_req_callback_data(subreq,
7140                 struct tevent_req);
7141         NTSTATUS status;
7142
7143         status = dcerpc_binding_handle_call_recv(subreq);
7144         if (!NT_STATUS_IS_OK(status)) {
7145                 tevent_req_nterror(req, status);
7146                 return;
7147         }
7148
7149         tevent_req_done(req);
7150 }
7151
7152 NTSTATUS dcerpc_spoolss_DeleteForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7153 {
7154         struct dcerpc_spoolss_DeleteForm_r_state *state =
7155                 tevent_req_data(req,
7156                 struct dcerpc_spoolss_DeleteForm_r_state);
7157         NTSTATUS status;
7158
7159         if (tevent_req_is_nterror(req, &status)) {
7160                 tevent_req_received(req);
7161                 return status;
7162         }
7163
7164         talloc_steal(mem_ctx, state->out_mem_ctx);
7165
7166         tevent_req_received(req);
7167         return NT_STATUS_OK;
7168 }
7169
7170 NTSTATUS dcerpc_spoolss_DeleteForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeleteForm *r)
7171 {
7172         NTSTATUS status;
7173
7174         status = dcerpc_binding_handle_call(h,
7175                         NULL, &ndr_table_spoolss,
7176                         NDR_SPOOLSS_DELETEFORM, mem_ctx, r);
7177
7178         return status;
7179 }
7180
7181 NTSTATUS dcerpc_spoolss_DeleteForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeleteForm *r)
7182 {
7183         NTSTATUS status;
7184
7185         status = dcerpc_spoolss_DeleteForm_r(p->binding_handle, mem_ctx, r);
7186
7187         if (NT_STATUS_IS_RPC(status)) {
7188                 status = NT_STATUS_NET_WRITE_FAULT;
7189         }
7190
7191         return status;
7192 }
7193
7194 struct dcerpc_spoolss_DeleteForm_state {
7195         struct spoolss_DeleteForm orig;
7196         struct spoolss_DeleteForm tmp;
7197         TALLOC_CTX *out_mem_ctx;
7198 };
7199
7200 static void dcerpc_spoolss_DeleteForm_done(struct tevent_req *subreq);
7201
7202 struct tevent_req *dcerpc_spoolss_DeleteForm_send(TALLOC_CTX *mem_ctx,
7203                                                   struct tevent_context *ev,
7204                                                   struct dcerpc_binding_handle *h,
7205                                                   struct policy_handle *_handle /* [in] [ref] */,
7206                                                   const char *_form_name /* [in] [charset(UTF16)] */)
7207 {
7208         struct tevent_req *req;
7209         struct dcerpc_spoolss_DeleteForm_state *state;
7210         struct tevent_req *subreq;
7211
7212         req = tevent_req_create(mem_ctx, &state,
7213                                 struct dcerpc_spoolss_DeleteForm_state);
7214         if (req == NULL) {
7215                 return NULL;
7216         }
7217         state->out_mem_ctx = NULL;
7218
7219         /* In parameters */
7220         state->orig.in.handle = _handle;
7221         state->orig.in.form_name = _form_name;
7222
7223         /* Out parameters */
7224
7225         /* Result */
7226         ZERO_STRUCT(state->orig.out.result);
7227
7228         /* make a temporary copy, that we pass to the dispatch function */
7229         state->tmp = state->orig;
7230
7231         subreq = dcerpc_spoolss_DeleteForm_r_send(state, ev, h, &state->tmp);
7232         if (tevent_req_nomem(subreq, req)) {
7233                 return tevent_req_post(req, ev);
7234         }
7235         tevent_req_set_callback(subreq, dcerpc_spoolss_DeleteForm_done, req);
7236         return req;
7237 }
7238
7239 static void dcerpc_spoolss_DeleteForm_done(struct tevent_req *subreq)
7240 {
7241         struct tevent_req *req = tevent_req_callback_data(
7242                 subreq, struct tevent_req);
7243         struct dcerpc_spoolss_DeleteForm_state *state = tevent_req_data(
7244                 req, struct dcerpc_spoolss_DeleteForm_state);
7245         NTSTATUS status;
7246         TALLOC_CTX *mem_ctx;
7247
7248         if (state->out_mem_ctx) {
7249                 mem_ctx = state->out_mem_ctx;
7250         } else {
7251                 mem_ctx = state;
7252         }
7253
7254         status = dcerpc_spoolss_DeleteForm_r_recv(subreq, mem_ctx);
7255         TALLOC_FREE(subreq);
7256         if (!NT_STATUS_IS_OK(status)) {
7257                 tevent_req_nterror(req, status);
7258                 return;
7259         }
7260
7261         /* Copy out parameters */
7262
7263         /* Copy result */
7264         state->orig.out.result = state->tmp.out.result;
7265
7266         /* Reset temporary structure */
7267         ZERO_STRUCT(state->tmp);
7268
7269         tevent_req_done(req);
7270 }
7271
7272 NTSTATUS dcerpc_spoolss_DeleteForm_recv(struct tevent_req *req,
7273                                         TALLOC_CTX *mem_ctx,
7274                                         WERROR *result)
7275 {
7276         struct dcerpc_spoolss_DeleteForm_state *state = tevent_req_data(
7277                 req, struct dcerpc_spoolss_DeleteForm_state);
7278         NTSTATUS status;
7279
7280         if (tevent_req_is_nterror(req, &status)) {
7281                 tevent_req_received(req);
7282                 return status;
7283         }
7284
7285         /* Steal possible out parameters to the callers context */
7286         talloc_steal(mem_ctx, state->out_mem_ctx);
7287
7288         /* Return result */
7289         *result = state->orig.out.result;
7290
7291         tevent_req_received(req);
7292         return NT_STATUS_OK;
7293 }
7294
7295 NTSTATUS dcerpc_spoolss_DeleteForm(struct dcerpc_binding_handle *h,
7296                                    TALLOC_CTX *mem_ctx,
7297                                    struct policy_handle *_handle /* [in] [ref] */,
7298                                    const char *_form_name /* [in] [charset(UTF16)] */,
7299                                    WERROR *result)
7300 {
7301         struct spoolss_DeleteForm r;
7302         NTSTATUS status;
7303
7304         /* In parameters */
7305         r.in.handle = _handle;
7306         r.in.form_name = _form_name;
7307
7308         status = dcerpc_spoolss_DeleteForm_r(h, mem_ctx, &r);
7309         if (!NT_STATUS_IS_OK(status)) {
7310                 return status;
7311         }
7312
7313         /* Return variables */
7314
7315         /* Return result */
7316         *result = r.out.result;
7317
7318         return NT_STATUS_OK;
7319 }
7320
7321 struct dcerpc_spoolss_GetForm_r_state {
7322         TALLOC_CTX *out_mem_ctx;
7323 };
7324
7325 static void dcerpc_spoolss_GetForm_r_done(struct tevent_req *subreq);
7326
7327 struct tevent_req *dcerpc_spoolss_GetForm_r_send(TALLOC_CTX *mem_ctx,
7328         struct tevent_context *ev,
7329         struct dcerpc_binding_handle *h,
7330         struct spoolss_GetForm *r)
7331 {
7332         struct tevent_req *req;
7333         struct dcerpc_spoolss_GetForm_r_state *state;
7334         struct tevent_req *subreq;
7335
7336         req = tevent_req_create(mem_ctx, &state,
7337                                 struct dcerpc_spoolss_GetForm_r_state);
7338         if (req == NULL) {
7339                 return NULL;
7340         }
7341
7342         state->out_mem_ctx = talloc_new(state);
7343         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7344                 return tevent_req_post(req, ev);
7345         }
7346
7347         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7348                         NULL, &ndr_table_spoolss,
7349                         NDR_SPOOLSS_GETFORM, state->out_mem_ctx, r);
7350         if (tevent_req_nomem(subreq, req)) {
7351                 return tevent_req_post(req, ev);
7352         }
7353         tevent_req_set_callback(subreq, dcerpc_spoolss_GetForm_r_done, req);
7354
7355         return req;
7356 }
7357
7358 static void dcerpc_spoolss_GetForm_r_done(struct tevent_req *subreq)
7359 {
7360         struct tevent_req *req =
7361                 tevent_req_callback_data(subreq,
7362                 struct tevent_req);
7363         NTSTATUS status;
7364
7365         status = dcerpc_binding_handle_call_recv(subreq);
7366         if (!NT_STATUS_IS_OK(status)) {
7367                 tevent_req_nterror(req, status);
7368                 return;
7369         }
7370
7371         tevent_req_done(req);
7372 }
7373
7374 NTSTATUS dcerpc_spoolss_GetForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7375 {
7376         struct dcerpc_spoolss_GetForm_r_state *state =
7377                 tevent_req_data(req,
7378                 struct dcerpc_spoolss_GetForm_r_state);
7379         NTSTATUS status;
7380
7381         if (tevent_req_is_nterror(req, &status)) {
7382                 tevent_req_received(req);
7383                 return status;
7384         }
7385
7386         talloc_steal(mem_ctx, state->out_mem_ctx);
7387
7388         tevent_req_received(req);
7389         return NT_STATUS_OK;
7390 }
7391
7392 NTSTATUS dcerpc_spoolss_GetForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetForm *r)
7393 {
7394         NTSTATUS status;
7395
7396         status = dcerpc_binding_handle_call(h,
7397                         NULL, &ndr_table_spoolss,
7398                         NDR_SPOOLSS_GETFORM, mem_ctx, r);
7399
7400         return status;
7401 }
7402
7403 NTSTATUS dcerpc_spoolss_GetForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetForm *r)
7404 {
7405         NTSTATUS status;
7406
7407         status = dcerpc_spoolss_GetForm_r(p->binding_handle, mem_ctx, r);
7408
7409         if (NT_STATUS_IS_RPC(status)) {
7410                 status = NT_STATUS_NET_WRITE_FAULT;
7411         }
7412
7413         return status;
7414 }
7415
7416 struct dcerpc_spoolss_GetForm_state {
7417         struct spoolss_GetForm orig;
7418         struct spoolss_GetForm tmp;
7419         TALLOC_CTX *out_mem_ctx;
7420 };
7421
7422 static void dcerpc_spoolss_GetForm_done(struct tevent_req *subreq);
7423
7424 struct tevent_req *dcerpc_spoolss_GetForm_send(TALLOC_CTX *mem_ctx,
7425                                                struct tevent_context *ev,
7426                                                struct dcerpc_binding_handle *h,
7427                                                struct policy_handle *_handle /* [in] [ref] */,
7428                                                const char *_form_name /* [in] [charset(UTF16)] */,
7429                                                uint32_t _level /* [in]  */,
7430                                                DATA_BLOB *_buffer /* [in] [unique] */,
7431                                                uint32_t _offered /* [in]  */,
7432                                                union spoolss_FormInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
7433                                                uint32_t *_needed /* [out] [ref] */)
7434 {
7435         struct tevent_req *req;
7436         struct dcerpc_spoolss_GetForm_state *state;
7437         struct tevent_req *subreq;
7438
7439         req = tevent_req_create(mem_ctx, &state,
7440                                 struct dcerpc_spoolss_GetForm_state);
7441         if (req == NULL) {
7442                 return NULL;
7443         }
7444         state->out_mem_ctx = NULL;
7445
7446         /* In parameters */
7447         state->orig.in.handle = _handle;
7448         state->orig.in.form_name = _form_name;
7449         state->orig.in.level = _level;
7450         state->orig.in.buffer = _buffer;
7451         state->orig.in.offered = _offered;
7452
7453         /* Out parameters */
7454         state->orig.out.info = _info;
7455         state->orig.out.needed = _needed;
7456
7457         /* Result */
7458         ZERO_STRUCT(state->orig.out.result);
7459
7460         state->out_mem_ctx = talloc_named_const(state, 0,
7461                              "dcerpc_spoolss_GetForm_out_memory");
7462         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7463                 return tevent_req_post(req, ev);
7464         }
7465
7466         /* make a temporary copy, that we pass to the dispatch function */
7467         state->tmp = state->orig;
7468
7469         subreq = dcerpc_spoolss_GetForm_r_send(state, ev, h, &state->tmp);
7470         if (tevent_req_nomem(subreq, req)) {
7471                 return tevent_req_post(req, ev);
7472         }
7473         tevent_req_set_callback(subreq, dcerpc_spoolss_GetForm_done, req);
7474         return req;
7475 }
7476
7477 static void dcerpc_spoolss_GetForm_done(struct tevent_req *subreq)
7478 {
7479         struct tevent_req *req = tevent_req_callback_data(
7480                 subreq, struct tevent_req);
7481         struct dcerpc_spoolss_GetForm_state *state = tevent_req_data(
7482                 req, struct dcerpc_spoolss_GetForm_state);
7483         NTSTATUS status;
7484         TALLOC_CTX *mem_ctx;
7485
7486         if (state->out_mem_ctx) {
7487                 mem_ctx = state->out_mem_ctx;
7488         } else {
7489                 mem_ctx = state;
7490         }
7491
7492         status = dcerpc_spoolss_GetForm_r_recv(subreq, mem_ctx);
7493         TALLOC_FREE(subreq);
7494         if (!NT_STATUS_IS_OK(status)) {
7495                 tevent_req_nterror(req, status);
7496                 return;
7497         }
7498
7499         /* Copy out parameters */
7500         if (state->orig.out.info && state->tmp.out.info) {
7501                 *state->orig.out.info = *state->tmp.out.info;
7502         }
7503         *state->orig.out.needed = *state->tmp.out.needed;
7504
7505         /* Copy result */
7506         state->orig.out.result = state->tmp.out.result;
7507
7508         /* Reset temporary structure */
7509         ZERO_STRUCT(state->tmp);
7510
7511         tevent_req_done(req);
7512 }
7513
7514 NTSTATUS dcerpc_spoolss_GetForm_recv(struct tevent_req *req,
7515                                      TALLOC_CTX *mem_ctx,
7516                                      WERROR *result)
7517 {
7518         struct dcerpc_spoolss_GetForm_state *state = tevent_req_data(
7519                 req, struct dcerpc_spoolss_GetForm_state);
7520         NTSTATUS status;
7521
7522         if (tevent_req_is_nterror(req, &status)) {
7523                 tevent_req_received(req);
7524                 return status;
7525         }
7526
7527         /* Steal possible out parameters to the callers context */
7528         talloc_steal(mem_ctx, state->out_mem_ctx);
7529
7530         /* Return result */
7531         *result = state->orig.out.result;
7532
7533         tevent_req_received(req);
7534         return NT_STATUS_OK;
7535 }
7536
7537 NTSTATUS dcerpc_spoolss_GetForm(struct dcerpc_binding_handle *h,
7538                                 TALLOC_CTX *mem_ctx,
7539                                 struct policy_handle *_handle /* [in] [ref] */,
7540                                 const char *_form_name /* [in] [charset(UTF16)] */,
7541                                 uint32_t _level /* [in]  */,
7542                                 DATA_BLOB *_buffer /* [in] [unique] */,
7543                                 uint32_t _offered /* [in]  */,
7544                                 union spoolss_FormInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
7545                                 uint32_t *_needed /* [out] [ref] */,
7546                                 WERROR *result)
7547 {
7548         struct spoolss_GetForm r;
7549         NTSTATUS status;
7550
7551         /* In parameters */
7552         r.in.handle = _handle;
7553         r.in.form_name = _form_name;
7554         r.in.level = _level;
7555         r.in.buffer = _buffer;
7556         r.in.offered = _offered;
7557
7558         status = dcerpc_spoolss_GetForm_r(h, mem_ctx, &r);
7559         if (!NT_STATUS_IS_OK(status)) {
7560                 return status;
7561         }
7562
7563         /* Return variables */
7564         if (_info && r.out.info) {
7565                 *_info = *r.out.info;
7566         }
7567         *_needed = *r.out.needed;
7568
7569         /* Return result */
7570         *result = r.out.result;
7571
7572         return NT_STATUS_OK;
7573 }
7574
7575 struct dcerpc_spoolss_SetForm_r_state {
7576         TALLOC_CTX *out_mem_ctx;
7577 };
7578
7579 static void dcerpc_spoolss_SetForm_r_done(struct tevent_req *subreq);
7580
7581 struct tevent_req *dcerpc_spoolss_SetForm_r_send(TALLOC_CTX *mem_ctx,
7582         struct tevent_context *ev,
7583         struct dcerpc_binding_handle *h,
7584         struct spoolss_SetForm *r)
7585 {
7586         struct tevent_req *req;
7587         struct dcerpc_spoolss_SetForm_r_state *state;
7588         struct tevent_req *subreq;
7589
7590         req = tevent_req_create(mem_ctx, &state,
7591                                 struct dcerpc_spoolss_SetForm_r_state);
7592         if (req == NULL) {
7593                 return NULL;
7594         }
7595
7596         state->out_mem_ctx = NULL;
7597         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7598                         NULL, &ndr_table_spoolss,
7599                         NDR_SPOOLSS_SETFORM, state, r);
7600         if (tevent_req_nomem(subreq, req)) {
7601                 return tevent_req_post(req, ev);
7602         }
7603         tevent_req_set_callback(subreq, dcerpc_spoolss_SetForm_r_done, req);
7604
7605         return req;
7606 }
7607
7608 static void dcerpc_spoolss_SetForm_r_done(struct tevent_req *subreq)
7609 {
7610         struct tevent_req *req =
7611                 tevent_req_callback_data(subreq,
7612                 struct tevent_req);
7613         NTSTATUS status;
7614
7615         status = dcerpc_binding_handle_call_recv(subreq);
7616         if (!NT_STATUS_IS_OK(status)) {
7617                 tevent_req_nterror(req, status);
7618                 return;
7619         }
7620
7621         tevent_req_done(req);
7622 }
7623
7624 NTSTATUS dcerpc_spoolss_SetForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7625 {
7626         struct dcerpc_spoolss_SetForm_r_state *state =
7627                 tevent_req_data(req,
7628                 struct dcerpc_spoolss_SetForm_r_state);
7629         NTSTATUS status;
7630
7631         if (tevent_req_is_nterror(req, &status)) {
7632                 tevent_req_received(req);
7633                 return status;
7634         }
7635
7636         talloc_steal(mem_ctx, state->out_mem_ctx);
7637
7638         tevent_req_received(req);
7639         return NT_STATUS_OK;
7640 }
7641
7642 NTSTATUS dcerpc_spoolss_SetForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetForm *r)
7643 {
7644         NTSTATUS status;
7645
7646         status = dcerpc_binding_handle_call(h,
7647                         NULL, &ndr_table_spoolss,
7648                         NDR_SPOOLSS_SETFORM, mem_ctx, r);
7649
7650         return status;
7651 }
7652
7653 NTSTATUS dcerpc_spoolss_SetForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetForm *r)
7654 {
7655         NTSTATUS status;
7656
7657         status = dcerpc_spoolss_SetForm_r(p->binding_handle, mem_ctx, r);
7658
7659         if (NT_STATUS_IS_RPC(status)) {
7660                 status = NT_STATUS_NET_WRITE_FAULT;
7661         }
7662
7663         return status;
7664 }
7665
7666 struct dcerpc_spoolss_SetForm_state {
7667         struct spoolss_SetForm orig;
7668         struct spoolss_SetForm tmp;
7669         TALLOC_CTX *out_mem_ctx;
7670 };
7671
7672 static void dcerpc_spoolss_SetForm_done(struct tevent_req *subreq);
7673
7674 struct tevent_req *dcerpc_spoolss_SetForm_send(TALLOC_CTX *mem_ctx,
7675                                                struct tevent_context *ev,
7676                                                struct dcerpc_binding_handle *h,
7677                                                struct policy_handle *_handle /* [in] [ref] */,
7678                                                const char *_form_name /* [in] [charset(UTF16)] */,
7679                                                uint32_t _level /* [in]  */,
7680                                                union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */)
7681 {
7682         struct tevent_req *req;
7683         struct dcerpc_spoolss_SetForm_state *state;
7684         struct tevent_req *subreq;
7685
7686         req = tevent_req_create(mem_ctx, &state,
7687                                 struct dcerpc_spoolss_SetForm_state);
7688         if (req == NULL) {
7689                 return NULL;
7690         }
7691         state->out_mem_ctx = NULL;
7692
7693         /* In parameters */
7694         state->orig.in.handle = _handle;
7695         state->orig.in.form_name = _form_name;
7696         state->orig.in.level = _level;
7697         state->orig.in.info = _info;
7698
7699         /* Out parameters */
7700
7701         /* Result */
7702         ZERO_STRUCT(state->orig.out.result);
7703
7704         /* make a temporary copy, that we pass to the dispatch function */
7705         state->tmp = state->orig;
7706
7707         subreq = dcerpc_spoolss_SetForm_r_send(state, ev, h, &state->tmp);
7708         if (tevent_req_nomem(subreq, req)) {
7709                 return tevent_req_post(req, ev);
7710         }
7711         tevent_req_set_callback(subreq, dcerpc_spoolss_SetForm_done, req);
7712         return req;
7713 }
7714
7715 static void dcerpc_spoolss_SetForm_done(struct tevent_req *subreq)
7716 {
7717         struct tevent_req *req = tevent_req_callback_data(
7718                 subreq, struct tevent_req);
7719         struct dcerpc_spoolss_SetForm_state *state = tevent_req_data(
7720                 req, struct dcerpc_spoolss_SetForm_state);
7721         NTSTATUS status;
7722         TALLOC_CTX *mem_ctx;
7723
7724         if (state->out_mem_ctx) {
7725                 mem_ctx = state->out_mem_ctx;
7726         } else {
7727                 mem_ctx = state;
7728         }
7729
7730         status = dcerpc_spoolss_SetForm_r_recv(subreq, mem_ctx);
7731         TALLOC_FREE(subreq);
7732         if (!NT_STATUS_IS_OK(status)) {
7733                 tevent_req_nterror(req, status);
7734                 return;
7735         }
7736
7737         /* Copy out parameters */
7738
7739         /* Copy result */
7740         state->orig.out.result = state->tmp.out.result;
7741
7742         /* Reset temporary structure */
7743         ZERO_STRUCT(state->tmp);
7744
7745         tevent_req_done(req);
7746 }
7747
7748 NTSTATUS dcerpc_spoolss_SetForm_recv(struct tevent_req *req,
7749                                      TALLOC_CTX *mem_ctx,
7750                                      WERROR *result)
7751 {
7752         struct dcerpc_spoolss_SetForm_state *state = tevent_req_data(
7753                 req, struct dcerpc_spoolss_SetForm_state);
7754         NTSTATUS status;
7755
7756         if (tevent_req_is_nterror(req, &status)) {
7757                 tevent_req_received(req);
7758                 return status;
7759         }
7760
7761         /* Steal possible out parameters to the callers context */
7762         talloc_steal(mem_ctx, state->out_mem_ctx);
7763
7764         /* Return result */
7765         *result = state->orig.out.result;
7766
7767         tevent_req_received(req);
7768         return NT_STATUS_OK;
7769 }
7770
7771 NTSTATUS dcerpc_spoolss_SetForm(struct dcerpc_binding_handle *h,
7772                                 TALLOC_CTX *mem_ctx,
7773                                 struct policy_handle *_handle /* [in] [ref] */,
7774                                 const char *_form_name /* [in] [charset(UTF16)] */,
7775                                 uint32_t _level /* [in]  */,
7776                                 union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */,
7777                                 WERROR *result)
7778 {
7779         struct spoolss_SetForm r;
7780         NTSTATUS status;
7781
7782         /* In parameters */
7783         r.in.handle = _handle;
7784         r.in.form_name = _form_name;
7785         r.in.level = _level;
7786         r.in.info = _info;
7787
7788         status = dcerpc_spoolss_SetForm_r(h, mem_ctx, &r);
7789         if (!NT_STATUS_IS_OK(status)) {
7790                 return status;
7791         }
7792
7793         /* Return variables */
7794
7795         /* Return result */
7796         *result = r.out.result;
7797
7798         return NT_STATUS_OK;
7799 }
7800
7801 struct dcerpc_spoolss_EnumForms_r_state {
7802         TALLOC_CTX *out_mem_ctx;
7803 };
7804
7805 static void dcerpc_spoolss_EnumForms_r_done(struct tevent_req *subreq);
7806
7807 struct tevent_req *dcerpc_spoolss_EnumForms_r_send(TALLOC_CTX *mem_ctx,
7808         struct tevent_context *ev,
7809         struct dcerpc_binding_handle *h,
7810         struct spoolss_EnumForms *r)
7811 {
7812         struct tevent_req *req;
7813         struct dcerpc_spoolss_EnumForms_r_state *state;
7814         struct tevent_req *subreq;
7815
7816         req = tevent_req_create(mem_ctx, &state,
7817                                 struct dcerpc_spoolss_EnumForms_r_state);
7818         if (req == NULL) {
7819                 return NULL;
7820         }
7821
7822         state->out_mem_ctx = talloc_new(state);
7823         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7824                 return tevent_req_post(req, ev);
7825         }
7826
7827         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7828                         NULL, &ndr_table_spoolss,
7829                         NDR_SPOOLSS_ENUMFORMS, state->out_mem_ctx, r);
7830         if (tevent_req_nomem(subreq, req)) {
7831                 return tevent_req_post(req, ev);
7832         }
7833         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumForms_r_done, req);
7834
7835         return req;
7836 }
7837
7838 static void dcerpc_spoolss_EnumForms_r_done(struct tevent_req *subreq)
7839 {
7840         struct tevent_req *req =
7841                 tevent_req_callback_data(subreq,
7842                 struct tevent_req);
7843         NTSTATUS status;
7844
7845         status = dcerpc_binding_handle_call_recv(subreq);
7846         if (!NT_STATUS_IS_OK(status)) {
7847                 tevent_req_nterror(req, status);
7848                 return;
7849         }
7850
7851         tevent_req_done(req);
7852 }
7853
7854 NTSTATUS dcerpc_spoolss_EnumForms_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7855 {
7856         struct dcerpc_spoolss_EnumForms_r_state *state =
7857                 tevent_req_data(req,
7858                 struct dcerpc_spoolss_EnumForms_r_state);
7859         NTSTATUS status;
7860
7861         if (tevent_req_is_nterror(req, &status)) {
7862                 tevent_req_received(req);
7863                 return status;
7864         }
7865
7866         talloc_steal(mem_ctx, state->out_mem_ctx);
7867
7868         tevent_req_received(req);
7869         return NT_STATUS_OK;
7870 }
7871
7872 NTSTATUS dcerpc_spoolss_EnumForms_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumForms *r)
7873 {
7874         NTSTATUS status;
7875
7876         status = dcerpc_binding_handle_call(h,
7877                         NULL, &ndr_table_spoolss,
7878                         NDR_SPOOLSS_ENUMFORMS, mem_ctx, r);
7879
7880         return status;
7881 }
7882
7883 NTSTATUS dcerpc_spoolss_EnumForms_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumForms *r)
7884 {
7885         NTSTATUS status;
7886
7887         status = dcerpc_spoolss_EnumForms_r(p->binding_handle, mem_ctx, r);
7888
7889         if (NT_STATUS_IS_RPC(status)) {
7890                 status = NT_STATUS_NET_WRITE_FAULT;
7891         }
7892
7893         return status;
7894 }
7895
7896 struct dcerpc_spoolss_EnumForms_state {
7897         struct spoolss_EnumForms orig;
7898         struct spoolss_EnumForms tmp;
7899         TALLOC_CTX *out_mem_ctx;
7900 };
7901
7902 static void dcerpc_spoolss_EnumForms_done(struct tevent_req *subreq);
7903
7904 struct tevent_req *dcerpc_spoolss_EnumForms_send(TALLOC_CTX *mem_ctx,
7905                                                  struct tevent_context *ev,
7906                                                  struct dcerpc_binding_handle *h,
7907                                                  struct policy_handle *_handle /* [in] [ref] */,
7908                                                  uint32_t _level /* [in]  */,
7909                                                  DATA_BLOB *_buffer /* [in] [unique] */,
7910                                                  uint32_t _offered /* [in]  */,
7911                                                  uint32_t *_count /* [out] [ref] */,
7912                                                  union spoolss_FormInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
7913                                                  uint32_t *_needed /* [out] [ref] */)
7914 {
7915         struct tevent_req *req;
7916         struct dcerpc_spoolss_EnumForms_state *state;
7917         struct tevent_req *subreq;
7918
7919         req = tevent_req_create(mem_ctx, &state,
7920                                 struct dcerpc_spoolss_EnumForms_state);
7921         if (req == NULL) {
7922                 return NULL;
7923         }
7924         state->out_mem_ctx = NULL;
7925
7926         /* In parameters */
7927         state->orig.in.handle = _handle;
7928         state->orig.in.level = _level;
7929         state->orig.in.buffer = _buffer;
7930         state->orig.in.offered = _offered;
7931
7932         /* Out parameters */
7933         state->orig.out.count = _count;
7934         state->orig.out.info = _info;
7935         state->orig.out.needed = _needed;
7936
7937         /* Result */
7938         ZERO_STRUCT(state->orig.out.result);
7939
7940         state->out_mem_ctx = talloc_named_const(state, 0,
7941                              "dcerpc_spoolss_EnumForms_out_memory");
7942         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7943                 return tevent_req_post(req, ev);
7944         }
7945
7946         /* make a temporary copy, that we pass to the dispatch function */
7947         state->tmp = state->orig;
7948
7949         subreq = dcerpc_spoolss_EnumForms_r_send(state, ev, h, &state->tmp);
7950         if (tevent_req_nomem(subreq, req)) {
7951                 return tevent_req_post(req, ev);
7952         }
7953         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumForms_done, req);
7954         return req;
7955 }
7956
7957 static void dcerpc_spoolss_EnumForms_done(struct tevent_req *subreq)
7958 {
7959         struct tevent_req *req = tevent_req_callback_data(
7960                 subreq, struct tevent_req);
7961         struct dcerpc_spoolss_EnumForms_state *state = tevent_req_data(
7962                 req, struct dcerpc_spoolss_EnumForms_state);
7963         NTSTATUS status;
7964         TALLOC_CTX *mem_ctx;
7965
7966         if (state->out_mem_ctx) {
7967                 mem_ctx = state->out_mem_ctx;
7968         } else {
7969                 mem_ctx = state;
7970         }
7971
7972         status = dcerpc_spoolss_EnumForms_r_recv(subreq, mem_ctx);
7973         TALLOC_FREE(subreq);
7974         if (!NT_STATUS_IS_OK(status)) {
7975                 tevent_req_nterror(req, status);
7976                 return;
7977         }
7978
7979         /* Copy out parameters */
7980         *state->orig.out.count = *state->tmp.out.count;
7981         *state->orig.out.info = *state->tmp.out.info;
7982         *state->orig.out.needed = *state->tmp.out.needed;
7983
7984         /* Copy result */
7985         state->orig.out.result = state->tmp.out.result;
7986
7987         /* Reset temporary structure */
7988         ZERO_STRUCT(state->tmp);
7989
7990         tevent_req_done(req);
7991 }
7992
7993 NTSTATUS dcerpc_spoolss_EnumForms_recv(struct tevent_req *req,
7994                                        TALLOC_CTX *mem_ctx,
7995                                        WERROR *result)
7996 {
7997         struct dcerpc_spoolss_EnumForms_state *state = tevent_req_data(
7998                 req, struct dcerpc_spoolss_EnumForms_state);
7999         NTSTATUS status;
8000
8001         if (tevent_req_is_nterror(req, &status)) {
8002                 tevent_req_received(req);
8003                 return status;
8004         }
8005
8006         /* Steal possible out parameters to the callers context */
8007         talloc_steal(mem_ctx, state->out_mem_ctx);
8008
8009         /* Return result */
8010         *result = state->orig.out.result;
8011
8012         tevent_req_received(req);
8013         return NT_STATUS_OK;
8014 }
8015
8016 NTSTATUS dcerpc_spoolss_EnumForms(struct dcerpc_binding_handle *h,
8017                                   TALLOC_CTX *mem_ctx,
8018                                   struct policy_handle *_handle /* [in] [ref] */,
8019                                   uint32_t _level /* [in]  */,
8020                                   DATA_BLOB *_buffer /* [in] [unique] */,
8021                                   uint32_t _offered /* [in]  */,
8022                                   uint32_t *_count /* [out] [ref] */,
8023                                   union spoolss_FormInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8024                                   uint32_t *_needed /* [out] [ref] */,
8025                                   WERROR *result)
8026 {
8027         struct spoolss_EnumForms r;
8028         NTSTATUS status;
8029
8030         /* In parameters */
8031         r.in.handle = _handle;
8032         r.in.level = _level;
8033         r.in.buffer = _buffer;
8034         r.in.offered = _offered;
8035
8036         status = dcerpc_spoolss_EnumForms_r(h, mem_ctx, &r);
8037         if (!NT_STATUS_IS_OK(status)) {
8038                 return status;
8039         }
8040
8041         /* Return variables */
8042         *_count = *r.out.count;
8043         *_info = *r.out.info;
8044         *_needed = *r.out.needed;
8045
8046         /* Return result */
8047         *result = r.out.result;
8048
8049         return NT_STATUS_OK;
8050 }
8051
8052 struct dcerpc_spoolss_EnumPorts_r_state {
8053         TALLOC_CTX *out_mem_ctx;
8054 };
8055
8056 static void dcerpc_spoolss_EnumPorts_r_done(struct tevent_req *subreq);
8057
8058 struct tevent_req *dcerpc_spoolss_EnumPorts_r_send(TALLOC_CTX *mem_ctx,
8059         struct tevent_context *ev,
8060         struct dcerpc_binding_handle *h,
8061         struct spoolss_EnumPorts *r)
8062 {
8063         struct tevent_req *req;
8064         struct dcerpc_spoolss_EnumPorts_r_state *state;
8065         struct tevent_req *subreq;
8066
8067         req = tevent_req_create(mem_ctx, &state,
8068                                 struct dcerpc_spoolss_EnumPorts_r_state);
8069         if (req == NULL) {
8070                 return NULL;
8071         }
8072
8073         state->out_mem_ctx = talloc_new(state);
8074         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8075                 return tevent_req_post(req, ev);
8076         }
8077
8078         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8079                         NULL, &ndr_table_spoolss,
8080                         NDR_SPOOLSS_ENUMPORTS, state->out_mem_ctx, r);
8081         if (tevent_req_nomem(subreq, req)) {
8082                 return tevent_req_post(req, ev);
8083         }
8084         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPorts_r_done, req);
8085
8086         return req;
8087 }
8088
8089 static void dcerpc_spoolss_EnumPorts_r_done(struct tevent_req *subreq)
8090 {
8091         struct tevent_req *req =
8092                 tevent_req_callback_data(subreq,
8093                 struct tevent_req);
8094         NTSTATUS status;
8095
8096         status = dcerpc_binding_handle_call_recv(subreq);
8097         if (!NT_STATUS_IS_OK(status)) {
8098                 tevent_req_nterror(req, status);
8099                 return;
8100         }
8101
8102         tevent_req_done(req);
8103 }
8104
8105 NTSTATUS dcerpc_spoolss_EnumPorts_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8106 {
8107         struct dcerpc_spoolss_EnumPorts_r_state *state =
8108                 tevent_req_data(req,
8109                 struct dcerpc_spoolss_EnumPorts_r_state);
8110         NTSTATUS status;
8111
8112         if (tevent_req_is_nterror(req, &status)) {
8113                 tevent_req_received(req);
8114                 return status;
8115         }
8116
8117         talloc_steal(mem_ctx, state->out_mem_ctx);
8118
8119         tevent_req_received(req);
8120         return NT_STATUS_OK;
8121 }
8122
8123 NTSTATUS dcerpc_spoolss_EnumPorts_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPorts *r)
8124 {
8125         NTSTATUS status;
8126
8127         status = dcerpc_binding_handle_call(h,
8128                         NULL, &ndr_table_spoolss,
8129                         NDR_SPOOLSS_ENUMPORTS, mem_ctx, r);
8130
8131         return status;
8132 }
8133
8134 NTSTATUS dcerpc_spoolss_EnumPorts_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPorts *r)
8135 {
8136         NTSTATUS status;
8137
8138         status = dcerpc_spoolss_EnumPorts_r(p->binding_handle, mem_ctx, r);
8139
8140         if (NT_STATUS_IS_RPC(status)) {
8141                 status = NT_STATUS_NET_WRITE_FAULT;
8142         }
8143
8144         return status;
8145 }
8146
8147 struct dcerpc_spoolss_EnumPorts_state {
8148         struct spoolss_EnumPorts orig;
8149         struct spoolss_EnumPorts tmp;
8150         TALLOC_CTX *out_mem_ctx;
8151 };
8152
8153 static void dcerpc_spoolss_EnumPorts_done(struct tevent_req *subreq);
8154
8155 struct tevent_req *dcerpc_spoolss_EnumPorts_send(TALLOC_CTX *mem_ctx,
8156                                                  struct tevent_context *ev,
8157                                                  struct dcerpc_binding_handle *h,
8158                                                  const char *_servername /* [in] [unique,charset(UTF16)] */,
8159                                                  uint32_t _level /* [in]  */,
8160                                                  DATA_BLOB *_buffer /* [in] [unique] */,
8161                                                  uint32_t _offered /* [in]  */,
8162                                                  uint32_t *_count /* [out] [ref] */,
8163                                                  union spoolss_PortInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8164                                                  uint32_t *_needed /* [out] [ref] */)
8165 {
8166         struct tevent_req *req;
8167         struct dcerpc_spoolss_EnumPorts_state *state;
8168         struct tevent_req *subreq;
8169
8170         req = tevent_req_create(mem_ctx, &state,
8171                                 struct dcerpc_spoolss_EnumPorts_state);
8172         if (req == NULL) {
8173                 return NULL;
8174         }
8175         state->out_mem_ctx = NULL;
8176
8177         /* In parameters */
8178         state->orig.in.servername = _servername;
8179         state->orig.in.level = _level;
8180         state->orig.in.buffer = _buffer;
8181         state->orig.in.offered = _offered;
8182
8183         /* Out parameters */
8184         state->orig.out.count = _count;
8185         state->orig.out.info = _info;
8186         state->orig.out.needed = _needed;
8187
8188         /* Result */
8189         ZERO_STRUCT(state->orig.out.result);
8190
8191         state->out_mem_ctx = talloc_named_const(state, 0,
8192                              "dcerpc_spoolss_EnumPorts_out_memory");
8193         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8194                 return tevent_req_post(req, ev);
8195         }
8196
8197         /* make a temporary copy, that we pass to the dispatch function */
8198         state->tmp = state->orig;
8199
8200         subreq = dcerpc_spoolss_EnumPorts_r_send(state, ev, h, &state->tmp);
8201         if (tevent_req_nomem(subreq, req)) {
8202                 return tevent_req_post(req, ev);
8203         }
8204         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPorts_done, req);
8205         return req;
8206 }
8207
8208 static void dcerpc_spoolss_EnumPorts_done(struct tevent_req *subreq)
8209 {
8210         struct tevent_req *req = tevent_req_callback_data(
8211                 subreq, struct tevent_req);
8212         struct dcerpc_spoolss_EnumPorts_state *state = tevent_req_data(
8213                 req, struct dcerpc_spoolss_EnumPorts_state);
8214         NTSTATUS status;
8215         TALLOC_CTX *mem_ctx;
8216
8217         if (state->out_mem_ctx) {
8218                 mem_ctx = state->out_mem_ctx;
8219         } else {
8220                 mem_ctx = state;
8221         }
8222
8223         status = dcerpc_spoolss_EnumPorts_r_recv(subreq, mem_ctx);
8224         TALLOC_FREE(subreq);
8225         if (!NT_STATUS_IS_OK(status)) {
8226                 tevent_req_nterror(req, status);
8227                 return;
8228         }
8229
8230         /* Copy out parameters */
8231         *state->orig.out.count = *state->tmp.out.count;
8232         *state->orig.out.info = *state->tmp.out.info;
8233         *state->orig.out.needed = *state->tmp.out.needed;
8234
8235         /* Copy result */
8236         state->orig.out.result = state->tmp.out.result;
8237
8238         /* Reset temporary structure */
8239         ZERO_STRUCT(state->tmp);
8240
8241         tevent_req_done(req);
8242 }
8243
8244 NTSTATUS dcerpc_spoolss_EnumPorts_recv(struct tevent_req *req,
8245                                        TALLOC_CTX *mem_ctx,
8246                                        WERROR *result)
8247 {
8248         struct dcerpc_spoolss_EnumPorts_state *state = tevent_req_data(
8249                 req, struct dcerpc_spoolss_EnumPorts_state);
8250         NTSTATUS status;
8251
8252         if (tevent_req_is_nterror(req, &status)) {
8253                 tevent_req_received(req);
8254                 return status;
8255         }
8256
8257         /* Steal possible out parameters to the callers context */
8258         talloc_steal(mem_ctx, state->out_mem_ctx);
8259
8260         /* Return result */
8261         *result = state->orig.out.result;
8262
8263         tevent_req_received(req);
8264         return NT_STATUS_OK;
8265 }
8266
8267 NTSTATUS dcerpc_spoolss_EnumPorts(struct dcerpc_binding_handle *h,
8268                                   TALLOC_CTX *mem_ctx,
8269                                   const char *_servername /* [in] [unique,charset(UTF16)] */,
8270                                   uint32_t _level /* [in]  */,
8271                                   DATA_BLOB *_buffer /* [in] [unique] */,
8272                                   uint32_t _offered /* [in]  */,
8273                                   uint32_t *_count /* [out] [ref] */,
8274                                   union spoolss_PortInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8275                                   uint32_t *_needed /* [out] [ref] */,
8276                                   WERROR *result)
8277 {
8278         struct spoolss_EnumPorts r;
8279         NTSTATUS status;
8280
8281         /* In parameters */
8282         r.in.servername = _servername;
8283         r.in.level = _level;
8284         r.in.buffer = _buffer;
8285         r.in.offered = _offered;
8286
8287         status = dcerpc_spoolss_EnumPorts_r(h, mem_ctx, &r);
8288         if (!NT_STATUS_IS_OK(status)) {
8289                 return status;
8290         }
8291
8292         /* Return variables */
8293         *_count = *r.out.count;
8294         *_info = *r.out.info;
8295         *_needed = *r.out.needed;
8296
8297         /* Return result */
8298         *result = r.out.result;
8299
8300         return NT_STATUS_OK;
8301 }
8302
8303 struct dcerpc_spoolss_EnumMonitors_r_state {
8304         TALLOC_CTX *out_mem_ctx;
8305 };
8306
8307 static void dcerpc_spoolss_EnumMonitors_r_done(struct tevent_req *subreq);
8308
8309 struct tevent_req *dcerpc_spoolss_EnumMonitors_r_send(TALLOC_CTX *mem_ctx,
8310         struct tevent_context *ev,
8311         struct dcerpc_binding_handle *h,
8312         struct spoolss_EnumMonitors *r)
8313 {
8314         struct tevent_req *req;
8315         struct dcerpc_spoolss_EnumMonitors_r_state *state;
8316         struct tevent_req *subreq;
8317
8318         req = tevent_req_create(mem_ctx, &state,
8319                                 struct dcerpc_spoolss_EnumMonitors_r_state);
8320         if (req == NULL) {
8321                 return NULL;
8322         }
8323
8324         state->out_mem_ctx = talloc_new(state);
8325         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8326                 return tevent_req_post(req, ev);
8327         }
8328
8329         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8330                         NULL, &ndr_table_spoolss,
8331                         NDR_SPOOLSS_ENUMMONITORS, state->out_mem_ctx, r);
8332         if (tevent_req_nomem(subreq, req)) {
8333                 return tevent_req_post(req, ev);
8334         }
8335         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumMonitors_r_done, req);
8336
8337         return req;
8338 }
8339
8340 static void dcerpc_spoolss_EnumMonitors_r_done(struct tevent_req *subreq)
8341 {
8342         struct tevent_req *req =
8343                 tevent_req_callback_data(subreq,
8344                 struct tevent_req);
8345         NTSTATUS status;
8346
8347         status = dcerpc_binding_handle_call_recv(subreq);
8348         if (!NT_STATUS_IS_OK(status)) {
8349                 tevent_req_nterror(req, status);
8350                 return;
8351         }
8352
8353         tevent_req_done(req);
8354 }
8355
8356 NTSTATUS dcerpc_spoolss_EnumMonitors_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8357 {
8358         struct dcerpc_spoolss_EnumMonitors_r_state *state =
8359                 tevent_req_data(req,
8360                 struct dcerpc_spoolss_EnumMonitors_r_state);
8361         NTSTATUS status;
8362
8363         if (tevent_req_is_nterror(req, &status)) {
8364                 tevent_req_received(req);
8365                 return status;
8366         }
8367
8368         talloc_steal(mem_ctx, state->out_mem_ctx);
8369
8370         tevent_req_received(req);
8371         return NT_STATUS_OK;
8372 }
8373
8374 NTSTATUS dcerpc_spoolss_EnumMonitors_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumMonitors *r)
8375 {
8376         NTSTATUS status;
8377
8378         status = dcerpc_binding_handle_call(h,
8379                         NULL, &ndr_table_spoolss,
8380                         NDR_SPOOLSS_ENUMMONITORS, mem_ctx, r);
8381
8382         return status;
8383 }
8384
8385 NTSTATUS dcerpc_spoolss_EnumMonitors_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumMonitors *r)
8386 {
8387         NTSTATUS status;
8388
8389         status = dcerpc_spoolss_EnumMonitors_r(p->binding_handle, mem_ctx, r);
8390
8391         if (NT_STATUS_IS_RPC(status)) {
8392                 status = NT_STATUS_NET_WRITE_FAULT;
8393         }
8394
8395         return status;
8396 }
8397
8398 struct dcerpc_spoolss_EnumMonitors_state {
8399         struct spoolss_EnumMonitors orig;
8400         struct spoolss_EnumMonitors tmp;
8401         TALLOC_CTX *out_mem_ctx;
8402 };
8403
8404 static void dcerpc_spoolss_EnumMonitors_done(struct tevent_req *subreq);
8405
8406 struct tevent_req *dcerpc_spoolss_EnumMonitors_send(TALLOC_CTX *mem_ctx,
8407                                                     struct tevent_context *ev,
8408                                                     struct dcerpc_binding_handle *h,
8409                                                     const char *_servername /* [in] [unique,charset(UTF16)] */,
8410                                                     uint32_t _level /* [in]  */,
8411                                                     DATA_BLOB *_buffer /* [in] [unique] */,
8412                                                     uint32_t _offered /* [in]  */,
8413                                                     uint32_t *_count /* [out] [ref] */,
8414                                                     union spoolss_MonitorInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8415                                                     uint32_t *_needed /* [out] [ref] */)
8416 {
8417         struct tevent_req *req;
8418         struct dcerpc_spoolss_EnumMonitors_state *state;
8419         struct tevent_req *subreq;
8420
8421         req = tevent_req_create(mem_ctx, &state,
8422                                 struct dcerpc_spoolss_EnumMonitors_state);
8423         if (req == NULL) {
8424                 return NULL;
8425         }
8426         state->out_mem_ctx = NULL;
8427
8428         /* In parameters */
8429         state->orig.in.servername = _servername;
8430         state->orig.in.level = _level;
8431         state->orig.in.buffer = _buffer;
8432         state->orig.in.offered = _offered;
8433
8434         /* Out parameters */
8435         state->orig.out.count = _count;
8436         state->orig.out.info = _info;
8437         state->orig.out.needed = _needed;
8438
8439         /* Result */
8440         ZERO_STRUCT(state->orig.out.result);
8441
8442         state->out_mem_ctx = talloc_named_const(state, 0,
8443                              "dcerpc_spoolss_EnumMonitors_out_memory");
8444         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8445                 return tevent_req_post(req, ev);
8446         }
8447
8448         /* make a temporary copy, that we pass to the dispatch function */
8449         state->tmp = state->orig;
8450
8451         subreq = dcerpc_spoolss_EnumMonitors_r_send(state, ev, h, &state->tmp);
8452         if (tevent_req_nomem(subreq, req)) {
8453                 return tevent_req_post(req, ev);
8454         }
8455         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumMonitors_done, req);
8456         return req;
8457 }
8458
8459 static void dcerpc_spoolss_EnumMonitors_done(struct tevent_req *subreq)
8460 {
8461         struct tevent_req *req = tevent_req_callback_data(
8462                 subreq, struct tevent_req);
8463         struct dcerpc_spoolss_EnumMonitors_state *state = tevent_req_data(
8464                 req, struct dcerpc_spoolss_EnumMonitors_state);
8465         NTSTATUS status;
8466         TALLOC_CTX *mem_ctx;
8467
8468         if (state->out_mem_ctx) {
8469                 mem_ctx = state->out_mem_ctx;
8470         } else {
8471                 mem_ctx = state;
8472         }
8473
8474         status = dcerpc_spoolss_EnumMonitors_r_recv(subreq, mem_ctx);
8475         TALLOC_FREE(subreq);
8476         if (!NT_STATUS_IS_OK(status)) {
8477                 tevent_req_nterror(req, status);
8478                 return;
8479         }
8480
8481         /* Copy out parameters */
8482         *state->orig.out.count = *state->tmp.out.count;
8483         *state->orig.out.info = *state->tmp.out.info;
8484         *state->orig.out.needed = *state->tmp.out.needed;
8485
8486         /* Copy result */
8487         state->orig.out.result = state->tmp.out.result;
8488
8489         /* Reset temporary structure */
8490         ZERO_STRUCT(state->tmp);
8491
8492         tevent_req_done(req);
8493 }
8494
8495 NTSTATUS dcerpc_spoolss_EnumMonitors_recv(struct tevent_req *req,
8496                                           TALLOC_CTX *mem_ctx,
8497                                           WERROR *result)
8498 {
8499         struct dcerpc_spoolss_EnumMonitors_state *state = tevent_req_data(
8500                 req, struct dcerpc_spoolss_EnumMonitors_state);
8501         NTSTATUS status;
8502
8503         if (tevent_req_is_nterror(req, &status)) {
8504                 tevent_req_received(req);
8505                 return status;
8506         }
8507
8508         /* Steal possible out parameters to the callers context */
8509         talloc_steal(mem_ctx, state->out_mem_ctx);
8510
8511         /* Return result */
8512         *result = state->orig.out.result;
8513
8514         tevent_req_received(req);
8515         return NT_STATUS_OK;
8516 }
8517
8518 NTSTATUS dcerpc_spoolss_EnumMonitors(struct dcerpc_binding_handle *h,
8519                                      TALLOC_CTX *mem_ctx,
8520                                      const char *_servername /* [in] [unique,charset(UTF16)] */,
8521                                      uint32_t _level /* [in]  */,
8522                                      DATA_BLOB *_buffer /* [in] [unique] */,
8523                                      uint32_t _offered /* [in]  */,
8524                                      uint32_t *_count /* [out] [ref] */,
8525                                      union spoolss_MonitorInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8526                                      uint32_t *_needed /* [out] [ref] */,
8527                                      WERROR *result)
8528 {
8529         struct spoolss_EnumMonitors r;
8530         NTSTATUS status;
8531
8532         /* In parameters */
8533         r.in.servername = _servername;
8534         r.in.level = _level;
8535         r.in.buffer = _buffer;
8536         r.in.offered = _offered;
8537
8538         status = dcerpc_spoolss_EnumMonitors_r(h, mem_ctx, &r);
8539         if (!NT_STATUS_IS_OK(status)) {
8540                 return status;
8541         }
8542
8543         /* Return variables */
8544         *_count = *r.out.count;
8545         *_info = *r.out.info;
8546         *_needed = *r.out.needed;
8547
8548         /* Return result */
8549         *result = r.out.result;
8550
8551         return NT_STATUS_OK;
8552 }
8553
8554 struct dcerpc_spoolss_AddPort_r_state {
8555         TALLOC_CTX *out_mem_ctx;
8556 };
8557
8558 static void dcerpc_spoolss_AddPort_r_done(struct tevent_req *subreq);
8559
8560 struct tevent_req *dcerpc_spoolss_AddPort_r_send(TALLOC_CTX *mem_ctx,
8561         struct tevent_context *ev,
8562         struct dcerpc_binding_handle *h,
8563         struct spoolss_AddPort *r)
8564 {
8565         struct tevent_req *req;
8566         struct dcerpc_spoolss_AddPort_r_state *state;
8567         struct tevent_req *subreq;
8568
8569         req = tevent_req_create(mem_ctx, &state,
8570                                 struct dcerpc_spoolss_AddPort_r_state);
8571         if (req == NULL) {
8572                 return NULL;
8573         }
8574
8575         state->out_mem_ctx = NULL;
8576         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8577                         NULL, &ndr_table_spoolss,
8578                         NDR_SPOOLSS_ADDPORT, state, r);
8579         if (tevent_req_nomem(subreq, req)) {
8580                 return tevent_req_post(req, ev);
8581         }
8582         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPort_r_done, req);
8583
8584         return req;
8585 }
8586
8587 static void dcerpc_spoolss_AddPort_r_done(struct tevent_req *subreq)
8588 {
8589         struct tevent_req *req =
8590                 tevent_req_callback_data(subreq,
8591                 struct tevent_req);
8592         NTSTATUS status;
8593
8594         status = dcerpc_binding_handle_call_recv(subreq);
8595         if (!NT_STATUS_IS_OK(status)) {
8596                 tevent_req_nterror(req, status);
8597                 return;
8598         }
8599
8600         tevent_req_done(req);
8601 }
8602
8603 NTSTATUS dcerpc_spoolss_AddPort_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8604 {
8605         struct dcerpc_spoolss_AddPort_r_state *state =
8606                 tevent_req_data(req,
8607                 struct dcerpc_spoolss_AddPort_r_state);
8608         NTSTATUS status;
8609
8610         if (tevent_req_is_nterror(req, &status)) {
8611                 tevent_req_received(req);
8612                 return status;
8613         }
8614
8615         talloc_steal(mem_ctx, state->out_mem_ctx);
8616
8617         tevent_req_received(req);
8618         return NT_STATUS_OK;
8619 }
8620
8621 NTSTATUS dcerpc_spoolss_AddPort_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPort *r)
8622 {
8623         NTSTATUS status;
8624
8625         status = dcerpc_binding_handle_call(h,
8626                         NULL, &ndr_table_spoolss,
8627                         NDR_SPOOLSS_ADDPORT, mem_ctx, r);
8628
8629         return status;
8630 }
8631
8632 NTSTATUS dcerpc_spoolss_AddPort_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPort *r)
8633 {
8634         NTSTATUS status;
8635
8636         status = dcerpc_spoolss_AddPort_r(p->binding_handle, mem_ctx, r);
8637
8638         if (NT_STATUS_IS_RPC(status)) {
8639                 status = NT_STATUS_NET_WRITE_FAULT;
8640         }
8641
8642         return status;
8643 }
8644
8645 struct dcerpc_spoolss_AddPort_state {
8646         struct spoolss_AddPort orig;
8647         struct spoolss_AddPort tmp;
8648         TALLOC_CTX *out_mem_ctx;
8649 };
8650
8651 static void dcerpc_spoolss_AddPort_done(struct tevent_req *subreq);
8652
8653 struct tevent_req *dcerpc_spoolss_AddPort_send(TALLOC_CTX *mem_ctx,
8654                                                struct tevent_context *ev,
8655                                                struct dcerpc_binding_handle *h,
8656                                                const char *_server_name /* [in] [unique,charset(UTF16)] */,
8657                                                uint32_t _unknown /* [in]  */,
8658                                                const char *_monitor_name /* [in] [charset(UTF16)] */)
8659 {
8660         struct tevent_req *req;
8661         struct dcerpc_spoolss_AddPort_state *state;
8662         struct tevent_req *subreq;
8663
8664         req = tevent_req_create(mem_ctx, &state,
8665                                 struct dcerpc_spoolss_AddPort_state);
8666         if (req == NULL) {
8667                 return NULL;
8668         }
8669         state->out_mem_ctx = NULL;
8670
8671         /* In parameters */
8672         state->orig.in.server_name = _server_name;
8673         state->orig.in.unknown = _unknown;
8674         state->orig.in.monitor_name = _monitor_name;
8675
8676         /* Out parameters */
8677
8678         /* Result */
8679         ZERO_STRUCT(state->orig.out.result);
8680
8681         /* make a temporary copy, that we pass to the dispatch function */
8682         state->tmp = state->orig;
8683
8684         subreq = dcerpc_spoolss_AddPort_r_send(state, ev, h, &state->tmp);
8685         if (tevent_req_nomem(subreq, req)) {
8686                 return tevent_req_post(req, ev);
8687         }
8688         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPort_done, req);
8689         return req;
8690 }
8691
8692 static void dcerpc_spoolss_AddPort_done(struct tevent_req *subreq)
8693 {
8694         struct tevent_req *req = tevent_req_callback_data(
8695                 subreq, struct tevent_req);
8696         struct dcerpc_spoolss_AddPort_state *state = tevent_req_data(
8697                 req, struct dcerpc_spoolss_AddPort_state);
8698         NTSTATUS status;
8699         TALLOC_CTX *mem_ctx;
8700
8701         if (state->out_mem_ctx) {
8702                 mem_ctx = state->out_mem_ctx;
8703         } else {
8704                 mem_ctx = state;
8705         }
8706
8707         status = dcerpc_spoolss_AddPort_r_recv(subreq, mem_ctx);
8708         TALLOC_FREE(subreq);
8709         if (!NT_STATUS_IS_OK(status)) {
8710                 tevent_req_nterror(req, status);
8711                 return;
8712         }
8713
8714         /* Copy out parameters */
8715
8716         /* Copy result */
8717         state->orig.out.result = state->tmp.out.result;
8718
8719         /* Reset temporary structure */
8720         ZERO_STRUCT(state->tmp);
8721
8722         tevent_req_done(req);
8723 }
8724
8725 NTSTATUS dcerpc_spoolss_AddPort_recv(struct tevent_req *req,
8726                                      TALLOC_CTX *mem_ctx,
8727                                      WERROR *result)
8728 {
8729         struct dcerpc_spoolss_AddPort_state *state = tevent_req_data(
8730                 req, struct dcerpc_spoolss_AddPort_state);
8731         NTSTATUS status;
8732
8733         if (tevent_req_is_nterror(req, &status)) {
8734                 tevent_req_received(req);
8735                 return status;
8736         }
8737
8738         /* Steal possible out parameters to the callers context */
8739         talloc_steal(mem_ctx, state->out_mem_ctx);
8740
8741         /* Return result */
8742         *result = state->orig.out.result;
8743
8744         tevent_req_received(req);
8745         return NT_STATUS_OK;
8746 }
8747
8748 NTSTATUS dcerpc_spoolss_AddPort(struct dcerpc_binding_handle *h,
8749                                 TALLOC_CTX *mem_ctx,
8750                                 const char *_server_name /* [in] [unique,charset(UTF16)] */,
8751                                 uint32_t _unknown /* [in]  */,
8752                                 const char *_monitor_name /* [in] [charset(UTF16)] */,
8753                                 WERROR *result)
8754 {
8755         struct spoolss_AddPort r;
8756         NTSTATUS status;
8757
8758         /* In parameters */
8759         r.in.server_name = _server_name;
8760         r.in.unknown = _unknown;
8761         r.in.monitor_name = _monitor_name;
8762
8763         status = dcerpc_spoolss_AddPort_r(h, mem_ctx, &r);
8764         if (!NT_STATUS_IS_OK(status)) {
8765                 return status;
8766         }
8767
8768         /* Return variables */
8769
8770         /* Return result */
8771         *result = r.out.result;
8772
8773         return NT_STATUS_OK;
8774 }
8775
8776 struct dcerpc_spoolss_CreatePrinterIC_r_state {
8777         TALLOC_CTX *out_mem_ctx;
8778 };
8779
8780 static void dcerpc_spoolss_CreatePrinterIC_r_done(struct tevent_req *subreq);
8781
8782 struct tevent_req *dcerpc_spoolss_CreatePrinterIC_r_send(TALLOC_CTX *mem_ctx,
8783         struct tevent_context *ev,
8784         struct dcerpc_binding_handle *h,
8785         struct spoolss_CreatePrinterIC *r)
8786 {
8787         struct tevent_req *req;
8788         struct dcerpc_spoolss_CreatePrinterIC_r_state *state;
8789         struct tevent_req *subreq;
8790
8791         req = tevent_req_create(mem_ctx, &state,
8792                                 struct dcerpc_spoolss_CreatePrinterIC_r_state);
8793         if (req == NULL) {
8794                 return NULL;
8795         }
8796
8797         state->out_mem_ctx = talloc_new(state);
8798         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8799                 return tevent_req_post(req, ev);
8800         }
8801
8802         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8803                         NULL, &ndr_table_spoolss,
8804                         NDR_SPOOLSS_CREATEPRINTERIC, state->out_mem_ctx, r);
8805         if (tevent_req_nomem(subreq, req)) {
8806                 return tevent_req_post(req, ev);
8807         }
8808         tevent_req_set_callback(subreq, dcerpc_spoolss_CreatePrinterIC_r_done, req);
8809
8810         return req;
8811 }
8812
8813 static void dcerpc_spoolss_CreatePrinterIC_r_done(struct tevent_req *subreq)
8814 {
8815         struct tevent_req *req =
8816                 tevent_req_callback_data(subreq,
8817                 struct tevent_req);
8818         NTSTATUS status;
8819
8820         status = dcerpc_binding_handle_call_recv(subreq);
8821         if (!NT_STATUS_IS_OK(status)) {
8822                 tevent_req_nterror(req, status);
8823                 return;
8824         }
8825
8826         tevent_req_done(req);
8827 }
8828
8829 NTSTATUS dcerpc_spoolss_CreatePrinterIC_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8830 {
8831         struct dcerpc_spoolss_CreatePrinterIC_r_state *state =
8832                 tevent_req_data(req,
8833                 struct dcerpc_spoolss_CreatePrinterIC_r_state);
8834         NTSTATUS status;
8835
8836         if (tevent_req_is_nterror(req, &status)) {
8837                 tevent_req_received(req);
8838                 return status;
8839         }
8840
8841         talloc_steal(mem_ctx, state->out_mem_ctx);
8842
8843         tevent_req_received(req);
8844         return NT_STATUS_OK;
8845 }
8846
8847 NTSTATUS dcerpc_spoolss_CreatePrinterIC_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_CreatePrinterIC *r)
8848 {
8849         NTSTATUS status;
8850
8851         status = dcerpc_binding_handle_call(h,
8852                         NULL, &ndr_table_spoolss,
8853                         NDR_SPOOLSS_CREATEPRINTERIC, mem_ctx, r);
8854
8855         return status;
8856 }
8857
8858 NTSTATUS dcerpc_spoolss_CreatePrinterIC_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_CreatePrinterIC *r)
8859 {
8860         NTSTATUS status;
8861
8862         status = dcerpc_spoolss_CreatePrinterIC_r(p->binding_handle, mem_ctx, r);
8863
8864         if (NT_STATUS_IS_RPC(status)) {
8865                 status = NT_STATUS_NET_WRITE_FAULT;
8866         }
8867
8868         return status;
8869 }
8870
8871 struct dcerpc_spoolss_CreatePrinterIC_state {
8872         struct spoolss_CreatePrinterIC orig;
8873         struct spoolss_CreatePrinterIC tmp;
8874         TALLOC_CTX *out_mem_ctx;
8875 };
8876
8877 static void dcerpc_spoolss_CreatePrinterIC_done(struct tevent_req *subreq);
8878
8879 struct tevent_req *dcerpc_spoolss_CreatePrinterIC_send(TALLOC_CTX *mem_ctx,
8880                                                        struct tevent_context *ev,
8881                                                        struct dcerpc_binding_handle *h,
8882                                                        struct policy_handle *_handle /* [in] [ref] */,
8883                                                        struct policy_handle *_gdi_handle /* [out] [ref] */,
8884                                                        struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */)
8885 {
8886         struct tevent_req *req;
8887         struct dcerpc_spoolss_CreatePrinterIC_state *state;
8888         struct tevent_req *subreq;
8889
8890         req = tevent_req_create(mem_ctx, &state,
8891                                 struct dcerpc_spoolss_CreatePrinterIC_state);
8892         if (req == NULL) {
8893                 return NULL;
8894         }
8895         state->out_mem_ctx = NULL;
8896
8897         /* In parameters */
8898         state->orig.in.handle = _handle;
8899         state->orig.in.devmode_ctr = _devmode_ctr;
8900
8901         /* Out parameters */
8902         state->orig.out.gdi_handle = _gdi_handle;
8903
8904         /* Result */
8905         ZERO_STRUCT(state->orig.out.result);
8906
8907         state->out_mem_ctx = talloc_named_const(state, 0,
8908                              "dcerpc_spoolss_CreatePrinterIC_out_memory");
8909         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8910                 return tevent_req_post(req, ev);
8911         }
8912
8913         /* make a temporary copy, that we pass to the dispatch function */
8914         state->tmp = state->orig;
8915
8916         subreq = dcerpc_spoolss_CreatePrinterIC_r_send(state, ev, h, &state->tmp);
8917         if (tevent_req_nomem(subreq, req)) {
8918                 return tevent_req_post(req, ev);
8919         }
8920         tevent_req_set_callback(subreq, dcerpc_spoolss_CreatePrinterIC_done, req);
8921         return req;
8922 }
8923
8924 static void dcerpc_spoolss_CreatePrinterIC_done(struct tevent_req *subreq)
8925 {
8926         struct tevent_req *req = tevent_req_callback_data(
8927                 subreq, struct tevent_req);
8928         struct dcerpc_spoolss_CreatePrinterIC_state *state = tevent_req_data(
8929                 req, struct dcerpc_spoolss_CreatePrinterIC_state);
8930         NTSTATUS status;
8931         TALLOC_CTX *mem_ctx;
8932
8933         if (state->out_mem_ctx) {
8934                 mem_ctx = state->out_mem_ctx;
8935         } else {
8936                 mem_ctx = state;
8937         }
8938
8939         status = dcerpc_spoolss_CreatePrinterIC_r_recv(subreq, mem_ctx);
8940         TALLOC_FREE(subreq);
8941         if (!NT_STATUS_IS_OK(status)) {
8942                 tevent_req_nterror(req, status);
8943                 return;
8944         }
8945
8946         /* Copy out parameters */
8947         *state->orig.out.gdi_handle = *state->tmp.out.gdi_handle;
8948
8949         /* Copy result */
8950         state->orig.out.result = state->tmp.out.result;
8951
8952         /* Reset temporary structure */
8953         ZERO_STRUCT(state->tmp);
8954
8955         tevent_req_done(req);
8956 }
8957
8958 NTSTATUS dcerpc_spoolss_CreatePrinterIC_recv(struct tevent_req *req,
8959                                              TALLOC_CTX *mem_ctx,
8960                                              WERROR *result)
8961 {
8962         struct dcerpc_spoolss_CreatePrinterIC_state *state = tevent_req_data(
8963                 req, struct dcerpc_spoolss_CreatePrinterIC_state);
8964         NTSTATUS status;
8965
8966         if (tevent_req_is_nterror(req, &status)) {
8967                 tevent_req_received(req);
8968                 return status;
8969         }
8970
8971         /* Steal possible out parameters to the callers context */
8972         talloc_steal(mem_ctx, state->out_mem_ctx);
8973
8974         /* Return result */
8975         *result = state->orig.out.result;
8976
8977         tevent_req_received(req);
8978         return NT_STATUS_OK;
8979 }
8980
8981 NTSTATUS dcerpc_spoolss_CreatePrinterIC(struct dcerpc_binding_handle *h,
8982                                         TALLOC_CTX *mem_ctx,
8983                                         struct policy_handle *_handle /* [in] [ref] */,
8984                                         struct policy_handle *_gdi_handle /* [out] [ref] */,
8985                                         struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
8986                                         WERROR *result)
8987 {
8988         struct spoolss_CreatePrinterIC r;
8989         NTSTATUS status;
8990
8991         /* In parameters */
8992         r.in.handle = _handle;
8993         r.in.devmode_ctr = _devmode_ctr;
8994
8995         status = dcerpc_spoolss_CreatePrinterIC_r(h, mem_ctx, &r);
8996         if (!NT_STATUS_IS_OK(status)) {
8997                 return status;
8998         }
8999
9000         /* Return variables */
9001         *_gdi_handle = *r.out.gdi_handle;
9002
9003         /* Return result */
9004         *result = r.out.result;
9005
9006         return NT_STATUS_OK;
9007 }
9008
9009 struct dcerpc_spoolss_DeletePrinterIC_r_state {
9010         TALLOC_CTX *out_mem_ctx;
9011 };
9012
9013 static void dcerpc_spoolss_DeletePrinterIC_r_done(struct tevent_req *subreq);
9014
9015 struct tevent_req *dcerpc_spoolss_DeletePrinterIC_r_send(TALLOC_CTX *mem_ctx,
9016         struct tevent_context *ev,
9017         struct dcerpc_binding_handle *h,
9018         struct spoolss_DeletePrinterIC *r)
9019 {
9020         struct tevent_req *req;
9021         struct dcerpc_spoolss_DeletePrinterIC_r_state *state;
9022         struct tevent_req *subreq;
9023
9024         req = tevent_req_create(mem_ctx, &state,
9025                                 struct dcerpc_spoolss_DeletePrinterIC_r_state);
9026         if (req == NULL) {
9027                 return NULL;
9028         }
9029
9030         state->out_mem_ctx = talloc_new(state);
9031         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9032                 return tevent_req_post(req, ev);
9033         }
9034
9035         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9036                         NULL, &ndr_table_spoolss,
9037                         NDR_SPOOLSS_DELETEPRINTERIC, state->out_mem_ctx, r);
9038         if (tevent_req_nomem(subreq, req)) {
9039                 return tevent_req_post(req, ev);
9040         }
9041         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterIC_r_done, req);
9042
9043         return req;
9044 }
9045
9046 static void dcerpc_spoolss_DeletePrinterIC_r_done(struct tevent_req *subreq)
9047 {
9048         struct tevent_req *req =
9049                 tevent_req_callback_data(subreq,
9050                 struct tevent_req);
9051         NTSTATUS status;
9052
9053         status = dcerpc_binding_handle_call_recv(subreq);
9054         if (!NT_STATUS_IS_OK(status)) {
9055                 tevent_req_nterror(req, status);
9056                 return;
9057         }
9058
9059         tevent_req_done(req);
9060 }
9061
9062 NTSTATUS dcerpc_spoolss_DeletePrinterIC_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9063 {
9064         struct dcerpc_spoolss_DeletePrinterIC_r_state *state =
9065                 tevent_req_data(req,
9066                 struct dcerpc_spoolss_DeletePrinterIC_r_state);
9067         NTSTATUS status;
9068
9069         if (tevent_req_is_nterror(req, &status)) {
9070                 tevent_req_received(req);
9071                 return status;
9072         }
9073
9074         talloc_steal(mem_ctx, state->out_mem_ctx);
9075
9076         tevent_req_received(req);
9077         return NT_STATUS_OK;
9078 }
9079
9080 NTSTATUS dcerpc_spoolss_DeletePrinterIC_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterIC *r)
9081 {
9082         NTSTATUS status;
9083
9084         status = dcerpc_binding_handle_call(h,
9085                         NULL, &ndr_table_spoolss,
9086                         NDR_SPOOLSS_DELETEPRINTERIC, mem_ctx, r);
9087
9088         return status;
9089 }
9090
9091 NTSTATUS dcerpc_spoolss_DeletePrinterIC_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterIC *r)
9092 {
9093         NTSTATUS status;
9094
9095         status = dcerpc_spoolss_DeletePrinterIC_r(p->binding_handle, mem_ctx, r);
9096
9097         if (NT_STATUS_IS_RPC(status)) {
9098                 status = NT_STATUS_NET_WRITE_FAULT;
9099         }
9100
9101         return status;
9102 }
9103
9104 struct dcerpc_spoolss_DeletePrinterIC_state {
9105         struct spoolss_DeletePrinterIC orig;
9106         struct spoolss_DeletePrinterIC tmp;
9107         TALLOC_CTX *out_mem_ctx;
9108 };
9109
9110 static void dcerpc_spoolss_DeletePrinterIC_done(struct tevent_req *subreq);
9111
9112 struct tevent_req *dcerpc_spoolss_DeletePrinterIC_send(TALLOC_CTX *mem_ctx,
9113                                                        struct tevent_context *ev,
9114                                                        struct dcerpc_binding_handle *h,
9115                                                        struct policy_handle *_gdi_handle /* [in,out] [ref] */)
9116 {
9117         struct tevent_req *req;
9118         struct dcerpc_spoolss_DeletePrinterIC_state *state;
9119         struct tevent_req *subreq;
9120
9121         req = tevent_req_create(mem_ctx, &state,
9122                                 struct dcerpc_spoolss_DeletePrinterIC_state);
9123         if (req == NULL) {
9124                 return NULL;
9125         }
9126         state->out_mem_ctx = NULL;
9127
9128         /* In parameters */
9129         state->orig.in.gdi_handle = _gdi_handle;
9130
9131         /* Out parameters */
9132         state->orig.out.gdi_handle = _gdi_handle;
9133
9134         /* Result */
9135         ZERO_STRUCT(state->orig.out.result);
9136
9137         state->out_mem_ctx = talloc_named_const(state, 0,
9138                              "dcerpc_spoolss_DeletePrinterIC_out_memory");
9139         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9140                 return tevent_req_post(req, ev);
9141         }
9142
9143         /* make a temporary copy, that we pass to the dispatch function */
9144         state->tmp = state->orig;
9145
9146         subreq = dcerpc_spoolss_DeletePrinterIC_r_send(state, ev, h, &state->tmp);
9147         if (tevent_req_nomem(subreq, req)) {
9148                 return tevent_req_post(req, ev);
9149         }
9150         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterIC_done, req);
9151         return req;
9152 }
9153
9154 static void dcerpc_spoolss_DeletePrinterIC_done(struct tevent_req *subreq)
9155 {
9156         struct tevent_req *req = tevent_req_callback_data(
9157                 subreq, struct tevent_req);
9158         struct dcerpc_spoolss_DeletePrinterIC_state *state = tevent_req_data(
9159                 req, struct dcerpc_spoolss_DeletePrinterIC_state);
9160         NTSTATUS status;
9161         TALLOC_CTX *mem_ctx;
9162
9163         if (state->out_mem_ctx) {
9164                 mem_ctx = state->out_mem_ctx;
9165         } else {
9166                 mem_ctx = state;
9167         }
9168
9169         status = dcerpc_spoolss_DeletePrinterIC_r_recv(subreq, mem_ctx);
9170         TALLOC_FREE(subreq);
9171         if (!NT_STATUS_IS_OK(status)) {
9172                 tevent_req_nterror(req, status);
9173                 return;
9174         }
9175
9176         /* Copy out parameters */
9177         *state->orig.out.gdi_handle = *state->tmp.out.gdi_handle;
9178
9179         /* Copy result */
9180         state->orig.out.result = state->tmp.out.result;
9181
9182         /* Reset temporary structure */
9183         ZERO_STRUCT(state->tmp);
9184
9185         tevent_req_done(req);
9186 }
9187
9188 NTSTATUS dcerpc_spoolss_DeletePrinterIC_recv(struct tevent_req *req,
9189                                              TALLOC_CTX *mem_ctx,
9190                                              WERROR *result)
9191 {
9192         struct dcerpc_spoolss_DeletePrinterIC_state *state = tevent_req_data(
9193                 req, struct dcerpc_spoolss_DeletePrinterIC_state);
9194         NTSTATUS status;
9195
9196         if (tevent_req_is_nterror(req, &status)) {
9197                 tevent_req_received(req);
9198                 return status;
9199         }
9200
9201         /* Steal possible out parameters to the callers context */
9202         talloc_steal(mem_ctx, state->out_mem_ctx);
9203
9204         /* Return result */
9205         *result = state->orig.out.result;
9206
9207         tevent_req_received(req);
9208         return NT_STATUS_OK;
9209 }
9210
9211 NTSTATUS dcerpc_spoolss_DeletePrinterIC(struct dcerpc_binding_handle *h,
9212                                         TALLOC_CTX *mem_ctx,
9213                                         struct policy_handle *_gdi_handle /* [in,out] [ref] */,
9214                                         WERROR *result)
9215 {
9216         struct spoolss_DeletePrinterIC r;
9217         NTSTATUS status;
9218
9219         /* In parameters */
9220         r.in.gdi_handle = _gdi_handle;
9221
9222         status = dcerpc_spoolss_DeletePrinterIC_r(h, mem_ctx, &r);
9223         if (!NT_STATUS_IS_OK(status)) {
9224                 return status;
9225         }
9226
9227         /* Return variables */
9228         *_gdi_handle = *r.out.gdi_handle;
9229
9230         /* Return result */
9231         *result = r.out.result;
9232
9233         return NT_STATUS_OK;
9234 }
9235
9236 struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state {
9237         TALLOC_CTX *out_mem_ctx;
9238 };
9239
9240 static void dcerpc_spoolss_EnumPrintProcDataTypes_r_done(struct tevent_req *subreq);
9241
9242 struct tevent_req *dcerpc_spoolss_EnumPrintProcDataTypes_r_send(TALLOC_CTX *mem_ctx,
9243         struct tevent_context *ev,
9244         struct dcerpc_binding_handle *h,
9245         struct spoolss_EnumPrintProcDataTypes *r)
9246 {
9247         struct tevent_req *req;
9248         struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state *state;
9249         struct tevent_req *subreq;
9250
9251         req = tevent_req_create(mem_ctx, &state,
9252                                 struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state);
9253         if (req == NULL) {
9254                 return NULL;
9255         }
9256
9257         state->out_mem_ctx = talloc_new(state);
9258         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9259                 return tevent_req_post(req, ev);
9260         }
9261
9262         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9263                         NULL, &ndr_table_spoolss,
9264                         NDR_SPOOLSS_ENUMPRINTPROCDATATYPES, state->out_mem_ctx, r);
9265         if (tevent_req_nomem(subreq, req)) {
9266                 return tevent_req_post(req, ev);
9267         }
9268         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrintProcDataTypes_r_done, req);
9269
9270         return req;
9271 }
9272
9273 static void dcerpc_spoolss_EnumPrintProcDataTypes_r_done(struct tevent_req *subreq)
9274 {
9275         struct tevent_req *req =
9276                 tevent_req_callback_data(subreq,
9277                 struct tevent_req);
9278         NTSTATUS status;
9279
9280         status = dcerpc_binding_handle_call_recv(subreq);
9281         if (!NT_STATUS_IS_OK(status)) {
9282                 tevent_req_nterror(req, status);
9283                 return;
9284         }
9285
9286         tevent_req_done(req);
9287 }
9288
9289 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9290 {
9291         struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state *state =
9292                 tevent_req_data(req,
9293                 struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state);
9294         NTSTATUS status;
9295
9296         if (tevent_req_is_nterror(req, &status)) {
9297                 tevent_req_received(req);
9298                 return status;
9299         }
9300
9301         talloc_steal(mem_ctx, state->out_mem_ctx);
9302
9303         tevent_req_received(req);
9304         return NT_STATUS_OK;
9305 }
9306
9307 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrintProcDataTypes *r)
9308 {
9309         NTSTATUS status;
9310
9311         status = dcerpc_binding_handle_call(h,
9312                         NULL, &ndr_table_spoolss,
9313                         NDR_SPOOLSS_ENUMPRINTPROCDATATYPES, mem_ctx, r);
9314
9315         return status;
9316 }
9317
9318 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrintProcDataTypes *r)
9319 {
9320         NTSTATUS status;
9321
9322         status = dcerpc_spoolss_EnumPrintProcDataTypes_r(p->binding_handle, mem_ctx, r);
9323
9324         if (NT_STATUS_IS_RPC(status)) {
9325                 status = NT_STATUS_NET_WRITE_FAULT;
9326         }
9327
9328         return status;
9329 }
9330
9331 struct dcerpc_spoolss_EnumPrintProcDataTypes_state {
9332         struct spoolss_EnumPrintProcDataTypes orig;
9333         struct spoolss_EnumPrintProcDataTypes tmp;
9334         TALLOC_CTX *out_mem_ctx;
9335 };
9336
9337 static void dcerpc_spoolss_EnumPrintProcDataTypes_done(struct tevent_req *subreq);
9338
9339 struct tevent_req *dcerpc_spoolss_EnumPrintProcDataTypes_send(TALLOC_CTX *mem_ctx,
9340                                                               struct tevent_context *ev,
9341                                                               struct dcerpc_binding_handle *h,
9342                                                               const char *_servername /* [in] [unique,charset(UTF16)] */,
9343                                                               const char *_print_processor_name /* [in] [unique,charset(UTF16)] */,
9344                                                               uint32_t _level /* [in]  */,
9345                                                               DATA_BLOB *_buffer /* [in] [unique] */,
9346                                                               uint32_t _offered /* [in]  */,
9347                                                               uint32_t *_count /* [out] [ref] */,
9348                                                               union spoolss_PrintProcDataTypesInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
9349                                                               uint32_t *_needed /* [out] [ref] */)
9350 {
9351         struct tevent_req *req;
9352         struct dcerpc_spoolss_EnumPrintProcDataTypes_state *state;
9353         struct tevent_req *subreq;
9354
9355         req = tevent_req_create(mem_ctx, &state,
9356                                 struct dcerpc_spoolss_EnumPrintProcDataTypes_state);
9357         if (req == NULL) {
9358                 return NULL;
9359         }
9360         state->out_mem_ctx = NULL;
9361
9362         /* In parameters */
9363         state->orig.in.servername = _servername;
9364         state->orig.in.print_processor_name = _print_processor_name;
9365         state->orig.in.level = _level;
9366         state->orig.in.buffer = _buffer;
9367         state->orig.in.offered = _offered;
9368
9369         /* Out parameters */
9370         state->orig.out.count = _count;
9371         state->orig.out.info = _info;
9372         state->orig.out.needed = _needed;
9373
9374         /* Result */
9375         ZERO_STRUCT(state->orig.out.result);
9376
9377         state->out_mem_ctx = talloc_named_const(state, 0,
9378                              "dcerpc_spoolss_EnumPrintProcDataTypes_out_memory");
9379         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9380                 return tevent_req_post(req, ev);
9381         }
9382
9383         /* make a temporary copy, that we pass to the dispatch function */
9384         state->tmp = state->orig;
9385
9386         subreq = dcerpc_spoolss_EnumPrintProcDataTypes_r_send(state, ev, h, &state->tmp);
9387         if (tevent_req_nomem(subreq, req)) {
9388                 return tevent_req_post(req, ev);
9389         }
9390         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrintProcDataTypes_done, req);
9391         return req;
9392 }
9393
9394 static void dcerpc_spoolss_EnumPrintProcDataTypes_done(struct tevent_req *subreq)
9395 {
9396         struct tevent_req *req = tevent_req_callback_data(
9397                 subreq, struct tevent_req);
9398         struct dcerpc_spoolss_EnumPrintProcDataTypes_state *state = tevent_req_data(
9399                 req, struct dcerpc_spoolss_EnumPrintProcDataTypes_state);
9400         NTSTATUS status;
9401         TALLOC_CTX *mem_ctx;
9402
9403         if (state->out_mem_ctx) {
9404                 mem_ctx = state->out_mem_ctx;
9405         } else {
9406                 mem_ctx = state;
9407         }
9408
9409         status = dcerpc_spoolss_EnumPrintProcDataTypes_r_recv(subreq, mem_ctx);
9410         TALLOC_FREE(subreq);
9411         if (!NT_STATUS_IS_OK(status)) {
9412                 tevent_req_nterror(req, status);
9413                 return;
9414         }
9415
9416         /* Copy out parameters */
9417         *state->orig.out.count = *state->tmp.out.count;
9418         *state->orig.out.info = *state->tmp.out.info;
9419         *state->orig.out.needed = *state->tmp.out.needed;
9420
9421         /* Copy result */
9422         state->orig.out.result = state->tmp.out.result;
9423
9424         /* Reset temporary structure */
9425         ZERO_STRUCT(state->tmp);
9426
9427         tevent_req_done(req);
9428 }
9429
9430 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_recv(struct tevent_req *req,
9431                                                     TALLOC_CTX *mem_ctx,
9432                                                     WERROR *result)
9433 {
9434         struct dcerpc_spoolss_EnumPrintProcDataTypes_state *state = tevent_req_data(
9435                 req, struct dcerpc_spoolss_EnumPrintProcDataTypes_state);
9436         NTSTATUS status;
9437
9438         if (tevent_req_is_nterror(req, &status)) {
9439                 tevent_req_received(req);
9440                 return status;
9441         }
9442
9443         /* Steal possible out parameters to the callers context */
9444         talloc_steal(mem_ctx, state->out_mem_ctx);
9445
9446         /* Return result */
9447         *result = state->orig.out.result;
9448
9449         tevent_req_received(req);
9450         return NT_STATUS_OK;
9451 }
9452
9453 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes(struct dcerpc_binding_handle *h,
9454                                                TALLOC_CTX *mem_ctx,
9455                                                const char *_servername /* [in] [unique,charset(UTF16)] */,
9456                                                const char *_print_processor_name /* [in] [unique,charset(UTF16)] */,
9457                                                uint32_t _level /* [in]  */,
9458                                                DATA_BLOB *_buffer /* [in] [unique] */,
9459                                                uint32_t _offered /* [in]  */,
9460                                                uint32_t *_count /* [out] [ref] */,
9461                                                union spoolss_PrintProcDataTypesInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
9462                                                uint32_t *_needed /* [out] [ref] */,
9463                                                WERROR *result)
9464 {
9465         struct spoolss_EnumPrintProcDataTypes r;
9466         NTSTATUS status;
9467
9468         /* In parameters */
9469         r.in.servername = _servername;
9470         r.in.print_processor_name = _print_processor_name;
9471         r.in.level = _level;
9472         r.in.buffer = _buffer;
9473         r.in.offered = _offered;
9474
9475         status = dcerpc_spoolss_EnumPrintProcDataTypes_r(h, mem_ctx, &r);
9476         if (!NT_STATUS_IS_OK(status)) {
9477                 return status;
9478         }
9479
9480         /* Return variables */
9481         *_count = *r.out.count;
9482         *_info = *r.out.info;
9483         *_needed = *r.out.needed;
9484
9485         /* Return result */
9486         *result = r.out.result;
9487
9488         return NT_STATUS_OK;
9489 }
9490
9491 struct dcerpc_spoolss_ResetPrinter_r_state {
9492         TALLOC_CTX *out_mem_ctx;
9493 };
9494
9495 static void dcerpc_spoolss_ResetPrinter_r_done(struct tevent_req *subreq);
9496
9497 struct tevent_req *dcerpc_spoolss_ResetPrinter_r_send(TALLOC_CTX *mem_ctx,
9498         struct tevent_context *ev,
9499         struct dcerpc_binding_handle *h,
9500         struct spoolss_ResetPrinter *r)
9501 {
9502         struct tevent_req *req;
9503         struct dcerpc_spoolss_ResetPrinter_r_state *state;
9504         struct tevent_req *subreq;
9505
9506         req = tevent_req_create(mem_ctx, &state,
9507                                 struct dcerpc_spoolss_ResetPrinter_r_state);
9508         if (req == NULL) {
9509                 return NULL;
9510         }
9511
9512         state->out_mem_ctx = NULL;
9513         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9514                         NULL, &ndr_table_spoolss,
9515                         NDR_SPOOLSS_RESETPRINTER, state, r);
9516         if (tevent_req_nomem(subreq, req)) {
9517                 return tevent_req_post(req, ev);
9518         }
9519         tevent_req_set_callback(subreq, dcerpc_spoolss_ResetPrinter_r_done, req);
9520
9521         return req;
9522 }
9523
9524 static void dcerpc_spoolss_ResetPrinter_r_done(struct tevent_req *subreq)
9525 {
9526         struct tevent_req *req =
9527                 tevent_req_callback_data(subreq,
9528                 struct tevent_req);
9529         NTSTATUS status;
9530
9531         status = dcerpc_binding_handle_call_recv(subreq);
9532         if (!NT_STATUS_IS_OK(status)) {
9533                 tevent_req_nterror(req, status);
9534                 return;
9535         }
9536
9537         tevent_req_done(req);
9538 }
9539
9540 NTSTATUS dcerpc_spoolss_ResetPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9541 {
9542         struct dcerpc_spoolss_ResetPrinter_r_state *state =
9543                 tevent_req_data(req,
9544                 struct dcerpc_spoolss_ResetPrinter_r_state);
9545         NTSTATUS status;
9546
9547         if (tevent_req_is_nterror(req, &status)) {
9548                 tevent_req_received(req);
9549                 return status;
9550         }
9551
9552         talloc_steal(mem_ctx, state->out_mem_ctx);
9553
9554         tevent_req_received(req);
9555         return NT_STATUS_OK;
9556 }
9557
9558 NTSTATUS dcerpc_spoolss_ResetPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ResetPrinter *r)
9559 {
9560         NTSTATUS status;
9561
9562         status = dcerpc_binding_handle_call(h,
9563                         NULL, &ndr_table_spoolss,
9564                         NDR_SPOOLSS_RESETPRINTER, mem_ctx, r);
9565
9566         return status;
9567 }
9568
9569 NTSTATUS dcerpc_spoolss_ResetPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ResetPrinter *r)
9570 {
9571         NTSTATUS status;
9572
9573         status = dcerpc_spoolss_ResetPrinter_r(p->binding_handle, mem_ctx, r);
9574
9575         if (NT_STATUS_IS_RPC(status)) {
9576                 status = NT_STATUS_NET_WRITE_FAULT;
9577         }
9578
9579         return status;
9580 }
9581
9582 struct dcerpc_spoolss_ResetPrinter_state {
9583         struct spoolss_ResetPrinter orig;
9584         struct spoolss_ResetPrinter tmp;
9585         TALLOC_CTX *out_mem_ctx;
9586 };
9587
9588 static void dcerpc_spoolss_ResetPrinter_done(struct tevent_req *subreq);
9589
9590 struct tevent_req *dcerpc_spoolss_ResetPrinter_send(TALLOC_CTX *mem_ctx,
9591                                                     struct tevent_context *ev,
9592                                                     struct dcerpc_binding_handle *h,
9593                                                     struct policy_handle *_handle /* [in] [ref] */,
9594                                                     const char *_data_type /* [in] [unique,charset(UTF16)] */,
9595                                                     struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */)
9596 {
9597         struct tevent_req *req;
9598         struct dcerpc_spoolss_ResetPrinter_state *state;
9599         struct tevent_req *subreq;
9600
9601         req = tevent_req_create(mem_ctx, &state,
9602                                 struct dcerpc_spoolss_ResetPrinter_state);
9603         if (req == NULL) {
9604                 return NULL;
9605         }
9606         state->out_mem_ctx = NULL;
9607
9608         /* In parameters */
9609         state->orig.in.handle = _handle;
9610         state->orig.in.data_type = _data_type;
9611         state->orig.in.devmode_ctr = _devmode_ctr;
9612
9613         /* Out parameters */
9614
9615         /* Result */
9616         ZERO_STRUCT(state->orig.out.result);
9617
9618         /* make a temporary copy, that we pass to the dispatch function */
9619         state->tmp = state->orig;
9620
9621         subreq = dcerpc_spoolss_ResetPrinter_r_send(state, ev, h, &state->tmp);
9622         if (tevent_req_nomem(subreq, req)) {
9623                 return tevent_req_post(req, ev);
9624         }
9625         tevent_req_set_callback(subreq, dcerpc_spoolss_ResetPrinter_done, req);
9626         return req;
9627 }
9628
9629 static void dcerpc_spoolss_ResetPrinter_done(struct tevent_req *subreq)
9630 {
9631         struct tevent_req *req = tevent_req_callback_data(
9632                 subreq, struct tevent_req);
9633         struct dcerpc_spoolss_ResetPrinter_state *state = tevent_req_data(
9634                 req, struct dcerpc_spoolss_ResetPrinter_state);
9635         NTSTATUS status;
9636         TALLOC_CTX *mem_ctx;
9637
9638         if (state->out_mem_ctx) {
9639                 mem_ctx = state->out_mem_ctx;
9640         } else {
9641                 mem_ctx = state;
9642         }
9643
9644         status = dcerpc_spoolss_ResetPrinter_r_recv(subreq, mem_ctx);
9645         TALLOC_FREE(subreq);
9646         if (!NT_STATUS_IS_OK(status)) {
9647                 tevent_req_nterror(req, status);
9648                 return;
9649         }
9650
9651         /* Copy out parameters */
9652
9653         /* Copy result */
9654         state->orig.out.result = state->tmp.out.result;
9655
9656         /* Reset temporary structure */
9657         ZERO_STRUCT(state->tmp);
9658
9659         tevent_req_done(req);
9660 }
9661
9662 NTSTATUS dcerpc_spoolss_ResetPrinter_recv(struct tevent_req *req,
9663                                           TALLOC_CTX *mem_ctx,
9664                                           WERROR *result)
9665 {
9666         struct dcerpc_spoolss_ResetPrinter_state *state = tevent_req_data(
9667                 req, struct dcerpc_spoolss_ResetPrinter_state);
9668         NTSTATUS status;
9669
9670         if (tevent_req_is_nterror(req, &status)) {
9671                 tevent_req_received(req);
9672                 return status;
9673         }
9674
9675         /* Steal possible out parameters to the callers context */
9676         talloc_steal(mem_ctx, state->out_mem_ctx);
9677
9678         /* Return result */
9679         *result = state->orig.out.result;
9680
9681         tevent_req_received(req);
9682         return NT_STATUS_OK;
9683 }
9684
9685 NTSTATUS dcerpc_spoolss_ResetPrinter(struct dcerpc_binding_handle *h,
9686                                      TALLOC_CTX *mem_ctx,
9687                                      struct policy_handle *_handle /* [in] [ref] */,
9688                                      const char *_data_type /* [in] [unique,charset(UTF16)] */,
9689                                      struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
9690                                      WERROR *result)
9691 {
9692         struct spoolss_ResetPrinter r;
9693         NTSTATUS status;
9694
9695         /* In parameters */
9696         r.in.handle = _handle;
9697         r.in.data_type = _data_type;
9698         r.in.devmode_ctr = _devmode_ctr;
9699
9700         status = dcerpc_spoolss_ResetPrinter_r(h, mem_ctx, &r);
9701         if (!NT_STATUS_IS_OK(status)) {
9702                 return status;
9703         }
9704
9705         /* Return variables */
9706
9707         /* Return result */
9708         *result = r.out.result;
9709
9710         return NT_STATUS_OK;
9711 }
9712
9713 struct dcerpc_spoolss_GetPrinterDriver2_r_state {
9714         TALLOC_CTX *out_mem_ctx;
9715 };
9716
9717 static void dcerpc_spoolss_GetPrinterDriver2_r_done(struct tevent_req *subreq);
9718
9719 struct tevent_req *dcerpc_spoolss_GetPrinterDriver2_r_send(TALLOC_CTX *mem_ctx,
9720         struct tevent_context *ev,
9721         struct dcerpc_binding_handle *h,
9722         struct spoolss_GetPrinterDriver2 *r)
9723 {
9724         struct tevent_req *req;
9725         struct dcerpc_spoolss_GetPrinterDriver2_r_state *state;
9726         struct tevent_req *subreq;
9727
9728         req = tevent_req_create(mem_ctx, &state,
9729                                 struct dcerpc_spoolss_GetPrinterDriver2_r_state);
9730         if (req == NULL) {
9731                 return NULL;
9732         }
9733
9734         state->out_mem_ctx = talloc_new(state);
9735         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9736                 return tevent_req_post(req, ev);
9737         }
9738
9739         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9740                         NULL, &ndr_table_spoolss,
9741                         NDR_SPOOLSS_GETPRINTERDRIVER2, state->out_mem_ctx, r);
9742         if (tevent_req_nomem(subreq, req)) {
9743                 return tevent_req_post(req, ev);
9744         }
9745         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriver2_r_done, req);
9746
9747         return req;
9748 }
9749
9750 static void dcerpc_spoolss_GetPrinterDriver2_r_done(struct tevent_req *subreq)
9751 {
9752         struct tevent_req *req =
9753                 tevent_req_callback_data(subreq,
9754                 struct tevent_req);
9755         NTSTATUS status;
9756
9757         status = dcerpc_binding_handle_call_recv(subreq);
9758         if (!NT_STATUS_IS_OK(status)) {
9759                 tevent_req_nterror(req, status);
9760                 return;
9761         }
9762
9763         tevent_req_done(req);
9764 }
9765
9766 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9767 {
9768         struct dcerpc_spoolss_GetPrinterDriver2_r_state *state =
9769                 tevent_req_data(req,
9770                 struct dcerpc_spoolss_GetPrinterDriver2_r_state);
9771         NTSTATUS status;
9772
9773         if (tevent_req_is_nterror(req, &status)) {
9774                 tevent_req_received(req);
9775                 return status;
9776         }
9777
9778         talloc_steal(mem_ctx, state->out_mem_ctx);
9779
9780         tevent_req_received(req);
9781         return NT_STATUS_OK;
9782 }
9783
9784 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriver2 *r)
9785 {
9786         NTSTATUS status;
9787
9788         status = dcerpc_binding_handle_call(h,
9789                         NULL, &ndr_table_spoolss,
9790                         NDR_SPOOLSS_GETPRINTERDRIVER2, mem_ctx, r);
9791
9792         return status;
9793 }
9794
9795 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriver2 *r)
9796 {
9797         NTSTATUS status;
9798
9799         status = dcerpc_spoolss_GetPrinterDriver2_r(p->binding_handle, mem_ctx, r);
9800
9801         if (NT_STATUS_IS_RPC(status)) {
9802                 status = NT_STATUS_NET_WRITE_FAULT;
9803         }
9804
9805         return status;
9806 }
9807
9808 struct dcerpc_spoolss_GetPrinterDriver2_state {
9809         struct spoolss_GetPrinterDriver2 orig;
9810         struct spoolss_GetPrinterDriver2 tmp;
9811         TALLOC_CTX *out_mem_ctx;
9812 };
9813
9814 static void dcerpc_spoolss_GetPrinterDriver2_done(struct tevent_req *subreq);
9815
9816 struct tevent_req *dcerpc_spoolss_GetPrinterDriver2_send(TALLOC_CTX *mem_ctx,
9817                                                          struct tevent_context *ev,
9818                                                          struct dcerpc_binding_handle *h,
9819                                                          struct policy_handle *_handle /* [in] [ref] */,
9820                                                          const char *_architecture /* [in] [unique,charset(UTF16)] */,
9821                                                          uint32_t _level /* [in]  */,
9822                                                          DATA_BLOB *_buffer /* [in] [unique] */,
9823                                                          uint32_t _offered /* [in]  */,
9824                                                          uint32_t _client_major_version /* [in]  */,
9825                                                          uint32_t _client_minor_version /* [in]  */,
9826                                                          union spoolss_DriverInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
9827                                                          uint32_t *_needed /* [out] [ref] */,
9828                                                          uint32_t *_server_major_version /* [out] [ref] */,
9829                                                          uint32_t *_server_minor_version /* [out] [ref] */)
9830 {
9831         struct tevent_req *req;
9832         struct dcerpc_spoolss_GetPrinterDriver2_state *state;
9833         struct tevent_req *subreq;
9834
9835         req = tevent_req_create(mem_ctx, &state,
9836                                 struct dcerpc_spoolss_GetPrinterDriver2_state);
9837         if (req == NULL) {
9838                 return NULL;
9839         }
9840         state->out_mem_ctx = NULL;
9841
9842         /* In parameters */
9843         state->orig.in.handle = _handle;
9844         state->orig.in.architecture = _architecture;
9845         state->orig.in.level = _level;
9846         state->orig.in.buffer = _buffer;
9847         state->orig.in.offered = _offered;
9848         state->orig.in.client_major_version = _client_major_version;
9849         state->orig.in.client_minor_version = _client_minor_version;
9850
9851         /* Out parameters */
9852         state->orig.out.info = _info;
9853         state->orig.out.needed = _needed;
9854         state->orig.out.server_major_version = _server_major_version;
9855         state->orig.out.server_minor_version = _server_minor_version;
9856
9857         /* Result */
9858         ZERO_STRUCT(state->orig.out.result);
9859
9860         state->out_mem_ctx = talloc_named_const(state, 0,
9861                              "dcerpc_spoolss_GetPrinterDriver2_out_memory");
9862         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9863                 return tevent_req_post(req, ev);
9864         }
9865
9866         /* make a temporary copy, that we pass to the dispatch function */
9867         state->tmp = state->orig;
9868
9869         subreq = dcerpc_spoolss_GetPrinterDriver2_r_send(state, ev, h, &state->tmp);
9870         if (tevent_req_nomem(subreq, req)) {
9871                 return tevent_req_post(req, ev);
9872         }
9873         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriver2_done, req);
9874         return req;
9875 }
9876
9877 static void dcerpc_spoolss_GetPrinterDriver2_done(struct tevent_req *subreq)
9878 {
9879         struct tevent_req *req = tevent_req_callback_data(
9880                 subreq, struct tevent_req);
9881         struct dcerpc_spoolss_GetPrinterDriver2_state *state = tevent_req_data(
9882                 req, struct dcerpc_spoolss_GetPrinterDriver2_state);
9883         NTSTATUS status;
9884         TALLOC_CTX *mem_ctx;
9885
9886         if (state->out_mem_ctx) {
9887                 mem_ctx = state->out_mem_ctx;
9888         } else {
9889                 mem_ctx = state;
9890         }
9891
9892         status = dcerpc_spoolss_GetPrinterDriver2_r_recv(subreq, mem_ctx);
9893         TALLOC_FREE(subreq);
9894         if (!NT_STATUS_IS_OK(status)) {
9895                 tevent_req_nterror(req, status);
9896                 return;
9897         }
9898
9899         /* Copy out parameters */
9900         if (state->orig.out.info && state->tmp.out.info) {
9901                 *state->orig.out.info = *state->tmp.out.info;
9902         }
9903         *state->orig.out.needed = *state->tmp.out.needed;
9904         *state->orig.out.server_major_version = *state->tmp.out.server_major_version;
9905         *state->orig.out.server_minor_version = *state->tmp.out.server_minor_version;
9906
9907         /* Copy result */
9908         state->orig.out.result = state->tmp.out.result;
9909
9910         /* Reset temporary structure */
9911         ZERO_STRUCT(state->tmp);
9912
9913         tevent_req_done(req);
9914 }
9915
9916 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_recv(struct tevent_req *req,
9917                                                TALLOC_CTX *mem_ctx,
9918                                                WERROR *result)
9919 {
9920         struct dcerpc_spoolss_GetPrinterDriver2_state *state = tevent_req_data(
9921                 req, struct dcerpc_spoolss_GetPrinterDriver2_state);
9922         NTSTATUS status;
9923
9924         if (tevent_req_is_nterror(req, &status)) {
9925                 tevent_req_received(req);
9926                 return status;
9927         }
9928
9929         /* Steal possible out parameters to the callers context */
9930         talloc_steal(mem_ctx, state->out_mem_ctx);
9931
9932         /* Return result */
9933         *result = state->orig.out.result;
9934
9935         tevent_req_received(req);
9936         return NT_STATUS_OK;
9937 }
9938
9939 NTSTATUS dcerpc_spoolss_GetPrinterDriver2(struct dcerpc_binding_handle *h,
9940                                           TALLOC_CTX *mem_ctx,
9941                                           struct policy_handle *_handle /* [in] [ref] */,
9942                                           const char *_architecture /* [in] [unique,charset(UTF16)] */,
9943                                           uint32_t _level /* [in]  */,
9944                                           DATA_BLOB *_buffer /* [in] [unique] */,
9945                                           uint32_t _offered /* [in]  */,
9946                                           uint32_t _client_major_version /* [in]  */,
9947                                           uint32_t _client_minor_version /* [in]  */,
9948                                           union spoolss_DriverInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
9949                                           uint32_t *_needed /* [out] [ref] */,
9950                                           uint32_t *_server_major_version /* [out] [ref] */,
9951                                           uint32_t *_server_minor_version /* [out] [ref] */,
9952                                           WERROR *result)
9953 {
9954         struct spoolss_GetPrinterDriver2 r;
9955         NTSTATUS status;
9956
9957         /* In parameters */
9958         r.in.handle = _handle;
9959         r.in.architecture = _architecture;
9960         r.in.level = _level;
9961         r.in.buffer = _buffer;
9962         r.in.offered = _offered;
9963         r.in.client_major_version = _client_major_version;
9964         r.in.client_minor_version = _client_minor_version;
9965
9966         status = dcerpc_spoolss_GetPrinterDriver2_r(h, mem_ctx, &r);
9967         if (!NT_STATUS_IS_OK(status)) {
9968                 return status;
9969         }
9970
9971         /* Return variables */
9972         if (_info && r.out.info) {
9973                 *_info = *r.out.info;
9974         }
9975         *_needed = *r.out.needed;
9976         *_server_major_version = *r.out.server_major_version;
9977         *_server_minor_version = *r.out.server_minor_version;
9978
9979         /* Return result */
9980         *result = r.out.result;
9981
9982         return NT_STATUS_OK;
9983 }
9984
9985 struct dcerpc_spoolss_FindClosePrinterNotify_r_state {
9986         TALLOC_CTX *out_mem_ctx;
9987 };
9988
9989 static void dcerpc_spoolss_FindClosePrinterNotify_r_done(struct tevent_req *subreq);
9990
9991 struct tevent_req *dcerpc_spoolss_FindClosePrinterNotify_r_send(TALLOC_CTX *mem_ctx,
9992         struct tevent_context *ev,
9993         struct dcerpc_binding_handle *h,
9994         struct spoolss_FindClosePrinterNotify *r)
9995 {
9996         struct tevent_req *req;
9997         struct dcerpc_spoolss_FindClosePrinterNotify_r_state *state;
9998         struct tevent_req *subreq;
9999
10000         req = tevent_req_create(mem_ctx, &state,
10001                                 struct dcerpc_spoolss_FindClosePrinterNotify_r_state);
10002         if (req == NULL) {
10003                 return NULL;
10004         }
10005
10006         state->out_mem_ctx = NULL;
10007         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10008                         NULL, &ndr_table_spoolss,
10009                         NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY, state, r);
10010         if (tevent_req_nomem(subreq, req)) {
10011                 return tevent_req_post(req, ev);
10012         }
10013         tevent_req_set_callback(subreq, dcerpc_spoolss_FindClosePrinterNotify_r_done, req);
10014
10015         return req;
10016 }
10017
10018 static void dcerpc_spoolss_FindClosePrinterNotify_r_done(struct tevent_req *subreq)
10019 {
10020         struct tevent_req *req =
10021                 tevent_req_callback_data(subreq,
10022                 struct tevent_req);
10023         NTSTATUS status;
10024
10025         status = dcerpc_binding_handle_call_recv(subreq);
10026         if (!NT_STATUS_IS_OK(status)) {
10027                 tevent_req_nterror(req, status);
10028                 return;
10029         }
10030
10031         tevent_req_done(req);
10032 }
10033
10034 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10035 {
10036         struct dcerpc_spoolss_FindClosePrinterNotify_r_state *state =
10037                 tevent_req_data(req,
10038                 struct dcerpc_spoolss_FindClosePrinterNotify_r_state);
10039         NTSTATUS status;
10040
10041         if (tevent_req_is_nterror(req, &status)) {
10042                 tevent_req_received(req);
10043                 return status;
10044         }
10045
10046         talloc_steal(mem_ctx, state->out_mem_ctx);
10047
10048         tevent_req_received(req);
10049         return NT_STATUS_OK;
10050 }
10051
10052 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_FindClosePrinterNotify *r)
10053 {
10054         NTSTATUS status;
10055
10056         status = dcerpc_binding_handle_call(h,
10057                         NULL, &ndr_table_spoolss,
10058                         NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY, mem_ctx, r);
10059
10060         return status;
10061 }
10062
10063 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_FindClosePrinterNotify *r)
10064 {
10065         NTSTATUS status;
10066
10067         status = dcerpc_spoolss_FindClosePrinterNotify_r(p->binding_handle, mem_ctx, r);
10068
10069         if (NT_STATUS_IS_RPC(status)) {
10070                 status = NT_STATUS_NET_WRITE_FAULT;
10071         }
10072
10073         return status;
10074 }
10075
10076 struct dcerpc_spoolss_FindClosePrinterNotify_state {
10077         struct spoolss_FindClosePrinterNotify orig;
10078         struct spoolss_FindClosePrinterNotify tmp;
10079         TALLOC_CTX *out_mem_ctx;
10080 };
10081
10082 static void dcerpc_spoolss_FindClosePrinterNotify_done(struct tevent_req *subreq);
10083
10084 struct tevent_req *dcerpc_spoolss_FindClosePrinterNotify_send(TALLOC_CTX *mem_ctx,
10085                                                               struct tevent_context *ev,
10086                                                               struct dcerpc_binding_handle *h,
10087                                                               struct policy_handle *_handle /* [in] [ref] */)
10088 {
10089         struct tevent_req *req;
10090         struct dcerpc_spoolss_FindClosePrinterNotify_state *state;
10091         struct tevent_req *subreq;
10092
10093         req = tevent_req_create(mem_ctx, &state,
10094                                 struct dcerpc_spoolss_FindClosePrinterNotify_state);
10095         if (req == NULL) {
10096                 return NULL;
10097         }
10098         state->out_mem_ctx = NULL;
10099
10100         /* In parameters */
10101         state->orig.in.handle = _handle;
10102
10103         /* Out parameters */
10104
10105         /* Result */
10106         ZERO_STRUCT(state->orig.out.result);
10107
10108         /* make a temporary copy, that we pass to the dispatch function */
10109         state->tmp = state->orig;
10110
10111         subreq = dcerpc_spoolss_FindClosePrinterNotify_r_send(state, ev, h, &state->tmp);
10112         if (tevent_req_nomem(subreq, req)) {
10113                 return tevent_req_post(req, ev);
10114         }
10115         tevent_req_set_callback(subreq, dcerpc_spoolss_FindClosePrinterNotify_done, req);
10116         return req;
10117 }
10118
10119 static void dcerpc_spoolss_FindClosePrinterNotify_done(struct tevent_req *subreq)
10120 {
10121         struct tevent_req *req = tevent_req_callback_data(
10122                 subreq, struct tevent_req);
10123         struct dcerpc_spoolss_FindClosePrinterNotify_state *state = tevent_req_data(
10124                 req, struct dcerpc_spoolss_FindClosePrinterNotify_state);
10125         NTSTATUS status;
10126         TALLOC_CTX *mem_ctx;
10127
10128         if (state->out_mem_ctx) {
10129                 mem_ctx = state->out_mem_ctx;
10130         } else {
10131                 mem_ctx = state;
10132         }
10133
10134         status = dcerpc_spoolss_FindClosePrinterNotify_r_recv(subreq, mem_ctx);
10135         TALLOC_FREE(subreq);
10136         if (!NT_STATUS_IS_OK(status)) {
10137                 tevent_req_nterror(req, status);
10138                 return;
10139         }
10140
10141         /* Copy out parameters */
10142
10143         /* Copy result */
10144         state->orig.out.result = state->tmp.out.result;
10145
10146         /* Reset temporary structure */
10147         ZERO_STRUCT(state->tmp);
10148
10149         tevent_req_done(req);
10150 }
10151
10152 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_recv(struct tevent_req *req,
10153                                                     TALLOC_CTX *mem_ctx,
10154                                                     WERROR *result)
10155 {
10156         struct dcerpc_spoolss_FindClosePrinterNotify_state *state = tevent_req_data(
10157                 req, struct dcerpc_spoolss_FindClosePrinterNotify_state);
10158         NTSTATUS status;
10159
10160         if (tevent_req_is_nterror(req, &status)) {
10161                 tevent_req_received(req);
10162                 return status;
10163         }
10164
10165         /* Steal possible out parameters to the callers context */
10166         talloc_steal(mem_ctx, state->out_mem_ctx);
10167
10168         /* Return result */
10169         *result = state->orig.out.result;
10170
10171         tevent_req_received(req);
10172         return NT_STATUS_OK;
10173 }
10174
10175 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify(struct dcerpc_binding_handle *h,
10176                                                TALLOC_CTX *mem_ctx,
10177                                                struct policy_handle *_handle /* [in] [ref] */,
10178                                                WERROR *result)
10179 {
10180         struct spoolss_FindClosePrinterNotify r;
10181         NTSTATUS status;
10182
10183         /* In parameters */
10184         r.in.handle = _handle;
10185
10186         status = dcerpc_spoolss_FindClosePrinterNotify_r(h, mem_ctx, &r);
10187         if (!NT_STATUS_IS_OK(status)) {
10188                 return status;
10189         }
10190
10191         /* Return variables */
10192
10193         /* Return result */
10194         *result = r.out.result;
10195
10196         return NT_STATUS_OK;
10197 }
10198
10199 struct dcerpc_spoolss_ReplyOpenPrinter_r_state {
10200         TALLOC_CTX *out_mem_ctx;
10201 };
10202
10203 static void dcerpc_spoolss_ReplyOpenPrinter_r_done(struct tevent_req *subreq);
10204
10205 struct tevent_req *dcerpc_spoolss_ReplyOpenPrinter_r_send(TALLOC_CTX *mem_ctx,
10206         struct tevent_context *ev,
10207         struct dcerpc_binding_handle *h,
10208         struct spoolss_ReplyOpenPrinter *r)
10209 {
10210         struct tevent_req *req;
10211         struct dcerpc_spoolss_ReplyOpenPrinter_r_state *state;
10212         struct tevent_req *subreq;
10213
10214         req = tevent_req_create(mem_ctx, &state,
10215                                 struct dcerpc_spoolss_ReplyOpenPrinter_r_state);
10216         if (req == NULL) {
10217                 return NULL;
10218         }
10219
10220         state->out_mem_ctx = talloc_new(state);
10221         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10222                 return tevent_req_post(req, ev);
10223         }
10224
10225         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10226                         NULL, &ndr_table_spoolss,
10227                         NDR_SPOOLSS_REPLYOPENPRINTER, state->out_mem_ctx, r);
10228         if (tevent_req_nomem(subreq, req)) {
10229                 return tevent_req_post(req, ev);
10230         }
10231         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyOpenPrinter_r_done, req);
10232
10233         return req;
10234 }
10235
10236 static void dcerpc_spoolss_ReplyOpenPrinter_r_done(struct tevent_req *subreq)
10237 {
10238         struct tevent_req *req =
10239                 tevent_req_callback_data(subreq,
10240                 struct tevent_req);
10241         NTSTATUS status;
10242
10243         status = dcerpc_binding_handle_call_recv(subreq);
10244         if (!NT_STATUS_IS_OK(status)) {
10245                 tevent_req_nterror(req, status);
10246                 return;
10247         }
10248
10249         tevent_req_done(req);
10250 }
10251
10252 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10253 {
10254         struct dcerpc_spoolss_ReplyOpenPrinter_r_state *state =
10255                 tevent_req_data(req,
10256                 struct dcerpc_spoolss_ReplyOpenPrinter_r_state);
10257         NTSTATUS status;
10258
10259         if (tevent_req_is_nterror(req, &status)) {
10260                 tevent_req_received(req);
10261                 return status;
10262         }
10263
10264         talloc_steal(mem_ctx, state->out_mem_ctx);
10265
10266         tevent_req_received(req);
10267         return NT_STATUS_OK;
10268 }
10269
10270 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ReplyOpenPrinter *r)
10271 {
10272         NTSTATUS status;
10273
10274         status = dcerpc_binding_handle_call(h,
10275                         NULL, &ndr_table_spoolss,
10276                         NDR_SPOOLSS_REPLYOPENPRINTER, mem_ctx, r);
10277
10278         return status;
10279 }
10280
10281 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ReplyOpenPrinter *r)
10282 {
10283         NTSTATUS status;
10284
10285         status = dcerpc_spoolss_ReplyOpenPrinter_r(p->binding_handle, mem_ctx, r);
10286
10287         if (NT_STATUS_IS_RPC(status)) {
10288                 status = NT_STATUS_NET_WRITE_FAULT;
10289         }
10290
10291         return status;
10292 }
10293
10294 struct dcerpc_spoolss_ReplyOpenPrinter_state {
10295         struct spoolss_ReplyOpenPrinter orig;
10296         struct spoolss_ReplyOpenPrinter tmp;
10297         TALLOC_CTX *out_mem_ctx;
10298 };
10299
10300 static void dcerpc_spoolss_ReplyOpenPrinter_done(struct tevent_req *subreq);
10301
10302 struct tevent_req *dcerpc_spoolss_ReplyOpenPrinter_send(TALLOC_CTX *mem_ctx,
10303                                                         struct tevent_context *ev,
10304                                                         struct dcerpc_binding_handle *h,
10305                                                         const char *_server_name /* [in] [charset(UTF16)] */,
10306                                                         uint32_t _printer_local /* [in]  */,
10307                                                         enum winreg_Type _type /* [in]  */,
10308                                                         uint32_t _bufsize /* [in] [range(0,512)] */,
10309                                                         uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */,
10310                                                         struct policy_handle *_handle /* [out] [ref] */)
10311 {
10312         struct tevent_req *req;
10313         struct dcerpc_spoolss_ReplyOpenPrinter_state *state;
10314         struct tevent_req *subreq;
10315
10316         req = tevent_req_create(mem_ctx, &state,
10317                                 struct dcerpc_spoolss_ReplyOpenPrinter_state);
10318         if (req == NULL) {
10319                 return NULL;
10320         }
10321         state->out_mem_ctx = NULL;
10322
10323         /* In parameters */
10324         state->orig.in.server_name = _server_name;
10325         state->orig.in.printer_local = _printer_local;
10326         state->orig.in.type = _type;
10327         state->orig.in.bufsize = _bufsize;
10328         state->orig.in.buffer = _buffer;
10329
10330         /* Out parameters */
10331         state->orig.out.handle = _handle;
10332
10333         /* Result */
10334         ZERO_STRUCT(state->orig.out.result);
10335
10336         state->out_mem_ctx = talloc_named_const(state, 0,
10337                              "dcerpc_spoolss_ReplyOpenPrinter_out_memory");
10338         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10339                 return tevent_req_post(req, ev);
10340         }
10341
10342         /* make a temporary copy, that we pass to the dispatch function */
10343         state->tmp = state->orig;
10344
10345         subreq = dcerpc_spoolss_ReplyOpenPrinter_r_send(state, ev, h, &state->tmp);
10346         if (tevent_req_nomem(subreq, req)) {
10347                 return tevent_req_post(req, ev);
10348         }
10349         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyOpenPrinter_done, req);
10350         return req;
10351 }
10352
10353 static void dcerpc_spoolss_ReplyOpenPrinter_done(struct tevent_req *subreq)
10354 {
10355         struct tevent_req *req = tevent_req_callback_data(
10356                 subreq, struct tevent_req);
10357         struct dcerpc_spoolss_ReplyOpenPrinter_state *state = tevent_req_data(
10358                 req, struct dcerpc_spoolss_ReplyOpenPrinter_state);
10359         NTSTATUS status;
10360         TALLOC_CTX *mem_ctx;
10361
10362         if (state->out_mem_ctx) {
10363                 mem_ctx = state->out_mem_ctx;
10364         } else {
10365                 mem_ctx = state;
10366         }
10367
10368         status = dcerpc_spoolss_ReplyOpenPrinter_r_recv(subreq, mem_ctx);
10369         TALLOC_FREE(subreq);
10370         if (!NT_STATUS_IS_OK(status)) {
10371                 tevent_req_nterror(req, status);
10372                 return;
10373         }
10374
10375         /* Copy out parameters */
10376         *state->orig.out.handle = *state->tmp.out.handle;
10377
10378         /* Copy result */
10379         state->orig.out.result = state->tmp.out.result;
10380
10381         /* Reset temporary structure */
10382         ZERO_STRUCT(state->tmp);
10383
10384         tevent_req_done(req);
10385 }
10386
10387 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_recv(struct tevent_req *req,
10388                                               TALLOC_CTX *mem_ctx,
10389                                               WERROR *result)
10390 {
10391         struct dcerpc_spoolss_ReplyOpenPrinter_state *state = tevent_req_data(
10392                 req, struct dcerpc_spoolss_ReplyOpenPrinter_state);
10393         NTSTATUS status;
10394
10395         if (tevent_req_is_nterror(req, &status)) {
10396                 tevent_req_received(req);
10397                 return status;
10398         }
10399
10400         /* Steal possible out parameters to the callers context */
10401         talloc_steal(mem_ctx, state->out_mem_ctx);
10402
10403         /* Return result */
10404         *result = state->orig.out.result;
10405
10406         tevent_req_received(req);
10407         return NT_STATUS_OK;
10408 }
10409
10410 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter(struct dcerpc_binding_handle *h,
10411                                          TALLOC_CTX *mem_ctx,
10412                                          const char *_server_name /* [in] [charset(UTF16)] */,
10413                                          uint32_t _printer_local /* [in]  */,
10414                                          enum winreg_Type _type /* [in]  */,
10415                                          uint32_t _bufsize /* [in] [range(0,512)] */,
10416                                          uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */,
10417                                          struct policy_handle *_handle /* [out] [ref] */,
10418                                          WERROR *result)
10419 {
10420         struct spoolss_ReplyOpenPrinter r;
10421         NTSTATUS status;
10422
10423         /* In parameters */
10424         r.in.server_name = _server_name;
10425         r.in.printer_local = _printer_local;
10426         r.in.type = _type;
10427         r.in.bufsize = _bufsize;
10428         r.in.buffer = _buffer;
10429
10430         status = dcerpc_spoolss_ReplyOpenPrinter_r(h, mem_ctx, &r);
10431         if (!NT_STATUS_IS_OK(status)) {
10432                 return status;
10433         }
10434
10435         /* Return variables */
10436         *_handle = *r.out.handle;
10437
10438         /* Return result */
10439         *result = r.out.result;
10440
10441         return NT_STATUS_OK;
10442 }
10443
10444 struct dcerpc_spoolss_RouterReplyPrinter_r_state {
10445         TALLOC_CTX *out_mem_ctx;
10446 };
10447
10448 static void dcerpc_spoolss_RouterReplyPrinter_r_done(struct tevent_req *subreq);
10449
10450 struct tevent_req *dcerpc_spoolss_RouterReplyPrinter_r_send(TALLOC_CTX *mem_ctx,
10451         struct tevent_context *ev,
10452         struct dcerpc_binding_handle *h,
10453         struct spoolss_RouterReplyPrinter *r)
10454 {
10455         struct tevent_req *req;
10456         struct dcerpc_spoolss_RouterReplyPrinter_r_state *state;
10457         struct tevent_req *subreq;
10458
10459         req = tevent_req_create(mem_ctx, &state,
10460                                 struct dcerpc_spoolss_RouterReplyPrinter_r_state);
10461         if (req == NULL) {
10462                 return NULL;
10463         }
10464
10465         state->out_mem_ctx = NULL;
10466         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10467                         NULL, &ndr_table_spoolss,
10468                         NDR_SPOOLSS_ROUTERREPLYPRINTER, state, r);
10469         if (tevent_req_nomem(subreq, req)) {
10470                 return tevent_req_post(req, ev);
10471         }
10472         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinter_r_done, req);
10473
10474         return req;
10475 }
10476
10477 static void dcerpc_spoolss_RouterReplyPrinter_r_done(struct tevent_req *subreq)
10478 {
10479         struct tevent_req *req =
10480                 tevent_req_callback_data(subreq,
10481                 struct tevent_req);
10482         NTSTATUS status;
10483
10484         status = dcerpc_binding_handle_call_recv(subreq);
10485         if (!NT_STATUS_IS_OK(status)) {
10486                 tevent_req_nterror(req, status);
10487                 return;
10488         }
10489
10490         tevent_req_done(req);
10491 }
10492
10493 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10494 {
10495         struct dcerpc_spoolss_RouterReplyPrinter_r_state *state =
10496                 tevent_req_data(req,
10497                 struct dcerpc_spoolss_RouterReplyPrinter_r_state);
10498         NTSTATUS status;
10499
10500         if (tevent_req_is_nterror(req, &status)) {
10501                 tevent_req_received(req);
10502                 return status;
10503         }
10504
10505         talloc_steal(mem_ctx, state->out_mem_ctx);
10506
10507         tevent_req_received(req);
10508         return NT_STATUS_OK;
10509 }
10510
10511 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinter *r)
10512 {
10513         NTSTATUS status;
10514
10515         status = dcerpc_binding_handle_call(h,
10516                         NULL, &ndr_table_spoolss,
10517                         NDR_SPOOLSS_ROUTERREPLYPRINTER, mem_ctx, r);
10518
10519         return status;
10520 }
10521
10522 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinter *r)
10523 {
10524         NTSTATUS status;
10525
10526         status = dcerpc_spoolss_RouterReplyPrinter_r(p->binding_handle, mem_ctx, r);
10527
10528         if (NT_STATUS_IS_RPC(status)) {
10529                 status = NT_STATUS_NET_WRITE_FAULT;
10530         }
10531
10532         return status;
10533 }
10534
10535 struct dcerpc_spoolss_RouterReplyPrinter_state {
10536         struct spoolss_RouterReplyPrinter orig;
10537         struct spoolss_RouterReplyPrinter tmp;
10538         TALLOC_CTX *out_mem_ctx;
10539 };
10540
10541 static void dcerpc_spoolss_RouterReplyPrinter_done(struct tevent_req *subreq);
10542
10543 struct tevent_req *dcerpc_spoolss_RouterReplyPrinter_send(TALLOC_CTX *mem_ctx,
10544                                                           struct tevent_context *ev,
10545                                                           struct dcerpc_binding_handle *h,
10546                                                           struct policy_handle *_handle /* [in] [ref] */,
10547                                                           uint32_t _flags /* [in]  */,
10548                                                           uint32_t _bufsize /* [in] [range(0,512)] */,
10549                                                           uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */)
10550 {
10551         struct tevent_req *req;
10552         struct dcerpc_spoolss_RouterReplyPrinter_state *state;
10553         struct tevent_req *subreq;
10554
10555         req = tevent_req_create(mem_ctx, &state,
10556                                 struct dcerpc_spoolss_RouterReplyPrinter_state);
10557         if (req == NULL) {
10558                 return NULL;
10559         }
10560         state->out_mem_ctx = NULL;
10561
10562         /* In parameters */
10563         state->orig.in.handle = _handle;
10564         state->orig.in.flags = _flags;
10565         state->orig.in.bufsize = _bufsize;
10566         state->orig.in.buffer = _buffer;
10567
10568         /* Out parameters */
10569
10570         /* Result */
10571         ZERO_STRUCT(state->orig.out.result);
10572
10573         /* make a temporary copy, that we pass to the dispatch function */
10574         state->tmp = state->orig;
10575
10576         subreq = dcerpc_spoolss_RouterReplyPrinter_r_send(state, ev, h, &state->tmp);
10577         if (tevent_req_nomem(subreq, req)) {
10578                 return tevent_req_post(req, ev);
10579         }
10580         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinter_done, req);
10581         return req;
10582 }
10583
10584 static void dcerpc_spoolss_RouterReplyPrinter_done(struct tevent_req *subreq)
10585 {
10586         struct tevent_req *req = tevent_req_callback_data(
10587                 subreq, struct tevent_req);
10588         struct dcerpc_spoolss_RouterReplyPrinter_state *state = tevent_req_data(
10589                 req, struct dcerpc_spoolss_RouterReplyPrinter_state);
10590         NTSTATUS status;
10591         TALLOC_CTX *mem_ctx;
10592
10593         if (state->out_mem_ctx) {
10594                 mem_ctx = state->out_mem_ctx;
10595         } else {
10596                 mem_ctx = state;
10597         }
10598
10599         status = dcerpc_spoolss_RouterReplyPrinter_r_recv(subreq, mem_ctx);
10600         TALLOC_FREE(subreq);
10601         if (!NT_STATUS_IS_OK(status)) {
10602                 tevent_req_nterror(req, status);
10603                 return;
10604         }
10605
10606         /* Copy out parameters */
10607
10608         /* Copy result */
10609         state->orig.out.result = state->tmp.out.result;
10610
10611         /* Reset temporary structure */
10612         ZERO_STRUCT(state->tmp);
10613
10614         tevent_req_done(req);
10615 }
10616
10617 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_recv(struct tevent_req *req,
10618                                                 TALLOC_CTX *mem_ctx,
10619                                                 WERROR *result)
10620 {
10621         struct dcerpc_spoolss_RouterReplyPrinter_state *state = tevent_req_data(
10622                 req, struct dcerpc_spoolss_RouterReplyPrinter_state);
10623         NTSTATUS status;
10624
10625         if (tevent_req_is_nterror(req, &status)) {
10626                 tevent_req_received(req);
10627                 return status;
10628         }
10629
10630         /* Steal possible out parameters to the callers context */
10631         talloc_steal(mem_ctx, state->out_mem_ctx);
10632
10633         /* Return result */
10634         *result = state->orig.out.result;
10635
10636         tevent_req_received(req);
10637         return NT_STATUS_OK;
10638 }
10639
10640 NTSTATUS dcerpc_spoolss_RouterReplyPrinter(struct dcerpc_binding_handle *h,
10641                                            TALLOC_CTX *mem_ctx,
10642                                            struct policy_handle *_handle /* [in] [ref] */,
10643                                            uint32_t _flags /* [in]  */,
10644                                            uint32_t _bufsize /* [in] [range(0,512)] */,
10645                                            uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */,
10646                                            WERROR *result)
10647 {
10648         struct spoolss_RouterReplyPrinter r;
10649         NTSTATUS status;
10650
10651         /* In parameters */
10652         r.in.handle = _handle;
10653         r.in.flags = _flags;
10654         r.in.bufsize = _bufsize;
10655         r.in.buffer = _buffer;
10656
10657         status = dcerpc_spoolss_RouterReplyPrinter_r(h, mem_ctx, &r);
10658         if (!NT_STATUS_IS_OK(status)) {
10659                 return status;
10660         }
10661
10662         /* Return variables */
10663
10664         /* Return result */
10665         *result = r.out.result;
10666
10667         return NT_STATUS_OK;
10668 }
10669
10670 struct dcerpc_spoolss_ReplyClosePrinter_r_state {
10671         TALLOC_CTX *out_mem_ctx;
10672 };
10673
10674 static void dcerpc_spoolss_ReplyClosePrinter_r_done(struct tevent_req *subreq);
10675
10676 struct tevent_req *dcerpc_spoolss_ReplyClosePrinter_r_send(TALLOC_CTX *mem_ctx,
10677         struct tevent_context *ev,
10678         struct dcerpc_binding_handle *h,
10679         struct spoolss_ReplyClosePrinter *r)
10680 {
10681         struct tevent_req *req;
10682         struct dcerpc_spoolss_ReplyClosePrinter_r_state *state;
10683         struct tevent_req *subreq;
10684
10685         req = tevent_req_create(mem_ctx, &state,
10686                                 struct dcerpc_spoolss_ReplyClosePrinter_r_state);
10687         if (req == NULL) {
10688                 return NULL;
10689         }
10690
10691         state->out_mem_ctx = talloc_new(state);
10692         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10693                 return tevent_req_post(req, ev);
10694         }
10695
10696         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10697                         NULL, &ndr_table_spoolss,
10698                         NDR_SPOOLSS_REPLYCLOSEPRINTER, state->out_mem_ctx, r);
10699         if (tevent_req_nomem(subreq, req)) {
10700                 return tevent_req_post(req, ev);
10701         }
10702         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyClosePrinter_r_done, req);
10703
10704         return req;
10705 }
10706
10707 static void dcerpc_spoolss_ReplyClosePrinter_r_done(struct tevent_req *subreq)
10708 {
10709         struct tevent_req *req =
10710                 tevent_req_callback_data(subreq,
10711                 struct tevent_req);
10712         NTSTATUS status;
10713
10714         status = dcerpc_binding_handle_call_recv(subreq);
10715         if (!NT_STATUS_IS_OK(status)) {
10716                 tevent_req_nterror(req, status);
10717                 return;
10718         }
10719
10720         tevent_req_done(req);
10721 }
10722
10723 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10724 {
10725         struct dcerpc_spoolss_ReplyClosePrinter_r_state *state =
10726                 tevent_req_data(req,
10727                 struct dcerpc_spoolss_ReplyClosePrinter_r_state);
10728         NTSTATUS status;
10729
10730         if (tevent_req_is_nterror(req, &status)) {
10731                 tevent_req_received(req);
10732                 return status;
10733         }
10734
10735         talloc_steal(mem_ctx, state->out_mem_ctx);
10736
10737         tevent_req_received(req);
10738         return NT_STATUS_OK;
10739 }
10740
10741 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ReplyClosePrinter *r)
10742 {
10743         NTSTATUS status;
10744
10745         status = dcerpc_binding_handle_call(h,
10746                         NULL, &ndr_table_spoolss,
10747                         NDR_SPOOLSS_REPLYCLOSEPRINTER, mem_ctx, r);
10748
10749         return status;
10750 }
10751
10752 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ReplyClosePrinter *r)
10753 {
10754         NTSTATUS status;
10755
10756         status = dcerpc_spoolss_ReplyClosePrinter_r(p->binding_handle, mem_ctx, r);
10757
10758         if (NT_STATUS_IS_RPC(status)) {
10759                 status = NT_STATUS_NET_WRITE_FAULT;
10760         }
10761
10762         return status;
10763 }
10764
10765 struct dcerpc_spoolss_ReplyClosePrinter_state {
10766         struct spoolss_ReplyClosePrinter orig;
10767         struct spoolss_ReplyClosePrinter tmp;
10768         TALLOC_CTX *out_mem_ctx;
10769 };
10770
10771 static void dcerpc_spoolss_ReplyClosePrinter_done(struct tevent_req *subreq);
10772
10773 struct tevent_req *dcerpc_spoolss_ReplyClosePrinter_send(TALLOC_CTX *mem_ctx,
10774                                                          struct tevent_context *ev,
10775                                                          struct dcerpc_binding_handle *h,
10776                                                          struct policy_handle *_handle /* [in,out] [ref] */)
10777 {
10778         struct tevent_req *req;
10779         struct dcerpc_spoolss_ReplyClosePrinter_state *state;
10780         struct tevent_req *subreq;
10781
10782         req = tevent_req_create(mem_ctx, &state,
10783                                 struct dcerpc_spoolss_ReplyClosePrinter_state);
10784         if (req == NULL) {
10785                 return NULL;
10786         }
10787         state->out_mem_ctx = NULL;
10788
10789         /* In parameters */
10790         state->orig.in.handle = _handle;
10791
10792         /* Out parameters */
10793         state->orig.out.handle = _handle;
10794
10795         /* Result */
10796         ZERO_STRUCT(state->orig.out.result);
10797
10798         state->out_mem_ctx = talloc_named_const(state, 0,
10799                              "dcerpc_spoolss_ReplyClosePrinter_out_memory");
10800         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10801                 return tevent_req_post(req, ev);
10802         }
10803
10804         /* make a temporary copy, that we pass to the dispatch function */
10805         state->tmp = state->orig;
10806
10807         subreq = dcerpc_spoolss_ReplyClosePrinter_r_send(state, ev, h, &state->tmp);
10808         if (tevent_req_nomem(subreq, req)) {
10809                 return tevent_req_post(req, ev);
10810         }
10811         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyClosePrinter_done, req);
10812         return req;
10813 }
10814
10815 static void dcerpc_spoolss_ReplyClosePrinter_done(struct tevent_req *subreq)
10816 {
10817         struct tevent_req *req = tevent_req_callback_data(
10818                 subreq, struct tevent_req);
10819         struct dcerpc_spoolss_ReplyClosePrinter_state *state = tevent_req_data(
10820                 req, struct dcerpc_spoolss_ReplyClosePrinter_state);
10821         NTSTATUS status;
10822         TALLOC_CTX *mem_ctx;
10823
10824         if (state->out_mem_ctx) {
10825                 mem_ctx = state->out_mem_ctx;
10826         } else {
10827                 mem_ctx = state;
10828         }
10829
10830         status = dcerpc_spoolss_ReplyClosePrinter_r_recv(subreq, mem_ctx);
10831         TALLOC_FREE(subreq);
10832         if (!NT_STATUS_IS_OK(status)) {
10833                 tevent_req_nterror(req, status);
10834                 return;
10835         }
10836
10837         /* Copy out parameters */
10838         *state->orig.out.handle = *state->tmp.out.handle;
10839
10840         /* Copy result */
10841         state->orig.out.result = state->tmp.out.result;
10842
10843         /* Reset temporary structure */
10844         ZERO_STRUCT(state->tmp);
10845
10846         tevent_req_done(req);
10847 }
10848
10849 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_recv(struct tevent_req *req,
10850                                                TALLOC_CTX *mem_ctx,
10851                                                WERROR *result)
10852 {
10853         struct dcerpc_spoolss_ReplyClosePrinter_state *state = tevent_req_data(
10854                 req, struct dcerpc_spoolss_ReplyClosePrinter_state);
10855         NTSTATUS status;
10856
10857         if (tevent_req_is_nterror(req, &status)) {
10858                 tevent_req_received(req);
10859                 return status;
10860         }
10861
10862         /* Steal possible out parameters to the callers context */
10863         talloc_steal(mem_ctx, state->out_mem_ctx);
10864
10865         /* Return result */
10866         *result = state->orig.out.result;
10867
10868         tevent_req_received(req);
10869         return NT_STATUS_OK;
10870 }
10871
10872 NTSTATUS dcerpc_spoolss_ReplyClosePrinter(struct dcerpc_binding_handle *h,
10873                                           TALLOC_CTX *mem_ctx,
10874                                           struct policy_handle *_handle /* [in,out] [ref] */,
10875                                           WERROR *result)
10876 {
10877         struct spoolss_ReplyClosePrinter r;
10878         NTSTATUS status;
10879
10880         /* In parameters */
10881         r.in.handle = _handle;
10882
10883         status = dcerpc_spoolss_ReplyClosePrinter_r(h, mem_ctx, &r);
10884         if (!NT_STATUS_IS_OK(status)) {
10885                 return status;
10886         }
10887
10888         /* Return variables */
10889         *_handle = *r.out.handle;
10890
10891         /* Return result */
10892         *result = r.out.result;
10893
10894         return NT_STATUS_OK;
10895 }
10896
10897 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state {
10898         TALLOC_CTX *out_mem_ctx;
10899 };
10900
10901 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_done(struct tevent_req *subreq);
10902
10903 struct tevent_req *dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_send(TALLOC_CTX *mem_ctx,
10904         struct tevent_context *ev,
10905         struct dcerpc_binding_handle *h,
10906         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
10907 {
10908         struct tevent_req *req;
10909         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state *state;
10910         struct tevent_req *subreq;
10911
10912         req = tevent_req_create(mem_ctx, &state,
10913                                 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state);
10914         if (req == NULL) {
10915                 return NULL;
10916         }
10917
10918         state->out_mem_ctx = NULL;
10919         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10920                         NULL, &ndr_table_spoolss,
10921                         NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX, state, r);
10922         if (tevent_req_nomem(subreq, req)) {
10923                 return tevent_req_post(req, ev);
10924         }
10925         tevent_req_set_callback(subreq, dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_done, req);
10926
10927         return req;
10928 }
10929
10930 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_done(struct tevent_req *subreq)
10931 {
10932         struct tevent_req *req =
10933                 tevent_req_callback_data(subreq,
10934                 struct tevent_req);
10935         NTSTATUS status;
10936
10937         status = dcerpc_binding_handle_call_recv(subreq);
10938         if (!NT_STATUS_IS_OK(status)) {
10939                 tevent_req_nterror(req, status);
10940                 return;
10941         }
10942
10943         tevent_req_done(req);
10944 }
10945
10946 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10947 {
10948         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state *state =
10949                 tevent_req_data(req,
10950                 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state);
10951         NTSTATUS status;
10952
10953         if (tevent_req_is_nterror(req, &status)) {
10954                 tevent_req_received(req);
10955                 return status;
10956         }
10957
10958         talloc_steal(mem_ctx, state->out_mem_ctx);
10959
10960         tevent_req_received(req);
10961         return NT_STATUS_OK;
10962 }
10963
10964 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
10965 {
10966         NTSTATUS status;
10967
10968         status = dcerpc_binding_handle_call(h,
10969                         NULL, &ndr_table_spoolss,
10970                         NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX, mem_ctx, r);
10971
10972         return status;
10973 }
10974
10975 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
10976 {
10977         NTSTATUS status;
10978
10979         status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r(p->binding_handle, mem_ctx, r);
10980
10981         if (NT_STATUS_IS_RPC(status)) {
10982                 status = NT_STATUS_NET_WRITE_FAULT;
10983         }
10984
10985         return status;
10986 }
10987
10988 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state {
10989         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx orig;
10990         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx tmp;
10991         TALLOC_CTX *out_mem_ctx;
10992 };
10993
10994 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_done(struct tevent_req *subreq);
10995
10996 struct tevent_req *dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_send(TALLOC_CTX *mem_ctx,
10997                                                                             struct tevent_context *ev,
10998                                                                             struct dcerpc_binding_handle *h,
10999                                                                             struct policy_handle *_handle /* [in] [ref] */,
11000                                                                             uint32_t _flags /* [in]  */,
11001                                                                             uint32_t _options /* [in]  */,
11002                                                                             const char *_local_machine /* [in] [unique,charset(UTF16)] */,
11003                                                                             uint32_t _printer_local /* [in]  */,
11004                                                                             struct spoolss_NotifyOption *_notify_options /* [in] [unique] */)
11005 {
11006         struct tevent_req *req;
11007         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state *state;
11008         struct tevent_req *subreq;
11009
11010         req = tevent_req_create(mem_ctx, &state,
11011                                 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state);
11012         if (req == NULL) {
11013                 return NULL;
11014         }
11015         state->out_mem_ctx = NULL;
11016
11017         /* In parameters */
11018         state->orig.in.handle = _handle;
11019         state->orig.in.flags = _flags;
11020         state->orig.in.options = _options;
11021         state->orig.in.local_machine = _local_machine;
11022         state->orig.in.printer_local = _printer_local;
11023         state->orig.in.notify_options = _notify_options;
11024
11025         /* Out parameters */
11026
11027         /* Result */
11028         ZERO_STRUCT(state->orig.out.result);
11029
11030         /* make a temporary copy, that we pass to the dispatch function */
11031         state->tmp = state->orig;
11032
11033         subreq = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_send(state, ev, h, &state->tmp);
11034         if (tevent_req_nomem(subreq, req)) {
11035                 return tevent_req_post(req, ev);
11036         }
11037         tevent_req_set_callback(subreq, dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_done, req);
11038         return req;
11039 }
11040
11041 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_done(struct tevent_req *subreq)
11042 {
11043         struct tevent_req *req = tevent_req_callback_data(
11044                 subreq, struct tevent_req);
11045         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state *state = tevent_req_data(
11046                 req, struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state);
11047         NTSTATUS status;
11048         TALLOC_CTX *mem_ctx;
11049
11050         if (state->out_mem_ctx) {
11051                 mem_ctx = state->out_mem_ctx;
11052         } else {
11053                 mem_ctx = state;
11054         }
11055
11056         status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_recv(subreq, mem_ctx);
11057         TALLOC_FREE(subreq);
11058         if (!NT_STATUS_IS_OK(status)) {
11059                 tevent_req_nterror(req, status);
11060                 return;
11061         }
11062
11063         /* Copy out parameters */
11064
11065         /* Copy result */
11066         state->orig.out.result = state->tmp.out.result;
11067
11068         /* Reset temporary structure */
11069         ZERO_STRUCT(state->tmp);
11070
11071         tevent_req_done(req);
11072 }
11073
11074 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_recv(struct tevent_req *req,
11075                                                                   TALLOC_CTX *mem_ctx,
11076                                                                   WERROR *result)
11077 {
11078         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state *state = tevent_req_data(
11079                 req, struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state);
11080         NTSTATUS status;
11081
11082         if (tevent_req_is_nterror(req, &status)) {
11083                 tevent_req_received(req);
11084                 return status;
11085         }
11086
11087         /* Steal possible out parameters to the callers context */
11088         talloc_steal(mem_ctx, state->out_mem_ctx);
11089
11090         /* Return result */
11091         *result = state->orig.out.result;
11092
11093         tevent_req_received(req);
11094         return NT_STATUS_OK;
11095 }
11096
11097 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcerpc_binding_handle *h,
11098                                                              TALLOC_CTX *mem_ctx,
11099                                                              struct policy_handle *_handle /* [in] [ref] */,
11100                                                              uint32_t _flags /* [in]  */,
11101                                                              uint32_t _options /* [in]  */,
11102                                                              const char *_local_machine /* [in] [unique,charset(UTF16)] */,
11103                                                              uint32_t _printer_local /* [in]  */,
11104                                                              struct spoolss_NotifyOption *_notify_options /* [in] [unique] */,
11105                                                              WERROR *result)
11106 {
11107         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r;
11108         NTSTATUS status;
11109
11110         /* In parameters */
11111         r.in.handle = _handle;
11112         r.in.flags = _flags;
11113         r.in.options = _options;
11114         r.in.local_machine = _local_machine;
11115         r.in.printer_local = _printer_local;
11116         r.in.notify_options = _notify_options;
11117
11118         status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r(h, mem_ctx, &r);
11119         if (!NT_STATUS_IS_OK(status)) {
11120                 return status;
11121         }
11122
11123         /* Return variables */
11124
11125         /* Return result */
11126         *result = r.out.result;
11127
11128         return NT_STATUS_OK;
11129 }
11130
11131 struct dcerpc_spoolss_RouterReplyPrinterEx_r_state {
11132         TALLOC_CTX *out_mem_ctx;
11133 };
11134
11135 static void dcerpc_spoolss_RouterReplyPrinterEx_r_done(struct tevent_req *subreq);
11136
11137 struct tevent_req *dcerpc_spoolss_RouterReplyPrinterEx_r_send(TALLOC_CTX *mem_ctx,
11138         struct tevent_context *ev,
11139         struct dcerpc_binding_handle *h,
11140         struct spoolss_RouterReplyPrinterEx *r)
11141 {
11142         struct tevent_req *req;
11143         struct dcerpc_spoolss_RouterReplyPrinterEx_r_state *state;
11144         struct tevent_req *subreq;
11145
11146         req = tevent_req_create(mem_ctx, &state,
11147                                 struct dcerpc_spoolss_RouterReplyPrinterEx_r_state);
11148         if (req == NULL) {
11149                 return NULL;
11150         }
11151
11152         state->out_mem_ctx = talloc_new(state);
11153         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11154                 return tevent_req_post(req, ev);
11155         }
11156
11157         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11158                         NULL, &ndr_table_spoolss,
11159                         NDR_SPOOLSS_ROUTERREPLYPRINTEREX, state->out_mem_ctx, r);
11160         if (tevent_req_nomem(subreq, req)) {
11161                 return tevent_req_post(req, ev);
11162         }
11163         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinterEx_r_done, req);
11164
11165         return req;
11166 }
11167
11168 static void dcerpc_spoolss_RouterReplyPrinterEx_r_done(struct tevent_req *subreq)
11169 {
11170         struct tevent_req *req =
11171                 tevent_req_callback_data(subreq,
11172                 struct tevent_req);
11173         NTSTATUS status;
11174
11175         status = dcerpc_binding_handle_call_recv(subreq);
11176         if (!NT_STATUS_IS_OK(status)) {
11177                 tevent_req_nterror(req, status);
11178                 return;
11179         }
11180
11181         tevent_req_done(req);
11182 }
11183
11184 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11185 {
11186         struct dcerpc_spoolss_RouterReplyPrinterEx_r_state *state =
11187                 tevent_req_data(req,
11188                 struct dcerpc_spoolss_RouterReplyPrinterEx_r_state);
11189         NTSTATUS status;
11190
11191         if (tevent_req_is_nterror(req, &status)) {
11192                 tevent_req_received(req);
11193                 return status;
11194         }
11195
11196         talloc_steal(mem_ctx, state->out_mem_ctx);
11197
11198         tevent_req_received(req);
11199         return NT_STATUS_OK;
11200 }
11201
11202 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinterEx *r)
11203 {
11204         NTSTATUS status;
11205
11206         status = dcerpc_binding_handle_call(h,
11207                         NULL, &ndr_table_spoolss,
11208                         NDR_SPOOLSS_ROUTERREPLYPRINTEREX, mem_ctx, r);
11209
11210         return status;
11211 }
11212
11213 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinterEx *r)
11214 {
11215         NTSTATUS status;
11216
11217         status = dcerpc_spoolss_RouterReplyPrinterEx_r(p->binding_handle, mem_ctx, r);
11218
11219         if (NT_STATUS_IS_RPC(status)) {
11220                 status = NT_STATUS_NET_WRITE_FAULT;
11221         }
11222
11223         return status;
11224 }
11225
11226 struct dcerpc_spoolss_RouterReplyPrinterEx_state {
11227         struct spoolss_RouterReplyPrinterEx orig;
11228         struct spoolss_RouterReplyPrinterEx tmp;
11229         TALLOC_CTX *out_mem_ctx;
11230 };
11231
11232 static void dcerpc_spoolss_RouterReplyPrinterEx_done(struct tevent_req *subreq);
11233
11234 struct tevent_req *dcerpc_spoolss_RouterReplyPrinterEx_send(TALLOC_CTX *mem_ctx,
11235                                                             struct tevent_context *ev,
11236                                                             struct dcerpc_binding_handle *h,
11237                                                             struct policy_handle *_handle /* [in] [ref] */,
11238                                                             uint32_t _color /* [in]  */,
11239                                                             uint32_t _flags /* [in]  */,
11240                                                             uint32_t *_reply_result /* [out] [ref] */,
11241                                                             uint32_t _reply_type /* [in]  */,
11242                                                             union spoolss_ReplyPrinterInfo _info /* [in] [switch_is(reply_type)] */)
11243 {
11244         struct tevent_req *req;
11245         struct dcerpc_spoolss_RouterReplyPrinterEx_state *state;
11246         struct tevent_req *subreq;
11247
11248         req = tevent_req_create(mem_ctx, &state,
11249                                 struct dcerpc_spoolss_RouterReplyPrinterEx_state);
11250         if (req == NULL) {
11251                 return NULL;
11252         }
11253         state->out_mem_ctx = NULL;
11254
11255         /* In parameters */
11256         state->orig.in.handle = _handle;
11257         state->orig.in.color = _color;
11258         state->orig.in.flags = _flags;
11259         state->orig.in.reply_type = _reply_type;
11260         state->orig.in.info = _info;
11261
11262         /* Out parameters */
11263         state->orig.out.reply_result = _reply_result;
11264
11265         /* Result */
11266         ZERO_STRUCT(state->orig.out.result);
11267
11268         state->out_mem_ctx = talloc_named_const(state, 0,
11269                              "dcerpc_spoolss_RouterReplyPrinterEx_out_memory");
11270         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11271                 return tevent_req_post(req, ev);
11272         }
11273
11274         /* make a temporary copy, that we pass to the dispatch function */
11275         state->tmp = state->orig;
11276
11277         subreq = dcerpc_spoolss_RouterReplyPrinterEx_r_send(state, ev, h, &state->tmp);
11278         if (tevent_req_nomem(subreq, req)) {
11279                 return tevent_req_post(req, ev);
11280         }
11281         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinterEx_done, req);
11282         return req;
11283 }
11284
11285 static void dcerpc_spoolss_RouterReplyPrinterEx_done(struct tevent_req *subreq)
11286 {
11287         struct tevent_req *req = tevent_req_callback_data(
11288                 subreq, struct tevent_req);
11289         struct dcerpc_spoolss_RouterReplyPrinterEx_state *state = tevent_req_data(
11290                 req, struct dcerpc_spoolss_RouterReplyPrinterEx_state);
11291         NTSTATUS status;
11292         TALLOC_CTX *mem_ctx;
11293
11294         if (state->out_mem_ctx) {
11295                 mem_ctx = state->out_mem_ctx;
11296         } else {
11297                 mem_ctx = state;
11298         }
11299
11300         status = dcerpc_spoolss_RouterReplyPrinterEx_r_recv(subreq, mem_ctx);
11301         TALLOC_FREE(subreq);
11302         if (!NT_STATUS_IS_OK(status)) {
11303                 tevent_req_nterror(req, status);
11304                 return;
11305         }
11306
11307         /* Copy out parameters */
11308         *state->orig.out.reply_result = *state->tmp.out.reply_result;
11309
11310         /* Copy result */
11311         state->orig.out.result = state->tmp.out.result;
11312
11313         /* Reset temporary structure */
11314         ZERO_STRUCT(state->tmp);
11315
11316         tevent_req_done(req);
11317 }
11318
11319 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_recv(struct tevent_req *req,
11320                                                   TALLOC_CTX *mem_ctx,
11321                                                   WERROR *result)
11322 {
11323         struct dcerpc_spoolss_RouterReplyPrinterEx_state *state = tevent_req_data(
11324                 req, struct dcerpc_spoolss_RouterReplyPrinterEx_state);
11325         NTSTATUS status;
11326
11327         if (tevent_req_is_nterror(req, &status)) {
11328                 tevent_req_received(req);
11329                 return status;
11330         }
11331
11332         /* Steal possible out parameters to the callers context */
11333         talloc_steal(mem_ctx, state->out_mem_ctx);
11334
11335         /* Return result */
11336         *result = state->orig.out.result;
11337
11338         tevent_req_received(req);
11339         return NT_STATUS_OK;
11340 }
11341
11342 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx(struct dcerpc_binding_handle *h,
11343                                              TALLOC_CTX *mem_ctx,
11344                                              struct policy_handle *_handle /* [in] [ref] */,
11345                                              uint32_t _color /* [in]  */,
11346                                              uint32_t _flags /* [in]  */,
11347                                              uint32_t *_reply_result /* [out] [ref] */,
11348                                              uint32_t _reply_type /* [in]  */,
11349                                              union spoolss_ReplyPrinterInfo _info /* [in] [switch_is(reply_type)] */,
11350                                              WERROR *result)
11351 {
11352         struct spoolss_RouterReplyPrinterEx r;
11353         NTSTATUS status;
11354
11355         /* In parameters */
11356         r.in.handle = _handle;
11357         r.in.color = _color;
11358         r.in.flags = _flags;
11359         r.in.reply_type = _reply_type;
11360         r.in.info = _info;
11361
11362         status = dcerpc_spoolss_RouterReplyPrinterEx_r(h, mem_ctx, &r);
11363         if (!NT_STATUS_IS_OK(status)) {
11364                 return status;
11365         }
11366
11367         /* Return variables */
11368         *_reply_result = *r.out.reply_result;
11369
11370         /* Return result */
11371         *result = r.out.result;
11372
11373         return NT_STATUS_OK;
11374 }
11375
11376 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state {
11377         TALLOC_CTX *out_mem_ctx;
11378 };
11379
11380 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_done(struct tevent_req *subreq);
11381
11382 struct tevent_req *dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_send(TALLOC_CTX *mem_ctx,
11383         struct tevent_context *ev,
11384         struct dcerpc_binding_handle *h,
11385         struct spoolss_RouterRefreshPrinterChangeNotify *r)
11386 {
11387         struct tevent_req *req;
11388         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state *state;
11389         struct tevent_req *subreq;
11390
11391         req = tevent_req_create(mem_ctx, &state,
11392                                 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state);
11393         if (req == NULL) {
11394                 return NULL;
11395         }
11396
11397         state->out_mem_ctx = talloc_new(state);
11398         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11399                 return tevent_req_post(req, ev);
11400         }
11401
11402         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11403                         NULL, &ndr_table_spoolss,
11404                         NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFY, state->out_mem_ctx, r);
11405         if (tevent_req_nomem(subreq, req)) {
11406                 return tevent_req_post(req, ev);
11407         }
11408         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_done, req);
11409
11410         return req;
11411 }
11412
11413 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_done(struct tevent_req *subreq)
11414 {
11415         struct tevent_req *req =
11416                 tevent_req_callback_data(subreq,
11417                 struct tevent_req);
11418         NTSTATUS status;
11419
11420         status = dcerpc_binding_handle_call_recv(subreq);
11421         if (!NT_STATUS_IS_OK(status)) {
11422                 tevent_req_nterror(req, status);
11423                 return;
11424         }
11425
11426         tevent_req_done(req);
11427 }
11428
11429 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11430 {
11431         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state *state =
11432                 tevent_req_data(req,
11433                 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state);
11434         NTSTATUS status;
11435
11436         if (tevent_req_is_nterror(req, &status)) {
11437                 tevent_req_received(req);
11438                 return status;
11439         }
11440
11441         talloc_steal(mem_ctx, state->out_mem_ctx);
11442
11443         tevent_req_received(req);
11444         return NT_STATUS_OK;
11445 }
11446
11447 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RouterRefreshPrinterChangeNotify *r)
11448 {
11449         NTSTATUS status;
11450
11451         status = dcerpc_binding_handle_call(h,
11452                         NULL, &ndr_table_spoolss,
11453                         NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFY, mem_ctx, r);
11454
11455         return status;
11456 }
11457
11458 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RouterRefreshPrinterChangeNotify *r)
11459 {
11460         NTSTATUS status;
11461
11462         status = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r(p->binding_handle, mem_ctx, r);
11463
11464         if (NT_STATUS_IS_RPC(status)) {
11465                 status = NT_STATUS_NET_WRITE_FAULT;
11466         }
11467
11468         return status;
11469 }
11470
11471 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state {
11472         struct spoolss_RouterRefreshPrinterChangeNotify orig;
11473         struct spoolss_RouterRefreshPrinterChangeNotify tmp;
11474         TALLOC_CTX *out_mem_ctx;
11475 };
11476
11477 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_done(struct tevent_req *subreq);
11478
11479 struct tevent_req *dcerpc_spoolss_RouterRefreshPrinterChangeNotify_send(TALLOC_CTX *mem_ctx,
11480                                                                         struct tevent_context *ev,
11481                                                                         struct dcerpc_binding_handle *h,
11482                                                                         struct policy_handle *_handle /* [in] [ref] */,
11483                                                                         uint32_t _change_low /* [in]  */,
11484                                                                         struct spoolss_NotifyOption *_options /* [in] [unique] */,
11485                                                                         struct spoolss_NotifyInfo **_info /* [out] [ref] */)
11486 {
11487         struct tevent_req *req;
11488         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state *state;
11489         struct tevent_req *subreq;
11490
11491         req = tevent_req_create(mem_ctx, &state,
11492                                 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state);
11493         if (req == NULL) {
11494                 return NULL;
11495         }
11496         state->out_mem_ctx = NULL;
11497
11498         /* In parameters */
11499         state->orig.in.handle = _handle;
11500         state->orig.in.change_low = _change_low;
11501         state->orig.in.options = _options;
11502
11503         /* Out parameters */
11504         state->orig.out.info = _info;
11505
11506         /* Result */
11507         ZERO_STRUCT(state->orig.out.result);
11508
11509         state->out_mem_ctx = talloc_named_const(state, 0,
11510                              "dcerpc_spoolss_RouterRefreshPrinterChangeNotify_out_memory");
11511         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11512                 return tevent_req_post(req, ev);
11513         }
11514
11515         /* make a temporary copy, that we pass to the dispatch function */
11516         state->tmp = state->orig;
11517
11518         subreq = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_send(state, ev, h, &state->tmp);
11519         if (tevent_req_nomem(subreq, req)) {
11520                 return tevent_req_post(req, ev);
11521         }
11522         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterRefreshPrinterChangeNotify_done, req);
11523         return req;
11524 }
11525
11526 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_done(struct tevent_req *subreq)
11527 {
11528         struct tevent_req *req = tevent_req_callback_data(
11529                 subreq, struct tevent_req);
11530         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state *state = tevent_req_data(
11531                 req, struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state);
11532         NTSTATUS status;
11533         TALLOC_CTX *mem_ctx;
11534
11535         if (state->out_mem_ctx) {
11536                 mem_ctx = state->out_mem_ctx;
11537         } else {
11538                 mem_ctx = state;
11539         }
11540
11541         status = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_recv(subreq, mem_ctx);
11542         TALLOC_FREE(subreq);
11543         if (!NT_STATUS_IS_OK(status)) {
11544                 tevent_req_nterror(req, status);
11545                 return;
11546         }
11547
11548         /* Copy out parameters */
11549         *state->orig.out.info = *state->tmp.out.info;
11550
11551         /* Copy result */
11552         state->orig.out.result = state->tmp.out.result;
11553
11554         /* Reset temporary structure */
11555         ZERO_STRUCT(state->tmp);
11556
11557         tevent_req_done(req);
11558 }
11559
11560 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_recv(struct tevent_req *req,
11561                                                               TALLOC_CTX *mem_ctx,
11562                                                               WERROR *result)
11563 {
11564         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state *state = tevent_req_data(
11565                 req, struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state);
11566         NTSTATUS status;
11567
11568         if (tevent_req_is_nterror(req, &status)) {
11569                 tevent_req_received(req);
11570                 return status;
11571         }
11572
11573         /* Steal possible out parameters to the callers context */
11574         talloc_steal(mem_ctx, state->out_mem_ctx);
11575
11576         /* Return result */
11577         *result = state->orig.out.result;
11578
11579         tevent_req_received(req);
11580         return NT_STATUS_OK;
11581 }
11582
11583 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify(struct dcerpc_binding_handle *h,
11584                                                          TALLOC_CTX *mem_ctx,
11585                                                          struct policy_handle *_handle /* [in] [ref] */,
11586                                                          uint32_t _change_low /* [in]  */,
11587                                                          struct spoolss_NotifyOption *_options /* [in] [unique] */,
11588                                                          struct spoolss_NotifyInfo **_info /* [out] [ref] */,
11589                                                          WERROR *result)
11590 {
11591         struct spoolss_RouterRefreshPrinterChangeNotify r;
11592         NTSTATUS status;
11593
11594         /* In parameters */
11595         r.in.handle = _handle;
11596         r.in.change_low = _change_low;
11597         r.in.options = _options;
11598
11599         status = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r(h, mem_ctx, &r);
11600         if (!NT_STATUS_IS_OK(status)) {
11601                 return status;
11602         }
11603
11604         /* Return variables */
11605         *_info = *r.out.info;
11606
11607         /* Return result */
11608         *result = r.out.result;
11609
11610         return NT_STATUS_OK;
11611 }
11612
11613 struct dcerpc_spoolss_OpenPrinterEx_r_state {
11614         TALLOC_CTX *out_mem_ctx;
11615 };
11616
11617 static void dcerpc_spoolss_OpenPrinterEx_r_done(struct tevent_req *subreq);
11618
11619 struct tevent_req *dcerpc_spoolss_OpenPrinterEx_r_send(TALLOC_CTX *mem_ctx,
11620         struct tevent_context *ev,
11621         struct dcerpc_binding_handle *h,
11622         struct spoolss_OpenPrinterEx *r)
11623 {
11624         struct tevent_req *req;
11625         struct dcerpc_spoolss_OpenPrinterEx_r_state *state;
11626         struct tevent_req *subreq;
11627
11628         req = tevent_req_create(mem_ctx, &state,
11629                                 struct dcerpc_spoolss_OpenPrinterEx_r_state);
11630         if (req == NULL) {
11631                 return NULL;
11632         }
11633
11634         state->out_mem_ctx = talloc_new(state);
11635         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11636                 return tevent_req_post(req, ev);
11637         }
11638
11639         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11640                         NULL, &ndr_table_spoolss,
11641                         NDR_SPOOLSS_OPENPRINTEREX, state->out_mem_ctx, r);
11642         if (tevent_req_nomem(subreq, req)) {
11643                 return tevent_req_post(req, ev);
11644         }
11645         tevent_req_set_callback(subreq, dcerpc_spoolss_OpenPrinterEx_r_done, req);
11646
11647         return req;
11648 }
11649
11650 static void dcerpc_spoolss_OpenPrinterEx_r_done(struct tevent_req *subreq)
11651 {
11652         struct tevent_req *req =
11653                 tevent_req_callback_data(subreq,
11654                 struct tevent_req);
11655         NTSTATUS status;
11656
11657         status = dcerpc_binding_handle_call_recv(subreq);
11658         if (!NT_STATUS_IS_OK(status)) {
11659                 tevent_req_nterror(req, status);
11660                 return;
11661         }
11662
11663         tevent_req_done(req);
11664 }
11665
11666 NTSTATUS dcerpc_spoolss_OpenPrinterEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11667 {
11668         struct dcerpc_spoolss_OpenPrinterEx_r_state *state =
11669                 tevent_req_data(req,
11670                 struct dcerpc_spoolss_OpenPrinterEx_r_state);
11671         NTSTATUS status;
11672
11673         if (tevent_req_is_nterror(req, &status)) {
11674                 tevent_req_received(req);
11675                 return status;
11676         }
11677
11678         talloc_steal(mem_ctx, state->out_mem_ctx);
11679
11680         tevent_req_received(req);
11681         return NT_STATUS_OK;
11682 }
11683
11684 NTSTATUS dcerpc_spoolss_OpenPrinterEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r)
11685 {
11686         NTSTATUS status;
11687
11688         status = dcerpc_binding_handle_call(h,
11689                         NULL, &ndr_table_spoolss,
11690                         NDR_SPOOLSS_OPENPRINTEREX, mem_ctx, r);
11691
11692         return status;
11693 }
11694
11695 NTSTATUS dcerpc_spoolss_OpenPrinterEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r)
11696 {
11697         NTSTATUS status;
11698
11699         status = dcerpc_spoolss_OpenPrinterEx_r(p->binding_handle, mem_ctx, r);
11700
11701         if (NT_STATUS_IS_RPC(status)) {
11702                 status = NT_STATUS_NET_WRITE_FAULT;
11703         }
11704
11705         return status;
11706 }
11707
11708 struct dcerpc_spoolss_OpenPrinterEx_state {
11709         struct spoolss_OpenPrinterEx orig;
11710         struct spoolss_OpenPrinterEx tmp;
11711         TALLOC_CTX *out_mem_ctx;
11712 };
11713
11714 static void dcerpc_spoolss_OpenPrinterEx_done(struct tevent_req *subreq);
11715
11716 struct tevent_req *dcerpc_spoolss_OpenPrinterEx_send(TALLOC_CTX *mem_ctx,
11717                                                      struct tevent_context *ev,
11718                                                      struct dcerpc_binding_handle *h,
11719                                                      const char *_printername /* [in] [unique,charset(UTF16)] */,
11720                                                      const char *_datatype /* [in] [unique,charset(UTF16)] */,
11721                                                      struct spoolss_DevmodeContainer _devmode_ctr /* [in]  */,
11722                                                      uint32_t _access_mask /* [in]  */,
11723                                                      uint32_t _level /* [in]  */,
11724                                                      union spoolss_UserLevel _userlevel /* [in] [switch_is(level)] */,
11725                                                      struct policy_handle *_handle /* [out] [ref] */)
11726 {
11727         struct tevent_req *req;
11728         struct dcerpc_spoolss_OpenPrinterEx_state *state;
11729         struct tevent_req *subreq;
11730
11731         req = tevent_req_create(mem_ctx, &state,
11732                                 struct dcerpc_spoolss_OpenPrinterEx_state);
11733         if (req == NULL) {
11734                 return NULL;
11735         }
11736         state->out_mem_ctx = NULL;
11737
11738         /* In parameters */
11739         state->orig.in.printername = _printername;
11740         state->orig.in.datatype = _datatype;
11741         state->orig.in.devmode_ctr = _devmode_ctr;
11742         state->orig.in.access_mask = _access_mask;
11743         state->orig.in.level = _level;
11744         state->orig.in.userlevel = _userlevel;
11745
11746         /* Out parameters */
11747         state->orig.out.handle = _handle;
11748
11749         /* Result */
11750         ZERO_STRUCT(state->orig.out.result);
11751
11752         state->out_mem_ctx = talloc_named_const(state, 0,
11753                              "dcerpc_spoolss_OpenPrinterEx_out_memory");
11754         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11755                 return tevent_req_post(req, ev);
11756         }
11757
11758         /* make a temporary copy, that we pass to the dispatch function */
11759         state->tmp = state->orig;
11760
11761         subreq = dcerpc_spoolss_OpenPrinterEx_r_send(state, ev, h, &state->tmp);
11762         if (tevent_req_nomem(subreq, req)) {
11763                 return tevent_req_post(req, ev);
11764         }
11765         tevent_req_set_callback(subreq, dcerpc_spoolss_OpenPrinterEx_done, req);
11766         return req;
11767 }
11768
11769 static void dcerpc_spoolss_OpenPrinterEx_done(struct tevent_req *subreq)
11770 {
11771         struct tevent_req *req = tevent_req_callback_data(
11772                 subreq, struct tevent_req);
11773         struct dcerpc_spoolss_OpenPrinterEx_state *state = tevent_req_data(
11774                 req, struct dcerpc_spoolss_OpenPrinterEx_state);
11775         NTSTATUS status;
11776         TALLOC_CTX *mem_ctx;
11777
11778         if (state->out_mem_ctx) {
11779                 mem_ctx = state->out_mem_ctx;
11780         } else {
11781                 mem_ctx = state;
11782         }
11783
11784         status = dcerpc_spoolss_OpenPrinterEx_r_recv(subreq, mem_ctx);
11785         TALLOC_FREE(subreq);
11786         if (!NT_STATUS_IS_OK(status)) {
11787                 tevent_req_nterror(req, status);
11788                 return;
11789         }
11790
11791         /* Copy out parameters */
11792         *state->orig.out.handle = *state->tmp.out.handle;
11793
11794         /* Copy result */
11795         state->orig.out.result = state->tmp.out.result;
11796
11797         /* Reset temporary structure */
11798         ZERO_STRUCT(state->tmp);
11799
11800         tevent_req_done(req);
11801 }
11802
11803 NTSTATUS dcerpc_spoolss_OpenPrinterEx_recv(struct tevent_req *req,
11804                                            TALLOC_CTX *mem_ctx,
11805                                            WERROR *result)
11806 {
11807         struct dcerpc_spoolss_OpenPrinterEx_state *state = tevent_req_data(
11808                 req, struct dcerpc_spoolss_OpenPrinterEx_state);
11809         NTSTATUS status;
11810
11811         if (tevent_req_is_nterror(req, &status)) {
11812                 tevent_req_received(req);
11813                 return status;
11814         }
11815
11816         /* Steal possible out parameters to the callers context */
11817         talloc_steal(mem_ctx, state->out_mem_ctx);
11818
11819         /* Return result */
11820         *result = state->orig.out.result;
11821
11822         tevent_req_received(req);
11823         return NT_STATUS_OK;
11824 }
11825
11826 NTSTATUS dcerpc_spoolss_OpenPrinterEx(struct dcerpc_binding_handle *h,
11827                                       TALLOC_CTX *mem_ctx,
11828                                       const char *_printername /* [in] [unique,charset(UTF16)] */,
11829                                       const char *_datatype /* [in] [unique,charset(UTF16)] */,
11830                                       struct spoolss_DevmodeContainer _devmode_ctr /* [in]  */,
11831                                       uint32_t _access_mask /* [in]  */,
11832                                       uint32_t _level /* [in]  */,
11833                                       union spoolss_UserLevel _userlevel /* [in] [switch_is(level)] */,
11834                                       struct policy_handle *_handle /* [out] [ref] */,
11835                                       WERROR *result)
11836 {
11837         struct spoolss_OpenPrinterEx r;
11838         NTSTATUS status;
11839
11840         /* In parameters */
11841         r.in.printername = _printername;
11842         r.in.datatype = _datatype;
11843         r.in.devmode_ctr = _devmode_ctr;
11844         r.in.access_mask = _access_mask;
11845         r.in.level = _level;
11846         r.in.userlevel = _userlevel;
11847
11848         status = dcerpc_spoolss_OpenPrinterEx_r(h, mem_ctx, &r);
11849         if (!NT_STATUS_IS_OK(status)) {
11850                 return status;
11851         }
11852
11853         /* Return variables */
11854         *_handle = *r.out.handle;
11855
11856         /* Return result */
11857         *result = r.out.result;
11858
11859         return NT_STATUS_OK;
11860 }
11861
11862 struct dcerpc_spoolss_AddPrinterEx_r_state {
11863         TALLOC_CTX *out_mem_ctx;
11864 };
11865
11866 static void dcerpc_spoolss_AddPrinterEx_r_done(struct tevent_req *subreq);
11867
11868 struct tevent_req *dcerpc_spoolss_AddPrinterEx_r_send(TALLOC_CTX *mem_ctx,
11869         struct tevent_context *ev,
11870         struct dcerpc_binding_handle *h,
11871         struct spoolss_AddPrinterEx *r)
11872 {
11873         struct tevent_req *req;
11874         struct dcerpc_spoolss_AddPrinterEx_r_state *state;
11875         struct tevent_req *subreq;
11876
11877         req = tevent_req_create(mem_ctx, &state,
11878                                 struct dcerpc_spoolss_AddPrinterEx_r_state);
11879         if (req == NULL) {
11880                 return NULL;
11881         }
11882
11883         state->out_mem_ctx = talloc_new(state);
11884         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11885                 return tevent_req_post(req, ev);
11886         }
11887
11888         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11889                         NULL, &ndr_table_spoolss,
11890                         NDR_SPOOLSS_ADDPRINTEREX, state->out_mem_ctx, r);
11891         if (tevent_req_nomem(subreq, req)) {
11892                 return tevent_req_post(req, ev);
11893         }
11894         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterEx_r_done, req);
11895
11896         return req;
11897 }
11898
11899 static void dcerpc_spoolss_AddPrinterEx_r_done(struct tevent_req *subreq)
11900 {
11901         struct tevent_req *req =
11902                 tevent_req_callback_data(subreq,
11903                 struct tevent_req);
11904         NTSTATUS status;
11905
11906         status = dcerpc_binding_handle_call_recv(subreq);
11907         if (!NT_STATUS_IS_OK(status)) {
11908                 tevent_req_nterror(req, status);
11909                 return;
11910         }
11911
11912         tevent_req_done(req);
11913 }
11914
11915 NTSTATUS dcerpc_spoolss_AddPrinterEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11916 {
11917         struct dcerpc_spoolss_AddPrinterEx_r_state *state =
11918                 tevent_req_data(req,
11919                 struct dcerpc_spoolss_AddPrinterEx_r_state);
11920         NTSTATUS status;
11921
11922         if (tevent_req_is_nterror(req, &status)) {
11923                 tevent_req_received(req);
11924                 return status;
11925         }
11926
11927         talloc_steal(mem_ctx, state->out_mem_ctx);
11928
11929         tevent_req_received(req);
11930         return NT_STATUS_OK;
11931 }
11932
11933 NTSTATUS dcerpc_spoolss_AddPrinterEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterEx *r)
11934 {
11935         NTSTATUS status;
11936
11937         status = dcerpc_binding_handle_call(h,
11938                         NULL, &ndr_table_spoolss,
11939                         NDR_SPOOLSS_ADDPRINTEREX, mem_ctx, r);
11940
11941         return status;
11942 }
11943
11944 NTSTATUS dcerpc_spoolss_AddPrinterEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterEx *r)
11945 {
11946         NTSTATUS status;
11947
11948         status = dcerpc_spoolss_AddPrinterEx_r(p->binding_handle, mem_ctx, r);
11949
11950         if (NT_STATUS_IS_RPC(status)) {
11951                 status = NT_STATUS_NET_WRITE_FAULT;
11952         }
11953
11954         return status;
11955 }
11956
11957 struct dcerpc_spoolss_AddPrinterEx_state {
11958         struct spoolss_AddPrinterEx orig;
11959         struct spoolss_AddPrinterEx tmp;
11960         TALLOC_CTX *out_mem_ctx;
11961 };
11962
11963 static void dcerpc_spoolss_AddPrinterEx_done(struct tevent_req *subreq);
11964
11965 struct tevent_req *dcerpc_spoolss_AddPrinterEx_send(TALLOC_CTX *mem_ctx,
11966                                                     struct tevent_context *ev,
11967                                                     struct dcerpc_binding_handle *h,
11968                                                     const char *_server /* [in] [unique,charset(UTF16)] */,
11969                                                     struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
11970                                                     struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
11971                                                     struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
11972                                                     struct spoolss_UserLevelCtr *_userlevel_ctr /* [in] [ref] */,
11973                                                     struct policy_handle *_handle /* [out] [ref] */)
11974 {
11975         struct tevent_req *req;
11976         struct dcerpc_spoolss_AddPrinterEx_state *state;
11977         struct tevent_req *subreq;
11978
11979         req = tevent_req_create(mem_ctx, &state,
11980                                 struct dcerpc_spoolss_AddPrinterEx_state);
11981         if (req == NULL) {
11982                 return NULL;
11983         }
11984         state->out_mem_ctx = NULL;
11985
11986         /* In parameters */
11987         state->orig.in.server = _server;
11988         state->orig.in.info_ctr = _info_ctr;
11989         state->orig.in.devmode_ctr = _devmode_ctr;
11990         state->orig.in.secdesc_ctr = _secdesc_ctr;
11991         state->orig.in.userlevel_ctr = _userlevel_ctr;
11992
11993         /* Out parameters */
11994         state->orig.out.handle = _handle;
11995
11996         /* Result */
11997         ZERO_STRUCT(state->orig.out.result);
11998
11999         state->out_mem_ctx = talloc_named_const(state, 0,
12000                              "dcerpc_spoolss_AddPrinterEx_out_memory");
12001         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12002                 return tevent_req_post(req, ev);
12003         }
12004
12005         /* make a temporary copy, that we pass to the dispatch function */
12006         state->tmp = state->orig;
12007
12008         subreq = dcerpc_spoolss_AddPrinterEx_r_send(state, ev, h, &state->tmp);
12009         if (tevent_req_nomem(subreq, req)) {
12010                 return tevent_req_post(req, ev);
12011         }
12012         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterEx_done, req);
12013         return req;
12014 }
12015
12016 static void dcerpc_spoolss_AddPrinterEx_done(struct tevent_req *subreq)
12017 {
12018         struct tevent_req *req = tevent_req_callback_data(
12019                 subreq, struct tevent_req);
12020         struct dcerpc_spoolss_AddPrinterEx_state *state = tevent_req_data(
12021                 req, struct dcerpc_spoolss_AddPrinterEx_state);
12022         NTSTATUS status;
12023         TALLOC_CTX *mem_ctx;
12024
12025         if (state->out_mem_ctx) {
12026                 mem_ctx = state->out_mem_ctx;
12027         } else {
12028                 mem_ctx = state;
12029         }
12030
12031         status = dcerpc_spoolss_AddPrinterEx_r_recv(subreq, mem_ctx);
12032         TALLOC_FREE(subreq);
12033         if (!NT_STATUS_IS_OK(status)) {
12034                 tevent_req_nterror(req, status);
12035                 return;
12036         }
12037
12038         /* Copy out parameters */
12039         *state->orig.out.handle = *state->tmp.out.handle;
12040
12041         /* Copy result */
12042         state->orig.out.result = state->tmp.out.result;
12043
12044         /* Reset temporary structure */
12045         ZERO_STRUCT(state->tmp);
12046
12047         tevent_req_done(req);
12048 }
12049
12050 NTSTATUS dcerpc_spoolss_AddPrinterEx_recv(struct tevent_req *req,
12051                                           TALLOC_CTX *mem_ctx,
12052                                           WERROR *result)
12053 {
12054         struct dcerpc_spoolss_AddPrinterEx_state *state = tevent_req_data(
12055                 req, struct dcerpc_spoolss_AddPrinterEx_state);
12056         NTSTATUS status;
12057
12058         if (tevent_req_is_nterror(req, &status)) {
12059                 tevent_req_received(req);
12060                 return status;
12061         }
12062
12063         /* Steal possible out parameters to the callers context */
12064         talloc_steal(mem_ctx, state->out_mem_ctx);
12065
12066         /* Return result */
12067         *result = state->orig.out.result;
12068
12069         tevent_req_received(req);
12070         return NT_STATUS_OK;
12071 }
12072
12073 NTSTATUS dcerpc_spoolss_AddPrinterEx(struct dcerpc_binding_handle *h,
12074                                      TALLOC_CTX *mem_ctx,
12075                                      const char *_server /* [in] [unique,charset(UTF16)] */,
12076                                      struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
12077                                      struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
12078                                      struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
12079                                      struct spoolss_UserLevelCtr *_userlevel_ctr /* [in] [ref] */,
12080                                      struct policy_handle *_handle /* [out] [ref] */,
12081                                      WERROR *result)
12082 {
12083         struct spoolss_AddPrinterEx r;
12084         NTSTATUS status;
12085
12086         /* In parameters */
12087         r.in.server = _server;
12088         r.in.info_ctr = _info_ctr;
12089         r.in.devmode_ctr = _devmode_ctr;
12090         r.in.secdesc_ctr = _secdesc_ctr;
12091         r.in.userlevel_ctr = _userlevel_ctr;
12092
12093         status = dcerpc_spoolss_AddPrinterEx_r(h, mem_ctx, &r);
12094         if (!NT_STATUS_IS_OK(status)) {
12095                 return status;
12096         }
12097
12098         /* Return variables */
12099         *_handle = *r.out.handle;
12100
12101         /* Return result */
12102         *result = r.out.result;
12103
12104         return NT_STATUS_OK;
12105 }
12106
12107 struct dcerpc_spoolss_EnumPrinterData_r_state {
12108         TALLOC_CTX *out_mem_ctx;
12109 };
12110
12111 static void dcerpc_spoolss_EnumPrinterData_r_done(struct tevent_req *subreq);
12112
12113 struct tevent_req *dcerpc_spoolss_EnumPrinterData_r_send(TALLOC_CTX *mem_ctx,
12114         struct tevent_context *ev,
12115         struct dcerpc_binding_handle *h,
12116         struct spoolss_EnumPrinterData *r)
12117 {
12118         struct tevent_req *req;
12119         struct dcerpc_spoolss_EnumPrinterData_r_state *state;
12120         struct tevent_req *subreq;
12121
12122         req = tevent_req_create(mem_ctx, &state,
12123                                 struct dcerpc_spoolss_EnumPrinterData_r_state);
12124         if (req == NULL) {
12125                 return NULL;
12126         }
12127
12128         state->out_mem_ctx = talloc_new(state);
12129         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12130                 return tevent_req_post(req, ev);
12131         }
12132
12133         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12134                         NULL, &ndr_table_spoolss,
12135                         NDR_SPOOLSS_ENUMPRINTERDATA, state->out_mem_ctx, r);
12136         if (tevent_req_nomem(subreq, req)) {
12137                 return tevent_req_post(req, ev);
12138         }
12139         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterData_r_done, req);
12140
12141         return req;
12142 }
12143
12144 static void dcerpc_spoolss_EnumPrinterData_r_done(struct tevent_req *subreq)
12145 {
12146         struct tevent_req *req =
12147                 tevent_req_callback_data(subreq,
12148                 struct tevent_req);
12149         NTSTATUS status;
12150
12151         status = dcerpc_binding_handle_call_recv(subreq);
12152         if (!NT_STATUS_IS_OK(status)) {
12153                 tevent_req_nterror(req, status);
12154                 return;
12155         }
12156
12157         tevent_req_done(req);
12158 }
12159
12160 NTSTATUS dcerpc_spoolss_EnumPrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12161 {
12162         struct dcerpc_spoolss_EnumPrinterData_r_state *state =
12163                 tevent_req_data(req,
12164                 struct dcerpc_spoolss_EnumPrinterData_r_state);
12165         NTSTATUS status;
12166
12167         if (tevent_req_is_nterror(req, &status)) {
12168                 tevent_req_received(req);
12169                 return status;
12170         }
12171
12172         talloc_steal(mem_ctx, state->out_mem_ctx);
12173
12174         tevent_req_received(req);
12175         return NT_STATUS_OK;
12176 }
12177
12178 NTSTATUS dcerpc_spoolss_EnumPrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterData *r)
12179 {
12180         NTSTATUS status;
12181
12182         status = dcerpc_binding_handle_call(h,
12183                         NULL, &ndr_table_spoolss,
12184                         NDR_SPOOLSS_ENUMPRINTERDATA, mem_ctx, r);
12185
12186         return status;
12187 }
12188
12189 NTSTATUS dcerpc_spoolss_EnumPrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterData *r)
12190 {
12191         NTSTATUS status;
12192
12193         status = dcerpc_spoolss_EnumPrinterData_r(p->binding_handle, mem_ctx, r);
12194
12195         if (NT_STATUS_IS_RPC(status)) {
12196                 status = NT_STATUS_NET_WRITE_FAULT;
12197         }
12198
12199         return status;
12200 }
12201
12202 struct dcerpc_spoolss_EnumPrinterData_state {
12203         struct spoolss_EnumPrinterData orig;
12204         struct spoolss_EnumPrinterData tmp;
12205         TALLOC_CTX *out_mem_ctx;
12206 };
12207
12208 static void dcerpc_spoolss_EnumPrinterData_done(struct tevent_req *subreq);
12209
12210 struct tevent_req *dcerpc_spoolss_EnumPrinterData_send(TALLOC_CTX *mem_ctx,
12211                                                        struct tevent_context *ev,
12212                                                        struct dcerpc_binding_handle *h,
12213                                                        struct policy_handle *_handle /* [in] [ref] */,
12214                                                        uint32_t _enum_index /* [in]  */,
12215                                                        const char *_value_name /* [out] [charset(UTF16),size_is(value_offered/2)] */,
12216                                                        uint32_t _value_offered /* [in]  */,
12217                                                        uint32_t *_value_needed /* [out] [ref] */,
12218                                                        enum winreg_Type *_type /* [out] [ref] */,
12219                                                        uint8_t *_data /* [out] [ref,flag(LIBNDR_PRINT_ARRAY_HEX),size_is(data_offered)] */,
12220                                                        uint32_t _data_offered /* [in]  */,
12221                                                        uint32_t *_data_needed /* [out] [ref] */)
12222 {
12223         struct tevent_req *req;
12224         struct dcerpc_spoolss_EnumPrinterData_state *state;
12225         struct tevent_req *subreq;
12226
12227         req = tevent_req_create(mem_ctx, &state,
12228                                 struct dcerpc_spoolss_EnumPrinterData_state);
12229         if (req == NULL) {
12230                 return NULL;
12231         }
12232         state->out_mem_ctx = NULL;
12233
12234         /* In parameters */
12235         state->orig.in.handle = _handle;
12236         state->orig.in.enum_index = _enum_index;
12237         state->orig.in.value_offered = _value_offered;
12238         state->orig.in.data_offered = _data_offered;
12239
12240         /* Out parameters */
12241         state->orig.out.value_name = _value_name;
12242         state->orig.out.value_needed = _value_needed;
12243         state->orig.out.type = _type;
12244         state->orig.out.data = _data;
12245         state->orig.out.data_needed = _data_needed;
12246
12247         /* Result */
12248         ZERO_STRUCT(state->orig.out.result);
12249
12250         state->out_mem_ctx = talloc_named_const(state, 0,
12251                              "dcerpc_spoolss_EnumPrinterData_out_memory");
12252         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12253                 return tevent_req_post(req, ev);
12254         }
12255
12256         /* make a temporary copy, that we pass to the dispatch function */
12257         state->tmp = state->orig;
12258
12259         subreq = dcerpc_spoolss_EnumPrinterData_r_send(state, ev, h, &state->tmp);
12260         if (tevent_req_nomem(subreq, req)) {
12261                 return tevent_req_post(req, ev);
12262         }
12263         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterData_done, req);
12264         return req;
12265 }
12266
12267 static void dcerpc_spoolss_EnumPrinterData_done(struct tevent_req *subreq)
12268 {
12269         struct tevent_req *req = tevent_req_callback_data(
12270                 subreq, struct tevent_req);
12271         struct dcerpc_spoolss_EnumPrinterData_state *state = tevent_req_data(
12272                 req, struct dcerpc_spoolss_EnumPrinterData_state);
12273         NTSTATUS status;
12274         TALLOC_CTX *mem_ctx;
12275
12276         if (state->out_mem_ctx) {
12277                 mem_ctx = state->out_mem_ctx;
12278         } else {
12279                 mem_ctx = state;
12280         }
12281
12282         status = dcerpc_spoolss_EnumPrinterData_r_recv(subreq, mem_ctx);
12283         TALLOC_FREE(subreq);
12284         if (!NT_STATUS_IS_OK(status)) {
12285                 tevent_req_nterror(req, status);
12286                 return;
12287         }
12288
12289         /* Copy out parameters */
12290         {
12291                 size_t _copy_len_value_name;
12292                 _copy_len_value_name = ndr_charset_length(state->tmp.out.value_name, CH_UNIX);
12293                 if (_copy_len_value_name > state->tmp.in.value_offered / 2) {
12294                         tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
12295                         return;
12296                 }
12297                 memcpy(discard_const_p(uint8_t *, state->orig.out.value_name), state->tmp.out.value_name, _copy_len_value_name * sizeof(*state->orig.out.value_name));
12298         }
12299         *state->orig.out.value_needed = *state->tmp.out.value_needed;
12300         *state->orig.out.type = *state->tmp.out.type;
12301         {
12302                 size_t _copy_len_data;
12303                 _copy_len_data = state->tmp.in.data_offered;
12304                 memcpy(state->orig.out.data, state->tmp.out.data, _copy_len_data * sizeof(*state->orig.out.data));
12305         }
12306         *state->orig.out.data_needed = *state->tmp.out.data_needed;
12307
12308         /* Copy result */
12309         state->orig.out.result = state->tmp.out.result;
12310
12311         /* Reset temporary structure */
12312         ZERO_STRUCT(state->tmp);
12313
12314         tevent_req_done(req);
12315 }
12316
12317 NTSTATUS dcerpc_spoolss_EnumPrinterData_recv(struct tevent_req *req,
12318                                              TALLOC_CTX *mem_ctx,
12319                                              WERROR *result)
12320 {
12321         struct dcerpc_spoolss_EnumPrinterData_state *state = tevent_req_data(
12322                 req, struct dcerpc_spoolss_EnumPrinterData_state);
12323         NTSTATUS status;
12324
12325         if (tevent_req_is_nterror(req, &status)) {
12326                 tevent_req_received(req);
12327                 return status;
12328         }
12329
12330         /* Steal possible out parameters to the callers context */
12331         talloc_steal(mem_ctx, state->out_mem_ctx);
12332
12333         /* Return result */
12334         *result = state->orig.out.result;
12335
12336         tevent_req_received(req);
12337         return NT_STATUS_OK;
12338 }
12339
12340 NTSTATUS dcerpc_spoolss_EnumPrinterData(struct dcerpc_binding_handle *h,
12341                                         TALLOC_CTX *mem_ctx,
12342                                         struct policy_handle *_handle /* [in] [ref] */,
12343                                         uint32_t _enum_index /* [in]  */,
12344                                         const char *_value_name /* [out] [charset(UTF16),size_is(value_offered/2)] */,
12345                                         uint32_t _value_offered /* [in]  */,
12346                                         uint32_t *_value_needed /* [out] [ref] */,
12347                                         enum winreg_Type *_type /* [out] [ref] */,
12348                                         uint8_t *_data /* [out] [ref,flag(LIBNDR_PRINT_ARRAY_HEX),size_is(data_offered)] */,
12349                                         uint32_t _data_offered /* [in]  */,
12350                                         uint32_t *_data_needed /* [out] [ref] */,
12351                                         WERROR *result)
12352 {
12353         struct spoolss_EnumPrinterData r;
12354         NTSTATUS status;
12355
12356         /* In parameters */
12357         r.in.handle = _handle;
12358         r.in.enum_index = _enum_index;
12359         r.in.value_offered = _value_offered;
12360         r.in.data_offered = _data_offered;
12361
12362         status = dcerpc_spoolss_EnumPrinterData_r(h, mem_ctx, &r);
12363         if (!NT_STATUS_IS_OK(status)) {
12364                 return status;
12365         }
12366
12367         /* Return variables */
12368         {
12369                 size_t _copy_len_value_name;
12370                 _copy_len_value_name = ndr_charset_length(r.out.value_name, CH_UNIX);
12371                 if (_copy_len_value_name > r.in.value_offered / 2) {
12372                         return NT_STATUS_INVALID_NETWORK_RESPONSE;
12373                 }
12374                 memcpy(discard_const_p(uint8_t *, _value_name), r.out.value_name, _copy_len_value_name * sizeof(*_value_name));
12375         }
12376         *_value_needed = *r.out.value_needed;
12377         *_type = *r.out.type;
12378         {
12379                 size_t _copy_len_data;
12380                 _copy_len_data = r.in.data_offered;
12381                 memcpy(_data, r.out.data, _copy_len_data * sizeof(*_data));
12382         }
12383         *_data_needed = *r.out.data_needed;
12384
12385         /* Return result */
12386         *result = r.out.result;
12387
12388         return NT_STATUS_OK;
12389 }
12390
12391 struct dcerpc_spoolss_DeletePrinterData_r_state {
12392         TALLOC_CTX *out_mem_ctx;
12393 };
12394
12395 static void dcerpc_spoolss_DeletePrinterData_r_done(struct tevent_req *subreq);
12396
12397 struct tevent_req *dcerpc_spoolss_DeletePrinterData_r_send(TALLOC_CTX *mem_ctx,
12398         struct tevent_context *ev,
12399         struct dcerpc_binding_handle *h,
12400         struct spoolss_DeletePrinterData *r)
12401 {
12402         struct tevent_req *req;
12403         struct dcerpc_spoolss_DeletePrinterData_r_state *state;
12404         struct tevent_req *subreq;
12405
12406         req = tevent_req_create(mem_ctx, &state,
12407                                 struct dcerpc_spoolss_DeletePrinterData_r_state);
12408         if (req == NULL) {
12409                 return NULL;
12410         }
12411
12412         state->out_mem_ctx = NULL;
12413         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12414                         NULL, &ndr_table_spoolss,
12415                         NDR_SPOOLSS_DELETEPRINTERDATA, state, r);
12416         if (tevent_req_nomem(subreq, req)) {
12417                 return tevent_req_post(req, ev);
12418         }
12419         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterData_r_done, req);
12420
12421         return req;
12422 }
12423
12424 static void dcerpc_spoolss_DeletePrinterData_r_done(struct tevent_req *subreq)
12425 {
12426         struct tevent_req *req =
12427                 tevent_req_callback_data(subreq,
12428                 struct tevent_req);
12429         NTSTATUS status;
12430
12431         status = dcerpc_binding_handle_call_recv(subreq);
12432         if (!NT_STATUS_IS_OK(status)) {
12433                 tevent_req_nterror(req, status);
12434                 return;
12435         }
12436
12437         tevent_req_done(req);
12438 }
12439
12440 NTSTATUS dcerpc_spoolss_DeletePrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12441 {
12442         struct dcerpc_spoolss_DeletePrinterData_r_state *state =
12443                 tevent_req_data(req,
12444                 struct dcerpc_spoolss_DeletePrinterData_r_state);
12445         NTSTATUS status;
12446
12447         if (tevent_req_is_nterror(req, &status)) {
12448                 tevent_req_received(req);
12449                 return status;
12450         }
12451
12452         talloc_steal(mem_ctx, state->out_mem_ctx);
12453
12454         tevent_req_received(req);
12455         return NT_STATUS_OK;
12456 }
12457
12458 NTSTATUS dcerpc_spoolss_DeletePrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterData *r)
12459 {
12460         NTSTATUS status;
12461
12462         status = dcerpc_binding_handle_call(h,
12463                         NULL, &ndr_table_spoolss,
12464                         NDR_SPOOLSS_DELETEPRINTERDATA, mem_ctx, r);
12465
12466         return status;
12467 }
12468
12469 NTSTATUS dcerpc_spoolss_DeletePrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterData *r)
12470 {
12471         NTSTATUS status;
12472
12473         status = dcerpc_spoolss_DeletePrinterData_r(p->binding_handle, mem_ctx, r);
12474
12475         if (NT_STATUS_IS_RPC(status)) {
12476                 status = NT_STATUS_NET_WRITE_FAULT;
12477         }
12478
12479         return status;
12480 }
12481
12482 struct dcerpc_spoolss_DeletePrinterData_state {
12483         struct spoolss_DeletePrinterData orig;
12484         struct spoolss_DeletePrinterData tmp;
12485         TALLOC_CTX *out_mem_ctx;
12486 };
12487
12488 static void dcerpc_spoolss_DeletePrinterData_done(struct tevent_req *subreq);
12489
12490 struct tevent_req *dcerpc_spoolss_DeletePrinterData_send(TALLOC_CTX *mem_ctx,
12491                                                          struct tevent_context *ev,
12492                                                          struct dcerpc_binding_handle *h,
12493                                                          struct policy_handle *_handle /* [in] [ref] */,
12494                                                          const char *_value_name /* [in] [charset(UTF16)] */)
12495 {
12496         struct tevent_req *req;
12497         struct dcerpc_spoolss_DeletePrinterData_state *state;
12498         struct tevent_req *subreq;
12499
12500         req = tevent_req_create(mem_ctx, &state,
12501                                 struct dcerpc_spoolss_DeletePrinterData_state);
12502         if (req == NULL) {
12503                 return NULL;
12504         }
12505         state->out_mem_ctx = NULL;
12506
12507         /* In parameters */
12508         state->orig.in.handle = _handle;
12509         state->orig.in.value_name = _value_name;
12510
12511         /* Out parameters */
12512
12513         /* Result */
12514         ZERO_STRUCT(state->orig.out.result);
12515
12516         /* make a temporary copy, that we pass to the dispatch function */
12517         state->tmp = state->orig;
12518
12519         subreq = dcerpc_spoolss_DeletePrinterData_r_send(state, ev, h, &state->tmp);
12520         if (tevent_req_nomem(subreq, req)) {
12521                 return tevent_req_post(req, ev);
12522         }
12523         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterData_done, req);
12524         return req;
12525 }
12526
12527 static void dcerpc_spoolss_DeletePrinterData_done(struct tevent_req *subreq)
12528 {
12529         struct tevent_req *req = tevent_req_callback_data(
12530                 subreq, struct tevent_req);
12531         struct dcerpc_spoolss_DeletePrinterData_state *state = tevent_req_data(
12532                 req, struct dcerpc_spoolss_DeletePrinterData_state);
12533         NTSTATUS status;
12534         TALLOC_CTX *mem_ctx;
12535
12536         if (state->out_mem_ctx) {
12537                 mem_ctx = state->out_mem_ctx;
12538         } else {
12539                 mem_ctx = state;
12540         }
12541
12542         status = dcerpc_spoolss_DeletePrinterData_r_recv(subreq, mem_ctx);
12543         TALLOC_FREE(subreq);
12544         if (!NT_STATUS_IS_OK(status)) {
12545                 tevent_req_nterror(req, status);
12546                 return;
12547         }
12548
12549         /* Copy out parameters */
12550
12551         /* Copy result */
12552         state->orig.out.result = state->tmp.out.result;
12553
12554         /* Reset temporary structure */
12555         ZERO_STRUCT(state->tmp);
12556
12557         tevent_req_done(req);
12558 }
12559
12560 NTSTATUS dcerpc_spoolss_DeletePrinterData_recv(struct tevent_req *req,
12561                                                TALLOC_CTX *mem_ctx,
12562                                                WERROR *result)
12563 {
12564         struct dcerpc_spoolss_DeletePrinterData_state *state = tevent_req_data(
12565                 req, struct dcerpc_spoolss_DeletePrinterData_state);
12566         NTSTATUS status;
12567
12568         if (tevent_req_is_nterror(req, &status)) {
12569                 tevent_req_received(req);
12570                 return status;
12571         }
12572
12573         /* Steal possible out parameters to the callers context */
12574         talloc_steal(mem_ctx, state->out_mem_ctx);
12575
12576         /* Return result */
12577         *result = state->orig.out.result;
12578
12579         tevent_req_received(req);
12580         return NT_STATUS_OK;
12581 }
12582
12583 NTSTATUS dcerpc_spoolss_DeletePrinterData(struct dcerpc_binding_handle *h,
12584                                           TALLOC_CTX *mem_ctx,
12585                                           struct policy_handle *_handle /* [in] [ref] */,
12586                                           const char *_value_name /* [in] [charset(UTF16)] */,
12587                                           WERROR *result)
12588 {
12589         struct spoolss_DeletePrinterData r;
12590         NTSTATUS status;
12591
12592         /* In parameters */
12593         r.in.handle = _handle;
12594         r.in.value_name = _value_name;
12595
12596         status = dcerpc_spoolss_DeletePrinterData_r(h, mem_ctx, &r);
12597         if (!NT_STATUS_IS_OK(status)) {
12598                 return status;
12599         }
12600
12601         /* Return variables */
12602
12603         /* Return result */
12604         *result = r.out.result;
12605
12606         return NT_STATUS_OK;
12607 }
12608
12609 struct dcerpc_spoolss_SetPrinterDataEx_r_state {
12610         TALLOC_CTX *out_mem_ctx;
12611 };
12612
12613 static void dcerpc_spoolss_SetPrinterDataEx_r_done(struct tevent_req *subreq);
12614
12615 struct tevent_req *dcerpc_spoolss_SetPrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
12616         struct tevent_context *ev,
12617         struct dcerpc_binding_handle *h,
12618         struct spoolss_SetPrinterDataEx *r)
12619 {
12620         struct tevent_req *req;
12621         struct dcerpc_spoolss_SetPrinterDataEx_r_state *state;
12622         struct tevent_req *subreq;
12623
12624         req = tevent_req_create(mem_ctx, &state,
12625                                 struct dcerpc_spoolss_SetPrinterDataEx_r_state);
12626         if (req == NULL) {
12627                 return NULL;
12628         }
12629
12630         state->out_mem_ctx = NULL;
12631         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12632                         NULL, &ndr_table_spoolss,
12633                         NDR_SPOOLSS_SETPRINTERDATAEX, state, r);
12634         if (tevent_req_nomem(subreq, req)) {
12635                 return tevent_req_post(req, ev);
12636         }
12637         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterDataEx_r_done, req);
12638
12639         return req;
12640 }
12641
12642 static void dcerpc_spoolss_SetPrinterDataEx_r_done(struct tevent_req *subreq)
12643 {
12644         struct tevent_req *req =
12645                 tevent_req_callback_data(subreq,
12646                 struct tevent_req);
12647         NTSTATUS status;
12648
12649         status = dcerpc_binding_handle_call_recv(subreq);
12650         if (!NT_STATUS_IS_OK(status)) {
12651                 tevent_req_nterror(req, status);
12652                 return;
12653         }
12654
12655         tevent_req_done(req);
12656 }
12657
12658 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12659 {
12660         struct dcerpc_spoolss_SetPrinterDataEx_r_state *state =
12661                 tevent_req_data(req,
12662                 struct dcerpc_spoolss_SetPrinterDataEx_r_state);
12663         NTSTATUS status;
12664
12665         if (tevent_req_is_nterror(req, &status)) {
12666                 tevent_req_received(req);
12667                 return status;
12668         }
12669
12670         talloc_steal(mem_ctx, state->out_mem_ctx);
12671
12672         tevent_req_received(req);
12673         return NT_STATUS_OK;
12674 }
12675
12676 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterDataEx *r)
12677 {
12678         NTSTATUS status;
12679
12680         status = dcerpc_binding_handle_call(h,
12681                         NULL, &ndr_table_spoolss,
12682                         NDR_SPOOLSS_SETPRINTERDATAEX, mem_ctx, r);
12683
12684         return status;
12685 }
12686
12687 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterDataEx *r)
12688 {
12689         NTSTATUS status;
12690
12691         status = dcerpc_spoolss_SetPrinterDataEx_r(p->binding_handle, mem_ctx, r);
12692
12693         if (NT_STATUS_IS_RPC(status)) {
12694                 status = NT_STATUS_NET_WRITE_FAULT;
12695         }
12696
12697         return status;
12698 }
12699
12700 struct dcerpc_spoolss_SetPrinterDataEx_state {
12701         struct spoolss_SetPrinterDataEx orig;
12702         struct spoolss_SetPrinterDataEx tmp;
12703         TALLOC_CTX *out_mem_ctx;
12704 };
12705
12706 static void dcerpc_spoolss_SetPrinterDataEx_done(struct tevent_req *subreq);
12707
12708 struct tevent_req *dcerpc_spoolss_SetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
12709                                                         struct tevent_context *ev,
12710                                                         struct dcerpc_binding_handle *h,
12711                                                         struct policy_handle *_handle /* [in] [ref] */,
12712                                                         const char *_key_name /* [in] [charset(UTF16)] */,
12713                                                         const char *_value_name /* [in] [charset(UTF16)] */,
12714                                                         enum winreg_Type _type /* [in]  */,
12715                                                         uint8_t *_data /* [in] [ref,size_is(offered)] */,
12716                                                         uint32_t _offered /* [in]  */)
12717 {
12718         struct tevent_req *req;
12719         struct dcerpc_spoolss_SetPrinterDataEx_state *state;
12720         struct tevent_req *subreq;
12721
12722         req = tevent_req_create(mem_ctx, &state,
12723                                 struct dcerpc_spoolss_SetPrinterDataEx_state);
12724         if (req == NULL) {
12725                 return NULL;
12726         }
12727         state->out_mem_ctx = NULL;
12728
12729         /* In parameters */
12730         state->orig.in.handle = _handle;
12731         state->orig.in.key_name = _key_name;
12732         state->orig.in.value_name = _value_name;
12733         state->orig.in.type = _type;
12734         state->orig.in.data = _data;
12735         state->orig.in.offered = _offered;
12736
12737         /* Out parameters */
12738
12739         /* Result */
12740         ZERO_STRUCT(state->orig.out.result);
12741
12742         /* make a temporary copy, that we pass to the dispatch function */
12743         state->tmp = state->orig;
12744
12745         subreq = dcerpc_spoolss_SetPrinterDataEx_r_send(state, ev, h, &state->tmp);
12746         if (tevent_req_nomem(subreq, req)) {
12747                 return tevent_req_post(req, ev);
12748         }
12749         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterDataEx_done, req);
12750         return req;
12751 }
12752
12753 static void dcerpc_spoolss_SetPrinterDataEx_done(struct tevent_req *subreq)
12754 {
12755         struct tevent_req *req = tevent_req_callback_data(
12756                 subreq, struct tevent_req);
12757         struct dcerpc_spoolss_SetPrinterDataEx_state *state = tevent_req_data(
12758                 req, struct dcerpc_spoolss_SetPrinterDataEx_state);
12759         NTSTATUS status;
12760         TALLOC_CTX *mem_ctx;
12761
12762         if (state->out_mem_ctx) {
12763                 mem_ctx = state->out_mem_ctx;
12764         } else {
12765                 mem_ctx = state;
12766         }
12767
12768         status = dcerpc_spoolss_SetPrinterDataEx_r_recv(subreq, mem_ctx);
12769         TALLOC_FREE(subreq);
12770         if (!NT_STATUS_IS_OK(status)) {
12771                 tevent_req_nterror(req, status);
12772                 return;
12773         }
12774
12775         /* Copy out parameters */
12776
12777         /* Copy result */
12778         state->orig.out.result = state->tmp.out.result;
12779
12780         /* Reset temporary structure */
12781         ZERO_STRUCT(state->tmp);
12782
12783         tevent_req_done(req);
12784 }
12785
12786 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_recv(struct tevent_req *req,
12787                                               TALLOC_CTX *mem_ctx,
12788                                               WERROR *result)
12789 {
12790         struct dcerpc_spoolss_SetPrinterDataEx_state *state = tevent_req_data(
12791                 req, struct dcerpc_spoolss_SetPrinterDataEx_state);
12792         NTSTATUS status;
12793
12794         if (tevent_req_is_nterror(req, &status)) {
12795                 tevent_req_received(req);
12796                 return status;
12797         }
12798
12799         /* Steal possible out parameters to the callers context */
12800         talloc_steal(mem_ctx, state->out_mem_ctx);
12801
12802         /* Return result */
12803         *result = state->orig.out.result;
12804
12805         tevent_req_received(req);
12806         return NT_STATUS_OK;
12807 }
12808
12809 NTSTATUS dcerpc_spoolss_SetPrinterDataEx(struct dcerpc_binding_handle *h,
12810                                          TALLOC_CTX *mem_ctx,
12811                                          struct policy_handle *_handle /* [in] [ref] */,
12812                                          const char *_key_name /* [in] [charset(UTF16)] */,
12813                                          const char *_value_name /* [in] [charset(UTF16)] */,
12814                                          enum winreg_Type _type /* [in]  */,
12815                                          uint8_t *_data /* [in] [ref,size_is(offered)] */,
12816                                          uint32_t _offered /* [in]  */,
12817                                          WERROR *result)
12818 {
12819         struct spoolss_SetPrinterDataEx r;
12820         NTSTATUS status;
12821
12822         /* In parameters */
12823         r.in.handle = _handle;
12824         r.in.key_name = _key_name;
12825         r.in.value_name = _value_name;
12826         r.in.type = _type;
12827         r.in.data = _data;
12828         r.in.offered = _offered;
12829
12830         status = dcerpc_spoolss_SetPrinterDataEx_r(h, mem_ctx, &r);
12831         if (!NT_STATUS_IS_OK(status)) {
12832                 return status;
12833         }
12834
12835         /* Return variables */
12836
12837         /* Return result */
12838         *result = r.out.result;
12839
12840         return NT_STATUS_OK;
12841 }
12842
12843 struct dcerpc_spoolss_GetPrinterDataEx_r_state {
12844         TALLOC_CTX *out_mem_ctx;
12845 };
12846
12847 static void dcerpc_spoolss_GetPrinterDataEx_r_done(struct tevent_req *subreq);
12848
12849 struct tevent_req *dcerpc_spoolss_GetPrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
12850         struct tevent_context *ev,
12851         struct dcerpc_binding_handle *h,
12852         struct spoolss_GetPrinterDataEx *r)
12853 {
12854         struct tevent_req *req;
12855         struct dcerpc_spoolss_GetPrinterDataEx_r_state *state;
12856         struct tevent_req *subreq;
12857
12858         req = tevent_req_create(mem_ctx, &state,
12859                                 struct dcerpc_spoolss_GetPrinterDataEx_r_state);
12860         if (req == NULL) {
12861                 return NULL;
12862         }
12863
12864         state->out_mem_ctx = talloc_new(state);
12865         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12866                 return tevent_req_post(req, ev);
12867         }
12868
12869         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12870                         NULL, &ndr_table_spoolss,
12871                         NDR_SPOOLSS_GETPRINTERDATAEX, state->out_mem_ctx, r);
12872         if (tevent_req_nomem(subreq, req)) {
12873                 return tevent_req_post(req, ev);
12874         }
12875         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDataEx_r_done, req);
12876
12877         return req;
12878 }
12879
12880 static void dcerpc_spoolss_GetPrinterDataEx_r_done(struct tevent_req *subreq)
12881 {
12882         struct tevent_req *req =
12883                 tevent_req_callback_data(subreq,
12884                 struct tevent_req);
12885         NTSTATUS status;
12886
12887         status = dcerpc_binding_handle_call_recv(subreq);
12888         if (!NT_STATUS_IS_OK(status)) {
12889                 tevent_req_nterror(req, status);
12890                 return;
12891         }
12892
12893         tevent_req_done(req);
12894 }
12895
12896 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12897 {
12898         struct dcerpc_spoolss_GetPrinterDataEx_r_state *state =
12899                 tevent_req_data(req,
12900                 struct dcerpc_spoolss_GetPrinterDataEx_r_state);
12901         NTSTATUS status;
12902
12903         if (tevent_req_is_nterror(req, &status)) {
12904                 tevent_req_received(req);
12905                 return status;
12906         }
12907
12908         talloc_steal(mem_ctx, state->out_mem_ctx);
12909
12910         tevent_req_received(req);
12911         return NT_STATUS_OK;
12912 }
12913
12914 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDataEx *r)
12915 {
12916         NTSTATUS status;
12917
12918         status = dcerpc_binding_handle_call(h,
12919                         NULL, &ndr_table_spoolss,
12920                         NDR_SPOOLSS_GETPRINTERDATAEX, mem_ctx, r);
12921
12922         return status;
12923 }
12924
12925 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDataEx *r)
12926 {
12927         NTSTATUS status;
12928
12929         status = dcerpc_spoolss_GetPrinterDataEx_r(p->binding_handle, mem_ctx, r);
12930
12931         if (NT_STATUS_IS_RPC(status)) {
12932                 status = NT_STATUS_NET_WRITE_FAULT;
12933         }
12934
12935         return status;
12936 }
12937
12938 struct dcerpc_spoolss_GetPrinterDataEx_state {
12939         struct spoolss_GetPrinterDataEx orig;
12940         struct spoolss_GetPrinterDataEx tmp;
12941         TALLOC_CTX *out_mem_ctx;
12942 };
12943
12944 static void dcerpc_spoolss_GetPrinterDataEx_done(struct tevent_req *subreq);
12945
12946 struct tevent_req *dcerpc_spoolss_GetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
12947                                                         struct tevent_context *ev,
12948                                                         struct dcerpc_binding_handle *h,
12949                                                         struct policy_handle *_handle /* [in] [ref] */,
12950                                                         const char *_key_name /* [in] [charset(UTF16)] */,
12951                                                         const char *_value_name /* [in] [charset(UTF16)] */,
12952                                                         enum winreg_Type *_type /* [out] [ref] */,
12953                                                         uint8_t *_data /* [out] [ref,size_is(offered)] */,
12954                                                         uint32_t _offered /* [in]  */,
12955                                                         uint32_t *_needed /* [out] [ref] */)
12956 {
12957         struct tevent_req *req;
12958         struct dcerpc_spoolss_GetPrinterDataEx_state *state;
12959         struct tevent_req *subreq;
12960
12961         req = tevent_req_create(mem_ctx, &state,
12962                                 struct dcerpc_spoolss_GetPrinterDataEx_state);
12963         if (req == NULL) {
12964                 return NULL;
12965         }
12966         state->out_mem_ctx = NULL;
12967
12968         /* In parameters */
12969         state->orig.in.handle = _handle;
12970         state->orig.in.key_name = _key_name;
12971         state->orig.in.value_name = _value_name;
12972         state->orig.in.offered = _offered;
12973
12974         /* Out parameters */
12975         state->orig.out.type = _type;
12976         state->orig.out.data = _data;
12977         state->orig.out.needed = _needed;
12978
12979         /* Result */
12980         ZERO_STRUCT(state->orig.out.result);
12981
12982         state->out_mem_ctx = talloc_named_const(state, 0,
12983                              "dcerpc_spoolss_GetPrinterDataEx_out_memory");
12984         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12985                 return tevent_req_post(req, ev);
12986         }
12987
12988         /* make a temporary copy, that we pass to the dispatch function */
12989         state->tmp = state->orig;
12990
12991         subreq = dcerpc_spoolss_GetPrinterDataEx_r_send(state, ev, h, &state->tmp);
12992         if (tevent_req_nomem(subreq, req)) {
12993                 return tevent_req_post(req, ev);
12994         }
12995         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDataEx_done, req);
12996         return req;
12997 }
12998
12999 static void dcerpc_spoolss_GetPrinterDataEx_done(struct tevent_req *subreq)
13000 {
13001         struct tevent_req *req = tevent_req_callback_data(
13002                 subreq, struct tevent_req);
13003         struct dcerpc_spoolss_GetPrinterDataEx_state *state = tevent_req_data(
13004                 req, struct dcerpc_spoolss_GetPrinterDataEx_state);
13005         NTSTATUS status;
13006         TALLOC_CTX *mem_ctx;
13007
13008         if (state->out_mem_ctx) {
13009                 mem_ctx = state->out_mem_ctx;
13010         } else {
13011                 mem_ctx = state;
13012         }
13013
13014         status = dcerpc_spoolss_GetPrinterDataEx_r_recv(subreq, mem_ctx);
13015         TALLOC_FREE(subreq);
13016         if (!NT_STATUS_IS_OK(status)) {
13017                 tevent_req_nterror(req, status);
13018                 return;
13019         }
13020
13021         /* Copy out parameters */
13022         *state->orig.out.type = *state->tmp.out.type;
13023         {
13024                 size_t _copy_len_data;
13025                 _copy_len_data = state->tmp.in.offered;
13026                 memcpy(state->orig.out.data, state->tmp.out.data, _copy_len_data * sizeof(*state->orig.out.data));
13027         }
13028         *state->orig.out.needed = *state->tmp.out.needed;
13029
13030         /* Copy result */
13031         state->orig.out.result = state->tmp.out.result;
13032
13033         /* Reset temporary structure */
13034         ZERO_STRUCT(state->tmp);
13035
13036         tevent_req_done(req);
13037 }
13038
13039 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_recv(struct tevent_req *req,
13040                                               TALLOC_CTX *mem_ctx,
13041                                               WERROR *result)
13042 {
13043         struct dcerpc_spoolss_GetPrinterDataEx_state *state = tevent_req_data(
13044                 req, struct dcerpc_spoolss_GetPrinterDataEx_state);
13045         NTSTATUS status;
13046
13047         if (tevent_req_is_nterror(req, &status)) {
13048                 tevent_req_received(req);
13049                 return status;
13050         }
13051
13052         /* Steal possible out parameters to the callers context */
13053         talloc_steal(mem_ctx, state->out_mem_ctx);
13054
13055         /* Return result */
13056         *result = state->orig.out.result;
13057
13058         tevent_req_received(req);
13059         return NT_STATUS_OK;
13060 }
13061
13062 NTSTATUS dcerpc_spoolss_GetPrinterDataEx(struct dcerpc_binding_handle *h,
13063                                          TALLOC_CTX *mem_ctx,
13064                                          struct policy_handle *_handle /* [in] [ref] */,
13065                                          const char *_key_name /* [in] [charset(UTF16)] */,
13066                                          const char *_value_name /* [in] [charset(UTF16)] */,
13067                                          enum winreg_Type *_type /* [out] [ref] */,
13068                                          uint8_t *_data /* [out] [ref,size_is(offered)] */,
13069                                          uint32_t _offered /* [in]  */,
13070                                          uint32_t *_needed /* [out] [ref] */,
13071                                          WERROR *result)
13072 {
13073         struct spoolss_GetPrinterDataEx r;
13074         NTSTATUS status;
13075
13076         /* In parameters */
13077         r.in.handle = _handle;
13078         r.in.key_name = _key_name;
13079         r.in.value_name = _value_name;
13080         r.in.offered = _offered;
13081
13082         status = dcerpc_spoolss_GetPrinterDataEx_r(h, mem_ctx, &r);
13083         if (!NT_STATUS_IS_OK(status)) {
13084                 return status;
13085         }
13086
13087         /* Return variables */
13088         *_type = *r.out.type;
13089         {
13090                 size_t _copy_len_data;
13091                 _copy_len_data = r.in.offered;
13092                 memcpy(_data, r.out.data, _copy_len_data * sizeof(*_data));
13093         }
13094         *_needed = *r.out.needed;
13095
13096         /* Return result */
13097         *result = r.out.result;
13098
13099         return NT_STATUS_OK;
13100 }
13101
13102 struct dcerpc_spoolss_EnumPrinterDataEx_r_state {
13103         TALLOC_CTX *out_mem_ctx;
13104 };
13105
13106 static void dcerpc_spoolss_EnumPrinterDataEx_r_done(struct tevent_req *subreq);
13107
13108 struct tevent_req *dcerpc_spoolss_EnumPrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
13109         struct tevent_context *ev,
13110         struct dcerpc_binding_handle *h,
13111         struct spoolss_EnumPrinterDataEx *r)
13112 {
13113         struct tevent_req *req;
13114         struct dcerpc_spoolss_EnumPrinterDataEx_r_state *state;
13115         struct tevent_req *subreq;
13116
13117         req = tevent_req_create(mem_ctx, &state,
13118                                 struct dcerpc_spoolss_EnumPrinterDataEx_r_state);
13119         if (req == NULL) {
13120                 return NULL;
13121         }
13122
13123         state->out_mem_ctx = talloc_new(state);
13124         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13125                 return tevent_req_post(req, ev);
13126         }
13127
13128         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13129                         NULL, &ndr_table_spoolss,
13130                         NDR_SPOOLSS_ENUMPRINTERDATAEX, state->out_mem_ctx, r);
13131         if (tevent_req_nomem(subreq, req)) {
13132                 return tevent_req_post(req, ev);
13133         }
13134         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterDataEx_r_done, req);
13135
13136         return req;
13137 }
13138
13139 static void dcerpc_spoolss_EnumPrinterDataEx_r_done(struct tevent_req *subreq)
13140 {
13141         struct tevent_req *req =
13142                 tevent_req_callback_data(subreq,
13143                 struct tevent_req);
13144         NTSTATUS status;
13145
13146         status = dcerpc_binding_handle_call_recv(subreq);
13147         if (!NT_STATUS_IS_OK(status)) {
13148                 tevent_req_nterror(req, status);
13149                 return;
13150         }
13151
13152         tevent_req_done(req);
13153 }
13154
13155 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13156 {
13157         struct dcerpc_spoolss_EnumPrinterDataEx_r_state *state =
13158                 tevent_req_data(req,
13159                 struct dcerpc_spoolss_EnumPrinterDataEx_r_state);
13160         NTSTATUS status;
13161
13162         if (tevent_req_is_nterror(req, &status)) {
13163                 tevent_req_received(req);
13164                 return status;
13165         }
13166
13167         talloc_steal(mem_ctx, state->out_mem_ctx);
13168
13169         tevent_req_received(req);
13170         return NT_STATUS_OK;
13171 }
13172
13173 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDataEx *r)
13174 {
13175         NTSTATUS status;
13176
13177         status = dcerpc_binding_handle_call(h,
13178                         NULL, &ndr_table_spoolss,
13179                         NDR_SPOOLSS_ENUMPRINTERDATAEX, mem_ctx, r);
13180
13181         return status;
13182 }
13183
13184 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDataEx *r)
13185 {
13186         NTSTATUS status;
13187
13188         status = dcerpc_spoolss_EnumPrinterDataEx_r(p->binding_handle, mem_ctx, r);
13189
13190         if (NT_STATUS_IS_RPC(status)) {
13191                 status = NT_STATUS_NET_WRITE_FAULT;
13192         }
13193
13194         return status;
13195 }
13196
13197 struct dcerpc_spoolss_EnumPrinterDataEx_state {
13198         struct spoolss_EnumPrinterDataEx orig;
13199         struct spoolss_EnumPrinterDataEx tmp;
13200         TALLOC_CTX *out_mem_ctx;
13201 };
13202
13203 static void dcerpc_spoolss_EnumPrinterDataEx_done(struct tevent_req *subreq);
13204
13205 struct tevent_req *dcerpc_spoolss_EnumPrinterDataEx_send(TALLOC_CTX *mem_ctx,
13206                                                          struct tevent_context *ev,
13207                                                          struct dcerpc_binding_handle *h,
13208                                                          struct policy_handle *_handle /* [in] [ref] */,
13209                                                          const char *_key_name /* [in] [charset(UTF16)] */,
13210                                                          uint32_t _offered /* [in]  */,
13211                                                          uint32_t *_count /* [out] [ref] */,
13212                                                          struct spoolss_PrinterEnumValues **_info /* [out] [ref,size_is(,*count)] */,
13213                                                          uint32_t *_needed /* [out] [ref] */)
13214 {
13215         struct tevent_req *req;
13216         struct dcerpc_spoolss_EnumPrinterDataEx_state *state;
13217         struct tevent_req *subreq;
13218
13219         req = tevent_req_create(mem_ctx, &state,
13220                                 struct dcerpc_spoolss_EnumPrinterDataEx_state);
13221         if (req == NULL) {
13222                 return NULL;
13223         }
13224         state->out_mem_ctx = NULL;
13225
13226         /* In parameters */
13227         state->orig.in.handle = _handle;
13228         state->orig.in.key_name = _key_name;
13229         state->orig.in.offered = _offered;
13230
13231         /* Out parameters */
13232         state->orig.out.count = _count;
13233         state->orig.out.info = _info;
13234         state->orig.out.needed = _needed;
13235
13236         /* Result */
13237         ZERO_STRUCT(state->orig.out.result);
13238
13239         state->out_mem_ctx = talloc_named_const(state, 0,
13240                              "dcerpc_spoolss_EnumPrinterDataEx_out_memory");
13241         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13242                 return tevent_req_post(req, ev);
13243         }
13244
13245         /* make a temporary copy, that we pass to the dispatch function */
13246         state->tmp = state->orig;
13247
13248         subreq = dcerpc_spoolss_EnumPrinterDataEx_r_send(state, ev, h, &state->tmp);
13249         if (tevent_req_nomem(subreq, req)) {
13250                 return tevent_req_post(req, ev);
13251         }
13252         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterDataEx_done, req);
13253         return req;
13254 }
13255
13256 static void dcerpc_spoolss_EnumPrinterDataEx_done(struct tevent_req *subreq)
13257 {
13258         struct tevent_req *req = tevent_req_callback_data(
13259                 subreq, struct tevent_req);
13260         struct dcerpc_spoolss_EnumPrinterDataEx_state *state = tevent_req_data(
13261                 req, struct dcerpc_spoolss_EnumPrinterDataEx_state);
13262         NTSTATUS status;
13263         TALLOC_CTX *mem_ctx;
13264
13265         if (state->out_mem_ctx) {
13266                 mem_ctx = state->out_mem_ctx;
13267         } else {
13268                 mem_ctx = state;
13269         }
13270
13271         status = dcerpc_spoolss_EnumPrinterDataEx_r_recv(subreq, mem_ctx);
13272         TALLOC_FREE(subreq);
13273         if (!NT_STATUS_IS_OK(status)) {
13274                 tevent_req_nterror(req, status);
13275                 return;
13276         }
13277
13278         /* Copy out parameters */
13279         *state->orig.out.count = *state->tmp.out.count;
13280         *state->orig.out.info = *state->tmp.out.info;
13281         *state->orig.out.needed = *state->tmp.out.needed;
13282
13283         /* Copy result */
13284         state->orig.out.result = state->tmp.out.result;
13285
13286         /* Reset temporary structure */
13287         ZERO_STRUCT(state->tmp);
13288
13289         tevent_req_done(req);
13290 }
13291
13292 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_recv(struct tevent_req *req,
13293                                                TALLOC_CTX *mem_ctx,
13294                                                WERROR *result)
13295 {
13296         struct dcerpc_spoolss_EnumPrinterDataEx_state *state = tevent_req_data(
13297                 req, struct dcerpc_spoolss_EnumPrinterDataEx_state);
13298         NTSTATUS status;
13299
13300         if (tevent_req_is_nterror(req, &status)) {
13301                 tevent_req_received(req);
13302                 return status;
13303         }
13304
13305         /* Steal possible out parameters to the callers context */
13306         talloc_steal(mem_ctx, state->out_mem_ctx);
13307
13308         /* Return result */
13309         *result = state->orig.out.result;
13310
13311         tevent_req_received(req);
13312         return NT_STATUS_OK;
13313 }
13314
13315 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx(struct dcerpc_binding_handle *h,
13316                                           TALLOC_CTX *mem_ctx,
13317                                           struct policy_handle *_handle /* [in] [ref] */,
13318                                           const char *_key_name /* [in] [charset(UTF16)] */,
13319                                           uint32_t _offered /* [in]  */,
13320                                           uint32_t *_count /* [out] [ref] */,
13321                                           struct spoolss_PrinterEnumValues **_info /* [out] [ref,size_is(,*count)] */,
13322                                           uint32_t *_needed /* [out] [ref] */,
13323                                           WERROR *result)
13324 {
13325         struct spoolss_EnumPrinterDataEx r;
13326         NTSTATUS status;
13327
13328         /* In parameters */
13329         r.in.handle = _handle;
13330         r.in.key_name = _key_name;
13331         r.in.offered = _offered;
13332
13333         status = dcerpc_spoolss_EnumPrinterDataEx_r(h, mem_ctx, &r);
13334         if (!NT_STATUS_IS_OK(status)) {
13335                 return status;
13336         }
13337
13338         /* Return variables */
13339         *_count = *r.out.count;
13340         *_info = *r.out.info;
13341         *_needed = *r.out.needed;
13342
13343         /* Return result */
13344         *result = r.out.result;
13345
13346         return NT_STATUS_OK;
13347 }
13348
13349 struct dcerpc_spoolss_EnumPrinterKey_r_state {
13350         TALLOC_CTX *out_mem_ctx;
13351 };
13352
13353 static void dcerpc_spoolss_EnumPrinterKey_r_done(struct tevent_req *subreq);
13354
13355 struct tevent_req *dcerpc_spoolss_EnumPrinterKey_r_send(TALLOC_CTX *mem_ctx,
13356         struct tevent_context *ev,
13357         struct dcerpc_binding_handle *h,
13358         struct spoolss_EnumPrinterKey *r)
13359 {
13360         struct tevent_req *req;
13361         struct dcerpc_spoolss_EnumPrinterKey_r_state *state;
13362         struct tevent_req *subreq;
13363
13364         req = tevent_req_create(mem_ctx, &state,
13365                                 struct dcerpc_spoolss_EnumPrinterKey_r_state);
13366         if (req == NULL) {
13367                 return NULL;
13368         }
13369
13370         state->out_mem_ctx = talloc_new(state);
13371         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13372                 return tevent_req_post(req, ev);
13373         }
13374
13375         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13376                         NULL, &ndr_table_spoolss,
13377                         NDR_SPOOLSS_ENUMPRINTERKEY, state->out_mem_ctx, r);
13378         if (tevent_req_nomem(subreq, req)) {
13379                 return tevent_req_post(req, ev);
13380         }
13381         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterKey_r_done, req);
13382
13383         return req;
13384 }
13385
13386 static void dcerpc_spoolss_EnumPrinterKey_r_done(struct tevent_req *subreq)
13387 {
13388         struct tevent_req *req =
13389                 tevent_req_callback_data(subreq,
13390                 struct tevent_req);
13391         NTSTATUS status;
13392
13393         status = dcerpc_binding_handle_call_recv(subreq);
13394         if (!NT_STATUS_IS_OK(status)) {
13395                 tevent_req_nterror(req, status);
13396                 return;
13397         }
13398
13399         tevent_req_done(req);
13400 }
13401
13402 NTSTATUS dcerpc_spoolss_EnumPrinterKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13403 {
13404         struct dcerpc_spoolss_EnumPrinterKey_r_state *state =
13405                 tevent_req_data(req,
13406                 struct dcerpc_spoolss_EnumPrinterKey_r_state);
13407         NTSTATUS status;
13408
13409         if (tevent_req_is_nterror(req, &status)) {
13410                 tevent_req_received(req);
13411                 return status;
13412         }
13413
13414         talloc_steal(mem_ctx, state->out_mem_ctx);
13415
13416         tevent_req_received(req);
13417         return NT_STATUS_OK;
13418 }
13419
13420 NTSTATUS dcerpc_spoolss_EnumPrinterKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterKey *r)
13421 {
13422         NTSTATUS status;
13423
13424         status = dcerpc_binding_handle_call(h,
13425                         NULL, &ndr_table_spoolss,
13426                         NDR_SPOOLSS_ENUMPRINTERKEY, mem_ctx, r);
13427
13428         return status;
13429 }
13430
13431 NTSTATUS dcerpc_spoolss_EnumPrinterKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterKey *r)
13432 {
13433         NTSTATUS status;
13434
13435         status = dcerpc_spoolss_EnumPrinterKey_r(p->binding_handle, mem_ctx, r);
13436
13437         if (NT_STATUS_IS_RPC(status)) {
13438                 status = NT_STATUS_NET_WRITE_FAULT;
13439         }
13440
13441         return status;
13442 }
13443
13444 struct dcerpc_spoolss_EnumPrinterKey_state {
13445         struct spoolss_EnumPrinterKey orig;
13446         struct spoolss_EnumPrinterKey tmp;
13447         TALLOC_CTX *out_mem_ctx;
13448 };
13449
13450 static void dcerpc_spoolss_EnumPrinterKey_done(struct tevent_req *subreq);
13451
13452 struct tevent_req *dcerpc_spoolss_EnumPrinterKey_send(TALLOC_CTX *mem_ctx,
13453                                                       struct tevent_context *ev,
13454                                                       struct dcerpc_binding_handle *h,
13455                                                       struct policy_handle *_handle /* [in] [ref] */,
13456                                                       const char *_key_name /* [in] [charset(UTF16)] */,
13457                                                       uint32_t *__ndr_size /* [out] [ref] */,
13458                                                       union spoolss_KeyNames *_key_buffer /* [out] [subcontext_size(*_ndr_size*2),ref,subcontext(0),switch_is(*_ndr_size)] */,
13459                                                       uint32_t _offered /* [in]  */,
13460                                                       uint32_t *_needed /* [out] [ref] */)
13461 {
13462         struct tevent_req *req;
13463         struct dcerpc_spoolss_EnumPrinterKey_state *state;
13464         struct tevent_req *subreq;
13465
13466         req = tevent_req_create(mem_ctx, &state,
13467                                 struct dcerpc_spoolss_EnumPrinterKey_state);
13468         if (req == NULL) {
13469                 return NULL;
13470         }
13471         state->out_mem_ctx = NULL;
13472
13473         /* In parameters */
13474         state->orig.in.handle = _handle;
13475         state->orig.in.key_name = _key_name;
13476         state->orig.in.offered = _offered;
13477
13478         /* Out parameters */
13479         state->orig.out._ndr_size = __ndr_size;
13480         state->orig.out.key_buffer = _key_buffer;
13481         state->orig.out.needed = _needed;
13482
13483         /* Result */
13484         ZERO_STRUCT(state->orig.out.result);
13485
13486         state->out_mem_ctx = talloc_named_const(state, 0,
13487                              "dcerpc_spoolss_EnumPrinterKey_out_memory");
13488         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13489                 return tevent_req_post(req, ev);
13490         }
13491
13492         /* make a temporary copy, that we pass to the dispatch function */
13493         state->tmp = state->orig;
13494
13495         subreq = dcerpc_spoolss_EnumPrinterKey_r_send(state, ev, h, &state->tmp);
13496         if (tevent_req_nomem(subreq, req)) {
13497                 return tevent_req_post(req, ev);
13498         }
13499         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterKey_done, req);
13500         return req;
13501 }
13502
13503 static void dcerpc_spoolss_EnumPrinterKey_done(struct tevent_req *subreq)
13504 {
13505         struct tevent_req *req = tevent_req_callback_data(
13506                 subreq, struct tevent_req);
13507         struct dcerpc_spoolss_EnumPrinterKey_state *state = tevent_req_data(
13508                 req, struct dcerpc_spoolss_EnumPrinterKey_state);
13509         NTSTATUS status;
13510         TALLOC_CTX *mem_ctx;
13511
13512         if (state->out_mem_ctx) {
13513                 mem_ctx = state->out_mem_ctx;
13514         } else {
13515                 mem_ctx = state;
13516         }
13517
13518         status = dcerpc_spoolss_EnumPrinterKey_r_recv(subreq, mem_ctx);
13519         TALLOC_FREE(subreq);
13520         if (!NT_STATUS_IS_OK(status)) {
13521                 tevent_req_nterror(req, status);
13522                 return;
13523         }
13524
13525         /* Copy out parameters */
13526         *state->orig.out._ndr_size = *state->tmp.out._ndr_size;
13527         *state->orig.out.key_buffer = *state->tmp.out.key_buffer;
13528         *state->orig.out.needed = *state->tmp.out.needed;
13529
13530         /* Copy result */
13531         state->orig.out.result = state->tmp.out.result;
13532
13533         /* Reset temporary structure */
13534         ZERO_STRUCT(state->tmp);
13535
13536         tevent_req_done(req);
13537 }
13538
13539 NTSTATUS dcerpc_spoolss_EnumPrinterKey_recv(struct tevent_req *req,
13540                                             TALLOC_CTX *mem_ctx,
13541                                             WERROR *result)
13542 {
13543         struct dcerpc_spoolss_EnumPrinterKey_state *state = tevent_req_data(
13544                 req, struct dcerpc_spoolss_EnumPrinterKey_state);
13545         NTSTATUS status;
13546
13547         if (tevent_req_is_nterror(req, &status)) {
13548                 tevent_req_received(req);
13549                 return status;
13550         }
13551
13552         /* Steal possible out parameters to the callers context */
13553         talloc_steal(mem_ctx, state->out_mem_ctx);
13554
13555         /* Return result */
13556         *result = state->orig.out.result;
13557
13558         tevent_req_received(req);
13559         return NT_STATUS_OK;
13560 }
13561
13562 NTSTATUS dcerpc_spoolss_EnumPrinterKey(struct dcerpc_binding_handle *h,
13563                                        TALLOC_CTX *mem_ctx,
13564                                        struct policy_handle *_handle /* [in] [ref] */,
13565                                        const char *_key_name /* [in] [charset(UTF16)] */,
13566                                        uint32_t *__ndr_size /* [out] [ref] */,
13567                                        union spoolss_KeyNames *_key_buffer /* [out] [subcontext_size(*_ndr_size*2),ref,subcontext(0),switch_is(*_ndr_size)] */,
13568                                        uint32_t _offered /* [in]  */,
13569                                        uint32_t *_needed /* [out] [ref] */,
13570                                        WERROR *result)
13571 {
13572         struct spoolss_EnumPrinterKey r;
13573         NTSTATUS status;
13574
13575         /* In parameters */
13576         r.in.handle = _handle;
13577         r.in.key_name = _key_name;
13578         r.in.offered = _offered;
13579
13580         status = dcerpc_spoolss_EnumPrinterKey_r(h, mem_ctx, &r);
13581         if (!NT_STATUS_IS_OK(status)) {
13582                 return status;
13583         }
13584
13585         /* Return variables */
13586         *__ndr_size = *r.out._ndr_size;
13587         *_key_buffer = *r.out.key_buffer;
13588         *_needed = *r.out.needed;
13589
13590         /* Return result */
13591         *result = r.out.result;
13592
13593         return NT_STATUS_OK;
13594 }
13595
13596 struct dcerpc_spoolss_DeletePrinterDataEx_r_state {
13597         TALLOC_CTX *out_mem_ctx;
13598 };
13599
13600 static void dcerpc_spoolss_DeletePrinterDataEx_r_done(struct tevent_req *subreq);
13601
13602 struct tevent_req *dcerpc_spoolss_DeletePrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
13603         struct tevent_context *ev,
13604         struct dcerpc_binding_handle *h,
13605         struct spoolss_DeletePrinterDataEx *r)
13606 {
13607         struct tevent_req *req;
13608         struct dcerpc_spoolss_DeletePrinterDataEx_r_state *state;
13609         struct tevent_req *subreq;
13610
13611         req = tevent_req_create(mem_ctx, &state,
13612                                 struct dcerpc_spoolss_DeletePrinterDataEx_r_state);
13613         if (req == NULL) {
13614                 return NULL;
13615         }
13616
13617         state->out_mem_ctx = NULL;
13618         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13619                         NULL, &ndr_table_spoolss,
13620                         NDR_SPOOLSS_DELETEPRINTERDATAEX, state, r);
13621         if (tevent_req_nomem(subreq, req)) {
13622                 return tevent_req_post(req, ev);
13623         }
13624         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDataEx_r_done, req);
13625
13626         return req;
13627 }
13628
13629 static void dcerpc_spoolss_DeletePrinterDataEx_r_done(struct tevent_req *subreq)
13630 {
13631         struct tevent_req *req =
13632                 tevent_req_callback_data(subreq,
13633                 struct tevent_req);
13634         NTSTATUS status;
13635
13636         status = dcerpc_binding_handle_call_recv(subreq);
13637         if (!NT_STATUS_IS_OK(status)) {
13638                 tevent_req_nterror(req, status);
13639                 return;
13640         }
13641
13642         tevent_req_done(req);
13643 }
13644
13645 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13646 {
13647         struct dcerpc_spoolss_DeletePrinterDataEx_r_state *state =
13648                 tevent_req_data(req,
13649                 struct dcerpc_spoolss_DeletePrinterDataEx_r_state);
13650         NTSTATUS status;
13651
13652         if (tevent_req_is_nterror(req, &status)) {
13653                 tevent_req_received(req);
13654                 return status;
13655         }
13656
13657         talloc_steal(mem_ctx, state->out_mem_ctx);
13658
13659         tevent_req_received(req);
13660         return NT_STATUS_OK;
13661 }
13662
13663 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDataEx *r)
13664 {
13665         NTSTATUS status;
13666
13667         status = dcerpc_binding_handle_call(h,
13668                         NULL, &ndr_table_spoolss,
13669                         NDR_SPOOLSS_DELETEPRINTERDATAEX, mem_ctx, r);
13670
13671         return status;
13672 }
13673
13674 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDataEx *r)
13675 {
13676         NTSTATUS status;
13677
13678         status = dcerpc_spoolss_DeletePrinterDataEx_r(p->binding_handle, mem_ctx, r);
13679
13680         if (NT_STATUS_IS_RPC(status)) {
13681                 status = NT_STATUS_NET_WRITE_FAULT;
13682         }
13683
13684         return status;
13685 }
13686
13687 struct dcerpc_spoolss_DeletePrinterDataEx_state {
13688         struct spoolss_DeletePrinterDataEx orig;
13689         struct spoolss_DeletePrinterDataEx tmp;
13690         TALLOC_CTX *out_mem_ctx;
13691 };
13692
13693 static void dcerpc_spoolss_DeletePrinterDataEx_done(struct tevent_req *subreq);
13694
13695 struct tevent_req *dcerpc_spoolss_DeletePrinterDataEx_send(TALLOC_CTX *mem_ctx,
13696                                                            struct tevent_context *ev,
13697                                                            struct dcerpc_binding_handle *h,
13698                                                            struct policy_handle *_handle /* [in] [ref] */,
13699                                                            const char *_key_name /* [in] [charset(UTF16)] */,
13700                                                            const char *_value_name /* [in] [charset(UTF16)] */)
13701 {
13702         struct tevent_req *req;
13703         struct dcerpc_spoolss_DeletePrinterDataEx_state *state;
13704         struct tevent_req *subreq;
13705
13706         req = tevent_req_create(mem_ctx, &state,
13707                                 struct dcerpc_spoolss_DeletePrinterDataEx_state);
13708         if (req == NULL) {
13709                 return NULL;
13710         }
13711         state->out_mem_ctx = NULL;
13712
13713         /* In parameters */
13714         state->orig.in.handle = _handle;
13715         state->orig.in.key_name = _key_name;
13716         state->orig.in.value_name = _value_name;
13717
13718         /* Out parameters */
13719
13720         /* Result */
13721         ZERO_STRUCT(state->orig.out.result);
13722
13723         /* make a temporary copy, that we pass to the dispatch function */
13724         state->tmp = state->orig;
13725
13726         subreq = dcerpc_spoolss_DeletePrinterDataEx_r_send(state, ev, h, &state->tmp);
13727         if (tevent_req_nomem(subreq, req)) {
13728                 return tevent_req_post(req, ev);
13729         }
13730         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDataEx_done, req);
13731         return req;
13732 }
13733
13734 static void dcerpc_spoolss_DeletePrinterDataEx_done(struct tevent_req *subreq)
13735 {
13736         struct tevent_req *req = tevent_req_callback_data(
13737                 subreq, struct tevent_req);
13738         struct dcerpc_spoolss_DeletePrinterDataEx_state *state = tevent_req_data(
13739                 req, struct dcerpc_spoolss_DeletePrinterDataEx_state);
13740         NTSTATUS status;
13741         TALLOC_CTX *mem_ctx;
13742
13743         if (state->out_mem_ctx) {
13744                 mem_ctx = state->out_mem_ctx;
13745         } else {
13746                 mem_ctx = state;
13747         }
13748
13749         status = dcerpc_spoolss_DeletePrinterDataEx_r_recv(subreq, mem_ctx);
13750         TALLOC_FREE(subreq);
13751         if (!NT_STATUS_IS_OK(status)) {
13752                 tevent_req_nterror(req, status);
13753                 return;
13754         }
13755
13756         /* Copy out parameters */
13757
13758         /* Copy result */
13759         state->orig.out.result = state->tmp.out.result;
13760
13761         /* Reset temporary structure */
13762         ZERO_STRUCT(state->tmp);
13763
13764         tevent_req_done(req);
13765 }
13766
13767 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_recv(struct tevent_req *req,
13768                                                  TALLOC_CTX *mem_ctx,
13769                                                  WERROR *result)
13770 {
13771         struct dcerpc_spoolss_DeletePrinterDataEx_state *state = tevent_req_data(
13772                 req, struct dcerpc_spoolss_DeletePrinterDataEx_state);
13773         NTSTATUS status;
13774
13775         if (tevent_req_is_nterror(req, &status)) {
13776                 tevent_req_received(req);
13777                 return status;
13778         }
13779
13780         /* Steal possible out parameters to the callers context */
13781         talloc_steal(mem_ctx, state->out_mem_ctx);
13782
13783         /* Return result */
13784         *result = state->orig.out.result;
13785
13786         tevent_req_received(req);
13787         return NT_STATUS_OK;
13788 }
13789
13790 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx(struct dcerpc_binding_handle *h,
13791                                             TALLOC_CTX *mem_ctx,
13792                                             struct policy_handle *_handle /* [in] [ref] */,
13793                                             const char *_key_name /* [in] [charset(UTF16)] */,
13794                                             const char *_value_name /* [in] [charset(UTF16)] */,
13795                                             WERROR *result)
13796 {
13797         struct spoolss_DeletePrinterDataEx r;
13798         NTSTATUS status;
13799
13800         /* In parameters */
13801         r.in.handle = _handle;
13802         r.in.key_name = _key_name;
13803         r.in.value_name = _value_name;
13804
13805         status = dcerpc_spoolss_DeletePrinterDataEx_r(h, mem_ctx, &r);
13806         if (!NT_STATUS_IS_OK(status)) {
13807                 return status;
13808         }
13809
13810         /* Return variables */
13811
13812         /* Return result */
13813         *result = r.out.result;
13814
13815         return NT_STATUS_OK;
13816 }
13817
13818 struct dcerpc_spoolss_DeletePrinterKey_r_state {
13819         TALLOC_CTX *out_mem_ctx;
13820 };
13821
13822 static void dcerpc_spoolss_DeletePrinterKey_r_done(struct tevent_req *subreq);
13823
13824 struct tevent_req *dcerpc_spoolss_DeletePrinterKey_r_send(TALLOC_CTX *mem_ctx,
13825         struct tevent_context *ev,
13826         struct dcerpc_binding_handle *h,
13827         struct spoolss_DeletePrinterKey *r)
13828 {
13829         struct tevent_req *req;
13830         struct dcerpc_spoolss_DeletePrinterKey_r_state *state;
13831         struct tevent_req *subreq;
13832
13833         req = tevent_req_create(mem_ctx, &state,
13834                                 struct dcerpc_spoolss_DeletePrinterKey_r_state);
13835         if (req == NULL) {
13836                 return NULL;
13837         }
13838
13839         state->out_mem_ctx = NULL;
13840         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13841                         NULL, &ndr_table_spoolss,
13842                         NDR_SPOOLSS_DELETEPRINTERKEY, state, r);
13843         if (tevent_req_nomem(subreq, req)) {
13844                 return tevent_req_post(req, ev);
13845         }
13846         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterKey_r_done, req);
13847
13848         return req;
13849 }
13850
13851 static void dcerpc_spoolss_DeletePrinterKey_r_done(struct tevent_req *subreq)
13852 {
13853         struct tevent_req *req =
13854                 tevent_req_callback_data(subreq,
13855                 struct tevent_req);
13856         NTSTATUS status;
13857
13858         status = dcerpc_binding_handle_call_recv(subreq);
13859         if (!NT_STATUS_IS_OK(status)) {
13860                 tevent_req_nterror(req, status);
13861                 return;
13862         }
13863
13864         tevent_req_done(req);
13865 }
13866
13867 NTSTATUS dcerpc_spoolss_DeletePrinterKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13868 {
13869         struct dcerpc_spoolss_DeletePrinterKey_r_state *state =
13870                 tevent_req_data(req,
13871                 struct dcerpc_spoolss_DeletePrinterKey_r_state);
13872         NTSTATUS status;
13873
13874         if (tevent_req_is_nterror(req, &status)) {
13875                 tevent_req_received(req);
13876                 return status;
13877         }
13878
13879         talloc_steal(mem_ctx, state->out_mem_ctx);
13880
13881         tevent_req_received(req);
13882         return NT_STATUS_OK;
13883 }
13884
13885 NTSTATUS dcerpc_spoolss_DeletePrinterKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterKey *r)
13886 {
13887         NTSTATUS status;
13888
13889         status = dcerpc_binding_handle_call(h,
13890                         NULL, &ndr_table_spoolss,
13891                         NDR_SPOOLSS_DELETEPRINTERKEY, mem_ctx, r);
13892
13893         return status;
13894 }
13895
13896 NTSTATUS dcerpc_spoolss_DeletePrinterKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterKey *r)
13897 {
13898         NTSTATUS status;
13899
13900         status = dcerpc_spoolss_DeletePrinterKey_r(p->binding_handle, mem_ctx, r);
13901
13902         if (NT_STATUS_IS_RPC(status)) {
13903                 status = NT_STATUS_NET_WRITE_FAULT;
13904         }
13905
13906         return status;
13907 }
13908
13909 struct dcerpc_spoolss_DeletePrinterKey_state {
13910         struct spoolss_DeletePrinterKey orig;
13911         struct spoolss_DeletePrinterKey tmp;
13912         TALLOC_CTX *out_mem_ctx;
13913 };
13914
13915 static void dcerpc_spoolss_DeletePrinterKey_done(struct tevent_req *subreq);
13916
13917 struct tevent_req *dcerpc_spoolss_DeletePrinterKey_send(TALLOC_CTX *mem_ctx,
13918                                                         struct tevent_context *ev,
13919                                                         struct dcerpc_binding_handle *h,
13920                                                         struct policy_handle *_handle /* [in] [ref] */,
13921                                                         const char *_key_name /* [in] [charset(UTF16)] */)
13922 {
13923         struct tevent_req *req;
13924         struct dcerpc_spoolss_DeletePrinterKey_state *state;
13925         struct tevent_req *subreq;
13926
13927         req = tevent_req_create(mem_ctx, &state,
13928                                 struct dcerpc_spoolss_DeletePrinterKey_state);
13929         if (req == NULL) {
13930                 return NULL;
13931         }
13932         state->out_mem_ctx = NULL;
13933
13934         /* In parameters */
13935         state->orig.in.handle = _handle;
13936         state->orig.in.key_name = _key_name;
13937
13938         /* Out parameters */
13939
13940         /* Result */
13941         ZERO_STRUCT(state->orig.out.result);
13942
13943         /* make a temporary copy, that we pass to the dispatch function */
13944         state->tmp = state->orig;
13945
13946         subreq = dcerpc_spoolss_DeletePrinterKey_r_send(state, ev, h, &state->tmp);
13947         if (tevent_req_nomem(subreq, req)) {
13948                 return tevent_req_post(req, ev);
13949         }
13950         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterKey_done, req);
13951         return req;
13952 }
13953
13954 static void dcerpc_spoolss_DeletePrinterKey_done(struct tevent_req *subreq)
13955 {
13956         struct tevent_req *req = tevent_req_callback_data(
13957                 subreq, struct tevent_req);
13958         struct dcerpc_spoolss_DeletePrinterKey_state *state = tevent_req_data(
13959                 req, struct dcerpc_spoolss_DeletePrinterKey_state);
13960         NTSTATUS status;
13961         TALLOC_CTX *mem_ctx;
13962
13963         if (state->out_mem_ctx) {
13964                 mem_ctx = state->out_mem_ctx;
13965         } else {
13966                 mem_ctx = state;
13967         }
13968
13969         status = dcerpc_spoolss_DeletePrinterKey_r_recv(subreq, mem_ctx);
13970         TALLOC_FREE(subreq);
13971         if (!NT_STATUS_IS_OK(status)) {
13972                 tevent_req_nterror(req, status);
13973                 return;
13974         }
13975
13976         /* Copy out parameters */
13977
13978         /* Copy result */
13979         state->orig.out.result = state->tmp.out.result;
13980
13981         /* Reset temporary structure */
13982         ZERO_STRUCT(state->tmp);
13983
13984         tevent_req_done(req);
13985 }
13986
13987 NTSTATUS dcerpc_spoolss_DeletePrinterKey_recv(struct tevent_req *req,
13988                                               TALLOC_CTX *mem_ctx,
13989                                               WERROR *result)
13990 {
13991         struct dcerpc_spoolss_DeletePrinterKey_state *state = tevent_req_data(
13992                 req, struct dcerpc_spoolss_DeletePrinterKey_state);
13993         NTSTATUS status;
13994
13995         if (tevent_req_is_nterror(req, &status)) {
13996                 tevent_req_received(req);
13997                 return status;
13998         }
13999
14000         /* Steal possible out parameters to the callers context */
14001         talloc_steal(mem_ctx, state->out_mem_ctx);
14002
14003         /* Return result */
14004         *result = state->orig.out.result;
14005
14006         tevent_req_received(req);
14007         return NT_STATUS_OK;
14008 }
14009
14010 NTSTATUS dcerpc_spoolss_DeletePrinterKey(struct dcerpc_binding_handle *h,
14011                                          TALLOC_CTX *mem_ctx,
14012                                          struct policy_handle *_handle /* [in] [ref] */,
14013                                          const char *_key_name /* [in] [charset(UTF16)] */,
14014                                          WERROR *result)
14015 {
14016         struct spoolss_DeletePrinterKey r;
14017         NTSTATUS status;
14018
14019         /* In parameters */
14020         r.in.handle = _handle;
14021         r.in.key_name = _key_name;
14022
14023         status = dcerpc_spoolss_DeletePrinterKey_r(h, mem_ctx, &r);
14024         if (!NT_STATUS_IS_OK(status)) {
14025                 return status;
14026         }
14027
14028         /* Return variables */
14029
14030         /* Return result */
14031         *result = r.out.result;
14032
14033         return NT_STATUS_OK;
14034 }
14035
14036 struct dcerpc_spoolss_DeletePrinterDriverEx_r_state {
14037         TALLOC_CTX *out_mem_ctx;
14038 };
14039
14040 static void dcerpc_spoolss_DeletePrinterDriverEx_r_done(struct tevent_req *subreq);
14041
14042 struct tevent_req *dcerpc_spoolss_DeletePrinterDriverEx_r_send(TALLOC_CTX *mem_ctx,
14043         struct tevent_context *ev,
14044         struct dcerpc_binding_handle *h,
14045         struct spoolss_DeletePrinterDriverEx *r)
14046 {
14047         struct tevent_req *req;
14048         struct dcerpc_spoolss_DeletePrinterDriverEx_r_state *state;
14049         struct tevent_req *subreq;
14050
14051         req = tevent_req_create(mem_ctx, &state,
14052                                 struct dcerpc_spoolss_DeletePrinterDriverEx_r_state);
14053         if (req == NULL) {
14054                 return NULL;
14055         }
14056
14057         state->out_mem_ctx = NULL;
14058         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14059                         NULL, &ndr_table_spoolss,
14060                         NDR_SPOOLSS_DELETEPRINTERDRIVEREX, state, r);
14061         if (tevent_req_nomem(subreq, req)) {
14062                 return tevent_req_post(req, ev);
14063         }
14064         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDriverEx_r_done, req);
14065
14066         return req;
14067 }
14068
14069 static void dcerpc_spoolss_DeletePrinterDriverEx_r_done(struct tevent_req *subreq)
14070 {
14071         struct tevent_req *req =
14072                 tevent_req_callback_data(subreq,
14073                 struct tevent_req);
14074         NTSTATUS status;
14075
14076         status = dcerpc_binding_handle_call_recv(subreq);
14077         if (!NT_STATUS_IS_OK(status)) {
14078                 tevent_req_nterror(req, status);
14079                 return;
14080         }
14081
14082         tevent_req_done(req);
14083 }
14084
14085 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14086 {
14087         struct dcerpc_spoolss_DeletePrinterDriverEx_r_state *state =
14088                 tevent_req_data(req,
14089                 struct dcerpc_spoolss_DeletePrinterDriverEx_r_state);
14090         NTSTATUS status;
14091
14092         if (tevent_req_is_nterror(req, &status)) {
14093                 tevent_req_received(req);
14094                 return status;
14095         }
14096
14097         talloc_steal(mem_ctx, state->out_mem_ctx);
14098
14099         tevent_req_received(req);
14100         return NT_STATUS_OK;
14101 }
14102
14103 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDriverEx *r)
14104 {
14105         NTSTATUS status;
14106
14107         status = dcerpc_binding_handle_call(h,
14108                         NULL, &ndr_table_spoolss,
14109                         NDR_SPOOLSS_DELETEPRINTERDRIVEREX, mem_ctx, r);
14110
14111         return status;
14112 }
14113
14114 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDriverEx *r)
14115 {
14116         NTSTATUS status;
14117
14118         status = dcerpc_spoolss_DeletePrinterDriverEx_r(p->binding_handle, mem_ctx, r);
14119
14120         if (NT_STATUS_IS_RPC(status)) {
14121                 status = NT_STATUS_NET_WRITE_FAULT;
14122         }
14123
14124         return status;
14125 }
14126
14127 struct dcerpc_spoolss_DeletePrinterDriverEx_state {
14128         struct spoolss_DeletePrinterDriverEx orig;
14129         struct spoolss_DeletePrinterDriverEx tmp;
14130         TALLOC_CTX *out_mem_ctx;
14131 };
14132
14133 static void dcerpc_spoolss_DeletePrinterDriverEx_done(struct tevent_req *subreq);
14134
14135 struct tevent_req *dcerpc_spoolss_DeletePrinterDriverEx_send(TALLOC_CTX *mem_ctx,
14136                                                              struct tevent_context *ev,
14137                                                              struct dcerpc_binding_handle *h,
14138                                                              const char *_server /* [in] [unique,charset(UTF16)] */,
14139                                                              const char *_architecture /* [in] [charset(UTF16)] */,
14140                                                              const char *_driver /* [in] [charset(UTF16)] */,
14141                                                              uint32_t _delete_flags /* [in]  */,
14142                                                              uint32_t _version /* [in]  */)
14143 {
14144         struct tevent_req *req;
14145         struct dcerpc_spoolss_DeletePrinterDriverEx_state *state;
14146         struct tevent_req *subreq;
14147
14148         req = tevent_req_create(mem_ctx, &state,
14149                                 struct dcerpc_spoolss_DeletePrinterDriverEx_state);
14150         if (req == NULL) {
14151                 return NULL;
14152         }
14153         state->out_mem_ctx = NULL;
14154
14155         /* In parameters */
14156         state->orig.in.server = _server;
14157         state->orig.in.architecture = _architecture;
14158         state->orig.in.driver = _driver;
14159         state->orig.in.delete_flags = _delete_flags;
14160         state->orig.in.version = _version;
14161
14162         /* Out parameters */
14163
14164         /* Result */
14165         ZERO_STRUCT(state->orig.out.result);
14166
14167         /* make a temporary copy, that we pass to the dispatch function */
14168         state->tmp = state->orig;
14169
14170         subreq = dcerpc_spoolss_DeletePrinterDriverEx_r_send(state, ev, h, &state->tmp);
14171         if (tevent_req_nomem(subreq, req)) {
14172                 return tevent_req_post(req, ev);
14173         }
14174         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDriverEx_done, req);
14175         return req;
14176 }
14177
14178 static void dcerpc_spoolss_DeletePrinterDriverEx_done(struct tevent_req *subreq)
14179 {
14180         struct tevent_req *req = tevent_req_callback_data(
14181                 subreq, struct tevent_req);
14182         struct dcerpc_spoolss_DeletePrinterDriverEx_state *state = tevent_req_data(
14183                 req, struct dcerpc_spoolss_DeletePrinterDriverEx_state);
14184         NTSTATUS status;
14185         TALLOC_CTX *mem_ctx;
14186
14187         if (state->out_mem_ctx) {
14188                 mem_ctx = state->out_mem_ctx;
14189         } else {
14190                 mem_ctx = state;
14191         }
14192
14193         status = dcerpc_spoolss_DeletePrinterDriverEx_r_recv(subreq, mem_ctx);
14194         TALLOC_FREE(subreq);
14195         if (!NT_STATUS_IS_OK(status)) {
14196                 tevent_req_nterror(req, status);
14197                 return;
14198         }
14199
14200         /* Copy out parameters */
14201
14202         /* Copy result */
14203         state->orig.out.result = state->tmp.out.result;
14204
14205         /* Reset temporary structure */
14206         ZERO_STRUCT(state->tmp);
14207
14208         tevent_req_done(req);
14209 }
14210
14211 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_recv(struct tevent_req *req,
14212                                                    TALLOC_CTX *mem_ctx,
14213                                                    WERROR *result)
14214 {
14215         struct dcerpc_spoolss_DeletePrinterDriverEx_state *state = tevent_req_data(
14216                 req, struct dcerpc_spoolss_DeletePrinterDriverEx_state);
14217         NTSTATUS status;
14218
14219         if (tevent_req_is_nterror(req, &status)) {
14220                 tevent_req_received(req);
14221                 return status;
14222         }
14223
14224         /* Steal possible out parameters to the callers context */
14225         talloc_steal(mem_ctx, state->out_mem_ctx);
14226
14227         /* Return result */
14228         *result = state->orig.out.result;
14229
14230         tevent_req_received(req);
14231         return NT_STATUS_OK;
14232 }
14233
14234 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx(struct dcerpc_binding_handle *h,
14235                                               TALLOC_CTX *mem_ctx,
14236                                               const char *_server /* [in] [unique,charset(UTF16)] */,
14237                                               const char *_architecture /* [in] [charset(UTF16)] */,
14238                                               const char *_driver /* [in] [charset(UTF16)] */,
14239                                               uint32_t _delete_flags /* [in]  */,
14240                                               uint32_t _version /* [in]  */,
14241                                               WERROR *result)
14242 {
14243         struct spoolss_DeletePrinterDriverEx r;
14244         NTSTATUS status;
14245
14246         /* In parameters */
14247         r.in.server = _server;
14248         r.in.architecture = _architecture;
14249         r.in.driver = _driver;
14250         r.in.delete_flags = _delete_flags;
14251         r.in.version = _version;
14252
14253         status = dcerpc_spoolss_DeletePrinterDriverEx_r(h, mem_ctx, &r);
14254         if (!NT_STATUS_IS_OK(status)) {
14255                 return status;
14256         }
14257
14258         /* Return variables */
14259
14260         /* Return result */
14261         *result = r.out.result;
14262
14263         return NT_STATUS_OK;
14264 }
14265
14266 struct dcerpc_spoolss_XcvData_r_state {
14267         TALLOC_CTX *out_mem_ctx;
14268 };
14269
14270 static void dcerpc_spoolss_XcvData_r_done(struct tevent_req *subreq);
14271
14272 struct tevent_req *dcerpc_spoolss_XcvData_r_send(TALLOC_CTX *mem_ctx,
14273         struct tevent_context *ev,
14274         struct dcerpc_binding_handle *h,
14275         struct spoolss_XcvData *r)
14276 {
14277         struct tevent_req *req;
14278         struct dcerpc_spoolss_XcvData_r_state *state;
14279         struct tevent_req *subreq;
14280
14281         req = tevent_req_create(mem_ctx, &state,
14282                                 struct dcerpc_spoolss_XcvData_r_state);
14283         if (req == NULL) {
14284                 return NULL;
14285         }
14286
14287         state->out_mem_ctx = talloc_new(state);
14288         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14289                 return tevent_req_post(req, ev);
14290         }
14291
14292         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14293                         NULL, &ndr_table_spoolss,
14294                         NDR_SPOOLSS_XCVDATA, state->out_mem_ctx, r);
14295         if (tevent_req_nomem(subreq, req)) {
14296                 return tevent_req_post(req, ev);
14297         }
14298         tevent_req_set_callback(subreq, dcerpc_spoolss_XcvData_r_done, req);
14299
14300         return req;
14301 }
14302
14303 static void dcerpc_spoolss_XcvData_r_done(struct tevent_req *subreq)
14304 {
14305         struct tevent_req *req =
14306                 tevent_req_callback_data(subreq,
14307                 struct tevent_req);
14308         NTSTATUS status;
14309
14310         status = dcerpc_binding_handle_call_recv(subreq);
14311         if (!NT_STATUS_IS_OK(status)) {
14312                 tevent_req_nterror(req, status);
14313                 return;
14314         }
14315
14316         tevent_req_done(req);
14317 }
14318
14319 NTSTATUS dcerpc_spoolss_XcvData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14320 {
14321         struct dcerpc_spoolss_XcvData_r_state *state =
14322                 tevent_req_data(req,
14323                 struct dcerpc_spoolss_XcvData_r_state);
14324         NTSTATUS status;
14325
14326         if (tevent_req_is_nterror(req, &status)) {
14327                 tevent_req_received(req);
14328                 return status;
14329         }
14330
14331         talloc_steal(mem_ctx, state->out_mem_ctx);
14332
14333         tevent_req_received(req);
14334         return NT_STATUS_OK;
14335 }
14336
14337 NTSTATUS dcerpc_spoolss_XcvData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_XcvData *r)
14338 {
14339         NTSTATUS status;
14340
14341         status = dcerpc_binding_handle_call(h,
14342                         NULL, &ndr_table_spoolss,
14343                         NDR_SPOOLSS_XCVDATA, mem_ctx, r);
14344
14345         return status;
14346 }
14347
14348 NTSTATUS dcerpc_spoolss_XcvData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_XcvData *r)
14349 {
14350         NTSTATUS status;
14351
14352         status = dcerpc_spoolss_XcvData_r(p->binding_handle, mem_ctx, r);
14353
14354         if (NT_STATUS_IS_RPC(status)) {
14355                 status = NT_STATUS_NET_WRITE_FAULT;
14356         }
14357
14358         return status;
14359 }
14360
14361 struct dcerpc_spoolss_XcvData_state {
14362         struct spoolss_XcvData orig;
14363         struct spoolss_XcvData tmp;
14364         TALLOC_CTX *out_mem_ctx;
14365 };
14366
14367 static void dcerpc_spoolss_XcvData_done(struct tevent_req *subreq);
14368
14369 struct tevent_req *dcerpc_spoolss_XcvData_send(TALLOC_CTX *mem_ctx,
14370                                                struct tevent_context *ev,
14371                                                struct dcerpc_binding_handle *h,
14372                                                struct policy_handle *_handle /* [in] [ref] */,
14373                                                const char *_function_name /* [in] [charset(UTF16)] */,
14374                                                DATA_BLOB _in_data /* [in]  */,
14375                                                uint32_t __in_data_length /* [in] [value(r->in.in_data.length)] */,
14376                                                uint8_t *_out_data /* [out] [ref,size_is(out_data_size)] */,
14377                                                uint32_t _out_data_size /* [in]  */,
14378                                                uint32_t *_needed /* [out] [ref] */,
14379                                                uint32_t *_status_code /* [in,out] [ref] */)
14380 {
14381         struct tevent_req *req;
14382         struct dcerpc_spoolss_XcvData_state *state;
14383         struct tevent_req *subreq;
14384
14385         req = tevent_req_create(mem_ctx, &state,
14386                                 struct dcerpc_spoolss_XcvData_state);
14387         if (req == NULL) {
14388                 return NULL;
14389         }
14390         state->out_mem_ctx = NULL;
14391
14392         /* In parameters */
14393         state->orig.in.handle = _handle;
14394         state->orig.in.function_name = _function_name;
14395         state->orig.in.in_data = _in_data;
14396         state->orig.in._in_data_length = __in_data_length;
14397         state->orig.in.out_data_size = _out_data_size;
14398         state->orig.in.status_code = _status_code;
14399
14400         /* Out parameters */
14401         state->orig.out.out_data = _out_data;
14402         state->orig.out.needed = _needed;
14403         state->orig.out.status_code = _status_code;
14404
14405         /* Result */
14406         ZERO_STRUCT(state->orig.out.result);
14407
14408         state->out_mem_ctx = talloc_named_const(state, 0,
14409                              "dcerpc_spoolss_XcvData_out_memory");
14410         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14411                 return tevent_req_post(req, ev);
14412         }
14413
14414         /* make a temporary copy, that we pass to the dispatch function */
14415         state->tmp = state->orig;
14416
14417         subreq = dcerpc_spoolss_XcvData_r_send(state, ev, h, &state->tmp);
14418         if (tevent_req_nomem(subreq, req)) {
14419                 return tevent_req_post(req, ev);
14420         }
14421         tevent_req_set_callback(subreq, dcerpc_spoolss_XcvData_done, req);
14422         return req;
14423 }
14424
14425 static void dcerpc_spoolss_XcvData_done(struct tevent_req *subreq)
14426 {
14427         struct tevent_req *req = tevent_req_callback_data(
14428                 subreq, struct tevent_req);
14429         struct dcerpc_spoolss_XcvData_state *state = tevent_req_data(
14430                 req, struct dcerpc_spoolss_XcvData_state);
14431         NTSTATUS status;
14432         TALLOC_CTX *mem_ctx;
14433
14434         if (state->out_mem_ctx) {
14435                 mem_ctx = state->out_mem_ctx;
14436         } else {
14437                 mem_ctx = state;
14438         }
14439
14440         status = dcerpc_spoolss_XcvData_r_recv(subreq, mem_ctx);
14441         TALLOC_FREE(subreq);
14442         if (!NT_STATUS_IS_OK(status)) {
14443                 tevent_req_nterror(req, status);
14444                 return;
14445         }
14446
14447         /* Copy out parameters */
14448         {
14449                 size_t _copy_len_out_data;
14450                 _copy_len_out_data = state->tmp.in.out_data_size;
14451                 memcpy(state->orig.out.out_data, state->tmp.out.out_data, _copy_len_out_data * sizeof(*state->orig.out.out_data));
14452         }
14453         *state->orig.out.needed = *state->tmp.out.needed;
14454         *state->orig.out.status_code = *state->tmp.out.status_code;
14455
14456         /* Copy result */
14457         state->orig.out.result = state->tmp.out.result;
14458
14459         /* Reset temporary structure */
14460         ZERO_STRUCT(state->tmp);
14461
14462         tevent_req_done(req);
14463 }
14464
14465 NTSTATUS dcerpc_spoolss_XcvData_recv(struct tevent_req *req,
14466                                      TALLOC_CTX *mem_ctx,
14467                                      WERROR *result)
14468 {
14469         struct dcerpc_spoolss_XcvData_state *state = tevent_req_data(
14470                 req, struct dcerpc_spoolss_XcvData_state);
14471         NTSTATUS status;
14472
14473         if (tevent_req_is_nterror(req, &status)) {
14474                 tevent_req_received(req);
14475                 return status;
14476         }
14477
14478         /* Steal possible out parameters to the callers context */
14479         talloc_steal(mem_ctx, state->out_mem_ctx);
14480
14481         /* Return result */
14482         *result = state->orig.out.result;
14483
14484         tevent_req_received(req);
14485         return NT_STATUS_OK;
14486 }
14487
14488 NTSTATUS dcerpc_spoolss_XcvData(struct dcerpc_binding_handle *h,
14489                                 TALLOC_CTX *mem_ctx,
14490                                 struct policy_handle *_handle /* [in] [ref] */,
14491                                 const char *_function_name /* [in] [charset(UTF16)] */,
14492                                 DATA_BLOB _in_data /* [in]  */,
14493                                 uint32_t __in_data_length /* [in] [value(r->in.in_data.length)] */,
14494                                 uint8_t *_out_data /* [out] [ref,size_is(out_data_size)] */,
14495                                 uint32_t _out_data_size /* [in]  */,
14496                                 uint32_t *_needed /* [out] [ref] */,
14497                                 uint32_t *_status_code /* [in,out] [ref] */,
14498                                 WERROR *result)
14499 {
14500         struct spoolss_XcvData r;
14501         NTSTATUS status;
14502
14503         /* In parameters */
14504         r.in.handle = _handle;
14505         r.in.function_name = _function_name;
14506         r.in.in_data = _in_data;
14507         r.in._in_data_length = __in_data_length;
14508         r.in.out_data_size = _out_data_size;
14509         r.in.status_code = _status_code;
14510
14511         status = dcerpc_spoolss_XcvData_r(h, mem_ctx, &r);
14512         if (!NT_STATUS_IS_OK(status)) {
14513                 return status;
14514         }
14515
14516         /* Return variables */
14517         {
14518                 size_t _copy_len_out_data;
14519                 _copy_len_out_data = r.in.out_data_size;
14520                 memcpy(_out_data, r.out.out_data, _copy_len_out_data * sizeof(*_out_data));
14521         }
14522         *_needed = *r.out.needed;
14523         *_status_code = *r.out.status_code;
14524
14525         /* Return result */
14526         *result = r.out.result;
14527
14528         return NT_STATUS_OK;
14529 }
14530
14531 struct dcerpc_spoolss_AddPrinterDriverEx_r_state {
14532         TALLOC_CTX *out_mem_ctx;
14533 };
14534
14535 static void dcerpc_spoolss_AddPrinterDriverEx_r_done(struct tevent_req *subreq);
14536
14537 struct tevent_req *dcerpc_spoolss_AddPrinterDriverEx_r_send(TALLOC_CTX *mem_ctx,
14538         struct tevent_context *ev,
14539         struct dcerpc_binding_handle *h,
14540         struct spoolss_AddPrinterDriverEx *r)
14541 {
14542         struct tevent_req *req;
14543         struct dcerpc_spoolss_AddPrinterDriverEx_r_state *state;
14544         struct tevent_req *subreq;
14545
14546         req = tevent_req_create(mem_ctx, &state,
14547                                 struct dcerpc_spoolss_AddPrinterDriverEx_r_state);
14548         if (req == NULL) {
14549                 return NULL;
14550         }
14551
14552         state->out_mem_ctx = NULL;
14553         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14554                         NULL, &ndr_table_spoolss,
14555                         NDR_SPOOLSS_ADDPRINTERDRIVEREX, state, r);
14556         if (tevent_req_nomem(subreq, req)) {
14557                 return tevent_req_post(req, ev);
14558         }
14559         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterDriverEx_r_done, req);
14560
14561         return req;
14562 }
14563
14564 static void dcerpc_spoolss_AddPrinterDriverEx_r_done(struct tevent_req *subreq)
14565 {
14566         struct tevent_req *req =
14567                 tevent_req_callback_data(subreq,
14568                 struct tevent_req);
14569         NTSTATUS status;
14570
14571         status = dcerpc_binding_handle_call_recv(subreq);
14572         if (!NT_STATUS_IS_OK(status)) {
14573                 tevent_req_nterror(req, status);
14574                 return;
14575         }
14576
14577         tevent_req_done(req);
14578 }
14579
14580 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14581 {
14582         struct dcerpc_spoolss_AddPrinterDriverEx_r_state *state =
14583                 tevent_req_data(req,
14584                 struct dcerpc_spoolss_AddPrinterDriverEx_r_state);
14585         NTSTATUS status;
14586
14587         if (tevent_req_is_nterror(req, &status)) {
14588                 tevent_req_received(req);
14589                 return status;
14590         }
14591
14592         talloc_steal(mem_ctx, state->out_mem_ctx);
14593
14594         tevent_req_received(req);
14595         return NT_STATUS_OK;
14596 }
14597
14598 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterDriverEx *r)
14599 {
14600         NTSTATUS status;
14601
14602         status = dcerpc_binding_handle_call(h,
14603                         NULL, &ndr_table_spoolss,
14604                         NDR_SPOOLSS_ADDPRINTERDRIVEREX, mem_ctx, r);
14605
14606         return status;
14607 }
14608
14609 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterDriverEx *r)
14610 {
14611         NTSTATUS status;
14612
14613         status = dcerpc_spoolss_AddPrinterDriverEx_r(p->binding_handle, mem_ctx, r);
14614
14615         if (NT_STATUS_IS_RPC(status)) {
14616                 status = NT_STATUS_NET_WRITE_FAULT;
14617         }
14618
14619         return status;
14620 }
14621
14622 struct dcerpc_spoolss_AddPrinterDriverEx_state {
14623         struct spoolss_AddPrinterDriverEx orig;
14624         struct spoolss_AddPrinterDriverEx tmp;
14625         TALLOC_CTX *out_mem_ctx;
14626 };
14627
14628 static void dcerpc_spoolss_AddPrinterDriverEx_done(struct tevent_req *subreq);
14629
14630 struct tevent_req *dcerpc_spoolss_AddPrinterDriverEx_send(TALLOC_CTX *mem_ctx,
14631                                                           struct tevent_context *ev,
14632                                                           struct dcerpc_binding_handle *h,
14633                                                           const char *_servername /* [in] [unique,charset(UTF16)] */,
14634                                                           struct spoolss_AddDriverInfoCtr *_info_ctr /* [in] [ref] */,
14635                                                           uint32_t _flags /* [in]  */)
14636 {
14637         struct tevent_req *req;
14638         struct dcerpc_spoolss_AddPrinterDriverEx_state *state;
14639         struct tevent_req *subreq;
14640
14641         req = tevent_req_create(mem_ctx, &state,
14642                                 struct dcerpc_spoolss_AddPrinterDriverEx_state);
14643         if (req == NULL) {
14644                 return NULL;
14645         }
14646         state->out_mem_ctx = NULL;
14647
14648         /* In parameters */
14649         state->orig.in.servername = _servername;
14650         state->orig.in.info_ctr = _info_ctr;
14651         state->orig.in.flags = _flags;
14652
14653         /* Out parameters */
14654
14655         /* Result */
14656         ZERO_STRUCT(state->orig.out.result);
14657
14658         /* make a temporary copy, that we pass to the dispatch function */
14659         state->tmp = state->orig;
14660
14661         subreq = dcerpc_spoolss_AddPrinterDriverEx_r_send(state, ev, h, &state->tmp);
14662         if (tevent_req_nomem(subreq, req)) {
14663                 return tevent_req_post(req, ev);
14664         }
14665         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterDriverEx_done, req);
14666         return req;
14667 }
14668
14669 static void dcerpc_spoolss_AddPrinterDriverEx_done(struct tevent_req *subreq)
14670 {
14671         struct tevent_req *req = tevent_req_callback_data(
14672                 subreq, struct tevent_req);
14673         struct dcerpc_spoolss_AddPrinterDriverEx_state *state = tevent_req_data(
14674                 req, struct dcerpc_spoolss_AddPrinterDriverEx_state);
14675         NTSTATUS status;
14676         TALLOC_CTX *mem_ctx;
14677
14678         if (state->out_mem_ctx) {
14679                 mem_ctx = state->out_mem_ctx;
14680         } else {
14681                 mem_ctx = state;
14682         }
14683
14684         status = dcerpc_spoolss_AddPrinterDriverEx_r_recv(subreq, mem_ctx);
14685         TALLOC_FREE(subreq);
14686         if (!NT_STATUS_IS_OK(status)) {
14687                 tevent_req_nterror(req, status);
14688                 return;
14689         }
14690
14691         /* Copy out parameters */
14692
14693         /* Copy result */
14694         state->orig.out.result = state->tmp.out.result;
14695
14696         /* Reset temporary structure */
14697         ZERO_STRUCT(state->tmp);
14698
14699         tevent_req_done(req);
14700 }
14701
14702 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_recv(struct tevent_req *req,
14703                                                 TALLOC_CTX *mem_ctx,
14704                                                 WERROR *result)
14705 {
14706         struct dcerpc_spoolss_AddPrinterDriverEx_state *state = tevent_req_data(
14707                 req, struct dcerpc_spoolss_AddPrinterDriverEx_state);
14708         NTSTATUS status;
14709
14710         if (tevent_req_is_nterror(req, &status)) {
14711                 tevent_req_received(req);
14712                 return status;
14713         }
14714
14715         /* Steal possible out parameters to the callers context */
14716         talloc_steal(mem_ctx, state->out_mem_ctx);
14717
14718         /* Return result */
14719         *result = state->orig.out.result;
14720
14721         tevent_req_received(req);
14722         return NT_STATUS_OK;
14723 }
14724
14725 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx(struct dcerpc_binding_handle *h,
14726                                            TALLOC_CTX *mem_ctx,
14727                                            const char *_servername /* [in] [unique,charset(UTF16)] */,
14728                                            struct spoolss_AddDriverInfoCtr *_info_ctr /* [in] [ref] */,
14729                                            uint32_t _flags /* [in]  */,
14730                                            WERROR *result)
14731 {
14732         struct spoolss_AddPrinterDriverEx r;
14733         NTSTATUS status;
14734
14735         /* In parameters */
14736         r.in.servername = _servername;
14737         r.in.info_ctr = _info_ctr;
14738         r.in.flags = _flags;
14739
14740         status = dcerpc_spoolss_AddPrinterDriverEx_r(h, mem_ctx, &r);
14741         if (!NT_STATUS_IS_OK(status)) {
14742                 return status;
14743         }
14744
14745         /* Return variables */
14746
14747         /* Return result */
14748         *result = r.out.result;
14749
14750         return NT_STATUS_OK;
14751 }
14752
14753 struct dcerpc_spoolss_GetCorePrinterDrivers_r_state {
14754         TALLOC_CTX *out_mem_ctx;
14755 };
14756
14757 static void dcerpc_spoolss_GetCorePrinterDrivers_r_done(struct tevent_req *subreq);
14758
14759 struct tevent_req *dcerpc_spoolss_GetCorePrinterDrivers_r_send(TALLOC_CTX *mem_ctx,
14760         struct tevent_context *ev,
14761         struct dcerpc_binding_handle *h,
14762         struct spoolss_GetCorePrinterDrivers *r)
14763 {
14764         struct tevent_req *req;
14765         struct dcerpc_spoolss_GetCorePrinterDrivers_r_state *state;
14766         struct tevent_req *subreq;
14767
14768         req = tevent_req_create(mem_ctx, &state,
14769                                 struct dcerpc_spoolss_GetCorePrinterDrivers_r_state);
14770         if (req == NULL) {
14771                 return NULL;
14772         }
14773
14774         state->out_mem_ctx = talloc_new(state);
14775         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14776                 return tevent_req_post(req, ev);
14777         }
14778
14779         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14780                         NULL, &ndr_table_spoolss,
14781                         NDR_SPOOLSS_GETCOREPRINTERDRIVERS, state->out_mem_ctx, r);
14782         if (tevent_req_nomem(subreq, req)) {
14783                 return tevent_req_post(req, ev);
14784         }
14785         tevent_req_set_callback(subreq, dcerpc_spoolss_GetCorePrinterDrivers_r_done, req);
14786
14787         return req;
14788 }
14789
14790 static void dcerpc_spoolss_GetCorePrinterDrivers_r_done(struct tevent_req *subreq)
14791 {
14792         struct tevent_req *req =
14793                 tevent_req_callback_data(subreq,
14794                 struct tevent_req);
14795         NTSTATUS status;
14796
14797         status = dcerpc_binding_handle_call_recv(subreq);
14798         if (!NT_STATUS_IS_OK(status)) {
14799                 tevent_req_nterror(req, status);
14800                 return;
14801         }
14802
14803         tevent_req_done(req);
14804 }
14805
14806 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14807 {
14808         struct dcerpc_spoolss_GetCorePrinterDrivers_r_state *state =
14809                 tevent_req_data(req,
14810                 struct dcerpc_spoolss_GetCorePrinterDrivers_r_state);
14811         NTSTATUS status;
14812
14813         if (tevent_req_is_nterror(req, &status)) {
14814                 tevent_req_received(req);
14815                 return status;
14816         }
14817
14818         talloc_steal(mem_ctx, state->out_mem_ctx);
14819
14820         tevent_req_received(req);
14821         return NT_STATUS_OK;
14822 }
14823
14824 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetCorePrinterDrivers *r)
14825 {
14826         NTSTATUS status;
14827
14828         status = dcerpc_binding_handle_call(h,
14829                         NULL, &ndr_table_spoolss,
14830                         NDR_SPOOLSS_GETCOREPRINTERDRIVERS, mem_ctx, r);
14831
14832         return status;
14833 }
14834
14835 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetCorePrinterDrivers *r)
14836 {
14837         NTSTATUS status;
14838
14839         status = dcerpc_spoolss_GetCorePrinterDrivers_r(p->binding_handle, mem_ctx, r);
14840
14841         if (NT_STATUS_IS_RPC(status)) {
14842                 status = NT_STATUS_NET_WRITE_FAULT;
14843         }
14844
14845         return status;
14846 }
14847
14848 struct dcerpc_spoolss_GetCorePrinterDrivers_state {
14849         struct spoolss_GetCorePrinterDrivers orig;
14850         struct spoolss_GetCorePrinterDrivers tmp;
14851         TALLOC_CTX *out_mem_ctx;
14852 };
14853
14854 static void dcerpc_spoolss_GetCorePrinterDrivers_done(struct tevent_req *subreq);
14855
14856 struct tevent_req *dcerpc_spoolss_GetCorePrinterDrivers_send(TALLOC_CTX *mem_ctx,
14857                                                              struct tevent_context *ev,
14858                                                              struct dcerpc_binding_handle *h,
14859                                                              const char *_servername /* [in] [unique,charset(UTF16)] */,
14860                                                              const char *_architecture /* [in] [ref,charset(UTF16)] */,
14861                                                              uint32_t _core_driver_size /* [in]  */,
14862                                                              const char *_core_driver_dependencies /* [in] [ref,charset(UTF16),size_is(core_driver_size)] */,
14863                                                              uint32_t _core_printer_driver_count /* [in]  */,
14864                                                              struct spoolss_CorePrinterDriver *_core_printer_drivers /* [out] [ref,size_is(core_printer_driver_count)] */)
14865 {
14866         struct tevent_req *req;
14867         struct dcerpc_spoolss_GetCorePrinterDrivers_state *state;
14868         struct tevent_req *subreq;
14869
14870         req = tevent_req_create(mem_ctx, &state,
14871                                 struct dcerpc_spoolss_GetCorePrinterDrivers_state);
14872         if (req == NULL) {
14873                 return NULL;
14874         }
14875         state->out_mem_ctx = NULL;
14876
14877         /* In parameters */
14878         state->orig.in.servername = _servername;
14879         state->orig.in.architecture = _architecture;
14880         state->orig.in.core_driver_size = _core_driver_size;
14881         state->orig.in.core_driver_dependencies = _core_driver_dependencies;
14882         state->orig.in.core_printer_driver_count = _core_printer_driver_count;
14883
14884         /* Out parameters */
14885         state->orig.out.core_printer_drivers = _core_printer_drivers;
14886
14887         /* Result */
14888         ZERO_STRUCT(state->orig.out.result);
14889
14890         state->out_mem_ctx = talloc_named_const(state, 0,
14891                              "dcerpc_spoolss_GetCorePrinterDrivers_out_memory");
14892         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14893                 return tevent_req_post(req, ev);
14894         }
14895
14896         /* make a temporary copy, that we pass to the dispatch function */
14897         state->tmp = state->orig;
14898
14899         subreq = dcerpc_spoolss_GetCorePrinterDrivers_r_send(state, ev, h, &state->tmp);
14900         if (tevent_req_nomem(subreq, req)) {
14901                 return tevent_req_post(req, ev);
14902         }
14903         tevent_req_set_callback(subreq, dcerpc_spoolss_GetCorePrinterDrivers_done, req);
14904         return req;
14905 }
14906
14907 static void dcerpc_spoolss_GetCorePrinterDrivers_done(struct tevent_req *subreq)
14908 {
14909         struct tevent_req *req = tevent_req_callback_data(
14910                 subreq, struct tevent_req);
14911         struct dcerpc_spoolss_GetCorePrinterDrivers_state *state = tevent_req_data(
14912                 req, struct dcerpc_spoolss_GetCorePrinterDrivers_state);
14913         NTSTATUS status;
14914         TALLOC_CTX *mem_ctx;
14915
14916         if (state->out_mem_ctx) {
14917                 mem_ctx = state->out_mem_ctx;
14918         } else {
14919                 mem_ctx = state;
14920         }
14921
14922         status = dcerpc_spoolss_GetCorePrinterDrivers_r_recv(subreq, mem_ctx);
14923         TALLOC_FREE(subreq);
14924         if (!NT_STATUS_IS_OK(status)) {
14925                 tevent_req_nterror(req, status);
14926                 return;
14927         }
14928
14929         /* Copy out parameters */
14930         {
14931                 size_t _copy_len_core_printer_drivers;
14932                 _copy_len_core_printer_drivers = state->tmp.in.core_printer_driver_count;
14933                 memcpy(state->orig.out.core_printer_drivers, state->tmp.out.core_printer_drivers, _copy_len_core_printer_drivers * sizeof(*state->orig.out.core_printer_drivers));
14934         }
14935
14936         /* Copy result */
14937         state->orig.out.result = state->tmp.out.result;
14938
14939         /* Reset temporary structure */
14940         ZERO_STRUCT(state->tmp);
14941
14942         tevent_req_done(req);
14943 }
14944
14945 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_recv(struct tevent_req *req,
14946                                                    TALLOC_CTX *mem_ctx,
14947                                                    WERROR *result)
14948 {
14949         struct dcerpc_spoolss_GetCorePrinterDrivers_state *state = tevent_req_data(
14950                 req, struct dcerpc_spoolss_GetCorePrinterDrivers_state);
14951         NTSTATUS status;
14952
14953         if (tevent_req_is_nterror(req, &status)) {
14954                 tevent_req_received(req);
14955                 return status;
14956         }
14957
14958         /* Steal possible out parameters to the callers context */
14959         talloc_steal(mem_ctx, state->out_mem_ctx);
14960
14961         /* Return result */
14962         *result = state->orig.out.result;
14963
14964         tevent_req_received(req);
14965         return NT_STATUS_OK;
14966 }
14967
14968 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers(struct dcerpc_binding_handle *h,
14969                                               TALLOC_CTX *mem_ctx,
14970                                               const char *_servername /* [in] [unique,charset(UTF16)] */,
14971                                               const char *_architecture /* [in] [ref,charset(UTF16)] */,
14972                                               uint32_t _core_driver_size /* [in]  */,
14973                                               const char *_core_driver_dependencies /* [in] [ref,charset(UTF16),size_is(core_driver_size)] */,
14974                                               uint32_t _core_printer_driver_count /* [in]  */,
14975                                               struct spoolss_CorePrinterDriver *_core_printer_drivers /* [out] [ref,size_is(core_printer_driver_count)] */,
14976                                               WERROR *result)
14977 {
14978         struct spoolss_GetCorePrinterDrivers r;
14979         NTSTATUS status;
14980
14981         /* In parameters */
14982         r.in.servername = _servername;
14983         r.in.architecture = _architecture;
14984         r.in.core_driver_size = _core_driver_size;
14985         r.in.core_driver_dependencies = _core_driver_dependencies;
14986         r.in.core_printer_driver_count = _core_printer_driver_count;
14987
14988         status = dcerpc_spoolss_GetCorePrinterDrivers_r(h, mem_ctx, &r);
14989         if (!NT_STATUS_IS_OK(status)) {
14990                 return status;
14991         }
14992
14993         /* Return variables */
14994         {
14995                 size_t _copy_len_core_printer_drivers;
14996                 _copy_len_core_printer_drivers = r.in.core_printer_driver_count;
14997                 memcpy(_core_printer_drivers, r.out.core_printer_drivers, _copy_len_core_printer_drivers * sizeof(*_core_printer_drivers));
14998         }
14999
15000         /* Return result */
15001         *result = r.out.result;
15002
15003         return NT_STATUS_OK;
15004 }
15005
15006 struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state {
15007         TALLOC_CTX *out_mem_ctx;
15008 };
15009
15010 static void dcerpc_spoolss_GetPrinterDriverPackagePath_r_done(struct tevent_req *subreq);
15011
15012 struct tevent_req *dcerpc_spoolss_GetPrinterDriverPackagePath_r_send(TALLOC_CTX *mem_ctx,
15013         struct tevent_context *ev,
15014         struct dcerpc_binding_handle *h,
15015         struct spoolss_GetPrinterDriverPackagePath *r)
15016 {
15017         struct tevent_req *req;
15018         struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state *state;
15019         struct tevent_req *subreq;
15020
15021         req = tevent_req_create(mem_ctx, &state,
15022                                 struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state);
15023         if (req == NULL) {
15024                 return NULL;
15025         }
15026
15027         state->out_mem_ctx = talloc_new(state);
15028         if (tevent_req_nomem(state->out_mem_ctx, req)) {
15029                 return tevent_req_post(req, ev);
15030         }
15031
15032         subreq = dcerpc_binding_handle_call_send(state, ev, h,
15033                         NULL, &ndr_table_spoolss,
15034                         NDR_SPOOLSS_GETPRINTERDRIVERPACKAGEPATH, state->out_mem_ctx, r);
15035         if (tevent_req_nomem(subreq, req)) {
15036                 return tevent_req_post(req, ev);
15037         }
15038         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriverPackagePath_r_done, req);
15039
15040         return req;
15041 }
15042
15043 static void dcerpc_spoolss_GetPrinterDriverPackagePath_r_done(struct tevent_req *subreq)
15044 {
15045         struct tevent_req *req =
15046                 tevent_req_callback_data(subreq,
15047                 struct tevent_req);
15048         NTSTATUS status;
15049
15050         status = dcerpc_binding_handle_call_recv(subreq);
15051         if (!NT_STATUS_IS_OK(status)) {
15052                 tevent_req_nterror(req, status);
15053                 return;
15054         }
15055
15056         tevent_req_done(req);
15057 }
15058
15059 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
15060 {
15061         struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state *state =
15062                 tevent_req_data(req,
15063                 struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state);
15064         NTSTATUS status;
15065
15066         if (tevent_req_is_nterror(req, &status)) {
15067                 tevent_req_received(req);
15068                 return status;
15069         }
15070
15071         talloc_steal(mem_ctx, state->out_mem_ctx);
15072
15073         tevent_req_received(req);
15074         return NT_STATUS_OK;
15075 }
15076
15077 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverPackagePath *r)
15078 {
15079         NTSTATUS status;
15080
15081         status = dcerpc_binding_handle_call(h,
15082                         NULL, &ndr_table_spoolss,
15083                         NDR_SPOOLSS_GETPRINTERDRIVERPACKAGEPATH, mem_ctx, r);
15084
15085         return status;
15086 }
15087
15088 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverPackagePath *r)
15089 {
15090         NTSTATUS status;
15091
15092         status = dcerpc_spoolss_GetPrinterDriverPackagePath_r(p->binding_handle, mem_ctx, r);
15093
15094         if (NT_STATUS_IS_RPC(status)) {
15095                 status = NT_STATUS_NET_WRITE_FAULT;
15096         }
15097
15098         return status;
15099 }
15100
15101 struct dcerpc_spoolss_GetPrinterDriverPackagePath_state {
15102         struct spoolss_GetPrinterDriverPackagePath orig;
15103         struct spoolss_GetPrinterDriverPackagePath tmp;
15104         TALLOC_CTX *out_mem_ctx;
15105 };
15106
15107 static void dcerpc_spoolss_GetPrinterDriverPackagePath_done(struct tevent_req *subreq);
15108
15109 struct tevent_req *dcerpc_spoolss_GetPrinterDriverPackagePath_send(TALLOC_CTX *mem_ctx,
15110                                                                    struct tevent_context *ev,
15111                                                                    struct dcerpc_binding_handle *h,
15112                                                                    const char *_servername /* [in] [unique,charset(UTF16)] */,
15113                                                                    const char *_architecture /* [in] [ref,charset(UTF16)] */,
15114                                                                    const char *_language /* [in] [unique,charset(UTF16)] */,
15115                                                                    const char *_package_id /* [in] [ref,charset(UTF16)] */,
15116                                                                    const char *_driver_package_cab /* [in,out] [unique,charset(UTF16),size_is(driver_package_cab_size)] */,
15117                                                                    uint32_t _driver_package_cab_size /* [in]  */,
15118                                                                    uint32_t *_required /* [out] [ref] */)
15119 {
15120         struct tevent_req *req;
15121         struct dcerpc_spoolss_GetPrinterDriverPackagePath_state *state;
15122         struct tevent_req *subreq;
15123
15124         req = tevent_req_create(mem_ctx, &state,
15125                                 struct dcerpc_spoolss_GetPrinterDriverPackagePath_state);
15126         if (req == NULL) {
15127                 return NULL;
15128         }
15129         state->out_mem_ctx = NULL;
15130
15131         /* In parameters */
15132         state->orig.in.servername = _servername;
15133         state->orig.in.architecture = _architecture;
15134         state->orig.in.language = _language;
15135         state->orig.in.package_id = _package_id;
15136         state->orig.in.driver_package_cab = _driver_package_cab;
15137         state->orig.in.driver_package_cab_size = _driver_package_cab_size;
15138
15139         /* Out parameters */
15140         state->orig.out.driver_package_cab = _driver_package_cab;
15141         state->orig.out.required = _required;
15142
15143         /* Result */
15144         ZERO_STRUCT(state->orig.out.result);
15145
15146         state->out_mem_ctx = talloc_named_const(state, 0,
15147                              "dcerpc_spoolss_GetPrinterDriverPackagePath_out_memory");
15148         if (tevent_req_nomem(state->out_mem_ctx, req)) {
15149                 return tevent_req_post(req, ev);
15150         }
15151
15152         /* make a temporary copy, that we pass to the dispatch function */
15153         state->tmp = state->orig;
15154
15155         subreq = dcerpc_spoolss_GetPrinterDriverPackagePath_r_send(state, ev, h, &state->tmp);
15156         if (tevent_req_nomem(subreq, req)) {
15157                 return tevent_req_post(req, ev);
15158         }
15159         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriverPackagePath_done, req);
15160         return req;
15161 }
15162
15163 static void dcerpc_spoolss_GetPrinterDriverPackagePath_done(struct tevent_req *subreq)
15164 {
15165         struct tevent_req *req = tevent_req_callback_data(
15166                 subreq, struct tevent_req);
15167         struct dcerpc_spoolss_GetPrinterDriverPackagePath_state *state = tevent_req_data(
15168                 req, struct dcerpc_spoolss_GetPrinterDriverPackagePath_state);
15169         NTSTATUS status;
15170         TALLOC_CTX *mem_ctx;
15171
15172         if (state->out_mem_ctx) {
15173                 mem_ctx = state->out_mem_ctx;
15174         } else {
15175                 mem_ctx = state;
15176         }
15177
15178         status = dcerpc_spoolss_GetPrinterDriverPackagePath_r_recv(subreq, mem_ctx);
15179         TALLOC_FREE(subreq);
15180         if (!NT_STATUS_IS_OK(status)) {
15181                 tevent_req_nterror(req, status);
15182                 return;
15183         }
15184
15185         /* Copy out parameters */
15186         if (state->orig.out.driver_package_cab && state->tmp.out.driver_package_cab) {
15187                 {
15188                         size_t _copy_len_driver_package_cab;
15189                         _copy_len_driver_package_cab = ndr_charset_length(state->tmp.out.driver_package_cab, CH_UNIX);
15190                         if (_copy_len_driver_package_cab > ndr_charset_length(state->tmp.in.driver_package_cab, CH_UNIX)) {
15191                                 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
15192                                 return;
15193                         }
15194                         memcpy(discard_const_p(uint8_t *, state->orig.out.driver_package_cab), state->tmp.out.driver_package_cab, _copy_len_driver_package_cab * sizeof(*state->orig.out.driver_package_cab));
15195                 }
15196         }
15197         *state->orig.out.required = *state->tmp.out.required;
15198
15199         /* Copy result */
15200         state->orig.out.result = state->tmp.out.result;
15201
15202         /* Reset temporary structure */
15203         ZERO_STRUCT(state->tmp);
15204
15205         tevent_req_done(req);
15206 }
15207
15208 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_recv(struct tevent_req *req,
15209                                                          TALLOC_CTX *mem_ctx,
15210                                                          WERROR *result)
15211 {
15212         struct dcerpc_spoolss_GetPrinterDriverPackagePath_state *state = tevent_req_data(
15213                 req, struct dcerpc_spoolss_GetPrinterDriverPackagePath_state);
15214         NTSTATUS status;
15215
15216         if (tevent_req_is_nterror(req, &status)) {
15217                 tevent_req_received(req);
15218                 return status;
15219         }
15220
15221         /* Steal possible out parameters to the callers context */
15222         talloc_steal(mem_ctx, state->out_mem_ctx);
15223
15224         /* Return result */
15225         *result = state->orig.out.result;
15226
15227         tevent_req_received(req);
15228         return NT_STATUS_OK;
15229 }
15230
15231 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath(struct dcerpc_binding_handle *h,
15232                                                     TALLOC_CTX *mem_ctx,
15233                                                     const char *_servername /* [in] [unique,charset(UTF16)] */,
15234                                                     const char *_architecture /* [in] [ref,charset(UTF16)] */,
15235                                                     const char *_language /* [in] [unique,charset(UTF16)] */,
15236                                                     const char *_package_id /* [in] [ref,charset(UTF16)] */,
15237                                                     const char *_driver_package_cab /* [in,out] [unique,charset(UTF16),size_is(driver_package_cab_size)] */,
15238                                                     uint32_t _driver_package_cab_size /* [in]  */,
15239                                                     uint32_t *_required /* [out] [ref] */,
15240                                                     WERROR *result)
15241 {
15242         struct spoolss_GetPrinterDriverPackagePath r;
15243         NTSTATUS status;
15244
15245         /* In parameters */
15246         r.in.servername = _servername;
15247         r.in.architecture = _architecture;
15248         r.in.language = _language;
15249         r.in.package_id = _package_id;
15250         r.in.driver_package_cab = _driver_package_cab;
15251         r.in.driver_package_cab_size = _driver_package_cab_size;
15252
15253         status = dcerpc_spoolss_GetPrinterDriverPackagePath_r(h, mem_ctx, &r);
15254         if (!NT_STATUS_IS_OK(status)) {
15255                 return status;
15256         }
15257
15258         /* Return variables */
15259         if (_driver_package_cab && r.out.driver_package_cab) {
15260                 {
15261                         size_t _copy_len_driver_package_cab;
15262                         _copy_len_driver_package_cab = ndr_charset_length(r.out.driver_package_cab, CH_UNIX);
15263                         if (_copy_len_driver_package_cab > ndr_charset_length(r.in.driver_package_cab, CH_UNIX)) {
15264                                 return NT_STATUS_INVALID_NETWORK_RESPONSE;
15265                         }
15266                         memcpy(discard_const_p(uint8_t *, _driver_package_cab), r.out.driver_package_cab, _copy_len_driver_package_cab * sizeof(*_driver_package_cab));
15267                 }
15268         }
15269         *_required = *r.out.required;
15270
15271         /* Return result */
15272         *result = r.out.result;
15273
15274         return NT_STATUS_OK;
15275 }
15276