8510802c445adea1bb202a1b40a328be54f0b397
[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         memcpy(state->orig.out.data, state->tmp.out.data, (state->tmp.in.data_size) * sizeof(*state->orig.out.data));
5409         *state->orig.out._data_size = *state->tmp.out._data_size;
5410
5411         /* Copy result */
5412         state->orig.out.result = state->tmp.out.result;
5413
5414         /* Reset temporary structure */
5415         ZERO_STRUCT(state->tmp);
5416
5417         tevent_req_done(req);
5418 }
5419
5420 NTSTATUS dcerpc_spoolss_ReadPrinter_recv(struct tevent_req *req,
5421                                          TALLOC_CTX *mem_ctx,
5422                                          WERROR *result)
5423 {
5424         struct dcerpc_spoolss_ReadPrinter_state *state = tevent_req_data(
5425                 req, struct dcerpc_spoolss_ReadPrinter_state);
5426         NTSTATUS status;
5427
5428         if (tevent_req_is_nterror(req, &status)) {
5429                 tevent_req_received(req);
5430                 return status;
5431         }
5432
5433         /* Steal possible out parameters to the callers context */
5434         talloc_steal(mem_ctx, state->out_mem_ctx);
5435
5436         /* Return result */
5437         *result = state->orig.out.result;
5438
5439         tevent_req_received(req);
5440         return NT_STATUS_OK;
5441 }
5442
5443 NTSTATUS dcerpc_spoolss_ReadPrinter(struct dcerpc_binding_handle *h,
5444                                     TALLOC_CTX *mem_ctx,
5445                                     struct policy_handle *_handle /* [in] [ref] */,
5446                                     uint8_t *_data /* [out] [ref,size_is(data_size)] */,
5447                                     uint32_t _data_size /* [in]  */,
5448                                     uint32_t *__data_size /* [out] [ref] */,
5449                                     WERROR *result)
5450 {
5451         struct spoolss_ReadPrinter r;
5452         NTSTATUS status;
5453
5454         /* In parameters */
5455         r.in.handle = _handle;
5456         r.in.data_size = _data_size;
5457
5458         status = dcerpc_spoolss_ReadPrinter_r(h, mem_ctx, &r);
5459         if (!NT_STATUS_IS_OK(status)) {
5460                 return status;
5461         }
5462
5463         /* Return variables */
5464         memcpy(_data, r.out.data, (r.in.data_size) * sizeof(*_data));
5465         *__data_size = *r.out._data_size;
5466
5467         /* Return result */
5468         *result = r.out.result;
5469
5470         return NT_STATUS_OK;
5471 }
5472
5473 struct dcerpc_spoolss_EndDocPrinter_r_state {
5474         TALLOC_CTX *out_mem_ctx;
5475 };
5476
5477 static void dcerpc_spoolss_EndDocPrinter_r_done(struct tevent_req *subreq);
5478
5479 struct tevent_req *dcerpc_spoolss_EndDocPrinter_r_send(TALLOC_CTX *mem_ctx,
5480         struct tevent_context *ev,
5481         struct dcerpc_binding_handle *h,
5482         struct spoolss_EndDocPrinter *r)
5483 {
5484         struct tevent_req *req;
5485         struct dcerpc_spoolss_EndDocPrinter_r_state *state;
5486         struct tevent_req *subreq;
5487
5488         req = tevent_req_create(mem_ctx, &state,
5489                                 struct dcerpc_spoolss_EndDocPrinter_r_state);
5490         if (req == NULL) {
5491                 return NULL;
5492         }
5493
5494         state->out_mem_ctx = NULL;
5495         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5496                         NULL, &ndr_table_spoolss,
5497                         NDR_SPOOLSS_ENDDOCPRINTER, state, r);
5498         if (tevent_req_nomem(subreq, req)) {
5499                 return tevent_req_post(req, ev);
5500         }
5501         tevent_req_set_callback(subreq, dcerpc_spoolss_EndDocPrinter_r_done, req);
5502
5503         return req;
5504 }
5505
5506 static void dcerpc_spoolss_EndDocPrinter_r_done(struct tevent_req *subreq)
5507 {
5508         struct tevent_req *req =
5509                 tevent_req_callback_data(subreq,
5510                 struct tevent_req);
5511         NTSTATUS status;
5512
5513         status = dcerpc_binding_handle_call_recv(subreq);
5514         if (!NT_STATUS_IS_OK(status)) {
5515                 tevent_req_nterror(req, status);
5516                 return;
5517         }
5518
5519         tevent_req_done(req);
5520 }
5521
5522 NTSTATUS dcerpc_spoolss_EndDocPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5523 {
5524         struct dcerpc_spoolss_EndDocPrinter_r_state *state =
5525                 tevent_req_data(req,
5526                 struct dcerpc_spoolss_EndDocPrinter_r_state);
5527         NTSTATUS status;
5528
5529         if (tevent_req_is_nterror(req, &status)) {
5530                 tevent_req_received(req);
5531                 return status;
5532         }
5533
5534         talloc_steal(mem_ctx, state->out_mem_ctx);
5535
5536         tevent_req_received(req);
5537         return NT_STATUS_OK;
5538 }
5539
5540 NTSTATUS dcerpc_spoolss_EndDocPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EndDocPrinter *r)
5541 {
5542         NTSTATUS status;
5543
5544         status = dcerpc_binding_handle_call(h,
5545                         NULL, &ndr_table_spoolss,
5546                         NDR_SPOOLSS_ENDDOCPRINTER, mem_ctx, r);
5547
5548         return status;
5549 }
5550
5551 NTSTATUS dcerpc_spoolss_EndDocPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EndDocPrinter *r)
5552 {
5553         NTSTATUS status;
5554
5555         status = dcerpc_spoolss_EndDocPrinter_r(p->binding_handle, mem_ctx, r);
5556
5557         if (NT_STATUS_IS_RPC(status)) {
5558                 status = NT_STATUS_NET_WRITE_FAULT;
5559         }
5560
5561         return status;
5562 }
5563
5564 struct dcerpc_spoolss_EndDocPrinter_state {
5565         struct spoolss_EndDocPrinter orig;
5566         struct spoolss_EndDocPrinter tmp;
5567         TALLOC_CTX *out_mem_ctx;
5568 };
5569
5570 static void dcerpc_spoolss_EndDocPrinter_done(struct tevent_req *subreq);
5571
5572 struct tevent_req *dcerpc_spoolss_EndDocPrinter_send(TALLOC_CTX *mem_ctx,
5573                                                      struct tevent_context *ev,
5574                                                      struct dcerpc_binding_handle *h,
5575                                                      struct policy_handle *_handle /* [in] [ref] */)
5576 {
5577         struct tevent_req *req;
5578         struct dcerpc_spoolss_EndDocPrinter_state *state;
5579         struct tevent_req *subreq;
5580
5581         req = tevent_req_create(mem_ctx, &state,
5582                                 struct dcerpc_spoolss_EndDocPrinter_state);
5583         if (req == NULL) {
5584                 return NULL;
5585         }
5586         state->out_mem_ctx = NULL;
5587
5588         /* In parameters */
5589         state->orig.in.handle = _handle;
5590
5591         /* Out parameters */
5592
5593         /* Result */
5594         ZERO_STRUCT(state->orig.out.result);
5595
5596         /* make a temporary copy, that we pass to the dispatch function */
5597         state->tmp = state->orig;
5598
5599         subreq = dcerpc_spoolss_EndDocPrinter_r_send(state, ev, h, &state->tmp);
5600         if (tevent_req_nomem(subreq, req)) {
5601                 return tevent_req_post(req, ev);
5602         }
5603         tevent_req_set_callback(subreq, dcerpc_spoolss_EndDocPrinter_done, req);
5604         return req;
5605 }
5606
5607 static void dcerpc_spoolss_EndDocPrinter_done(struct tevent_req *subreq)
5608 {
5609         struct tevent_req *req = tevent_req_callback_data(
5610                 subreq, struct tevent_req);
5611         struct dcerpc_spoolss_EndDocPrinter_state *state = tevent_req_data(
5612                 req, struct dcerpc_spoolss_EndDocPrinter_state);
5613         NTSTATUS status;
5614         TALLOC_CTX *mem_ctx;
5615
5616         if (state->out_mem_ctx) {
5617                 mem_ctx = state->out_mem_ctx;
5618         } else {
5619                 mem_ctx = state;
5620         }
5621
5622         status = dcerpc_spoolss_EndDocPrinter_r_recv(subreq, mem_ctx);
5623         TALLOC_FREE(subreq);
5624         if (!NT_STATUS_IS_OK(status)) {
5625                 tevent_req_nterror(req, status);
5626                 return;
5627         }
5628
5629         /* Copy out parameters */
5630
5631         /* Copy result */
5632         state->orig.out.result = state->tmp.out.result;
5633
5634         /* Reset temporary structure */
5635         ZERO_STRUCT(state->tmp);
5636
5637         tevent_req_done(req);
5638 }
5639
5640 NTSTATUS dcerpc_spoolss_EndDocPrinter_recv(struct tevent_req *req,
5641                                            TALLOC_CTX *mem_ctx,
5642                                            WERROR *result)
5643 {
5644         struct dcerpc_spoolss_EndDocPrinter_state *state = tevent_req_data(
5645                 req, struct dcerpc_spoolss_EndDocPrinter_state);
5646         NTSTATUS status;
5647
5648         if (tevent_req_is_nterror(req, &status)) {
5649                 tevent_req_received(req);
5650                 return status;
5651         }
5652
5653         /* Steal possible out parameters to the callers context */
5654         talloc_steal(mem_ctx, state->out_mem_ctx);
5655
5656         /* Return result */
5657         *result = state->orig.out.result;
5658
5659         tevent_req_received(req);
5660         return NT_STATUS_OK;
5661 }
5662
5663 NTSTATUS dcerpc_spoolss_EndDocPrinter(struct dcerpc_binding_handle *h,
5664                                       TALLOC_CTX *mem_ctx,
5665                                       struct policy_handle *_handle /* [in] [ref] */,
5666                                       WERROR *result)
5667 {
5668         struct spoolss_EndDocPrinter r;
5669         NTSTATUS status;
5670
5671         /* In parameters */
5672         r.in.handle = _handle;
5673
5674         status = dcerpc_spoolss_EndDocPrinter_r(h, mem_ctx, &r);
5675         if (!NT_STATUS_IS_OK(status)) {
5676                 return status;
5677         }
5678
5679         /* Return variables */
5680
5681         /* Return result */
5682         *result = r.out.result;
5683
5684         return NT_STATUS_OK;
5685 }
5686
5687 struct dcerpc_spoolss_AddJob_r_state {
5688         TALLOC_CTX *out_mem_ctx;
5689 };
5690
5691 static void dcerpc_spoolss_AddJob_r_done(struct tevent_req *subreq);
5692
5693 struct tevent_req *dcerpc_spoolss_AddJob_r_send(TALLOC_CTX *mem_ctx,
5694         struct tevent_context *ev,
5695         struct dcerpc_binding_handle *h,
5696         struct spoolss_AddJob *r)
5697 {
5698         struct tevent_req *req;
5699         struct dcerpc_spoolss_AddJob_r_state *state;
5700         struct tevent_req *subreq;
5701
5702         req = tevent_req_create(mem_ctx, &state,
5703                                 struct dcerpc_spoolss_AddJob_r_state);
5704         if (req == NULL) {
5705                 return NULL;
5706         }
5707
5708         state->out_mem_ctx = talloc_new(state);
5709         if (tevent_req_nomem(state->out_mem_ctx, req)) {
5710                 return tevent_req_post(req, ev);
5711         }
5712
5713         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5714                         NULL, &ndr_table_spoolss,
5715                         NDR_SPOOLSS_ADDJOB, state->out_mem_ctx, r);
5716         if (tevent_req_nomem(subreq, req)) {
5717                 return tevent_req_post(req, ev);
5718         }
5719         tevent_req_set_callback(subreq, dcerpc_spoolss_AddJob_r_done, req);
5720
5721         return req;
5722 }
5723
5724 static void dcerpc_spoolss_AddJob_r_done(struct tevent_req *subreq)
5725 {
5726         struct tevent_req *req =
5727                 tevent_req_callback_data(subreq,
5728                 struct tevent_req);
5729         NTSTATUS status;
5730
5731         status = dcerpc_binding_handle_call_recv(subreq);
5732         if (!NT_STATUS_IS_OK(status)) {
5733                 tevent_req_nterror(req, status);
5734                 return;
5735         }
5736
5737         tevent_req_done(req);
5738 }
5739
5740 NTSTATUS dcerpc_spoolss_AddJob_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5741 {
5742         struct dcerpc_spoolss_AddJob_r_state *state =
5743                 tevent_req_data(req,
5744                 struct dcerpc_spoolss_AddJob_r_state);
5745         NTSTATUS status;
5746
5747         if (tevent_req_is_nterror(req, &status)) {
5748                 tevent_req_received(req);
5749                 return status;
5750         }
5751
5752         talloc_steal(mem_ctx, state->out_mem_ctx);
5753
5754         tevent_req_received(req);
5755         return NT_STATUS_OK;
5756 }
5757
5758 NTSTATUS dcerpc_spoolss_AddJob_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddJob *r)
5759 {
5760         NTSTATUS status;
5761
5762         status = dcerpc_binding_handle_call(h,
5763                         NULL, &ndr_table_spoolss,
5764                         NDR_SPOOLSS_ADDJOB, mem_ctx, r);
5765
5766         return status;
5767 }
5768
5769 NTSTATUS dcerpc_spoolss_AddJob_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddJob *r)
5770 {
5771         NTSTATUS status;
5772
5773         status = dcerpc_spoolss_AddJob_r(p->binding_handle, mem_ctx, r);
5774
5775         if (NT_STATUS_IS_RPC(status)) {
5776                 status = NT_STATUS_NET_WRITE_FAULT;
5777         }
5778
5779         return status;
5780 }
5781
5782 struct dcerpc_spoolss_AddJob_state {
5783         struct spoolss_AddJob orig;
5784         struct spoolss_AddJob tmp;
5785         TALLOC_CTX *out_mem_ctx;
5786 };
5787
5788 static void dcerpc_spoolss_AddJob_done(struct tevent_req *subreq);
5789
5790 struct tevent_req *dcerpc_spoolss_AddJob_send(TALLOC_CTX *mem_ctx,
5791                                               struct tevent_context *ev,
5792                                               struct dcerpc_binding_handle *h,
5793                                               struct policy_handle *_handle /* [in] [ref] */,
5794                                               uint32_t _level /* [in]  */,
5795                                               uint8_t *_buffer /* [in,out] [unique,size_is(offered)] */,
5796                                               uint32_t _offered /* [in]  */,
5797                                               uint32_t *_needed /* [out] [ref] */)
5798 {
5799         struct tevent_req *req;
5800         struct dcerpc_spoolss_AddJob_state *state;
5801         struct tevent_req *subreq;
5802
5803         req = tevent_req_create(mem_ctx, &state,
5804                                 struct dcerpc_spoolss_AddJob_state);
5805         if (req == NULL) {
5806                 return NULL;
5807         }
5808         state->out_mem_ctx = NULL;
5809
5810         /* In parameters */
5811         state->orig.in.handle = _handle;
5812         state->orig.in.level = _level;
5813         state->orig.in.buffer = _buffer;
5814         state->orig.in.offered = _offered;
5815
5816         /* Out parameters */
5817         state->orig.out.buffer = _buffer;
5818         state->orig.out.needed = _needed;
5819
5820         /* Result */
5821         ZERO_STRUCT(state->orig.out.result);
5822
5823         state->out_mem_ctx = talloc_named_const(state, 0,
5824                              "dcerpc_spoolss_AddJob_out_memory");
5825         if (tevent_req_nomem(state->out_mem_ctx, req)) {
5826                 return tevent_req_post(req, ev);
5827         }
5828
5829         /* make a temporary copy, that we pass to the dispatch function */
5830         state->tmp = state->orig;
5831
5832         subreq = dcerpc_spoolss_AddJob_r_send(state, ev, h, &state->tmp);
5833         if (tevent_req_nomem(subreq, req)) {
5834                 return tevent_req_post(req, ev);
5835         }
5836         tevent_req_set_callback(subreq, dcerpc_spoolss_AddJob_done, req);
5837         return req;
5838 }
5839
5840 static void dcerpc_spoolss_AddJob_done(struct tevent_req *subreq)
5841 {
5842         struct tevent_req *req = tevent_req_callback_data(
5843                 subreq, struct tevent_req);
5844         struct dcerpc_spoolss_AddJob_state *state = tevent_req_data(
5845                 req, struct dcerpc_spoolss_AddJob_state);
5846         NTSTATUS status;
5847         TALLOC_CTX *mem_ctx;
5848
5849         if (state->out_mem_ctx) {
5850                 mem_ctx = state->out_mem_ctx;
5851         } else {
5852                 mem_ctx = state;
5853         }
5854
5855         status = dcerpc_spoolss_AddJob_r_recv(subreq, mem_ctx);
5856         TALLOC_FREE(subreq);
5857         if (!NT_STATUS_IS_OK(status)) {
5858                 tevent_req_nterror(req, status);
5859                 return;
5860         }
5861
5862         /* Copy out parameters */
5863         if (state->orig.out.buffer && state->tmp.out.buffer) {
5864                 memcpy(state->orig.out.buffer, state->tmp.out.buffer, (state->tmp.in.offered) * sizeof(*state->orig.out.buffer));
5865         }
5866         *state->orig.out.needed = *state->tmp.out.needed;
5867
5868         /* Copy result */
5869         state->orig.out.result = state->tmp.out.result;
5870
5871         /* Reset temporary structure */
5872         ZERO_STRUCT(state->tmp);
5873
5874         tevent_req_done(req);
5875 }
5876
5877 NTSTATUS dcerpc_spoolss_AddJob_recv(struct tevent_req *req,
5878                                     TALLOC_CTX *mem_ctx,
5879                                     WERROR *result)
5880 {
5881         struct dcerpc_spoolss_AddJob_state *state = tevent_req_data(
5882                 req, struct dcerpc_spoolss_AddJob_state);
5883         NTSTATUS status;
5884
5885         if (tevent_req_is_nterror(req, &status)) {
5886                 tevent_req_received(req);
5887                 return status;
5888         }
5889
5890         /* Steal possible out parameters to the callers context */
5891         talloc_steal(mem_ctx, state->out_mem_ctx);
5892
5893         /* Return result */
5894         *result = state->orig.out.result;
5895
5896         tevent_req_received(req);
5897         return NT_STATUS_OK;
5898 }
5899
5900 NTSTATUS dcerpc_spoolss_AddJob(struct dcerpc_binding_handle *h,
5901                                TALLOC_CTX *mem_ctx,
5902                                struct policy_handle *_handle /* [in] [ref] */,
5903                                uint32_t _level /* [in]  */,
5904                                uint8_t *_buffer /* [in,out] [unique,size_is(offered)] */,
5905                                uint32_t _offered /* [in]  */,
5906                                uint32_t *_needed /* [out] [ref] */,
5907                                WERROR *result)
5908 {
5909         struct spoolss_AddJob r;
5910         NTSTATUS status;
5911
5912         /* In parameters */
5913         r.in.handle = _handle;
5914         r.in.level = _level;
5915         r.in.buffer = _buffer;
5916         r.in.offered = _offered;
5917
5918         status = dcerpc_spoolss_AddJob_r(h, mem_ctx, &r);
5919         if (!NT_STATUS_IS_OK(status)) {
5920                 return status;
5921         }
5922
5923         /* Return variables */
5924         if (_buffer && r.out.buffer) {
5925                 memcpy(_buffer, r.out.buffer, (r.in.offered) * sizeof(*_buffer));
5926         }
5927         *_needed = *r.out.needed;
5928
5929         /* Return result */
5930         *result = r.out.result;
5931
5932         return NT_STATUS_OK;
5933 }
5934
5935 struct dcerpc_spoolss_ScheduleJob_r_state {
5936         TALLOC_CTX *out_mem_ctx;
5937 };
5938
5939 static void dcerpc_spoolss_ScheduleJob_r_done(struct tevent_req *subreq);
5940
5941 struct tevent_req *dcerpc_spoolss_ScheduleJob_r_send(TALLOC_CTX *mem_ctx,
5942         struct tevent_context *ev,
5943         struct dcerpc_binding_handle *h,
5944         struct spoolss_ScheduleJob *r)
5945 {
5946         struct tevent_req *req;
5947         struct dcerpc_spoolss_ScheduleJob_r_state *state;
5948         struct tevent_req *subreq;
5949
5950         req = tevent_req_create(mem_ctx, &state,
5951                                 struct dcerpc_spoolss_ScheduleJob_r_state);
5952         if (req == NULL) {
5953                 return NULL;
5954         }
5955
5956         state->out_mem_ctx = NULL;
5957         subreq = dcerpc_binding_handle_call_send(state, ev, h,
5958                         NULL, &ndr_table_spoolss,
5959                         NDR_SPOOLSS_SCHEDULEJOB, state, r);
5960         if (tevent_req_nomem(subreq, req)) {
5961                 return tevent_req_post(req, ev);
5962         }
5963         tevent_req_set_callback(subreq, dcerpc_spoolss_ScheduleJob_r_done, req);
5964
5965         return req;
5966 }
5967
5968 static void dcerpc_spoolss_ScheduleJob_r_done(struct tevent_req *subreq)
5969 {
5970         struct tevent_req *req =
5971                 tevent_req_callback_data(subreq,
5972                 struct tevent_req);
5973         NTSTATUS status;
5974
5975         status = dcerpc_binding_handle_call_recv(subreq);
5976         if (!NT_STATUS_IS_OK(status)) {
5977                 tevent_req_nterror(req, status);
5978                 return;
5979         }
5980
5981         tevent_req_done(req);
5982 }
5983
5984 NTSTATUS dcerpc_spoolss_ScheduleJob_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
5985 {
5986         struct dcerpc_spoolss_ScheduleJob_r_state *state =
5987                 tevent_req_data(req,
5988                 struct dcerpc_spoolss_ScheduleJob_r_state);
5989         NTSTATUS status;
5990
5991         if (tevent_req_is_nterror(req, &status)) {
5992                 tevent_req_received(req);
5993                 return status;
5994         }
5995
5996         talloc_steal(mem_ctx, state->out_mem_ctx);
5997
5998         tevent_req_received(req);
5999         return NT_STATUS_OK;
6000 }
6001
6002 NTSTATUS dcerpc_spoolss_ScheduleJob_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ScheduleJob *r)
6003 {
6004         NTSTATUS status;
6005
6006         status = dcerpc_binding_handle_call(h,
6007                         NULL, &ndr_table_spoolss,
6008                         NDR_SPOOLSS_SCHEDULEJOB, mem_ctx, r);
6009
6010         return status;
6011 }
6012
6013 NTSTATUS dcerpc_spoolss_ScheduleJob_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ScheduleJob *r)
6014 {
6015         NTSTATUS status;
6016
6017         status = dcerpc_spoolss_ScheduleJob_r(p->binding_handle, mem_ctx, r);
6018
6019         if (NT_STATUS_IS_RPC(status)) {
6020                 status = NT_STATUS_NET_WRITE_FAULT;
6021         }
6022
6023         return status;
6024 }
6025
6026 struct dcerpc_spoolss_ScheduleJob_state {
6027         struct spoolss_ScheduleJob orig;
6028         struct spoolss_ScheduleJob tmp;
6029         TALLOC_CTX *out_mem_ctx;
6030 };
6031
6032 static void dcerpc_spoolss_ScheduleJob_done(struct tevent_req *subreq);
6033
6034 struct tevent_req *dcerpc_spoolss_ScheduleJob_send(TALLOC_CTX *mem_ctx,
6035                                                    struct tevent_context *ev,
6036                                                    struct dcerpc_binding_handle *h,
6037                                                    struct policy_handle *_handle /* [in] [ref] */,
6038                                                    uint32_t _jobid /* [in]  */)
6039 {
6040         struct tevent_req *req;
6041         struct dcerpc_spoolss_ScheduleJob_state *state;
6042         struct tevent_req *subreq;
6043
6044         req = tevent_req_create(mem_ctx, &state,
6045                                 struct dcerpc_spoolss_ScheduleJob_state);
6046         if (req == NULL) {
6047                 return NULL;
6048         }
6049         state->out_mem_ctx = NULL;
6050
6051         /* In parameters */
6052         state->orig.in.handle = _handle;
6053         state->orig.in.jobid = _jobid;
6054
6055         /* Out parameters */
6056
6057         /* Result */
6058         ZERO_STRUCT(state->orig.out.result);
6059
6060         /* make a temporary copy, that we pass to the dispatch function */
6061         state->tmp = state->orig;
6062
6063         subreq = dcerpc_spoolss_ScheduleJob_r_send(state, ev, h, &state->tmp);
6064         if (tevent_req_nomem(subreq, req)) {
6065                 return tevent_req_post(req, ev);
6066         }
6067         tevent_req_set_callback(subreq, dcerpc_spoolss_ScheduleJob_done, req);
6068         return req;
6069 }
6070
6071 static void dcerpc_spoolss_ScheduleJob_done(struct tevent_req *subreq)
6072 {
6073         struct tevent_req *req = tevent_req_callback_data(
6074                 subreq, struct tevent_req);
6075         struct dcerpc_spoolss_ScheduleJob_state *state = tevent_req_data(
6076                 req, struct dcerpc_spoolss_ScheduleJob_state);
6077         NTSTATUS status;
6078         TALLOC_CTX *mem_ctx;
6079
6080         if (state->out_mem_ctx) {
6081                 mem_ctx = state->out_mem_ctx;
6082         } else {
6083                 mem_ctx = state;
6084         }
6085
6086         status = dcerpc_spoolss_ScheduleJob_r_recv(subreq, mem_ctx);
6087         TALLOC_FREE(subreq);
6088         if (!NT_STATUS_IS_OK(status)) {
6089                 tevent_req_nterror(req, status);
6090                 return;
6091         }
6092
6093         /* Copy out parameters */
6094
6095         /* Copy result */
6096         state->orig.out.result = state->tmp.out.result;
6097
6098         /* Reset temporary structure */
6099         ZERO_STRUCT(state->tmp);
6100
6101         tevent_req_done(req);
6102 }
6103
6104 NTSTATUS dcerpc_spoolss_ScheduleJob_recv(struct tevent_req *req,
6105                                          TALLOC_CTX *mem_ctx,
6106                                          WERROR *result)
6107 {
6108         struct dcerpc_spoolss_ScheduleJob_state *state = tevent_req_data(
6109                 req, struct dcerpc_spoolss_ScheduleJob_state);
6110         NTSTATUS status;
6111
6112         if (tevent_req_is_nterror(req, &status)) {
6113                 tevent_req_received(req);
6114                 return status;
6115         }
6116
6117         /* Steal possible out parameters to the callers context */
6118         talloc_steal(mem_ctx, state->out_mem_ctx);
6119
6120         /* Return result */
6121         *result = state->orig.out.result;
6122
6123         tevent_req_received(req);
6124         return NT_STATUS_OK;
6125 }
6126
6127 NTSTATUS dcerpc_spoolss_ScheduleJob(struct dcerpc_binding_handle *h,
6128                                     TALLOC_CTX *mem_ctx,
6129                                     struct policy_handle *_handle /* [in] [ref] */,
6130                                     uint32_t _jobid /* [in]  */,
6131                                     WERROR *result)
6132 {
6133         struct spoolss_ScheduleJob r;
6134         NTSTATUS status;
6135
6136         /* In parameters */
6137         r.in.handle = _handle;
6138         r.in.jobid = _jobid;
6139
6140         status = dcerpc_spoolss_ScheduleJob_r(h, mem_ctx, &r);
6141         if (!NT_STATUS_IS_OK(status)) {
6142                 return status;
6143         }
6144
6145         /* Return variables */
6146
6147         /* Return result */
6148         *result = r.out.result;
6149
6150         return NT_STATUS_OK;
6151 }
6152
6153 struct dcerpc_spoolss_GetPrinterData_r_state {
6154         TALLOC_CTX *out_mem_ctx;
6155 };
6156
6157 static void dcerpc_spoolss_GetPrinterData_r_done(struct tevent_req *subreq);
6158
6159 struct tevent_req *dcerpc_spoolss_GetPrinterData_r_send(TALLOC_CTX *mem_ctx,
6160         struct tevent_context *ev,
6161         struct dcerpc_binding_handle *h,
6162         struct spoolss_GetPrinterData *r)
6163 {
6164         struct tevent_req *req;
6165         struct dcerpc_spoolss_GetPrinterData_r_state *state;
6166         struct tevent_req *subreq;
6167
6168         req = tevent_req_create(mem_ctx, &state,
6169                                 struct dcerpc_spoolss_GetPrinterData_r_state);
6170         if (req == NULL) {
6171                 return NULL;
6172         }
6173
6174         state->out_mem_ctx = talloc_new(state);
6175         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6176                 return tevent_req_post(req, ev);
6177         }
6178
6179         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6180                         NULL, &ndr_table_spoolss,
6181                         NDR_SPOOLSS_GETPRINTERDATA, state->out_mem_ctx, r);
6182         if (tevent_req_nomem(subreq, req)) {
6183                 return tevent_req_post(req, ev);
6184         }
6185         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterData_r_done, req);
6186
6187         return req;
6188 }
6189
6190 static void dcerpc_spoolss_GetPrinterData_r_done(struct tevent_req *subreq)
6191 {
6192         struct tevent_req *req =
6193                 tevent_req_callback_data(subreq,
6194                 struct tevent_req);
6195         NTSTATUS status;
6196
6197         status = dcerpc_binding_handle_call_recv(subreq);
6198         if (!NT_STATUS_IS_OK(status)) {
6199                 tevent_req_nterror(req, status);
6200                 return;
6201         }
6202
6203         tevent_req_done(req);
6204 }
6205
6206 NTSTATUS dcerpc_spoolss_GetPrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6207 {
6208         struct dcerpc_spoolss_GetPrinterData_r_state *state =
6209                 tevent_req_data(req,
6210                 struct dcerpc_spoolss_GetPrinterData_r_state);
6211         NTSTATUS status;
6212
6213         if (tevent_req_is_nterror(req, &status)) {
6214                 tevent_req_received(req);
6215                 return status;
6216         }
6217
6218         talloc_steal(mem_ctx, state->out_mem_ctx);
6219
6220         tevent_req_received(req);
6221         return NT_STATUS_OK;
6222 }
6223
6224 NTSTATUS dcerpc_spoolss_GetPrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterData *r)
6225 {
6226         NTSTATUS status;
6227
6228         status = dcerpc_binding_handle_call(h,
6229                         NULL, &ndr_table_spoolss,
6230                         NDR_SPOOLSS_GETPRINTERDATA, mem_ctx, r);
6231
6232         return status;
6233 }
6234
6235 NTSTATUS dcerpc_spoolss_GetPrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterData *r)
6236 {
6237         NTSTATUS status;
6238
6239         status = dcerpc_spoolss_GetPrinterData_r(p->binding_handle, mem_ctx, r);
6240
6241         if (NT_STATUS_IS_RPC(status)) {
6242                 status = NT_STATUS_NET_WRITE_FAULT;
6243         }
6244
6245         return status;
6246 }
6247
6248 struct dcerpc_spoolss_GetPrinterData_state {
6249         struct spoolss_GetPrinterData orig;
6250         struct spoolss_GetPrinterData tmp;
6251         TALLOC_CTX *out_mem_ctx;
6252 };
6253
6254 static void dcerpc_spoolss_GetPrinterData_done(struct tevent_req *subreq);
6255
6256 struct tevent_req *dcerpc_spoolss_GetPrinterData_send(TALLOC_CTX *mem_ctx,
6257                                                       struct tevent_context *ev,
6258                                                       struct dcerpc_binding_handle *h,
6259                                                       struct policy_handle *_handle /* [in] [ref] */,
6260                                                       const char *_value_name /* [in] [charset(UTF16)] */,
6261                                                       enum winreg_Type *_type /* [out] [ref] */,
6262                                                       uint8_t *_data /* [out] [ref,size_is(offered)] */,
6263                                                       uint32_t _offered /* [in]  */,
6264                                                       uint32_t *_needed /* [out] [ref] */)
6265 {
6266         struct tevent_req *req;
6267         struct dcerpc_spoolss_GetPrinterData_state *state;
6268         struct tevent_req *subreq;
6269
6270         req = tevent_req_create(mem_ctx, &state,
6271                                 struct dcerpc_spoolss_GetPrinterData_state);
6272         if (req == NULL) {
6273                 return NULL;
6274         }
6275         state->out_mem_ctx = NULL;
6276
6277         /* In parameters */
6278         state->orig.in.handle = _handle;
6279         state->orig.in.value_name = _value_name;
6280         state->orig.in.offered = _offered;
6281
6282         /* Out parameters */
6283         state->orig.out.type = _type;
6284         state->orig.out.data = _data;
6285         state->orig.out.needed = _needed;
6286
6287         /* Result */
6288         ZERO_STRUCT(state->orig.out.result);
6289
6290         state->out_mem_ctx = talloc_named_const(state, 0,
6291                              "dcerpc_spoolss_GetPrinterData_out_memory");
6292         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6293                 return tevent_req_post(req, ev);
6294         }
6295
6296         /* make a temporary copy, that we pass to the dispatch function */
6297         state->tmp = state->orig;
6298
6299         subreq = dcerpc_spoolss_GetPrinterData_r_send(state, ev, h, &state->tmp);
6300         if (tevent_req_nomem(subreq, req)) {
6301                 return tevent_req_post(req, ev);
6302         }
6303         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterData_done, req);
6304         return req;
6305 }
6306
6307 static void dcerpc_spoolss_GetPrinterData_done(struct tevent_req *subreq)
6308 {
6309         struct tevent_req *req = tevent_req_callback_data(
6310                 subreq, struct tevent_req);
6311         struct dcerpc_spoolss_GetPrinterData_state *state = tevent_req_data(
6312                 req, struct dcerpc_spoolss_GetPrinterData_state);
6313         NTSTATUS status;
6314         TALLOC_CTX *mem_ctx;
6315
6316         if (state->out_mem_ctx) {
6317                 mem_ctx = state->out_mem_ctx;
6318         } else {
6319                 mem_ctx = state;
6320         }
6321
6322         status = dcerpc_spoolss_GetPrinterData_r_recv(subreq, mem_ctx);
6323         TALLOC_FREE(subreq);
6324         if (!NT_STATUS_IS_OK(status)) {
6325                 tevent_req_nterror(req, status);
6326                 return;
6327         }
6328
6329         /* Copy out parameters */
6330         *state->orig.out.type = *state->tmp.out.type;
6331         memcpy(state->orig.out.data, state->tmp.out.data, (state->tmp.in.offered) * sizeof(*state->orig.out.data));
6332         *state->orig.out.needed = *state->tmp.out.needed;
6333
6334         /* Copy result */
6335         state->orig.out.result = state->tmp.out.result;
6336
6337         /* Reset temporary structure */
6338         ZERO_STRUCT(state->tmp);
6339
6340         tevent_req_done(req);
6341 }
6342
6343 NTSTATUS dcerpc_spoolss_GetPrinterData_recv(struct tevent_req *req,
6344                                             TALLOC_CTX *mem_ctx,
6345                                             WERROR *result)
6346 {
6347         struct dcerpc_spoolss_GetPrinterData_state *state = tevent_req_data(
6348                 req, struct dcerpc_spoolss_GetPrinterData_state);
6349         NTSTATUS status;
6350
6351         if (tevent_req_is_nterror(req, &status)) {
6352                 tevent_req_received(req);
6353                 return status;
6354         }
6355
6356         /* Steal possible out parameters to the callers context */
6357         talloc_steal(mem_ctx, state->out_mem_ctx);
6358
6359         /* Return result */
6360         *result = state->orig.out.result;
6361
6362         tevent_req_received(req);
6363         return NT_STATUS_OK;
6364 }
6365
6366 NTSTATUS dcerpc_spoolss_GetPrinterData(struct dcerpc_binding_handle *h,
6367                                        TALLOC_CTX *mem_ctx,
6368                                        struct policy_handle *_handle /* [in] [ref] */,
6369                                        const char *_value_name /* [in] [charset(UTF16)] */,
6370                                        enum winreg_Type *_type /* [out] [ref] */,
6371                                        uint8_t *_data /* [out] [ref,size_is(offered)] */,
6372                                        uint32_t _offered /* [in]  */,
6373                                        uint32_t *_needed /* [out] [ref] */,
6374                                        WERROR *result)
6375 {
6376         struct spoolss_GetPrinterData r;
6377         NTSTATUS status;
6378
6379         /* In parameters */
6380         r.in.handle = _handle;
6381         r.in.value_name = _value_name;
6382         r.in.offered = _offered;
6383
6384         status = dcerpc_spoolss_GetPrinterData_r(h, mem_ctx, &r);
6385         if (!NT_STATUS_IS_OK(status)) {
6386                 return status;
6387         }
6388
6389         /* Return variables */
6390         *_type = *r.out.type;
6391         memcpy(_data, r.out.data, (r.in.offered) * sizeof(*_data));
6392         *_needed = *r.out.needed;
6393
6394         /* Return result */
6395         *result = r.out.result;
6396
6397         return NT_STATUS_OK;
6398 }
6399
6400 struct dcerpc_spoolss_SetPrinterData_r_state {
6401         TALLOC_CTX *out_mem_ctx;
6402 };
6403
6404 static void dcerpc_spoolss_SetPrinterData_r_done(struct tevent_req *subreq);
6405
6406 struct tevent_req *dcerpc_spoolss_SetPrinterData_r_send(TALLOC_CTX *mem_ctx,
6407         struct tevent_context *ev,
6408         struct dcerpc_binding_handle *h,
6409         struct spoolss_SetPrinterData *r)
6410 {
6411         struct tevent_req *req;
6412         struct dcerpc_spoolss_SetPrinterData_r_state *state;
6413         struct tevent_req *subreq;
6414
6415         req = tevent_req_create(mem_ctx, &state,
6416                                 struct dcerpc_spoolss_SetPrinterData_r_state);
6417         if (req == NULL) {
6418                 return NULL;
6419         }
6420
6421         state->out_mem_ctx = NULL;
6422         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6423                         NULL, &ndr_table_spoolss,
6424                         NDR_SPOOLSS_SETPRINTERDATA, state, r);
6425         if (tevent_req_nomem(subreq, req)) {
6426                 return tevent_req_post(req, ev);
6427         }
6428         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterData_r_done, req);
6429
6430         return req;
6431 }
6432
6433 static void dcerpc_spoolss_SetPrinterData_r_done(struct tevent_req *subreq)
6434 {
6435         struct tevent_req *req =
6436                 tevent_req_callback_data(subreq,
6437                 struct tevent_req);
6438         NTSTATUS status;
6439
6440         status = dcerpc_binding_handle_call_recv(subreq);
6441         if (!NT_STATUS_IS_OK(status)) {
6442                 tevent_req_nterror(req, status);
6443                 return;
6444         }
6445
6446         tevent_req_done(req);
6447 }
6448
6449 NTSTATUS dcerpc_spoolss_SetPrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6450 {
6451         struct dcerpc_spoolss_SetPrinterData_r_state *state =
6452                 tevent_req_data(req,
6453                 struct dcerpc_spoolss_SetPrinterData_r_state);
6454         NTSTATUS status;
6455
6456         if (tevent_req_is_nterror(req, &status)) {
6457                 tevent_req_received(req);
6458                 return status;
6459         }
6460
6461         talloc_steal(mem_ctx, state->out_mem_ctx);
6462
6463         tevent_req_received(req);
6464         return NT_STATUS_OK;
6465 }
6466
6467 NTSTATUS dcerpc_spoolss_SetPrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterData *r)
6468 {
6469         NTSTATUS status;
6470
6471         status = dcerpc_binding_handle_call(h,
6472                         NULL, &ndr_table_spoolss,
6473                         NDR_SPOOLSS_SETPRINTERDATA, mem_ctx, r);
6474
6475         return status;
6476 }
6477
6478 NTSTATUS dcerpc_spoolss_SetPrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterData *r)
6479 {
6480         NTSTATUS status;
6481
6482         status = dcerpc_spoolss_SetPrinterData_r(p->binding_handle, mem_ctx, r);
6483
6484         if (NT_STATUS_IS_RPC(status)) {
6485                 status = NT_STATUS_NET_WRITE_FAULT;
6486         }
6487
6488         return status;
6489 }
6490
6491 struct dcerpc_spoolss_SetPrinterData_state {
6492         struct spoolss_SetPrinterData orig;
6493         struct spoolss_SetPrinterData tmp;
6494         TALLOC_CTX *out_mem_ctx;
6495 };
6496
6497 static void dcerpc_spoolss_SetPrinterData_done(struct tevent_req *subreq);
6498
6499 struct tevent_req *dcerpc_spoolss_SetPrinterData_send(TALLOC_CTX *mem_ctx,
6500                                                       struct tevent_context *ev,
6501                                                       struct dcerpc_binding_handle *h,
6502                                                       struct policy_handle *_handle /* [in] [ref] */,
6503                                                       const char *_value_name /* [in] [charset(UTF16)] */,
6504                                                       enum winreg_Type _type /* [in]  */,
6505                                                       uint8_t *_data /* [in] [ref,size_is(offered)] */,
6506                                                       uint32_t _offered /* [in]  */)
6507 {
6508         struct tevent_req *req;
6509         struct dcerpc_spoolss_SetPrinterData_state *state;
6510         struct tevent_req *subreq;
6511
6512         req = tevent_req_create(mem_ctx, &state,
6513                                 struct dcerpc_spoolss_SetPrinterData_state);
6514         if (req == NULL) {
6515                 return NULL;
6516         }
6517         state->out_mem_ctx = NULL;
6518
6519         /* In parameters */
6520         state->orig.in.handle = _handle;
6521         state->orig.in.value_name = _value_name;
6522         state->orig.in.type = _type;
6523         state->orig.in.data = _data;
6524         state->orig.in.offered = _offered;
6525
6526         /* Out parameters */
6527
6528         /* Result */
6529         ZERO_STRUCT(state->orig.out.result);
6530
6531         /* make a temporary copy, that we pass to the dispatch function */
6532         state->tmp = state->orig;
6533
6534         subreq = dcerpc_spoolss_SetPrinterData_r_send(state, ev, h, &state->tmp);
6535         if (tevent_req_nomem(subreq, req)) {
6536                 return tevent_req_post(req, ev);
6537         }
6538         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterData_done, req);
6539         return req;
6540 }
6541
6542 static void dcerpc_spoolss_SetPrinterData_done(struct tevent_req *subreq)
6543 {
6544         struct tevent_req *req = tevent_req_callback_data(
6545                 subreq, struct tevent_req);
6546         struct dcerpc_spoolss_SetPrinterData_state *state = tevent_req_data(
6547                 req, struct dcerpc_spoolss_SetPrinterData_state);
6548         NTSTATUS status;
6549         TALLOC_CTX *mem_ctx;
6550
6551         if (state->out_mem_ctx) {
6552                 mem_ctx = state->out_mem_ctx;
6553         } else {
6554                 mem_ctx = state;
6555         }
6556
6557         status = dcerpc_spoolss_SetPrinterData_r_recv(subreq, mem_ctx);
6558         TALLOC_FREE(subreq);
6559         if (!NT_STATUS_IS_OK(status)) {
6560                 tevent_req_nterror(req, status);
6561                 return;
6562         }
6563
6564         /* Copy out parameters */
6565
6566         /* Copy result */
6567         state->orig.out.result = state->tmp.out.result;
6568
6569         /* Reset temporary structure */
6570         ZERO_STRUCT(state->tmp);
6571
6572         tevent_req_done(req);
6573 }
6574
6575 NTSTATUS dcerpc_spoolss_SetPrinterData_recv(struct tevent_req *req,
6576                                             TALLOC_CTX *mem_ctx,
6577                                             WERROR *result)
6578 {
6579         struct dcerpc_spoolss_SetPrinterData_state *state = tevent_req_data(
6580                 req, struct dcerpc_spoolss_SetPrinterData_state);
6581         NTSTATUS status;
6582
6583         if (tevent_req_is_nterror(req, &status)) {
6584                 tevent_req_received(req);
6585                 return status;
6586         }
6587
6588         /* Steal possible out parameters to the callers context */
6589         talloc_steal(mem_ctx, state->out_mem_ctx);
6590
6591         /* Return result */
6592         *result = state->orig.out.result;
6593
6594         tevent_req_received(req);
6595         return NT_STATUS_OK;
6596 }
6597
6598 NTSTATUS dcerpc_spoolss_SetPrinterData(struct dcerpc_binding_handle *h,
6599                                        TALLOC_CTX *mem_ctx,
6600                                        struct policy_handle *_handle /* [in] [ref] */,
6601                                        const char *_value_name /* [in] [charset(UTF16)] */,
6602                                        enum winreg_Type _type /* [in]  */,
6603                                        uint8_t *_data /* [in] [ref,size_is(offered)] */,
6604                                        uint32_t _offered /* [in]  */,
6605                                        WERROR *result)
6606 {
6607         struct spoolss_SetPrinterData r;
6608         NTSTATUS status;
6609
6610         /* In parameters */
6611         r.in.handle = _handle;
6612         r.in.value_name = _value_name;
6613         r.in.type = _type;
6614         r.in.data = _data;
6615         r.in.offered = _offered;
6616
6617         status = dcerpc_spoolss_SetPrinterData_r(h, mem_ctx, &r);
6618         if (!NT_STATUS_IS_OK(status)) {
6619                 return status;
6620         }
6621
6622         /* Return variables */
6623
6624         /* Return result */
6625         *result = r.out.result;
6626
6627         return NT_STATUS_OK;
6628 }
6629
6630 struct dcerpc_spoolss_ClosePrinter_r_state {
6631         TALLOC_CTX *out_mem_ctx;
6632 };
6633
6634 static void dcerpc_spoolss_ClosePrinter_r_done(struct tevent_req *subreq);
6635
6636 struct tevent_req *dcerpc_spoolss_ClosePrinter_r_send(TALLOC_CTX *mem_ctx,
6637         struct tevent_context *ev,
6638         struct dcerpc_binding_handle *h,
6639         struct spoolss_ClosePrinter *r)
6640 {
6641         struct tevent_req *req;
6642         struct dcerpc_spoolss_ClosePrinter_r_state *state;
6643         struct tevent_req *subreq;
6644
6645         req = tevent_req_create(mem_ctx, &state,
6646                                 struct dcerpc_spoolss_ClosePrinter_r_state);
6647         if (req == NULL) {
6648                 return NULL;
6649         }
6650
6651         state->out_mem_ctx = talloc_new(state);
6652         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6653                 return tevent_req_post(req, ev);
6654         }
6655
6656         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6657                         NULL, &ndr_table_spoolss,
6658                         NDR_SPOOLSS_CLOSEPRINTER, state->out_mem_ctx, r);
6659         if (tevent_req_nomem(subreq, req)) {
6660                 return tevent_req_post(req, ev);
6661         }
6662         tevent_req_set_callback(subreq, dcerpc_spoolss_ClosePrinter_r_done, req);
6663
6664         return req;
6665 }
6666
6667 static void dcerpc_spoolss_ClosePrinter_r_done(struct tevent_req *subreq)
6668 {
6669         struct tevent_req *req =
6670                 tevent_req_callback_data(subreq,
6671                 struct tevent_req);
6672         NTSTATUS status;
6673
6674         status = dcerpc_binding_handle_call_recv(subreq);
6675         if (!NT_STATUS_IS_OK(status)) {
6676                 tevent_req_nterror(req, status);
6677                 return;
6678         }
6679
6680         tevent_req_done(req);
6681 }
6682
6683 NTSTATUS dcerpc_spoolss_ClosePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6684 {
6685         struct dcerpc_spoolss_ClosePrinter_r_state *state =
6686                 tevent_req_data(req,
6687                 struct dcerpc_spoolss_ClosePrinter_r_state);
6688         NTSTATUS status;
6689
6690         if (tevent_req_is_nterror(req, &status)) {
6691                 tevent_req_received(req);
6692                 return status;
6693         }
6694
6695         talloc_steal(mem_ctx, state->out_mem_ctx);
6696
6697         tevent_req_received(req);
6698         return NT_STATUS_OK;
6699 }
6700
6701 NTSTATUS dcerpc_spoolss_ClosePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ClosePrinter *r)
6702 {
6703         NTSTATUS status;
6704
6705         status = dcerpc_binding_handle_call(h,
6706                         NULL, &ndr_table_spoolss,
6707                         NDR_SPOOLSS_CLOSEPRINTER, mem_ctx, r);
6708
6709         return status;
6710 }
6711
6712 NTSTATUS dcerpc_spoolss_ClosePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ClosePrinter *r)
6713 {
6714         NTSTATUS status;
6715
6716         status = dcerpc_spoolss_ClosePrinter_r(p->binding_handle, mem_ctx, r);
6717
6718         if (NT_STATUS_IS_RPC(status)) {
6719                 status = NT_STATUS_NET_WRITE_FAULT;
6720         }
6721
6722         return status;
6723 }
6724
6725 struct dcerpc_spoolss_ClosePrinter_state {
6726         struct spoolss_ClosePrinter orig;
6727         struct spoolss_ClosePrinter tmp;
6728         TALLOC_CTX *out_mem_ctx;
6729 };
6730
6731 static void dcerpc_spoolss_ClosePrinter_done(struct tevent_req *subreq);
6732
6733 struct tevent_req *dcerpc_spoolss_ClosePrinter_send(TALLOC_CTX *mem_ctx,
6734                                                     struct tevent_context *ev,
6735                                                     struct dcerpc_binding_handle *h,
6736                                                     struct policy_handle *_handle /* [in,out] [ref] */)
6737 {
6738         struct tevent_req *req;
6739         struct dcerpc_spoolss_ClosePrinter_state *state;
6740         struct tevent_req *subreq;
6741
6742         req = tevent_req_create(mem_ctx, &state,
6743                                 struct dcerpc_spoolss_ClosePrinter_state);
6744         if (req == NULL) {
6745                 return NULL;
6746         }
6747         state->out_mem_ctx = NULL;
6748
6749         /* In parameters */
6750         state->orig.in.handle = _handle;
6751
6752         /* Out parameters */
6753         state->orig.out.handle = _handle;
6754
6755         /* Result */
6756         ZERO_STRUCT(state->orig.out.result);
6757
6758         state->out_mem_ctx = talloc_named_const(state, 0,
6759                              "dcerpc_spoolss_ClosePrinter_out_memory");
6760         if (tevent_req_nomem(state->out_mem_ctx, req)) {
6761                 return tevent_req_post(req, ev);
6762         }
6763
6764         /* make a temporary copy, that we pass to the dispatch function */
6765         state->tmp = state->orig;
6766
6767         subreq = dcerpc_spoolss_ClosePrinter_r_send(state, ev, h, &state->tmp);
6768         if (tevent_req_nomem(subreq, req)) {
6769                 return tevent_req_post(req, ev);
6770         }
6771         tevent_req_set_callback(subreq, dcerpc_spoolss_ClosePrinter_done, req);
6772         return req;
6773 }
6774
6775 static void dcerpc_spoolss_ClosePrinter_done(struct tevent_req *subreq)
6776 {
6777         struct tevent_req *req = tevent_req_callback_data(
6778                 subreq, struct tevent_req);
6779         struct dcerpc_spoolss_ClosePrinter_state *state = tevent_req_data(
6780                 req, struct dcerpc_spoolss_ClosePrinter_state);
6781         NTSTATUS status;
6782         TALLOC_CTX *mem_ctx;
6783
6784         if (state->out_mem_ctx) {
6785                 mem_ctx = state->out_mem_ctx;
6786         } else {
6787                 mem_ctx = state;
6788         }
6789
6790         status = dcerpc_spoolss_ClosePrinter_r_recv(subreq, mem_ctx);
6791         TALLOC_FREE(subreq);
6792         if (!NT_STATUS_IS_OK(status)) {
6793                 tevent_req_nterror(req, status);
6794                 return;
6795         }
6796
6797         /* Copy out parameters */
6798         *state->orig.out.handle = *state->tmp.out.handle;
6799
6800         /* Copy result */
6801         state->orig.out.result = state->tmp.out.result;
6802
6803         /* Reset temporary structure */
6804         ZERO_STRUCT(state->tmp);
6805
6806         tevent_req_done(req);
6807 }
6808
6809 NTSTATUS dcerpc_spoolss_ClosePrinter_recv(struct tevent_req *req,
6810                                           TALLOC_CTX *mem_ctx,
6811                                           WERROR *result)
6812 {
6813         struct dcerpc_spoolss_ClosePrinter_state *state = tevent_req_data(
6814                 req, struct dcerpc_spoolss_ClosePrinter_state);
6815         NTSTATUS status;
6816
6817         if (tevent_req_is_nterror(req, &status)) {
6818                 tevent_req_received(req);
6819                 return status;
6820         }
6821
6822         /* Steal possible out parameters to the callers context */
6823         talloc_steal(mem_ctx, state->out_mem_ctx);
6824
6825         /* Return result */
6826         *result = state->orig.out.result;
6827
6828         tevent_req_received(req);
6829         return NT_STATUS_OK;
6830 }
6831
6832 NTSTATUS dcerpc_spoolss_ClosePrinter(struct dcerpc_binding_handle *h,
6833                                      TALLOC_CTX *mem_ctx,
6834                                      struct policy_handle *_handle /* [in,out] [ref] */,
6835                                      WERROR *result)
6836 {
6837         struct spoolss_ClosePrinter r;
6838         NTSTATUS status;
6839
6840         /* In parameters */
6841         r.in.handle = _handle;
6842
6843         status = dcerpc_spoolss_ClosePrinter_r(h, mem_ctx, &r);
6844         if (!NT_STATUS_IS_OK(status)) {
6845                 return status;
6846         }
6847
6848         /* Return variables */
6849         *_handle = *r.out.handle;
6850
6851         /* Return result */
6852         *result = r.out.result;
6853
6854         return NT_STATUS_OK;
6855 }
6856
6857 struct dcerpc_spoolss_AddForm_r_state {
6858         TALLOC_CTX *out_mem_ctx;
6859 };
6860
6861 static void dcerpc_spoolss_AddForm_r_done(struct tevent_req *subreq);
6862
6863 struct tevent_req *dcerpc_spoolss_AddForm_r_send(TALLOC_CTX *mem_ctx,
6864         struct tevent_context *ev,
6865         struct dcerpc_binding_handle *h,
6866         struct spoolss_AddForm *r)
6867 {
6868         struct tevent_req *req;
6869         struct dcerpc_spoolss_AddForm_r_state *state;
6870         struct tevent_req *subreq;
6871
6872         req = tevent_req_create(mem_ctx, &state,
6873                                 struct dcerpc_spoolss_AddForm_r_state);
6874         if (req == NULL) {
6875                 return NULL;
6876         }
6877
6878         state->out_mem_ctx = NULL;
6879         subreq = dcerpc_binding_handle_call_send(state, ev, h,
6880                         NULL, &ndr_table_spoolss,
6881                         NDR_SPOOLSS_ADDFORM, state, r);
6882         if (tevent_req_nomem(subreq, req)) {
6883                 return tevent_req_post(req, ev);
6884         }
6885         tevent_req_set_callback(subreq, dcerpc_spoolss_AddForm_r_done, req);
6886
6887         return req;
6888 }
6889
6890 static void dcerpc_spoolss_AddForm_r_done(struct tevent_req *subreq)
6891 {
6892         struct tevent_req *req =
6893                 tevent_req_callback_data(subreq,
6894                 struct tevent_req);
6895         NTSTATUS status;
6896
6897         status = dcerpc_binding_handle_call_recv(subreq);
6898         if (!NT_STATUS_IS_OK(status)) {
6899                 tevent_req_nterror(req, status);
6900                 return;
6901         }
6902
6903         tevent_req_done(req);
6904 }
6905
6906 NTSTATUS dcerpc_spoolss_AddForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
6907 {
6908         struct dcerpc_spoolss_AddForm_r_state *state =
6909                 tevent_req_data(req,
6910                 struct dcerpc_spoolss_AddForm_r_state);
6911         NTSTATUS status;
6912
6913         if (tevent_req_is_nterror(req, &status)) {
6914                 tevent_req_received(req);
6915                 return status;
6916         }
6917
6918         talloc_steal(mem_ctx, state->out_mem_ctx);
6919
6920         tevent_req_received(req);
6921         return NT_STATUS_OK;
6922 }
6923
6924 NTSTATUS dcerpc_spoolss_AddForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddForm *r)
6925 {
6926         NTSTATUS status;
6927
6928         status = dcerpc_binding_handle_call(h,
6929                         NULL, &ndr_table_spoolss,
6930                         NDR_SPOOLSS_ADDFORM, mem_ctx, r);
6931
6932         return status;
6933 }
6934
6935 NTSTATUS dcerpc_spoolss_AddForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddForm *r)
6936 {
6937         NTSTATUS status;
6938
6939         status = dcerpc_spoolss_AddForm_r(p->binding_handle, mem_ctx, r);
6940
6941         if (NT_STATUS_IS_RPC(status)) {
6942                 status = NT_STATUS_NET_WRITE_FAULT;
6943         }
6944
6945         return status;
6946 }
6947
6948 struct dcerpc_spoolss_AddForm_state {
6949         struct spoolss_AddForm orig;
6950         struct spoolss_AddForm tmp;
6951         TALLOC_CTX *out_mem_ctx;
6952 };
6953
6954 static void dcerpc_spoolss_AddForm_done(struct tevent_req *subreq);
6955
6956 struct tevent_req *dcerpc_spoolss_AddForm_send(TALLOC_CTX *mem_ctx,
6957                                                struct tevent_context *ev,
6958                                                struct dcerpc_binding_handle *h,
6959                                                struct policy_handle *_handle /* [in] [ref] */,
6960                                                uint32_t _level /* [in]  */,
6961                                                union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */)
6962 {
6963         struct tevent_req *req;
6964         struct dcerpc_spoolss_AddForm_state *state;
6965         struct tevent_req *subreq;
6966
6967         req = tevent_req_create(mem_ctx, &state,
6968                                 struct dcerpc_spoolss_AddForm_state);
6969         if (req == NULL) {
6970                 return NULL;
6971         }
6972         state->out_mem_ctx = NULL;
6973
6974         /* In parameters */
6975         state->orig.in.handle = _handle;
6976         state->orig.in.level = _level;
6977         state->orig.in.info = _info;
6978
6979         /* Out parameters */
6980
6981         /* Result */
6982         ZERO_STRUCT(state->orig.out.result);
6983
6984         /* make a temporary copy, that we pass to the dispatch function */
6985         state->tmp = state->orig;
6986
6987         subreq = dcerpc_spoolss_AddForm_r_send(state, ev, h, &state->tmp);
6988         if (tevent_req_nomem(subreq, req)) {
6989                 return tevent_req_post(req, ev);
6990         }
6991         tevent_req_set_callback(subreq, dcerpc_spoolss_AddForm_done, req);
6992         return req;
6993 }
6994
6995 static void dcerpc_spoolss_AddForm_done(struct tevent_req *subreq)
6996 {
6997         struct tevent_req *req = tevent_req_callback_data(
6998                 subreq, struct tevent_req);
6999         struct dcerpc_spoolss_AddForm_state *state = tevent_req_data(
7000                 req, struct dcerpc_spoolss_AddForm_state);
7001         NTSTATUS status;
7002         TALLOC_CTX *mem_ctx;
7003
7004         if (state->out_mem_ctx) {
7005                 mem_ctx = state->out_mem_ctx;
7006         } else {
7007                 mem_ctx = state;
7008         }
7009
7010         status = dcerpc_spoolss_AddForm_r_recv(subreq, mem_ctx);
7011         TALLOC_FREE(subreq);
7012         if (!NT_STATUS_IS_OK(status)) {
7013                 tevent_req_nterror(req, status);
7014                 return;
7015         }
7016
7017         /* Copy out parameters */
7018
7019         /* Copy result */
7020         state->orig.out.result = state->tmp.out.result;
7021
7022         /* Reset temporary structure */
7023         ZERO_STRUCT(state->tmp);
7024
7025         tevent_req_done(req);
7026 }
7027
7028 NTSTATUS dcerpc_spoolss_AddForm_recv(struct tevent_req *req,
7029                                      TALLOC_CTX *mem_ctx,
7030                                      WERROR *result)
7031 {
7032         struct dcerpc_spoolss_AddForm_state *state = tevent_req_data(
7033                 req, struct dcerpc_spoolss_AddForm_state);
7034         NTSTATUS status;
7035
7036         if (tevent_req_is_nterror(req, &status)) {
7037                 tevent_req_received(req);
7038                 return status;
7039         }
7040
7041         /* Steal possible out parameters to the callers context */
7042         talloc_steal(mem_ctx, state->out_mem_ctx);
7043
7044         /* Return result */
7045         *result = state->orig.out.result;
7046
7047         tevent_req_received(req);
7048         return NT_STATUS_OK;
7049 }
7050
7051 NTSTATUS dcerpc_spoolss_AddForm(struct dcerpc_binding_handle *h,
7052                                 TALLOC_CTX *mem_ctx,
7053                                 struct policy_handle *_handle /* [in] [ref] */,
7054                                 uint32_t _level /* [in]  */,
7055                                 union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */,
7056                                 WERROR *result)
7057 {
7058         struct spoolss_AddForm r;
7059         NTSTATUS status;
7060
7061         /* In parameters */
7062         r.in.handle = _handle;
7063         r.in.level = _level;
7064         r.in.info = _info;
7065
7066         status = dcerpc_spoolss_AddForm_r(h, mem_ctx, &r);
7067         if (!NT_STATUS_IS_OK(status)) {
7068                 return status;
7069         }
7070
7071         /* Return variables */
7072
7073         /* Return result */
7074         *result = r.out.result;
7075
7076         return NT_STATUS_OK;
7077 }
7078
7079 struct dcerpc_spoolss_DeleteForm_r_state {
7080         TALLOC_CTX *out_mem_ctx;
7081 };
7082
7083 static void dcerpc_spoolss_DeleteForm_r_done(struct tevent_req *subreq);
7084
7085 struct tevent_req *dcerpc_spoolss_DeleteForm_r_send(TALLOC_CTX *mem_ctx,
7086         struct tevent_context *ev,
7087         struct dcerpc_binding_handle *h,
7088         struct spoolss_DeleteForm *r)
7089 {
7090         struct tevent_req *req;
7091         struct dcerpc_spoolss_DeleteForm_r_state *state;
7092         struct tevent_req *subreq;
7093
7094         req = tevent_req_create(mem_ctx, &state,
7095                                 struct dcerpc_spoolss_DeleteForm_r_state);
7096         if (req == NULL) {
7097                 return NULL;
7098         }
7099
7100         state->out_mem_ctx = NULL;
7101         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7102                         NULL, &ndr_table_spoolss,
7103                         NDR_SPOOLSS_DELETEFORM, state, r);
7104         if (tevent_req_nomem(subreq, req)) {
7105                 return tevent_req_post(req, ev);
7106         }
7107         tevent_req_set_callback(subreq, dcerpc_spoolss_DeleteForm_r_done, req);
7108
7109         return req;
7110 }
7111
7112 static void dcerpc_spoolss_DeleteForm_r_done(struct tevent_req *subreq)
7113 {
7114         struct tevent_req *req =
7115                 tevent_req_callback_data(subreq,
7116                 struct tevent_req);
7117         NTSTATUS status;
7118
7119         status = dcerpc_binding_handle_call_recv(subreq);
7120         if (!NT_STATUS_IS_OK(status)) {
7121                 tevent_req_nterror(req, status);
7122                 return;
7123         }
7124
7125         tevent_req_done(req);
7126 }
7127
7128 NTSTATUS dcerpc_spoolss_DeleteForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7129 {
7130         struct dcerpc_spoolss_DeleteForm_r_state *state =
7131                 tevent_req_data(req,
7132                 struct dcerpc_spoolss_DeleteForm_r_state);
7133         NTSTATUS status;
7134
7135         if (tevent_req_is_nterror(req, &status)) {
7136                 tevent_req_received(req);
7137                 return status;
7138         }
7139
7140         talloc_steal(mem_ctx, state->out_mem_ctx);
7141
7142         tevent_req_received(req);
7143         return NT_STATUS_OK;
7144 }
7145
7146 NTSTATUS dcerpc_spoolss_DeleteForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeleteForm *r)
7147 {
7148         NTSTATUS status;
7149
7150         status = dcerpc_binding_handle_call(h,
7151                         NULL, &ndr_table_spoolss,
7152                         NDR_SPOOLSS_DELETEFORM, mem_ctx, r);
7153
7154         return status;
7155 }
7156
7157 NTSTATUS dcerpc_spoolss_DeleteForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeleteForm *r)
7158 {
7159         NTSTATUS status;
7160
7161         status = dcerpc_spoolss_DeleteForm_r(p->binding_handle, mem_ctx, r);
7162
7163         if (NT_STATUS_IS_RPC(status)) {
7164                 status = NT_STATUS_NET_WRITE_FAULT;
7165         }
7166
7167         return status;
7168 }
7169
7170 struct dcerpc_spoolss_DeleteForm_state {
7171         struct spoolss_DeleteForm orig;
7172         struct spoolss_DeleteForm tmp;
7173         TALLOC_CTX *out_mem_ctx;
7174 };
7175
7176 static void dcerpc_spoolss_DeleteForm_done(struct tevent_req *subreq);
7177
7178 struct tevent_req *dcerpc_spoolss_DeleteForm_send(TALLOC_CTX *mem_ctx,
7179                                                   struct tevent_context *ev,
7180                                                   struct dcerpc_binding_handle *h,
7181                                                   struct policy_handle *_handle /* [in] [ref] */,
7182                                                   const char *_form_name /* [in] [charset(UTF16)] */)
7183 {
7184         struct tevent_req *req;
7185         struct dcerpc_spoolss_DeleteForm_state *state;
7186         struct tevent_req *subreq;
7187
7188         req = tevent_req_create(mem_ctx, &state,
7189                                 struct dcerpc_spoolss_DeleteForm_state);
7190         if (req == NULL) {
7191                 return NULL;
7192         }
7193         state->out_mem_ctx = NULL;
7194
7195         /* In parameters */
7196         state->orig.in.handle = _handle;
7197         state->orig.in.form_name = _form_name;
7198
7199         /* Out parameters */
7200
7201         /* Result */
7202         ZERO_STRUCT(state->orig.out.result);
7203
7204         /* make a temporary copy, that we pass to the dispatch function */
7205         state->tmp = state->orig;
7206
7207         subreq = dcerpc_spoolss_DeleteForm_r_send(state, ev, h, &state->tmp);
7208         if (tevent_req_nomem(subreq, req)) {
7209                 return tevent_req_post(req, ev);
7210         }
7211         tevent_req_set_callback(subreq, dcerpc_spoolss_DeleteForm_done, req);
7212         return req;
7213 }
7214
7215 static void dcerpc_spoolss_DeleteForm_done(struct tevent_req *subreq)
7216 {
7217         struct tevent_req *req = tevent_req_callback_data(
7218                 subreq, struct tevent_req);
7219         struct dcerpc_spoolss_DeleteForm_state *state = tevent_req_data(
7220                 req, struct dcerpc_spoolss_DeleteForm_state);
7221         NTSTATUS status;
7222         TALLOC_CTX *mem_ctx;
7223
7224         if (state->out_mem_ctx) {
7225                 mem_ctx = state->out_mem_ctx;
7226         } else {
7227                 mem_ctx = state;
7228         }
7229
7230         status = dcerpc_spoolss_DeleteForm_r_recv(subreq, mem_ctx);
7231         TALLOC_FREE(subreq);
7232         if (!NT_STATUS_IS_OK(status)) {
7233                 tevent_req_nterror(req, status);
7234                 return;
7235         }
7236
7237         /* Copy out parameters */
7238
7239         /* Copy result */
7240         state->orig.out.result = state->tmp.out.result;
7241
7242         /* Reset temporary structure */
7243         ZERO_STRUCT(state->tmp);
7244
7245         tevent_req_done(req);
7246 }
7247
7248 NTSTATUS dcerpc_spoolss_DeleteForm_recv(struct tevent_req *req,
7249                                         TALLOC_CTX *mem_ctx,
7250                                         WERROR *result)
7251 {
7252         struct dcerpc_spoolss_DeleteForm_state *state = tevent_req_data(
7253                 req, struct dcerpc_spoolss_DeleteForm_state);
7254         NTSTATUS status;
7255
7256         if (tevent_req_is_nterror(req, &status)) {
7257                 tevent_req_received(req);
7258                 return status;
7259         }
7260
7261         /* Steal possible out parameters to the callers context */
7262         talloc_steal(mem_ctx, state->out_mem_ctx);
7263
7264         /* Return result */
7265         *result = state->orig.out.result;
7266
7267         tevent_req_received(req);
7268         return NT_STATUS_OK;
7269 }
7270
7271 NTSTATUS dcerpc_spoolss_DeleteForm(struct dcerpc_binding_handle *h,
7272                                    TALLOC_CTX *mem_ctx,
7273                                    struct policy_handle *_handle /* [in] [ref] */,
7274                                    const char *_form_name /* [in] [charset(UTF16)] */,
7275                                    WERROR *result)
7276 {
7277         struct spoolss_DeleteForm r;
7278         NTSTATUS status;
7279
7280         /* In parameters */
7281         r.in.handle = _handle;
7282         r.in.form_name = _form_name;
7283
7284         status = dcerpc_spoolss_DeleteForm_r(h, mem_ctx, &r);
7285         if (!NT_STATUS_IS_OK(status)) {
7286                 return status;
7287         }
7288
7289         /* Return variables */
7290
7291         /* Return result */
7292         *result = r.out.result;
7293
7294         return NT_STATUS_OK;
7295 }
7296
7297 struct dcerpc_spoolss_GetForm_r_state {
7298         TALLOC_CTX *out_mem_ctx;
7299 };
7300
7301 static void dcerpc_spoolss_GetForm_r_done(struct tevent_req *subreq);
7302
7303 struct tevent_req *dcerpc_spoolss_GetForm_r_send(TALLOC_CTX *mem_ctx,
7304         struct tevent_context *ev,
7305         struct dcerpc_binding_handle *h,
7306         struct spoolss_GetForm *r)
7307 {
7308         struct tevent_req *req;
7309         struct dcerpc_spoolss_GetForm_r_state *state;
7310         struct tevent_req *subreq;
7311
7312         req = tevent_req_create(mem_ctx, &state,
7313                                 struct dcerpc_spoolss_GetForm_r_state);
7314         if (req == NULL) {
7315                 return NULL;
7316         }
7317
7318         state->out_mem_ctx = talloc_new(state);
7319         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7320                 return tevent_req_post(req, ev);
7321         }
7322
7323         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7324                         NULL, &ndr_table_spoolss,
7325                         NDR_SPOOLSS_GETFORM, state->out_mem_ctx, r);
7326         if (tevent_req_nomem(subreq, req)) {
7327                 return tevent_req_post(req, ev);
7328         }
7329         tevent_req_set_callback(subreq, dcerpc_spoolss_GetForm_r_done, req);
7330
7331         return req;
7332 }
7333
7334 static void dcerpc_spoolss_GetForm_r_done(struct tevent_req *subreq)
7335 {
7336         struct tevent_req *req =
7337                 tevent_req_callback_data(subreq,
7338                 struct tevent_req);
7339         NTSTATUS status;
7340
7341         status = dcerpc_binding_handle_call_recv(subreq);
7342         if (!NT_STATUS_IS_OK(status)) {
7343                 tevent_req_nterror(req, status);
7344                 return;
7345         }
7346
7347         tevent_req_done(req);
7348 }
7349
7350 NTSTATUS dcerpc_spoolss_GetForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7351 {
7352         struct dcerpc_spoolss_GetForm_r_state *state =
7353                 tevent_req_data(req,
7354                 struct dcerpc_spoolss_GetForm_r_state);
7355         NTSTATUS status;
7356
7357         if (tevent_req_is_nterror(req, &status)) {
7358                 tevent_req_received(req);
7359                 return status;
7360         }
7361
7362         talloc_steal(mem_ctx, state->out_mem_ctx);
7363
7364         tevent_req_received(req);
7365         return NT_STATUS_OK;
7366 }
7367
7368 NTSTATUS dcerpc_spoolss_GetForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetForm *r)
7369 {
7370         NTSTATUS status;
7371
7372         status = dcerpc_binding_handle_call(h,
7373                         NULL, &ndr_table_spoolss,
7374                         NDR_SPOOLSS_GETFORM, mem_ctx, r);
7375
7376         return status;
7377 }
7378
7379 NTSTATUS dcerpc_spoolss_GetForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetForm *r)
7380 {
7381         NTSTATUS status;
7382
7383         status = dcerpc_spoolss_GetForm_r(p->binding_handle, mem_ctx, r);
7384
7385         if (NT_STATUS_IS_RPC(status)) {
7386                 status = NT_STATUS_NET_WRITE_FAULT;
7387         }
7388
7389         return status;
7390 }
7391
7392 struct dcerpc_spoolss_GetForm_state {
7393         struct spoolss_GetForm orig;
7394         struct spoolss_GetForm tmp;
7395         TALLOC_CTX *out_mem_ctx;
7396 };
7397
7398 static void dcerpc_spoolss_GetForm_done(struct tevent_req *subreq);
7399
7400 struct tevent_req *dcerpc_spoolss_GetForm_send(TALLOC_CTX *mem_ctx,
7401                                                struct tevent_context *ev,
7402                                                struct dcerpc_binding_handle *h,
7403                                                struct policy_handle *_handle /* [in] [ref] */,
7404                                                const char *_form_name /* [in] [charset(UTF16)] */,
7405                                                uint32_t _level /* [in]  */,
7406                                                DATA_BLOB *_buffer /* [in] [unique] */,
7407                                                uint32_t _offered /* [in]  */,
7408                                                union spoolss_FormInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
7409                                                uint32_t *_needed /* [out] [ref] */)
7410 {
7411         struct tevent_req *req;
7412         struct dcerpc_spoolss_GetForm_state *state;
7413         struct tevent_req *subreq;
7414
7415         req = tevent_req_create(mem_ctx, &state,
7416                                 struct dcerpc_spoolss_GetForm_state);
7417         if (req == NULL) {
7418                 return NULL;
7419         }
7420         state->out_mem_ctx = NULL;
7421
7422         /* In parameters */
7423         state->orig.in.handle = _handle;
7424         state->orig.in.form_name = _form_name;
7425         state->orig.in.level = _level;
7426         state->orig.in.buffer = _buffer;
7427         state->orig.in.offered = _offered;
7428
7429         /* Out parameters */
7430         state->orig.out.info = _info;
7431         state->orig.out.needed = _needed;
7432
7433         /* Result */
7434         ZERO_STRUCT(state->orig.out.result);
7435
7436         state->out_mem_ctx = talloc_named_const(state, 0,
7437                              "dcerpc_spoolss_GetForm_out_memory");
7438         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7439                 return tevent_req_post(req, ev);
7440         }
7441
7442         /* make a temporary copy, that we pass to the dispatch function */
7443         state->tmp = state->orig;
7444
7445         subreq = dcerpc_spoolss_GetForm_r_send(state, ev, h, &state->tmp);
7446         if (tevent_req_nomem(subreq, req)) {
7447                 return tevent_req_post(req, ev);
7448         }
7449         tevent_req_set_callback(subreq, dcerpc_spoolss_GetForm_done, req);
7450         return req;
7451 }
7452
7453 static void dcerpc_spoolss_GetForm_done(struct tevent_req *subreq)
7454 {
7455         struct tevent_req *req = tevent_req_callback_data(
7456                 subreq, struct tevent_req);
7457         struct dcerpc_spoolss_GetForm_state *state = tevent_req_data(
7458                 req, struct dcerpc_spoolss_GetForm_state);
7459         NTSTATUS status;
7460         TALLOC_CTX *mem_ctx;
7461
7462         if (state->out_mem_ctx) {
7463                 mem_ctx = state->out_mem_ctx;
7464         } else {
7465                 mem_ctx = state;
7466         }
7467
7468         status = dcerpc_spoolss_GetForm_r_recv(subreq, mem_ctx);
7469         TALLOC_FREE(subreq);
7470         if (!NT_STATUS_IS_OK(status)) {
7471                 tevent_req_nterror(req, status);
7472                 return;
7473         }
7474
7475         /* Copy out parameters */
7476         if (state->orig.out.info && state->tmp.out.info) {
7477                 *state->orig.out.info = *state->tmp.out.info;
7478         }
7479         *state->orig.out.needed = *state->tmp.out.needed;
7480
7481         /* Copy result */
7482         state->orig.out.result = state->tmp.out.result;
7483
7484         /* Reset temporary structure */
7485         ZERO_STRUCT(state->tmp);
7486
7487         tevent_req_done(req);
7488 }
7489
7490 NTSTATUS dcerpc_spoolss_GetForm_recv(struct tevent_req *req,
7491                                      TALLOC_CTX *mem_ctx,
7492                                      WERROR *result)
7493 {
7494         struct dcerpc_spoolss_GetForm_state *state = tevent_req_data(
7495                 req, struct dcerpc_spoolss_GetForm_state);
7496         NTSTATUS status;
7497
7498         if (tevent_req_is_nterror(req, &status)) {
7499                 tevent_req_received(req);
7500                 return status;
7501         }
7502
7503         /* Steal possible out parameters to the callers context */
7504         talloc_steal(mem_ctx, state->out_mem_ctx);
7505
7506         /* Return result */
7507         *result = state->orig.out.result;
7508
7509         tevent_req_received(req);
7510         return NT_STATUS_OK;
7511 }
7512
7513 NTSTATUS dcerpc_spoolss_GetForm(struct dcerpc_binding_handle *h,
7514                                 TALLOC_CTX *mem_ctx,
7515                                 struct policy_handle *_handle /* [in] [ref] */,
7516                                 const char *_form_name /* [in] [charset(UTF16)] */,
7517                                 uint32_t _level /* [in]  */,
7518                                 DATA_BLOB *_buffer /* [in] [unique] */,
7519                                 uint32_t _offered /* [in]  */,
7520                                 union spoolss_FormInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
7521                                 uint32_t *_needed /* [out] [ref] */,
7522                                 WERROR *result)
7523 {
7524         struct spoolss_GetForm r;
7525         NTSTATUS status;
7526
7527         /* In parameters */
7528         r.in.handle = _handle;
7529         r.in.form_name = _form_name;
7530         r.in.level = _level;
7531         r.in.buffer = _buffer;
7532         r.in.offered = _offered;
7533
7534         status = dcerpc_spoolss_GetForm_r(h, mem_ctx, &r);
7535         if (!NT_STATUS_IS_OK(status)) {
7536                 return status;
7537         }
7538
7539         /* Return variables */
7540         if (_info && r.out.info) {
7541                 *_info = *r.out.info;
7542         }
7543         *_needed = *r.out.needed;
7544
7545         /* Return result */
7546         *result = r.out.result;
7547
7548         return NT_STATUS_OK;
7549 }
7550
7551 struct dcerpc_spoolss_SetForm_r_state {
7552         TALLOC_CTX *out_mem_ctx;
7553 };
7554
7555 static void dcerpc_spoolss_SetForm_r_done(struct tevent_req *subreq);
7556
7557 struct tevent_req *dcerpc_spoolss_SetForm_r_send(TALLOC_CTX *mem_ctx,
7558         struct tevent_context *ev,
7559         struct dcerpc_binding_handle *h,
7560         struct spoolss_SetForm *r)
7561 {
7562         struct tevent_req *req;
7563         struct dcerpc_spoolss_SetForm_r_state *state;
7564         struct tevent_req *subreq;
7565
7566         req = tevent_req_create(mem_ctx, &state,
7567                                 struct dcerpc_spoolss_SetForm_r_state);
7568         if (req == NULL) {
7569                 return NULL;
7570         }
7571
7572         state->out_mem_ctx = NULL;
7573         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7574                         NULL, &ndr_table_spoolss,
7575                         NDR_SPOOLSS_SETFORM, state, r);
7576         if (tevent_req_nomem(subreq, req)) {
7577                 return tevent_req_post(req, ev);
7578         }
7579         tevent_req_set_callback(subreq, dcerpc_spoolss_SetForm_r_done, req);
7580
7581         return req;
7582 }
7583
7584 static void dcerpc_spoolss_SetForm_r_done(struct tevent_req *subreq)
7585 {
7586         struct tevent_req *req =
7587                 tevent_req_callback_data(subreq,
7588                 struct tevent_req);
7589         NTSTATUS status;
7590
7591         status = dcerpc_binding_handle_call_recv(subreq);
7592         if (!NT_STATUS_IS_OK(status)) {
7593                 tevent_req_nterror(req, status);
7594                 return;
7595         }
7596
7597         tevent_req_done(req);
7598 }
7599
7600 NTSTATUS dcerpc_spoolss_SetForm_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7601 {
7602         struct dcerpc_spoolss_SetForm_r_state *state =
7603                 tevent_req_data(req,
7604                 struct dcerpc_spoolss_SetForm_r_state);
7605         NTSTATUS status;
7606
7607         if (tevent_req_is_nterror(req, &status)) {
7608                 tevent_req_received(req);
7609                 return status;
7610         }
7611
7612         talloc_steal(mem_ctx, state->out_mem_ctx);
7613
7614         tevent_req_received(req);
7615         return NT_STATUS_OK;
7616 }
7617
7618 NTSTATUS dcerpc_spoolss_SetForm_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetForm *r)
7619 {
7620         NTSTATUS status;
7621
7622         status = dcerpc_binding_handle_call(h,
7623                         NULL, &ndr_table_spoolss,
7624                         NDR_SPOOLSS_SETFORM, mem_ctx, r);
7625
7626         return status;
7627 }
7628
7629 NTSTATUS dcerpc_spoolss_SetForm_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetForm *r)
7630 {
7631         NTSTATUS status;
7632
7633         status = dcerpc_spoolss_SetForm_r(p->binding_handle, mem_ctx, r);
7634
7635         if (NT_STATUS_IS_RPC(status)) {
7636                 status = NT_STATUS_NET_WRITE_FAULT;
7637         }
7638
7639         return status;
7640 }
7641
7642 struct dcerpc_spoolss_SetForm_state {
7643         struct spoolss_SetForm orig;
7644         struct spoolss_SetForm tmp;
7645         TALLOC_CTX *out_mem_ctx;
7646 };
7647
7648 static void dcerpc_spoolss_SetForm_done(struct tevent_req *subreq);
7649
7650 struct tevent_req *dcerpc_spoolss_SetForm_send(TALLOC_CTX *mem_ctx,
7651                                                struct tevent_context *ev,
7652                                                struct dcerpc_binding_handle *h,
7653                                                struct policy_handle *_handle /* [in] [ref] */,
7654                                                const char *_form_name /* [in] [charset(UTF16)] */,
7655                                                uint32_t _level /* [in]  */,
7656                                                union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */)
7657 {
7658         struct tevent_req *req;
7659         struct dcerpc_spoolss_SetForm_state *state;
7660         struct tevent_req *subreq;
7661
7662         req = tevent_req_create(mem_ctx, &state,
7663                                 struct dcerpc_spoolss_SetForm_state);
7664         if (req == NULL) {
7665                 return NULL;
7666         }
7667         state->out_mem_ctx = NULL;
7668
7669         /* In parameters */
7670         state->orig.in.handle = _handle;
7671         state->orig.in.form_name = _form_name;
7672         state->orig.in.level = _level;
7673         state->orig.in.info = _info;
7674
7675         /* Out parameters */
7676
7677         /* Result */
7678         ZERO_STRUCT(state->orig.out.result);
7679
7680         /* make a temporary copy, that we pass to the dispatch function */
7681         state->tmp = state->orig;
7682
7683         subreq = dcerpc_spoolss_SetForm_r_send(state, ev, h, &state->tmp);
7684         if (tevent_req_nomem(subreq, req)) {
7685                 return tevent_req_post(req, ev);
7686         }
7687         tevent_req_set_callback(subreq, dcerpc_spoolss_SetForm_done, req);
7688         return req;
7689 }
7690
7691 static void dcerpc_spoolss_SetForm_done(struct tevent_req *subreq)
7692 {
7693         struct tevent_req *req = tevent_req_callback_data(
7694                 subreq, struct tevent_req);
7695         struct dcerpc_spoolss_SetForm_state *state = tevent_req_data(
7696                 req, struct dcerpc_spoolss_SetForm_state);
7697         NTSTATUS status;
7698         TALLOC_CTX *mem_ctx;
7699
7700         if (state->out_mem_ctx) {
7701                 mem_ctx = state->out_mem_ctx;
7702         } else {
7703                 mem_ctx = state;
7704         }
7705
7706         status = dcerpc_spoolss_SetForm_r_recv(subreq, mem_ctx);
7707         TALLOC_FREE(subreq);
7708         if (!NT_STATUS_IS_OK(status)) {
7709                 tevent_req_nterror(req, status);
7710                 return;
7711         }
7712
7713         /* Copy out parameters */
7714
7715         /* Copy result */
7716         state->orig.out.result = state->tmp.out.result;
7717
7718         /* Reset temporary structure */
7719         ZERO_STRUCT(state->tmp);
7720
7721         tevent_req_done(req);
7722 }
7723
7724 NTSTATUS dcerpc_spoolss_SetForm_recv(struct tevent_req *req,
7725                                      TALLOC_CTX *mem_ctx,
7726                                      WERROR *result)
7727 {
7728         struct dcerpc_spoolss_SetForm_state *state = tevent_req_data(
7729                 req, struct dcerpc_spoolss_SetForm_state);
7730         NTSTATUS status;
7731
7732         if (tevent_req_is_nterror(req, &status)) {
7733                 tevent_req_received(req);
7734                 return status;
7735         }
7736
7737         /* Steal possible out parameters to the callers context */
7738         talloc_steal(mem_ctx, state->out_mem_ctx);
7739
7740         /* Return result */
7741         *result = state->orig.out.result;
7742
7743         tevent_req_received(req);
7744         return NT_STATUS_OK;
7745 }
7746
7747 NTSTATUS dcerpc_spoolss_SetForm(struct dcerpc_binding_handle *h,
7748                                 TALLOC_CTX *mem_ctx,
7749                                 struct policy_handle *_handle /* [in] [ref] */,
7750                                 const char *_form_name /* [in] [charset(UTF16)] */,
7751                                 uint32_t _level /* [in]  */,
7752                                 union spoolss_AddFormInfo _info /* [in] [switch_is(level)] */,
7753                                 WERROR *result)
7754 {
7755         struct spoolss_SetForm r;
7756         NTSTATUS status;
7757
7758         /* In parameters */
7759         r.in.handle = _handle;
7760         r.in.form_name = _form_name;
7761         r.in.level = _level;
7762         r.in.info = _info;
7763
7764         status = dcerpc_spoolss_SetForm_r(h, mem_ctx, &r);
7765         if (!NT_STATUS_IS_OK(status)) {
7766                 return status;
7767         }
7768
7769         /* Return variables */
7770
7771         /* Return result */
7772         *result = r.out.result;
7773
7774         return NT_STATUS_OK;
7775 }
7776
7777 struct dcerpc_spoolss_EnumForms_r_state {
7778         TALLOC_CTX *out_mem_ctx;
7779 };
7780
7781 static void dcerpc_spoolss_EnumForms_r_done(struct tevent_req *subreq);
7782
7783 struct tevent_req *dcerpc_spoolss_EnumForms_r_send(TALLOC_CTX *mem_ctx,
7784         struct tevent_context *ev,
7785         struct dcerpc_binding_handle *h,
7786         struct spoolss_EnumForms *r)
7787 {
7788         struct tevent_req *req;
7789         struct dcerpc_spoolss_EnumForms_r_state *state;
7790         struct tevent_req *subreq;
7791
7792         req = tevent_req_create(mem_ctx, &state,
7793                                 struct dcerpc_spoolss_EnumForms_r_state);
7794         if (req == NULL) {
7795                 return NULL;
7796         }
7797
7798         state->out_mem_ctx = talloc_new(state);
7799         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7800                 return tevent_req_post(req, ev);
7801         }
7802
7803         subreq = dcerpc_binding_handle_call_send(state, ev, h,
7804                         NULL, &ndr_table_spoolss,
7805                         NDR_SPOOLSS_ENUMFORMS, state->out_mem_ctx, r);
7806         if (tevent_req_nomem(subreq, req)) {
7807                 return tevent_req_post(req, ev);
7808         }
7809         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumForms_r_done, req);
7810
7811         return req;
7812 }
7813
7814 static void dcerpc_spoolss_EnumForms_r_done(struct tevent_req *subreq)
7815 {
7816         struct tevent_req *req =
7817                 tevent_req_callback_data(subreq,
7818                 struct tevent_req);
7819         NTSTATUS status;
7820
7821         status = dcerpc_binding_handle_call_recv(subreq);
7822         if (!NT_STATUS_IS_OK(status)) {
7823                 tevent_req_nterror(req, status);
7824                 return;
7825         }
7826
7827         tevent_req_done(req);
7828 }
7829
7830 NTSTATUS dcerpc_spoolss_EnumForms_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
7831 {
7832         struct dcerpc_spoolss_EnumForms_r_state *state =
7833                 tevent_req_data(req,
7834                 struct dcerpc_spoolss_EnumForms_r_state);
7835         NTSTATUS status;
7836
7837         if (tevent_req_is_nterror(req, &status)) {
7838                 tevent_req_received(req);
7839                 return status;
7840         }
7841
7842         talloc_steal(mem_ctx, state->out_mem_ctx);
7843
7844         tevent_req_received(req);
7845         return NT_STATUS_OK;
7846 }
7847
7848 NTSTATUS dcerpc_spoolss_EnumForms_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumForms *r)
7849 {
7850         NTSTATUS status;
7851
7852         status = dcerpc_binding_handle_call(h,
7853                         NULL, &ndr_table_spoolss,
7854                         NDR_SPOOLSS_ENUMFORMS, mem_ctx, r);
7855
7856         return status;
7857 }
7858
7859 NTSTATUS dcerpc_spoolss_EnumForms_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumForms *r)
7860 {
7861         NTSTATUS status;
7862
7863         status = dcerpc_spoolss_EnumForms_r(p->binding_handle, mem_ctx, r);
7864
7865         if (NT_STATUS_IS_RPC(status)) {
7866                 status = NT_STATUS_NET_WRITE_FAULT;
7867         }
7868
7869         return status;
7870 }
7871
7872 struct dcerpc_spoolss_EnumForms_state {
7873         struct spoolss_EnumForms orig;
7874         struct spoolss_EnumForms tmp;
7875         TALLOC_CTX *out_mem_ctx;
7876 };
7877
7878 static void dcerpc_spoolss_EnumForms_done(struct tevent_req *subreq);
7879
7880 struct tevent_req *dcerpc_spoolss_EnumForms_send(TALLOC_CTX *mem_ctx,
7881                                                  struct tevent_context *ev,
7882                                                  struct dcerpc_binding_handle *h,
7883                                                  struct policy_handle *_handle /* [in] [ref] */,
7884                                                  uint32_t _level /* [in]  */,
7885                                                  DATA_BLOB *_buffer /* [in] [unique] */,
7886                                                  uint32_t _offered /* [in]  */,
7887                                                  uint32_t *_count /* [out] [ref] */,
7888                                                  union spoolss_FormInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
7889                                                  uint32_t *_needed /* [out] [ref] */)
7890 {
7891         struct tevent_req *req;
7892         struct dcerpc_spoolss_EnumForms_state *state;
7893         struct tevent_req *subreq;
7894
7895         req = tevent_req_create(mem_ctx, &state,
7896                                 struct dcerpc_spoolss_EnumForms_state);
7897         if (req == NULL) {
7898                 return NULL;
7899         }
7900         state->out_mem_ctx = NULL;
7901
7902         /* In parameters */
7903         state->orig.in.handle = _handle;
7904         state->orig.in.level = _level;
7905         state->orig.in.buffer = _buffer;
7906         state->orig.in.offered = _offered;
7907
7908         /* Out parameters */
7909         state->orig.out.count = _count;
7910         state->orig.out.info = _info;
7911         state->orig.out.needed = _needed;
7912
7913         /* Result */
7914         ZERO_STRUCT(state->orig.out.result);
7915
7916         state->out_mem_ctx = talloc_named_const(state, 0,
7917                              "dcerpc_spoolss_EnumForms_out_memory");
7918         if (tevent_req_nomem(state->out_mem_ctx, req)) {
7919                 return tevent_req_post(req, ev);
7920         }
7921
7922         /* make a temporary copy, that we pass to the dispatch function */
7923         state->tmp = state->orig;
7924
7925         subreq = dcerpc_spoolss_EnumForms_r_send(state, ev, h, &state->tmp);
7926         if (tevent_req_nomem(subreq, req)) {
7927                 return tevent_req_post(req, ev);
7928         }
7929         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumForms_done, req);
7930         return req;
7931 }
7932
7933 static void dcerpc_spoolss_EnumForms_done(struct tevent_req *subreq)
7934 {
7935         struct tevent_req *req = tevent_req_callback_data(
7936                 subreq, struct tevent_req);
7937         struct dcerpc_spoolss_EnumForms_state *state = tevent_req_data(
7938                 req, struct dcerpc_spoolss_EnumForms_state);
7939         NTSTATUS status;
7940         TALLOC_CTX *mem_ctx;
7941
7942         if (state->out_mem_ctx) {
7943                 mem_ctx = state->out_mem_ctx;
7944         } else {
7945                 mem_ctx = state;
7946         }
7947
7948         status = dcerpc_spoolss_EnumForms_r_recv(subreq, mem_ctx);
7949         TALLOC_FREE(subreq);
7950         if (!NT_STATUS_IS_OK(status)) {
7951                 tevent_req_nterror(req, status);
7952                 return;
7953         }
7954
7955         /* Copy out parameters */
7956         *state->orig.out.count = *state->tmp.out.count;
7957         *state->orig.out.info = *state->tmp.out.info;
7958         *state->orig.out.needed = *state->tmp.out.needed;
7959
7960         /* Copy result */
7961         state->orig.out.result = state->tmp.out.result;
7962
7963         /* Reset temporary structure */
7964         ZERO_STRUCT(state->tmp);
7965
7966         tevent_req_done(req);
7967 }
7968
7969 NTSTATUS dcerpc_spoolss_EnumForms_recv(struct tevent_req *req,
7970                                        TALLOC_CTX *mem_ctx,
7971                                        WERROR *result)
7972 {
7973         struct dcerpc_spoolss_EnumForms_state *state = tevent_req_data(
7974                 req, struct dcerpc_spoolss_EnumForms_state);
7975         NTSTATUS status;
7976
7977         if (tevent_req_is_nterror(req, &status)) {
7978                 tevent_req_received(req);
7979                 return status;
7980         }
7981
7982         /* Steal possible out parameters to the callers context */
7983         talloc_steal(mem_ctx, state->out_mem_ctx);
7984
7985         /* Return result */
7986         *result = state->orig.out.result;
7987
7988         tevent_req_received(req);
7989         return NT_STATUS_OK;
7990 }
7991
7992 NTSTATUS dcerpc_spoolss_EnumForms(struct dcerpc_binding_handle *h,
7993                                   TALLOC_CTX *mem_ctx,
7994                                   struct policy_handle *_handle /* [in] [ref] */,
7995                                   uint32_t _level /* [in]  */,
7996                                   DATA_BLOB *_buffer /* [in] [unique] */,
7997                                   uint32_t _offered /* [in]  */,
7998                                   uint32_t *_count /* [out] [ref] */,
7999                                   union spoolss_FormInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8000                                   uint32_t *_needed /* [out] [ref] */,
8001                                   WERROR *result)
8002 {
8003         struct spoolss_EnumForms r;
8004         NTSTATUS status;
8005
8006         /* In parameters */
8007         r.in.handle = _handle;
8008         r.in.level = _level;
8009         r.in.buffer = _buffer;
8010         r.in.offered = _offered;
8011
8012         status = dcerpc_spoolss_EnumForms_r(h, mem_ctx, &r);
8013         if (!NT_STATUS_IS_OK(status)) {
8014                 return status;
8015         }
8016
8017         /* Return variables */
8018         *_count = *r.out.count;
8019         *_info = *r.out.info;
8020         *_needed = *r.out.needed;
8021
8022         /* Return result */
8023         *result = r.out.result;
8024
8025         return NT_STATUS_OK;
8026 }
8027
8028 struct dcerpc_spoolss_EnumPorts_r_state {
8029         TALLOC_CTX *out_mem_ctx;
8030 };
8031
8032 static void dcerpc_spoolss_EnumPorts_r_done(struct tevent_req *subreq);
8033
8034 struct tevent_req *dcerpc_spoolss_EnumPorts_r_send(TALLOC_CTX *mem_ctx,
8035         struct tevent_context *ev,
8036         struct dcerpc_binding_handle *h,
8037         struct spoolss_EnumPorts *r)
8038 {
8039         struct tevent_req *req;
8040         struct dcerpc_spoolss_EnumPorts_r_state *state;
8041         struct tevent_req *subreq;
8042
8043         req = tevent_req_create(mem_ctx, &state,
8044                                 struct dcerpc_spoolss_EnumPorts_r_state);
8045         if (req == NULL) {
8046                 return NULL;
8047         }
8048
8049         state->out_mem_ctx = talloc_new(state);
8050         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8051                 return tevent_req_post(req, ev);
8052         }
8053
8054         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8055                         NULL, &ndr_table_spoolss,
8056                         NDR_SPOOLSS_ENUMPORTS, state->out_mem_ctx, r);
8057         if (tevent_req_nomem(subreq, req)) {
8058                 return tevent_req_post(req, ev);
8059         }
8060         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPorts_r_done, req);
8061
8062         return req;
8063 }
8064
8065 static void dcerpc_spoolss_EnumPorts_r_done(struct tevent_req *subreq)
8066 {
8067         struct tevent_req *req =
8068                 tevent_req_callback_data(subreq,
8069                 struct tevent_req);
8070         NTSTATUS status;
8071
8072         status = dcerpc_binding_handle_call_recv(subreq);
8073         if (!NT_STATUS_IS_OK(status)) {
8074                 tevent_req_nterror(req, status);
8075                 return;
8076         }
8077
8078         tevent_req_done(req);
8079 }
8080
8081 NTSTATUS dcerpc_spoolss_EnumPorts_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8082 {
8083         struct dcerpc_spoolss_EnumPorts_r_state *state =
8084                 tevent_req_data(req,
8085                 struct dcerpc_spoolss_EnumPorts_r_state);
8086         NTSTATUS status;
8087
8088         if (tevent_req_is_nterror(req, &status)) {
8089                 tevent_req_received(req);
8090                 return status;
8091         }
8092
8093         talloc_steal(mem_ctx, state->out_mem_ctx);
8094
8095         tevent_req_received(req);
8096         return NT_STATUS_OK;
8097 }
8098
8099 NTSTATUS dcerpc_spoolss_EnumPorts_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPorts *r)
8100 {
8101         NTSTATUS status;
8102
8103         status = dcerpc_binding_handle_call(h,
8104                         NULL, &ndr_table_spoolss,
8105                         NDR_SPOOLSS_ENUMPORTS, mem_ctx, r);
8106
8107         return status;
8108 }
8109
8110 NTSTATUS dcerpc_spoolss_EnumPorts_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPorts *r)
8111 {
8112         NTSTATUS status;
8113
8114         status = dcerpc_spoolss_EnumPorts_r(p->binding_handle, mem_ctx, r);
8115
8116         if (NT_STATUS_IS_RPC(status)) {
8117                 status = NT_STATUS_NET_WRITE_FAULT;
8118         }
8119
8120         return status;
8121 }
8122
8123 struct dcerpc_spoolss_EnumPorts_state {
8124         struct spoolss_EnumPorts orig;
8125         struct spoolss_EnumPorts tmp;
8126         TALLOC_CTX *out_mem_ctx;
8127 };
8128
8129 static void dcerpc_spoolss_EnumPorts_done(struct tevent_req *subreq);
8130
8131 struct tevent_req *dcerpc_spoolss_EnumPorts_send(TALLOC_CTX *mem_ctx,
8132                                                  struct tevent_context *ev,
8133                                                  struct dcerpc_binding_handle *h,
8134                                                  const char *_servername /* [in] [unique,charset(UTF16)] */,
8135                                                  uint32_t _level /* [in]  */,
8136                                                  DATA_BLOB *_buffer /* [in] [unique] */,
8137                                                  uint32_t _offered /* [in]  */,
8138                                                  uint32_t *_count /* [out] [ref] */,
8139                                                  union spoolss_PortInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8140                                                  uint32_t *_needed /* [out] [ref] */)
8141 {
8142         struct tevent_req *req;
8143         struct dcerpc_spoolss_EnumPorts_state *state;
8144         struct tevent_req *subreq;
8145
8146         req = tevent_req_create(mem_ctx, &state,
8147                                 struct dcerpc_spoolss_EnumPorts_state);
8148         if (req == NULL) {
8149                 return NULL;
8150         }
8151         state->out_mem_ctx = NULL;
8152
8153         /* In parameters */
8154         state->orig.in.servername = _servername;
8155         state->orig.in.level = _level;
8156         state->orig.in.buffer = _buffer;
8157         state->orig.in.offered = _offered;
8158
8159         /* Out parameters */
8160         state->orig.out.count = _count;
8161         state->orig.out.info = _info;
8162         state->orig.out.needed = _needed;
8163
8164         /* Result */
8165         ZERO_STRUCT(state->orig.out.result);
8166
8167         state->out_mem_ctx = talloc_named_const(state, 0,
8168                              "dcerpc_spoolss_EnumPorts_out_memory");
8169         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8170                 return tevent_req_post(req, ev);
8171         }
8172
8173         /* make a temporary copy, that we pass to the dispatch function */
8174         state->tmp = state->orig;
8175
8176         subreq = dcerpc_spoolss_EnumPorts_r_send(state, ev, h, &state->tmp);
8177         if (tevent_req_nomem(subreq, req)) {
8178                 return tevent_req_post(req, ev);
8179         }
8180         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPorts_done, req);
8181         return req;
8182 }
8183
8184 static void dcerpc_spoolss_EnumPorts_done(struct tevent_req *subreq)
8185 {
8186         struct tevent_req *req = tevent_req_callback_data(
8187                 subreq, struct tevent_req);
8188         struct dcerpc_spoolss_EnumPorts_state *state = tevent_req_data(
8189                 req, struct dcerpc_spoolss_EnumPorts_state);
8190         NTSTATUS status;
8191         TALLOC_CTX *mem_ctx;
8192
8193         if (state->out_mem_ctx) {
8194                 mem_ctx = state->out_mem_ctx;
8195         } else {
8196                 mem_ctx = state;
8197         }
8198
8199         status = dcerpc_spoolss_EnumPorts_r_recv(subreq, mem_ctx);
8200         TALLOC_FREE(subreq);
8201         if (!NT_STATUS_IS_OK(status)) {
8202                 tevent_req_nterror(req, status);
8203                 return;
8204         }
8205
8206         /* Copy out parameters */
8207         *state->orig.out.count = *state->tmp.out.count;
8208         *state->orig.out.info = *state->tmp.out.info;
8209         *state->orig.out.needed = *state->tmp.out.needed;
8210
8211         /* Copy result */
8212         state->orig.out.result = state->tmp.out.result;
8213
8214         /* Reset temporary structure */
8215         ZERO_STRUCT(state->tmp);
8216
8217         tevent_req_done(req);
8218 }
8219
8220 NTSTATUS dcerpc_spoolss_EnumPorts_recv(struct tevent_req *req,
8221                                        TALLOC_CTX *mem_ctx,
8222                                        WERROR *result)
8223 {
8224         struct dcerpc_spoolss_EnumPorts_state *state = tevent_req_data(
8225                 req, struct dcerpc_spoolss_EnumPorts_state);
8226         NTSTATUS status;
8227
8228         if (tevent_req_is_nterror(req, &status)) {
8229                 tevent_req_received(req);
8230                 return status;
8231         }
8232
8233         /* Steal possible out parameters to the callers context */
8234         talloc_steal(mem_ctx, state->out_mem_ctx);
8235
8236         /* Return result */
8237         *result = state->orig.out.result;
8238
8239         tevent_req_received(req);
8240         return NT_STATUS_OK;
8241 }
8242
8243 NTSTATUS dcerpc_spoolss_EnumPorts(struct dcerpc_binding_handle *h,
8244                                   TALLOC_CTX *mem_ctx,
8245                                   const char *_servername /* [in] [unique,charset(UTF16)] */,
8246                                   uint32_t _level /* [in]  */,
8247                                   DATA_BLOB *_buffer /* [in] [unique] */,
8248                                   uint32_t _offered /* [in]  */,
8249                                   uint32_t *_count /* [out] [ref] */,
8250                                   union spoolss_PortInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8251                                   uint32_t *_needed /* [out] [ref] */,
8252                                   WERROR *result)
8253 {
8254         struct spoolss_EnumPorts r;
8255         NTSTATUS status;
8256
8257         /* In parameters */
8258         r.in.servername = _servername;
8259         r.in.level = _level;
8260         r.in.buffer = _buffer;
8261         r.in.offered = _offered;
8262
8263         status = dcerpc_spoolss_EnumPorts_r(h, mem_ctx, &r);
8264         if (!NT_STATUS_IS_OK(status)) {
8265                 return status;
8266         }
8267
8268         /* Return variables */
8269         *_count = *r.out.count;
8270         *_info = *r.out.info;
8271         *_needed = *r.out.needed;
8272
8273         /* Return result */
8274         *result = r.out.result;
8275
8276         return NT_STATUS_OK;
8277 }
8278
8279 struct dcerpc_spoolss_EnumMonitors_r_state {
8280         TALLOC_CTX *out_mem_ctx;
8281 };
8282
8283 static void dcerpc_spoolss_EnumMonitors_r_done(struct tevent_req *subreq);
8284
8285 struct tevent_req *dcerpc_spoolss_EnumMonitors_r_send(TALLOC_CTX *mem_ctx,
8286         struct tevent_context *ev,
8287         struct dcerpc_binding_handle *h,
8288         struct spoolss_EnumMonitors *r)
8289 {
8290         struct tevent_req *req;
8291         struct dcerpc_spoolss_EnumMonitors_r_state *state;
8292         struct tevent_req *subreq;
8293
8294         req = tevent_req_create(mem_ctx, &state,
8295                                 struct dcerpc_spoolss_EnumMonitors_r_state);
8296         if (req == NULL) {
8297                 return NULL;
8298         }
8299
8300         state->out_mem_ctx = talloc_new(state);
8301         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8302                 return tevent_req_post(req, ev);
8303         }
8304
8305         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8306                         NULL, &ndr_table_spoolss,
8307                         NDR_SPOOLSS_ENUMMONITORS, state->out_mem_ctx, r);
8308         if (tevent_req_nomem(subreq, req)) {
8309                 return tevent_req_post(req, ev);
8310         }
8311         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumMonitors_r_done, req);
8312
8313         return req;
8314 }
8315
8316 static void dcerpc_spoolss_EnumMonitors_r_done(struct tevent_req *subreq)
8317 {
8318         struct tevent_req *req =
8319                 tevent_req_callback_data(subreq,
8320                 struct tevent_req);
8321         NTSTATUS status;
8322
8323         status = dcerpc_binding_handle_call_recv(subreq);
8324         if (!NT_STATUS_IS_OK(status)) {
8325                 tevent_req_nterror(req, status);
8326                 return;
8327         }
8328
8329         tevent_req_done(req);
8330 }
8331
8332 NTSTATUS dcerpc_spoolss_EnumMonitors_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8333 {
8334         struct dcerpc_spoolss_EnumMonitors_r_state *state =
8335                 tevent_req_data(req,
8336                 struct dcerpc_spoolss_EnumMonitors_r_state);
8337         NTSTATUS status;
8338
8339         if (tevent_req_is_nterror(req, &status)) {
8340                 tevent_req_received(req);
8341                 return status;
8342         }
8343
8344         talloc_steal(mem_ctx, state->out_mem_ctx);
8345
8346         tevent_req_received(req);
8347         return NT_STATUS_OK;
8348 }
8349
8350 NTSTATUS dcerpc_spoolss_EnumMonitors_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumMonitors *r)
8351 {
8352         NTSTATUS status;
8353
8354         status = dcerpc_binding_handle_call(h,
8355                         NULL, &ndr_table_spoolss,
8356                         NDR_SPOOLSS_ENUMMONITORS, mem_ctx, r);
8357
8358         return status;
8359 }
8360
8361 NTSTATUS dcerpc_spoolss_EnumMonitors_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumMonitors *r)
8362 {
8363         NTSTATUS status;
8364
8365         status = dcerpc_spoolss_EnumMonitors_r(p->binding_handle, mem_ctx, r);
8366
8367         if (NT_STATUS_IS_RPC(status)) {
8368                 status = NT_STATUS_NET_WRITE_FAULT;
8369         }
8370
8371         return status;
8372 }
8373
8374 struct dcerpc_spoolss_EnumMonitors_state {
8375         struct spoolss_EnumMonitors orig;
8376         struct spoolss_EnumMonitors tmp;
8377         TALLOC_CTX *out_mem_ctx;
8378 };
8379
8380 static void dcerpc_spoolss_EnumMonitors_done(struct tevent_req *subreq);
8381
8382 struct tevent_req *dcerpc_spoolss_EnumMonitors_send(TALLOC_CTX *mem_ctx,
8383                                                     struct tevent_context *ev,
8384                                                     struct dcerpc_binding_handle *h,
8385                                                     const char *_servername /* [in] [unique,charset(UTF16)] */,
8386                                                     uint32_t _level /* [in]  */,
8387                                                     DATA_BLOB *_buffer /* [in] [unique] */,
8388                                                     uint32_t _offered /* [in]  */,
8389                                                     uint32_t *_count /* [out] [ref] */,
8390                                                     union spoolss_MonitorInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8391                                                     uint32_t *_needed /* [out] [ref] */)
8392 {
8393         struct tevent_req *req;
8394         struct dcerpc_spoolss_EnumMonitors_state *state;
8395         struct tevent_req *subreq;
8396
8397         req = tevent_req_create(mem_ctx, &state,
8398                                 struct dcerpc_spoolss_EnumMonitors_state);
8399         if (req == NULL) {
8400                 return NULL;
8401         }
8402         state->out_mem_ctx = NULL;
8403
8404         /* In parameters */
8405         state->orig.in.servername = _servername;
8406         state->orig.in.level = _level;
8407         state->orig.in.buffer = _buffer;
8408         state->orig.in.offered = _offered;
8409
8410         /* Out parameters */
8411         state->orig.out.count = _count;
8412         state->orig.out.info = _info;
8413         state->orig.out.needed = _needed;
8414
8415         /* Result */
8416         ZERO_STRUCT(state->orig.out.result);
8417
8418         state->out_mem_ctx = talloc_named_const(state, 0,
8419                              "dcerpc_spoolss_EnumMonitors_out_memory");
8420         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8421                 return tevent_req_post(req, ev);
8422         }
8423
8424         /* make a temporary copy, that we pass to the dispatch function */
8425         state->tmp = state->orig;
8426
8427         subreq = dcerpc_spoolss_EnumMonitors_r_send(state, ev, h, &state->tmp);
8428         if (tevent_req_nomem(subreq, req)) {
8429                 return tevent_req_post(req, ev);
8430         }
8431         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumMonitors_done, req);
8432         return req;
8433 }
8434
8435 static void dcerpc_spoolss_EnumMonitors_done(struct tevent_req *subreq)
8436 {
8437         struct tevent_req *req = tevent_req_callback_data(
8438                 subreq, struct tevent_req);
8439         struct dcerpc_spoolss_EnumMonitors_state *state = tevent_req_data(
8440                 req, struct dcerpc_spoolss_EnumMonitors_state);
8441         NTSTATUS status;
8442         TALLOC_CTX *mem_ctx;
8443
8444         if (state->out_mem_ctx) {
8445                 mem_ctx = state->out_mem_ctx;
8446         } else {
8447                 mem_ctx = state;
8448         }
8449
8450         status = dcerpc_spoolss_EnumMonitors_r_recv(subreq, mem_ctx);
8451         TALLOC_FREE(subreq);
8452         if (!NT_STATUS_IS_OK(status)) {
8453                 tevent_req_nterror(req, status);
8454                 return;
8455         }
8456
8457         /* Copy out parameters */
8458         *state->orig.out.count = *state->tmp.out.count;
8459         *state->orig.out.info = *state->tmp.out.info;
8460         *state->orig.out.needed = *state->tmp.out.needed;
8461
8462         /* Copy result */
8463         state->orig.out.result = state->tmp.out.result;
8464
8465         /* Reset temporary structure */
8466         ZERO_STRUCT(state->tmp);
8467
8468         tevent_req_done(req);
8469 }
8470
8471 NTSTATUS dcerpc_spoolss_EnumMonitors_recv(struct tevent_req *req,
8472                                           TALLOC_CTX *mem_ctx,
8473                                           WERROR *result)
8474 {
8475         struct dcerpc_spoolss_EnumMonitors_state *state = tevent_req_data(
8476                 req, struct dcerpc_spoolss_EnumMonitors_state);
8477         NTSTATUS status;
8478
8479         if (tevent_req_is_nterror(req, &status)) {
8480                 tevent_req_received(req);
8481                 return status;
8482         }
8483
8484         /* Steal possible out parameters to the callers context */
8485         talloc_steal(mem_ctx, state->out_mem_ctx);
8486
8487         /* Return result */
8488         *result = state->orig.out.result;
8489
8490         tevent_req_received(req);
8491         return NT_STATUS_OK;
8492 }
8493
8494 NTSTATUS dcerpc_spoolss_EnumMonitors(struct dcerpc_binding_handle *h,
8495                                      TALLOC_CTX *mem_ctx,
8496                                      const char *_servername /* [in] [unique,charset(UTF16)] */,
8497                                      uint32_t _level /* [in]  */,
8498                                      DATA_BLOB *_buffer /* [in] [unique] */,
8499                                      uint32_t _offered /* [in]  */,
8500                                      uint32_t *_count /* [out] [ref] */,
8501                                      union spoolss_MonitorInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
8502                                      uint32_t *_needed /* [out] [ref] */,
8503                                      WERROR *result)
8504 {
8505         struct spoolss_EnumMonitors r;
8506         NTSTATUS status;
8507
8508         /* In parameters */
8509         r.in.servername = _servername;
8510         r.in.level = _level;
8511         r.in.buffer = _buffer;
8512         r.in.offered = _offered;
8513
8514         status = dcerpc_spoolss_EnumMonitors_r(h, mem_ctx, &r);
8515         if (!NT_STATUS_IS_OK(status)) {
8516                 return status;
8517         }
8518
8519         /* Return variables */
8520         *_count = *r.out.count;
8521         *_info = *r.out.info;
8522         *_needed = *r.out.needed;
8523
8524         /* Return result */
8525         *result = r.out.result;
8526
8527         return NT_STATUS_OK;
8528 }
8529
8530 struct dcerpc_spoolss_AddPort_r_state {
8531         TALLOC_CTX *out_mem_ctx;
8532 };
8533
8534 static void dcerpc_spoolss_AddPort_r_done(struct tevent_req *subreq);
8535
8536 struct tevent_req *dcerpc_spoolss_AddPort_r_send(TALLOC_CTX *mem_ctx,
8537         struct tevent_context *ev,
8538         struct dcerpc_binding_handle *h,
8539         struct spoolss_AddPort *r)
8540 {
8541         struct tevent_req *req;
8542         struct dcerpc_spoolss_AddPort_r_state *state;
8543         struct tevent_req *subreq;
8544
8545         req = tevent_req_create(mem_ctx, &state,
8546                                 struct dcerpc_spoolss_AddPort_r_state);
8547         if (req == NULL) {
8548                 return NULL;
8549         }
8550
8551         state->out_mem_ctx = NULL;
8552         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8553                         NULL, &ndr_table_spoolss,
8554                         NDR_SPOOLSS_ADDPORT, state, r);
8555         if (tevent_req_nomem(subreq, req)) {
8556                 return tevent_req_post(req, ev);
8557         }
8558         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPort_r_done, req);
8559
8560         return req;
8561 }
8562
8563 static void dcerpc_spoolss_AddPort_r_done(struct tevent_req *subreq)
8564 {
8565         struct tevent_req *req =
8566                 tevent_req_callback_data(subreq,
8567                 struct tevent_req);
8568         NTSTATUS status;
8569
8570         status = dcerpc_binding_handle_call_recv(subreq);
8571         if (!NT_STATUS_IS_OK(status)) {
8572                 tevent_req_nterror(req, status);
8573                 return;
8574         }
8575
8576         tevent_req_done(req);
8577 }
8578
8579 NTSTATUS dcerpc_spoolss_AddPort_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8580 {
8581         struct dcerpc_spoolss_AddPort_r_state *state =
8582                 tevent_req_data(req,
8583                 struct dcerpc_spoolss_AddPort_r_state);
8584         NTSTATUS status;
8585
8586         if (tevent_req_is_nterror(req, &status)) {
8587                 tevent_req_received(req);
8588                 return status;
8589         }
8590
8591         talloc_steal(mem_ctx, state->out_mem_ctx);
8592
8593         tevent_req_received(req);
8594         return NT_STATUS_OK;
8595 }
8596
8597 NTSTATUS dcerpc_spoolss_AddPort_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPort *r)
8598 {
8599         NTSTATUS status;
8600
8601         status = dcerpc_binding_handle_call(h,
8602                         NULL, &ndr_table_spoolss,
8603                         NDR_SPOOLSS_ADDPORT, mem_ctx, r);
8604
8605         return status;
8606 }
8607
8608 NTSTATUS dcerpc_spoolss_AddPort_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPort *r)
8609 {
8610         NTSTATUS status;
8611
8612         status = dcerpc_spoolss_AddPort_r(p->binding_handle, mem_ctx, r);
8613
8614         if (NT_STATUS_IS_RPC(status)) {
8615                 status = NT_STATUS_NET_WRITE_FAULT;
8616         }
8617
8618         return status;
8619 }
8620
8621 struct dcerpc_spoolss_AddPort_state {
8622         struct spoolss_AddPort orig;
8623         struct spoolss_AddPort tmp;
8624         TALLOC_CTX *out_mem_ctx;
8625 };
8626
8627 static void dcerpc_spoolss_AddPort_done(struct tevent_req *subreq);
8628
8629 struct tevent_req *dcerpc_spoolss_AddPort_send(TALLOC_CTX *mem_ctx,
8630                                                struct tevent_context *ev,
8631                                                struct dcerpc_binding_handle *h,
8632                                                const char *_server_name /* [in] [unique,charset(UTF16)] */,
8633                                                uint32_t _unknown /* [in]  */,
8634                                                const char *_monitor_name /* [in] [charset(UTF16)] */)
8635 {
8636         struct tevent_req *req;
8637         struct dcerpc_spoolss_AddPort_state *state;
8638         struct tevent_req *subreq;
8639
8640         req = tevent_req_create(mem_ctx, &state,
8641                                 struct dcerpc_spoolss_AddPort_state);
8642         if (req == NULL) {
8643                 return NULL;
8644         }
8645         state->out_mem_ctx = NULL;
8646
8647         /* In parameters */
8648         state->orig.in.server_name = _server_name;
8649         state->orig.in.unknown = _unknown;
8650         state->orig.in.monitor_name = _monitor_name;
8651
8652         /* Out parameters */
8653
8654         /* Result */
8655         ZERO_STRUCT(state->orig.out.result);
8656
8657         /* make a temporary copy, that we pass to the dispatch function */
8658         state->tmp = state->orig;
8659
8660         subreq = dcerpc_spoolss_AddPort_r_send(state, ev, h, &state->tmp);
8661         if (tevent_req_nomem(subreq, req)) {
8662                 return tevent_req_post(req, ev);
8663         }
8664         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPort_done, req);
8665         return req;
8666 }
8667
8668 static void dcerpc_spoolss_AddPort_done(struct tevent_req *subreq)
8669 {
8670         struct tevent_req *req = tevent_req_callback_data(
8671                 subreq, struct tevent_req);
8672         struct dcerpc_spoolss_AddPort_state *state = tevent_req_data(
8673                 req, struct dcerpc_spoolss_AddPort_state);
8674         NTSTATUS status;
8675         TALLOC_CTX *mem_ctx;
8676
8677         if (state->out_mem_ctx) {
8678                 mem_ctx = state->out_mem_ctx;
8679         } else {
8680                 mem_ctx = state;
8681         }
8682
8683         status = dcerpc_spoolss_AddPort_r_recv(subreq, mem_ctx);
8684         TALLOC_FREE(subreq);
8685         if (!NT_STATUS_IS_OK(status)) {
8686                 tevent_req_nterror(req, status);
8687                 return;
8688         }
8689
8690         /* Copy out parameters */
8691
8692         /* Copy result */
8693         state->orig.out.result = state->tmp.out.result;
8694
8695         /* Reset temporary structure */
8696         ZERO_STRUCT(state->tmp);
8697
8698         tevent_req_done(req);
8699 }
8700
8701 NTSTATUS dcerpc_spoolss_AddPort_recv(struct tevent_req *req,
8702                                      TALLOC_CTX *mem_ctx,
8703                                      WERROR *result)
8704 {
8705         struct dcerpc_spoolss_AddPort_state *state = tevent_req_data(
8706                 req, struct dcerpc_spoolss_AddPort_state);
8707         NTSTATUS status;
8708
8709         if (tevent_req_is_nterror(req, &status)) {
8710                 tevent_req_received(req);
8711                 return status;
8712         }
8713
8714         /* Steal possible out parameters to the callers context */
8715         talloc_steal(mem_ctx, state->out_mem_ctx);
8716
8717         /* Return result */
8718         *result = state->orig.out.result;
8719
8720         tevent_req_received(req);
8721         return NT_STATUS_OK;
8722 }
8723
8724 NTSTATUS dcerpc_spoolss_AddPort(struct dcerpc_binding_handle *h,
8725                                 TALLOC_CTX *mem_ctx,
8726                                 const char *_server_name /* [in] [unique,charset(UTF16)] */,
8727                                 uint32_t _unknown /* [in]  */,
8728                                 const char *_monitor_name /* [in] [charset(UTF16)] */,
8729                                 WERROR *result)
8730 {
8731         struct spoolss_AddPort r;
8732         NTSTATUS status;
8733
8734         /* In parameters */
8735         r.in.server_name = _server_name;
8736         r.in.unknown = _unknown;
8737         r.in.monitor_name = _monitor_name;
8738
8739         status = dcerpc_spoolss_AddPort_r(h, mem_ctx, &r);
8740         if (!NT_STATUS_IS_OK(status)) {
8741                 return status;
8742         }
8743
8744         /* Return variables */
8745
8746         /* Return result */
8747         *result = r.out.result;
8748
8749         return NT_STATUS_OK;
8750 }
8751
8752 struct dcerpc_spoolss_CreatePrinterIC_r_state {
8753         TALLOC_CTX *out_mem_ctx;
8754 };
8755
8756 static void dcerpc_spoolss_CreatePrinterIC_r_done(struct tevent_req *subreq);
8757
8758 struct tevent_req *dcerpc_spoolss_CreatePrinterIC_r_send(TALLOC_CTX *mem_ctx,
8759         struct tevent_context *ev,
8760         struct dcerpc_binding_handle *h,
8761         struct spoolss_CreatePrinterIC *r)
8762 {
8763         struct tevent_req *req;
8764         struct dcerpc_spoolss_CreatePrinterIC_r_state *state;
8765         struct tevent_req *subreq;
8766
8767         req = tevent_req_create(mem_ctx, &state,
8768                                 struct dcerpc_spoolss_CreatePrinterIC_r_state);
8769         if (req == NULL) {
8770                 return NULL;
8771         }
8772
8773         state->out_mem_ctx = talloc_new(state);
8774         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8775                 return tevent_req_post(req, ev);
8776         }
8777
8778         subreq = dcerpc_binding_handle_call_send(state, ev, h,
8779                         NULL, &ndr_table_spoolss,
8780                         NDR_SPOOLSS_CREATEPRINTERIC, state->out_mem_ctx, r);
8781         if (tevent_req_nomem(subreq, req)) {
8782                 return tevent_req_post(req, ev);
8783         }
8784         tevent_req_set_callback(subreq, dcerpc_spoolss_CreatePrinterIC_r_done, req);
8785
8786         return req;
8787 }
8788
8789 static void dcerpc_spoolss_CreatePrinterIC_r_done(struct tevent_req *subreq)
8790 {
8791         struct tevent_req *req =
8792                 tevent_req_callback_data(subreq,
8793                 struct tevent_req);
8794         NTSTATUS status;
8795
8796         status = dcerpc_binding_handle_call_recv(subreq);
8797         if (!NT_STATUS_IS_OK(status)) {
8798                 tevent_req_nterror(req, status);
8799                 return;
8800         }
8801
8802         tevent_req_done(req);
8803 }
8804
8805 NTSTATUS dcerpc_spoolss_CreatePrinterIC_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
8806 {
8807         struct dcerpc_spoolss_CreatePrinterIC_r_state *state =
8808                 tevent_req_data(req,
8809                 struct dcerpc_spoolss_CreatePrinterIC_r_state);
8810         NTSTATUS status;
8811
8812         if (tevent_req_is_nterror(req, &status)) {
8813                 tevent_req_received(req);
8814                 return status;
8815         }
8816
8817         talloc_steal(mem_ctx, state->out_mem_ctx);
8818
8819         tevent_req_received(req);
8820         return NT_STATUS_OK;
8821 }
8822
8823 NTSTATUS dcerpc_spoolss_CreatePrinterIC_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_CreatePrinterIC *r)
8824 {
8825         NTSTATUS status;
8826
8827         status = dcerpc_binding_handle_call(h,
8828                         NULL, &ndr_table_spoolss,
8829                         NDR_SPOOLSS_CREATEPRINTERIC, mem_ctx, r);
8830
8831         return status;
8832 }
8833
8834 NTSTATUS dcerpc_spoolss_CreatePrinterIC_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_CreatePrinterIC *r)
8835 {
8836         NTSTATUS status;
8837
8838         status = dcerpc_spoolss_CreatePrinterIC_r(p->binding_handle, mem_ctx, r);
8839
8840         if (NT_STATUS_IS_RPC(status)) {
8841                 status = NT_STATUS_NET_WRITE_FAULT;
8842         }
8843
8844         return status;
8845 }
8846
8847 struct dcerpc_spoolss_CreatePrinterIC_state {
8848         struct spoolss_CreatePrinterIC orig;
8849         struct spoolss_CreatePrinterIC tmp;
8850         TALLOC_CTX *out_mem_ctx;
8851 };
8852
8853 static void dcerpc_spoolss_CreatePrinterIC_done(struct tevent_req *subreq);
8854
8855 struct tevent_req *dcerpc_spoolss_CreatePrinterIC_send(TALLOC_CTX *mem_ctx,
8856                                                        struct tevent_context *ev,
8857                                                        struct dcerpc_binding_handle *h,
8858                                                        struct policy_handle *_handle /* [in] [ref] */,
8859                                                        struct policy_handle *_gdi_handle /* [out] [ref] */,
8860                                                        struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */)
8861 {
8862         struct tevent_req *req;
8863         struct dcerpc_spoolss_CreatePrinterIC_state *state;
8864         struct tevent_req *subreq;
8865
8866         req = tevent_req_create(mem_ctx, &state,
8867                                 struct dcerpc_spoolss_CreatePrinterIC_state);
8868         if (req == NULL) {
8869                 return NULL;
8870         }
8871         state->out_mem_ctx = NULL;
8872
8873         /* In parameters */
8874         state->orig.in.handle = _handle;
8875         state->orig.in.devmode_ctr = _devmode_ctr;
8876
8877         /* Out parameters */
8878         state->orig.out.gdi_handle = _gdi_handle;
8879
8880         /* Result */
8881         ZERO_STRUCT(state->orig.out.result);
8882
8883         state->out_mem_ctx = talloc_named_const(state, 0,
8884                              "dcerpc_spoolss_CreatePrinterIC_out_memory");
8885         if (tevent_req_nomem(state->out_mem_ctx, req)) {
8886                 return tevent_req_post(req, ev);
8887         }
8888
8889         /* make a temporary copy, that we pass to the dispatch function */
8890         state->tmp = state->orig;
8891
8892         subreq = dcerpc_spoolss_CreatePrinterIC_r_send(state, ev, h, &state->tmp);
8893         if (tevent_req_nomem(subreq, req)) {
8894                 return tevent_req_post(req, ev);
8895         }
8896         tevent_req_set_callback(subreq, dcerpc_spoolss_CreatePrinterIC_done, req);
8897         return req;
8898 }
8899
8900 static void dcerpc_spoolss_CreatePrinterIC_done(struct tevent_req *subreq)
8901 {
8902         struct tevent_req *req = tevent_req_callback_data(
8903                 subreq, struct tevent_req);
8904         struct dcerpc_spoolss_CreatePrinterIC_state *state = tevent_req_data(
8905                 req, struct dcerpc_spoolss_CreatePrinterIC_state);
8906         NTSTATUS status;
8907         TALLOC_CTX *mem_ctx;
8908
8909         if (state->out_mem_ctx) {
8910                 mem_ctx = state->out_mem_ctx;
8911         } else {
8912                 mem_ctx = state;
8913         }
8914
8915         status = dcerpc_spoolss_CreatePrinterIC_r_recv(subreq, mem_ctx);
8916         TALLOC_FREE(subreq);
8917         if (!NT_STATUS_IS_OK(status)) {
8918                 tevent_req_nterror(req, status);
8919                 return;
8920         }
8921
8922         /* Copy out parameters */
8923         *state->orig.out.gdi_handle = *state->tmp.out.gdi_handle;
8924
8925         /* Copy result */
8926         state->orig.out.result = state->tmp.out.result;
8927
8928         /* Reset temporary structure */
8929         ZERO_STRUCT(state->tmp);
8930
8931         tevent_req_done(req);
8932 }
8933
8934 NTSTATUS dcerpc_spoolss_CreatePrinterIC_recv(struct tevent_req *req,
8935                                              TALLOC_CTX *mem_ctx,
8936                                              WERROR *result)
8937 {
8938         struct dcerpc_spoolss_CreatePrinterIC_state *state = tevent_req_data(
8939                 req, struct dcerpc_spoolss_CreatePrinterIC_state);
8940         NTSTATUS status;
8941
8942         if (tevent_req_is_nterror(req, &status)) {
8943                 tevent_req_received(req);
8944                 return status;
8945         }
8946
8947         /* Steal possible out parameters to the callers context */
8948         talloc_steal(mem_ctx, state->out_mem_ctx);
8949
8950         /* Return result */
8951         *result = state->orig.out.result;
8952
8953         tevent_req_received(req);
8954         return NT_STATUS_OK;
8955 }
8956
8957 NTSTATUS dcerpc_spoolss_CreatePrinterIC(struct dcerpc_binding_handle *h,
8958                                         TALLOC_CTX *mem_ctx,
8959                                         struct policy_handle *_handle /* [in] [ref] */,
8960                                         struct policy_handle *_gdi_handle /* [out] [ref] */,
8961                                         struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
8962                                         WERROR *result)
8963 {
8964         struct spoolss_CreatePrinterIC r;
8965         NTSTATUS status;
8966
8967         /* In parameters */
8968         r.in.handle = _handle;
8969         r.in.devmode_ctr = _devmode_ctr;
8970
8971         status = dcerpc_spoolss_CreatePrinterIC_r(h, mem_ctx, &r);
8972         if (!NT_STATUS_IS_OK(status)) {
8973                 return status;
8974         }
8975
8976         /* Return variables */
8977         *_gdi_handle = *r.out.gdi_handle;
8978
8979         /* Return result */
8980         *result = r.out.result;
8981
8982         return NT_STATUS_OK;
8983 }
8984
8985 struct dcerpc_spoolss_DeletePrinterIC_r_state {
8986         TALLOC_CTX *out_mem_ctx;
8987 };
8988
8989 static void dcerpc_spoolss_DeletePrinterIC_r_done(struct tevent_req *subreq);
8990
8991 struct tevent_req *dcerpc_spoolss_DeletePrinterIC_r_send(TALLOC_CTX *mem_ctx,
8992         struct tevent_context *ev,
8993         struct dcerpc_binding_handle *h,
8994         struct spoolss_DeletePrinterIC *r)
8995 {
8996         struct tevent_req *req;
8997         struct dcerpc_spoolss_DeletePrinterIC_r_state *state;
8998         struct tevent_req *subreq;
8999
9000         req = tevent_req_create(mem_ctx, &state,
9001                                 struct dcerpc_spoolss_DeletePrinterIC_r_state);
9002         if (req == NULL) {
9003                 return NULL;
9004         }
9005
9006         state->out_mem_ctx = talloc_new(state);
9007         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9008                 return tevent_req_post(req, ev);
9009         }
9010
9011         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9012                         NULL, &ndr_table_spoolss,
9013                         NDR_SPOOLSS_DELETEPRINTERIC, state->out_mem_ctx, r);
9014         if (tevent_req_nomem(subreq, req)) {
9015                 return tevent_req_post(req, ev);
9016         }
9017         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterIC_r_done, req);
9018
9019         return req;
9020 }
9021
9022 static void dcerpc_spoolss_DeletePrinterIC_r_done(struct tevent_req *subreq)
9023 {
9024         struct tevent_req *req =
9025                 tevent_req_callback_data(subreq,
9026                 struct tevent_req);
9027         NTSTATUS status;
9028
9029         status = dcerpc_binding_handle_call_recv(subreq);
9030         if (!NT_STATUS_IS_OK(status)) {
9031                 tevent_req_nterror(req, status);
9032                 return;
9033         }
9034
9035         tevent_req_done(req);
9036 }
9037
9038 NTSTATUS dcerpc_spoolss_DeletePrinterIC_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9039 {
9040         struct dcerpc_spoolss_DeletePrinterIC_r_state *state =
9041                 tevent_req_data(req,
9042                 struct dcerpc_spoolss_DeletePrinterIC_r_state);
9043         NTSTATUS status;
9044
9045         if (tevent_req_is_nterror(req, &status)) {
9046                 tevent_req_received(req);
9047                 return status;
9048         }
9049
9050         talloc_steal(mem_ctx, state->out_mem_ctx);
9051
9052         tevent_req_received(req);
9053         return NT_STATUS_OK;
9054 }
9055
9056 NTSTATUS dcerpc_spoolss_DeletePrinterIC_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterIC *r)
9057 {
9058         NTSTATUS status;
9059
9060         status = dcerpc_binding_handle_call(h,
9061                         NULL, &ndr_table_spoolss,
9062                         NDR_SPOOLSS_DELETEPRINTERIC, mem_ctx, r);
9063
9064         return status;
9065 }
9066
9067 NTSTATUS dcerpc_spoolss_DeletePrinterIC_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterIC *r)
9068 {
9069         NTSTATUS status;
9070
9071         status = dcerpc_spoolss_DeletePrinterIC_r(p->binding_handle, mem_ctx, r);
9072
9073         if (NT_STATUS_IS_RPC(status)) {
9074                 status = NT_STATUS_NET_WRITE_FAULT;
9075         }
9076
9077         return status;
9078 }
9079
9080 struct dcerpc_spoolss_DeletePrinterIC_state {
9081         struct spoolss_DeletePrinterIC orig;
9082         struct spoolss_DeletePrinterIC tmp;
9083         TALLOC_CTX *out_mem_ctx;
9084 };
9085
9086 static void dcerpc_spoolss_DeletePrinterIC_done(struct tevent_req *subreq);
9087
9088 struct tevent_req *dcerpc_spoolss_DeletePrinterIC_send(TALLOC_CTX *mem_ctx,
9089                                                        struct tevent_context *ev,
9090                                                        struct dcerpc_binding_handle *h,
9091                                                        struct policy_handle *_gdi_handle /* [in,out] [ref] */)
9092 {
9093         struct tevent_req *req;
9094         struct dcerpc_spoolss_DeletePrinterIC_state *state;
9095         struct tevent_req *subreq;
9096
9097         req = tevent_req_create(mem_ctx, &state,
9098                                 struct dcerpc_spoolss_DeletePrinterIC_state);
9099         if (req == NULL) {
9100                 return NULL;
9101         }
9102         state->out_mem_ctx = NULL;
9103
9104         /* In parameters */
9105         state->orig.in.gdi_handle = _gdi_handle;
9106
9107         /* Out parameters */
9108         state->orig.out.gdi_handle = _gdi_handle;
9109
9110         /* Result */
9111         ZERO_STRUCT(state->orig.out.result);
9112
9113         state->out_mem_ctx = talloc_named_const(state, 0,
9114                              "dcerpc_spoolss_DeletePrinterIC_out_memory");
9115         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9116                 return tevent_req_post(req, ev);
9117         }
9118
9119         /* make a temporary copy, that we pass to the dispatch function */
9120         state->tmp = state->orig;
9121
9122         subreq = dcerpc_spoolss_DeletePrinterIC_r_send(state, ev, h, &state->tmp);
9123         if (tevent_req_nomem(subreq, req)) {
9124                 return tevent_req_post(req, ev);
9125         }
9126         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterIC_done, req);
9127         return req;
9128 }
9129
9130 static void dcerpc_spoolss_DeletePrinterIC_done(struct tevent_req *subreq)
9131 {
9132         struct tevent_req *req = tevent_req_callback_data(
9133                 subreq, struct tevent_req);
9134         struct dcerpc_spoolss_DeletePrinterIC_state *state = tevent_req_data(
9135                 req, struct dcerpc_spoolss_DeletePrinterIC_state);
9136         NTSTATUS status;
9137         TALLOC_CTX *mem_ctx;
9138
9139         if (state->out_mem_ctx) {
9140                 mem_ctx = state->out_mem_ctx;
9141         } else {
9142                 mem_ctx = state;
9143         }
9144
9145         status = dcerpc_spoolss_DeletePrinterIC_r_recv(subreq, mem_ctx);
9146         TALLOC_FREE(subreq);
9147         if (!NT_STATUS_IS_OK(status)) {
9148                 tevent_req_nterror(req, status);
9149                 return;
9150         }
9151
9152         /* Copy out parameters */
9153         *state->orig.out.gdi_handle = *state->tmp.out.gdi_handle;
9154
9155         /* Copy result */
9156         state->orig.out.result = state->tmp.out.result;
9157
9158         /* Reset temporary structure */
9159         ZERO_STRUCT(state->tmp);
9160
9161         tevent_req_done(req);
9162 }
9163
9164 NTSTATUS dcerpc_spoolss_DeletePrinterIC_recv(struct tevent_req *req,
9165                                              TALLOC_CTX *mem_ctx,
9166                                              WERROR *result)
9167 {
9168         struct dcerpc_spoolss_DeletePrinterIC_state *state = tevent_req_data(
9169                 req, struct dcerpc_spoolss_DeletePrinterIC_state);
9170         NTSTATUS status;
9171
9172         if (tevent_req_is_nterror(req, &status)) {
9173                 tevent_req_received(req);
9174                 return status;
9175         }
9176
9177         /* Steal possible out parameters to the callers context */
9178         talloc_steal(mem_ctx, state->out_mem_ctx);
9179
9180         /* Return result */
9181         *result = state->orig.out.result;
9182
9183         tevent_req_received(req);
9184         return NT_STATUS_OK;
9185 }
9186
9187 NTSTATUS dcerpc_spoolss_DeletePrinterIC(struct dcerpc_binding_handle *h,
9188                                         TALLOC_CTX *mem_ctx,
9189                                         struct policy_handle *_gdi_handle /* [in,out] [ref] */,
9190                                         WERROR *result)
9191 {
9192         struct spoolss_DeletePrinterIC r;
9193         NTSTATUS status;
9194
9195         /* In parameters */
9196         r.in.gdi_handle = _gdi_handle;
9197
9198         status = dcerpc_spoolss_DeletePrinterIC_r(h, mem_ctx, &r);
9199         if (!NT_STATUS_IS_OK(status)) {
9200                 return status;
9201         }
9202
9203         /* Return variables */
9204         *_gdi_handle = *r.out.gdi_handle;
9205
9206         /* Return result */
9207         *result = r.out.result;
9208
9209         return NT_STATUS_OK;
9210 }
9211
9212 struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state {
9213         TALLOC_CTX *out_mem_ctx;
9214 };
9215
9216 static void dcerpc_spoolss_EnumPrintProcDataTypes_r_done(struct tevent_req *subreq);
9217
9218 struct tevent_req *dcerpc_spoolss_EnumPrintProcDataTypes_r_send(TALLOC_CTX *mem_ctx,
9219         struct tevent_context *ev,
9220         struct dcerpc_binding_handle *h,
9221         struct spoolss_EnumPrintProcDataTypes *r)
9222 {
9223         struct tevent_req *req;
9224         struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state *state;
9225         struct tevent_req *subreq;
9226
9227         req = tevent_req_create(mem_ctx, &state,
9228                                 struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state);
9229         if (req == NULL) {
9230                 return NULL;
9231         }
9232
9233         state->out_mem_ctx = talloc_new(state);
9234         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9235                 return tevent_req_post(req, ev);
9236         }
9237
9238         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9239                         NULL, &ndr_table_spoolss,
9240                         NDR_SPOOLSS_ENUMPRINTPROCDATATYPES, state->out_mem_ctx, r);
9241         if (tevent_req_nomem(subreq, req)) {
9242                 return tevent_req_post(req, ev);
9243         }
9244         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrintProcDataTypes_r_done, req);
9245
9246         return req;
9247 }
9248
9249 static void dcerpc_spoolss_EnumPrintProcDataTypes_r_done(struct tevent_req *subreq)
9250 {
9251         struct tevent_req *req =
9252                 tevent_req_callback_data(subreq,
9253                 struct tevent_req);
9254         NTSTATUS status;
9255
9256         status = dcerpc_binding_handle_call_recv(subreq);
9257         if (!NT_STATUS_IS_OK(status)) {
9258                 tevent_req_nterror(req, status);
9259                 return;
9260         }
9261
9262         tevent_req_done(req);
9263 }
9264
9265 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9266 {
9267         struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state *state =
9268                 tevent_req_data(req,
9269                 struct dcerpc_spoolss_EnumPrintProcDataTypes_r_state);
9270         NTSTATUS status;
9271
9272         if (tevent_req_is_nterror(req, &status)) {
9273                 tevent_req_received(req);
9274                 return status;
9275         }
9276
9277         talloc_steal(mem_ctx, state->out_mem_ctx);
9278
9279         tevent_req_received(req);
9280         return NT_STATUS_OK;
9281 }
9282
9283 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrintProcDataTypes *r)
9284 {
9285         NTSTATUS status;
9286
9287         status = dcerpc_binding_handle_call(h,
9288                         NULL, &ndr_table_spoolss,
9289                         NDR_SPOOLSS_ENUMPRINTPROCDATATYPES, mem_ctx, r);
9290
9291         return status;
9292 }
9293
9294 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrintProcDataTypes *r)
9295 {
9296         NTSTATUS status;
9297
9298         status = dcerpc_spoolss_EnumPrintProcDataTypes_r(p->binding_handle, mem_ctx, r);
9299
9300         if (NT_STATUS_IS_RPC(status)) {
9301                 status = NT_STATUS_NET_WRITE_FAULT;
9302         }
9303
9304         return status;
9305 }
9306
9307 struct dcerpc_spoolss_EnumPrintProcDataTypes_state {
9308         struct spoolss_EnumPrintProcDataTypes orig;
9309         struct spoolss_EnumPrintProcDataTypes tmp;
9310         TALLOC_CTX *out_mem_ctx;
9311 };
9312
9313 static void dcerpc_spoolss_EnumPrintProcDataTypes_done(struct tevent_req *subreq);
9314
9315 struct tevent_req *dcerpc_spoolss_EnumPrintProcDataTypes_send(TALLOC_CTX *mem_ctx,
9316                                                               struct tevent_context *ev,
9317                                                               struct dcerpc_binding_handle *h,
9318                                                               const char *_servername /* [in] [unique,charset(UTF16)] */,
9319                                                               const char *_print_processor_name /* [in] [unique,charset(UTF16)] */,
9320                                                               uint32_t _level /* [in]  */,
9321                                                               DATA_BLOB *_buffer /* [in] [unique] */,
9322                                                               uint32_t _offered /* [in]  */,
9323                                                               uint32_t *_count /* [out] [ref] */,
9324                                                               union spoolss_PrintProcDataTypesInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
9325                                                               uint32_t *_needed /* [out] [ref] */)
9326 {
9327         struct tevent_req *req;
9328         struct dcerpc_spoolss_EnumPrintProcDataTypes_state *state;
9329         struct tevent_req *subreq;
9330
9331         req = tevent_req_create(mem_ctx, &state,
9332                                 struct dcerpc_spoolss_EnumPrintProcDataTypes_state);
9333         if (req == NULL) {
9334                 return NULL;
9335         }
9336         state->out_mem_ctx = NULL;
9337
9338         /* In parameters */
9339         state->orig.in.servername = _servername;
9340         state->orig.in.print_processor_name = _print_processor_name;
9341         state->orig.in.level = _level;
9342         state->orig.in.buffer = _buffer;
9343         state->orig.in.offered = _offered;
9344
9345         /* Out parameters */
9346         state->orig.out.count = _count;
9347         state->orig.out.info = _info;
9348         state->orig.out.needed = _needed;
9349
9350         /* Result */
9351         ZERO_STRUCT(state->orig.out.result);
9352
9353         state->out_mem_ctx = talloc_named_const(state, 0,
9354                              "dcerpc_spoolss_EnumPrintProcDataTypes_out_memory");
9355         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9356                 return tevent_req_post(req, ev);
9357         }
9358
9359         /* make a temporary copy, that we pass to the dispatch function */
9360         state->tmp = state->orig;
9361
9362         subreq = dcerpc_spoolss_EnumPrintProcDataTypes_r_send(state, ev, h, &state->tmp);
9363         if (tevent_req_nomem(subreq, req)) {
9364                 return tevent_req_post(req, ev);
9365         }
9366         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrintProcDataTypes_done, req);
9367         return req;
9368 }
9369
9370 static void dcerpc_spoolss_EnumPrintProcDataTypes_done(struct tevent_req *subreq)
9371 {
9372         struct tevent_req *req = tevent_req_callback_data(
9373                 subreq, struct tevent_req);
9374         struct dcerpc_spoolss_EnumPrintProcDataTypes_state *state = tevent_req_data(
9375                 req, struct dcerpc_spoolss_EnumPrintProcDataTypes_state);
9376         NTSTATUS status;
9377         TALLOC_CTX *mem_ctx;
9378
9379         if (state->out_mem_ctx) {
9380                 mem_ctx = state->out_mem_ctx;
9381         } else {
9382                 mem_ctx = state;
9383         }
9384
9385         status = dcerpc_spoolss_EnumPrintProcDataTypes_r_recv(subreq, mem_ctx);
9386         TALLOC_FREE(subreq);
9387         if (!NT_STATUS_IS_OK(status)) {
9388                 tevent_req_nterror(req, status);
9389                 return;
9390         }
9391
9392         /* Copy out parameters */
9393         *state->orig.out.count = *state->tmp.out.count;
9394         *state->orig.out.info = *state->tmp.out.info;
9395         *state->orig.out.needed = *state->tmp.out.needed;
9396
9397         /* Copy result */
9398         state->orig.out.result = state->tmp.out.result;
9399
9400         /* Reset temporary structure */
9401         ZERO_STRUCT(state->tmp);
9402
9403         tevent_req_done(req);
9404 }
9405
9406 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes_recv(struct tevent_req *req,
9407                                                     TALLOC_CTX *mem_ctx,
9408                                                     WERROR *result)
9409 {
9410         struct dcerpc_spoolss_EnumPrintProcDataTypes_state *state = tevent_req_data(
9411                 req, struct dcerpc_spoolss_EnumPrintProcDataTypes_state);
9412         NTSTATUS status;
9413
9414         if (tevent_req_is_nterror(req, &status)) {
9415                 tevent_req_received(req);
9416                 return status;
9417         }
9418
9419         /* Steal possible out parameters to the callers context */
9420         talloc_steal(mem_ctx, state->out_mem_ctx);
9421
9422         /* Return result */
9423         *result = state->orig.out.result;
9424
9425         tevent_req_received(req);
9426         return NT_STATUS_OK;
9427 }
9428
9429 NTSTATUS dcerpc_spoolss_EnumPrintProcDataTypes(struct dcerpc_binding_handle *h,
9430                                                TALLOC_CTX *mem_ctx,
9431                                                const char *_servername /* [in] [unique,charset(UTF16)] */,
9432                                                const char *_print_processor_name /* [in] [unique,charset(UTF16)] */,
9433                                                uint32_t _level /* [in]  */,
9434                                                DATA_BLOB *_buffer /* [in] [unique] */,
9435                                                uint32_t _offered /* [in]  */,
9436                                                uint32_t *_count /* [out] [ref] */,
9437                                                union spoolss_PrintProcDataTypesInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
9438                                                uint32_t *_needed /* [out] [ref] */,
9439                                                WERROR *result)
9440 {
9441         struct spoolss_EnumPrintProcDataTypes r;
9442         NTSTATUS status;
9443
9444         /* In parameters */
9445         r.in.servername = _servername;
9446         r.in.print_processor_name = _print_processor_name;
9447         r.in.level = _level;
9448         r.in.buffer = _buffer;
9449         r.in.offered = _offered;
9450
9451         status = dcerpc_spoolss_EnumPrintProcDataTypes_r(h, mem_ctx, &r);
9452         if (!NT_STATUS_IS_OK(status)) {
9453                 return status;
9454         }
9455
9456         /* Return variables */
9457         *_count = *r.out.count;
9458         *_info = *r.out.info;
9459         *_needed = *r.out.needed;
9460
9461         /* Return result */
9462         *result = r.out.result;
9463
9464         return NT_STATUS_OK;
9465 }
9466
9467 struct dcerpc_spoolss_ResetPrinter_r_state {
9468         TALLOC_CTX *out_mem_ctx;
9469 };
9470
9471 static void dcerpc_spoolss_ResetPrinter_r_done(struct tevent_req *subreq);
9472
9473 struct tevent_req *dcerpc_spoolss_ResetPrinter_r_send(TALLOC_CTX *mem_ctx,
9474         struct tevent_context *ev,
9475         struct dcerpc_binding_handle *h,
9476         struct spoolss_ResetPrinter *r)
9477 {
9478         struct tevent_req *req;
9479         struct dcerpc_spoolss_ResetPrinter_r_state *state;
9480         struct tevent_req *subreq;
9481
9482         req = tevent_req_create(mem_ctx, &state,
9483                                 struct dcerpc_spoolss_ResetPrinter_r_state);
9484         if (req == NULL) {
9485                 return NULL;
9486         }
9487
9488         state->out_mem_ctx = NULL;
9489         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9490                         NULL, &ndr_table_spoolss,
9491                         NDR_SPOOLSS_RESETPRINTER, state, r);
9492         if (tevent_req_nomem(subreq, req)) {
9493                 return tevent_req_post(req, ev);
9494         }
9495         tevent_req_set_callback(subreq, dcerpc_spoolss_ResetPrinter_r_done, req);
9496
9497         return req;
9498 }
9499
9500 static void dcerpc_spoolss_ResetPrinter_r_done(struct tevent_req *subreq)
9501 {
9502         struct tevent_req *req =
9503                 tevent_req_callback_data(subreq,
9504                 struct tevent_req);
9505         NTSTATUS status;
9506
9507         status = dcerpc_binding_handle_call_recv(subreq);
9508         if (!NT_STATUS_IS_OK(status)) {
9509                 tevent_req_nterror(req, status);
9510                 return;
9511         }
9512
9513         tevent_req_done(req);
9514 }
9515
9516 NTSTATUS dcerpc_spoolss_ResetPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9517 {
9518         struct dcerpc_spoolss_ResetPrinter_r_state *state =
9519                 tevent_req_data(req,
9520                 struct dcerpc_spoolss_ResetPrinter_r_state);
9521         NTSTATUS status;
9522
9523         if (tevent_req_is_nterror(req, &status)) {
9524                 tevent_req_received(req);
9525                 return status;
9526         }
9527
9528         talloc_steal(mem_ctx, state->out_mem_ctx);
9529
9530         tevent_req_received(req);
9531         return NT_STATUS_OK;
9532 }
9533
9534 NTSTATUS dcerpc_spoolss_ResetPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ResetPrinter *r)
9535 {
9536         NTSTATUS status;
9537
9538         status = dcerpc_binding_handle_call(h,
9539                         NULL, &ndr_table_spoolss,
9540                         NDR_SPOOLSS_RESETPRINTER, mem_ctx, r);
9541
9542         return status;
9543 }
9544
9545 NTSTATUS dcerpc_spoolss_ResetPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ResetPrinter *r)
9546 {
9547         NTSTATUS status;
9548
9549         status = dcerpc_spoolss_ResetPrinter_r(p->binding_handle, mem_ctx, r);
9550
9551         if (NT_STATUS_IS_RPC(status)) {
9552                 status = NT_STATUS_NET_WRITE_FAULT;
9553         }
9554
9555         return status;
9556 }
9557
9558 struct dcerpc_spoolss_ResetPrinter_state {
9559         struct spoolss_ResetPrinter orig;
9560         struct spoolss_ResetPrinter tmp;
9561         TALLOC_CTX *out_mem_ctx;
9562 };
9563
9564 static void dcerpc_spoolss_ResetPrinter_done(struct tevent_req *subreq);
9565
9566 struct tevent_req *dcerpc_spoolss_ResetPrinter_send(TALLOC_CTX *mem_ctx,
9567                                                     struct tevent_context *ev,
9568                                                     struct dcerpc_binding_handle *h,
9569                                                     struct policy_handle *_handle /* [in] [ref] */,
9570                                                     const char *_data_type /* [in] [unique,charset(UTF16)] */,
9571                                                     struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */)
9572 {
9573         struct tevent_req *req;
9574         struct dcerpc_spoolss_ResetPrinter_state *state;
9575         struct tevent_req *subreq;
9576
9577         req = tevent_req_create(mem_ctx, &state,
9578                                 struct dcerpc_spoolss_ResetPrinter_state);
9579         if (req == NULL) {
9580                 return NULL;
9581         }
9582         state->out_mem_ctx = NULL;
9583
9584         /* In parameters */
9585         state->orig.in.handle = _handle;
9586         state->orig.in.data_type = _data_type;
9587         state->orig.in.devmode_ctr = _devmode_ctr;
9588
9589         /* Out parameters */
9590
9591         /* Result */
9592         ZERO_STRUCT(state->orig.out.result);
9593
9594         /* make a temporary copy, that we pass to the dispatch function */
9595         state->tmp = state->orig;
9596
9597         subreq = dcerpc_spoolss_ResetPrinter_r_send(state, ev, h, &state->tmp);
9598         if (tevent_req_nomem(subreq, req)) {
9599                 return tevent_req_post(req, ev);
9600         }
9601         tevent_req_set_callback(subreq, dcerpc_spoolss_ResetPrinter_done, req);
9602         return req;
9603 }
9604
9605 static void dcerpc_spoolss_ResetPrinter_done(struct tevent_req *subreq)
9606 {
9607         struct tevent_req *req = tevent_req_callback_data(
9608                 subreq, struct tevent_req);
9609         struct dcerpc_spoolss_ResetPrinter_state *state = tevent_req_data(
9610                 req, struct dcerpc_spoolss_ResetPrinter_state);
9611         NTSTATUS status;
9612         TALLOC_CTX *mem_ctx;
9613
9614         if (state->out_mem_ctx) {
9615                 mem_ctx = state->out_mem_ctx;
9616         } else {
9617                 mem_ctx = state;
9618         }
9619
9620         status = dcerpc_spoolss_ResetPrinter_r_recv(subreq, mem_ctx);
9621         TALLOC_FREE(subreq);
9622         if (!NT_STATUS_IS_OK(status)) {
9623                 tevent_req_nterror(req, status);
9624                 return;
9625         }
9626
9627         /* Copy out parameters */
9628
9629         /* Copy result */
9630         state->orig.out.result = state->tmp.out.result;
9631
9632         /* Reset temporary structure */
9633         ZERO_STRUCT(state->tmp);
9634
9635         tevent_req_done(req);
9636 }
9637
9638 NTSTATUS dcerpc_spoolss_ResetPrinter_recv(struct tevent_req *req,
9639                                           TALLOC_CTX *mem_ctx,
9640                                           WERROR *result)
9641 {
9642         struct dcerpc_spoolss_ResetPrinter_state *state = tevent_req_data(
9643                 req, struct dcerpc_spoolss_ResetPrinter_state);
9644         NTSTATUS status;
9645
9646         if (tevent_req_is_nterror(req, &status)) {
9647                 tevent_req_received(req);
9648                 return status;
9649         }
9650
9651         /* Steal possible out parameters to the callers context */
9652         talloc_steal(mem_ctx, state->out_mem_ctx);
9653
9654         /* Return result */
9655         *result = state->orig.out.result;
9656
9657         tevent_req_received(req);
9658         return NT_STATUS_OK;
9659 }
9660
9661 NTSTATUS dcerpc_spoolss_ResetPrinter(struct dcerpc_binding_handle *h,
9662                                      TALLOC_CTX *mem_ctx,
9663                                      struct policy_handle *_handle /* [in] [ref] */,
9664                                      const char *_data_type /* [in] [unique,charset(UTF16)] */,
9665                                      struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
9666                                      WERROR *result)
9667 {
9668         struct spoolss_ResetPrinter r;
9669         NTSTATUS status;
9670
9671         /* In parameters */
9672         r.in.handle = _handle;
9673         r.in.data_type = _data_type;
9674         r.in.devmode_ctr = _devmode_ctr;
9675
9676         status = dcerpc_spoolss_ResetPrinter_r(h, mem_ctx, &r);
9677         if (!NT_STATUS_IS_OK(status)) {
9678                 return status;
9679         }
9680
9681         /* Return variables */
9682
9683         /* Return result */
9684         *result = r.out.result;
9685
9686         return NT_STATUS_OK;
9687 }
9688
9689 struct dcerpc_spoolss_GetPrinterDriver2_r_state {
9690         TALLOC_CTX *out_mem_ctx;
9691 };
9692
9693 static void dcerpc_spoolss_GetPrinterDriver2_r_done(struct tevent_req *subreq);
9694
9695 struct tevent_req *dcerpc_spoolss_GetPrinterDriver2_r_send(TALLOC_CTX *mem_ctx,
9696         struct tevent_context *ev,
9697         struct dcerpc_binding_handle *h,
9698         struct spoolss_GetPrinterDriver2 *r)
9699 {
9700         struct tevent_req *req;
9701         struct dcerpc_spoolss_GetPrinterDriver2_r_state *state;
9702         struct tevent_req *subreq;
9703
9704         req = tevent_req_create(mem_ctx, &state,
9705                                 struct dcerpc_spoolss_GetPrinterDriver2_r_state);
9706         if (req == NULL) {
9707                 return NULL;
9708         }
9709
9710         state->out_mem_ctx = talloc_new(state);
9711         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9712                 return tevent_req_post(req, ev);
9713         }
9714
9715         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9716                         NULL, &ndr_table_spoolss,
9717                         NDR_SPOOLSS_GETPRINTERDRIVER2, state->out_mem_ctx, r);
9718         if (tevent_req_nomem(subreq, req)) {
9719                 return tevent_req_post(req, ev);
9720         }
9721         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriver2_r_done, req);
9722
9723         return req;
9724 }
9725
9726 static void dcerpc_spoolss_GetPrinterDriver2_r_done(struct tevent_req *subreq)
9727 {
9728         struct tevent_req *req =
9729                 tevent_req_callback_data(subreq,
9730                 struct tevent_req);
9731         NTSTATUS status;
9732
9733         status = dcerpc_binding_handle_call_recv(subreq);
9734         if (!NT_STATUS_IS_OK(status)) {
9735                 tevent_req_nterror(req, status);
9736                 return;
9737         }
9738
9739         tevent_req_done(req);
9740 }
9741
9742 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
9743 {
9744         struct dcerpc_spoolss_GetPrinterDriver2_r_state *state =
9745                 tevent_req_data(req,
9746                 struct dcerpc_spoolss_GetPrinterDriver2_r_state);
9747         NTSTATUS status;
9748
9749         if (tevent_req_is_nterror(req, &status)) {
9750                 tevent_req_received(req);
9751                 return status;
9752         }
9753
9754         talloc_steal(mem_ctx, state->out_mem_ctx);
9755
9756         tevent_req_received(req);
9757         return NT_STATUS_OK;
9758 }
9759
9760 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriver2 *r)
9761 {
9762         NTSTATUS status;
9763
9764         status = dcerpc_binding_handle_call(h,
9765                         NULL, &ndr_table_spoolss,
9766                         NDR_SPOOLSS_GETPRINTERDRIVER2, mem_ctx, r);
9767
9768         return status;
9769 }
9770
9771 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriver2 *r)
9772 {
9773         NTSTATUS status;
9774
9775         status = dcerpc_spoolss_GetPrinterDriver2_r(p->binding_handle, mem_ctx, r);
9776
9777         if (NT_STATUS_IS_RPC(status)) {
9778                 status = NT_STATUS_NET_WRITE_FAULT;
9779         }
9780
9781         return status;
9782 }
9783
9784 struct dcerpc_spoolss_GetPrinterDriver2_state {
9785         struct spoolss_GetPrinterDriver2 orig;
9786         struct spoolss_GetPrinterDriver2 tmp;
9787         TALLOC_CTX *out_mem_ctx;
9788 };
9789
9790 static void dcerpc_spoolss_GetPrinterDriver2_done(struct tevent_req *subreq);
9791
9792 struct tevent_req *dcerpc_spoolss_GetPrinterDriver2_send(TALLOC_CTX *mem_ctx,
9793                                                          struct tevent_context *ev,
9794                                                          struct dcerpc_binding_handle *h,
9795                                                          struct policy_handle *_handle /* [in] [ref] */,
9796                                                          const char *_architecture /* [in] [unique,charset(UTF16)] */,
9797                                                          uint32_t _level /* [in]  */,
9798                                                          DATA_BLOB *_buffer /* [in] [unique] */,
9799                                                          uint32_t _offered /* [in]  */,
9800                                                          uint32_t _client_major_version /* [in]  */,
9801                                                          uint32_t _client_minor_version /* [in]  */,
9802                                                          union spoolss_DriverInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
9803                                                          uint32_t *_needed /* [out] [ref] */,
9804                                                          uint32_t *_server_major_version /* [out] [ref] */,
9805                                                          uint32_t *_server_minor_version /* [out] [ref] */)
9806 {
9807         struct tevent_req *req;
9808         struct dcerpc_spoolss_GetPrinterDriver2_state *state;
9809         struct tevent_req *subreq;
9810
9811         req = tevent_req_create(mem_ctx, &state,
9812                                 struct dcerpc_spoolss_GetPrinterDriver2_state);
9813         if (req == NULL) {
9814                 return NULL;
9815         }
9816         state->out_mem_ctx = NULL;
9817
9818         /* In parameters */
9819         state->orig.in.handle = _handle;
9820         state->orig.in.architecture = _architecture;
9821         state->orig.in.level = _level;
9822         state->orig.in.buffer = _buffer;
9823         state->orig.in.offered = _offered;
9824         state->orig.in.client_major_version = _client_major_version;
9825         state->orig.in.client_minor_version = _client_minor_version;
9826
9827         /* Out parameters */
9828         state->orig.out.info = _info;
9829         state->orig.out.needed = _needed;
9830         state->orig.out.server_major_version = _server_major_version;
9831         state->orig.out.server_minor_version = _server_minor_version;
9832
9833         /* Result */
9834         ZERO_STRUCT(state->orig.out.result);
9835
9836         state->out_mem_ctx = talloc_named_const(state, 0,
9837                              "dcerpc_spoolss_GetPrinterDriver2_out_memory");
9838         if (tevent_req_nomem(state->out_mem_ctx, req)) {
9839                 return tevent_req_post(req, ev);
9840         }
9841
9842         /* make a temporary copy, that we pass to the dispatch function */
9843         state->tmp = state->orig;
9844
9845         subreq = dcerpc_spoolss_GetPrinterDriver2_r_send(state, ev, h, &state->tmp);
9846         if (tevent_req_nomem(subreq, req)) {
9847                 return tevent_req_post(req, ev);
9848         }
9849         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriver2_done, req);
9850         return req;
9851 }
9852
9853 static void dcerpc_spoolss_GetPrinterDriver2_done(struct tevent_req *subreq)
9854 {
9855         struct tevent_req *req = tevent_req_callback_data(
9856                 subreq, struct tevent_req);
9857         struct dcerpc_spoolss_GetPrinterDriver2_state *state = tevent_req_data(
9858                 req, struct dcerpc_spoolss_GetPrinterDriver2_state);
9859         NTSTATUS status;
9860         TALLOC_CTX *mem_ctx;
9861
9862         if (state->out_mem_ctx) {
9863                 mem_ctx = state->out_mem_ctx;
9864         } else {
9865                 mem_ctx = state;
9866         }
9867
9868         status = dcerpc_spoolss_GetPrinterDriver2_r_recv(subreq, mem_ctx);
9869         TALLOC_FREE(subreq);
9870         if (!NT_STATUS_IS_OK(status)) {
9871                 tevent_req_nterror(req, status);
9872                 return;
9873         }
9874
9875         /* Copy out parameters */
9876         if (state->orig.out.info && state->tmp.out.info) {
9877                 *state->orig.out.info = *state->tmp.out.info;
9878         }
9879         *state->orig.out.needed = *state->tmp.out.needed;
9880         *state->orig.out.server_major_version = *state->tmp.out.server_major_version;
9881         *state->orig.out.server_minor_version = *state->tmp.out.server_minor_version;
9882
9883         /* Copy result */
9884         state->orig.out.result = state->tmp.out.result;
9885
9886         /* Reset temporary structure */
9887         ZERO_STRUCT(state->tmp);
9888
9889         tevent_req_done(req);
9890 }
9891
9892 NTSTATUS dcerpc_spoolss_GetPrinterDriver2_recv(struct tevent_req *req,
9893                                                TALLOC_CTX *mem_ctx,
9894                                                WERROR *result)
9895 {
9896         struct dcerpc_spoolss_GetPrinterDriver2_state *state = tevent_req_data(
9897                 req, struct dcerpc_spoolss_GetPrinterDriver2_state);
9898         NTSTATUS status;
9899
9900         if (tevent_req_is_nterror(req, &status)) {
9901                 tevent_req_received(req);
9902                 return status;
9903         }
9904
9905         /* Steal possible out parameters to the callers context */
9906         talloc_steal(mem_ctx, state->out_mem_ctx);
9907
9908         /* Return result */
9909         *result = state->orig.out.result;
9910
9911         tevent_req_received(req);
9912         return NT_STATUS_OK;
9913 }
9914
9915 NTSTATUS dcerpc_spoolss_GetPrinterDriver2(struct dcerpc_binding_handle *h,
9916                                           TALLOC_CTX *mem_ctx,
9917                                           struct policy_handle *_handle /* [in] [ref] */,
9918                                           const char *_architecture /* [in] [unique,charset(UTF16)] */,
9919                                           uint32_t _level /* [in]  */,
9920                                           DATA_BLOB *_buffer /* [in] [unique] */,
9921                                           uint32_t _offered /* [in]  */,
9922                                           uint32_t _client_major_version /* [in]  */,
9923                                           uint32_t _client_minor_version /* [in]  */,
9924                                           union spoolss_DriverInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
9925                                           uint32_t *_needed /* [out] [ref] */,
9926                                           uint32_t *_server_major_version /* [out] [ref] */,
9927                                           uint32_t *_server_minor_version /* [out] [ref] */,
9928                                           WERROR *result)
9929 {
9930         struct spoolss_GetPrinterDriver2 r;
9931         NTSTATUS status;
9932
9933         /* In parameters */
9934         r.in.handle = _handle;
9935         r.in.architecture = _architecture;
9936         r.in.level = _level;
9937         r.in.buffer = _buffer;
9938         r.in.offered = _offered;
9939         r.in.client_major_version = _client_major_version;
9940         r.in.client_minor_version = _client_minor_version;
9941
9942         status = dcerpc_spoolss_GetPrinterDriver2_r(h, mem_ctx, &r);
9943         if (!NT_STATUS_IS_OK(status)) {
9944                 return status;
9945         }
9946
9947         /* Return variables */
9948         if (_info && r.out.info) {
9949                 *_info = *r.out.info;
9950         }
9951         *_needed = *r.out.needed;
9952         *_server_major_version = *r.out.server_major_version;
9953         *_server_minor_version = *r.out.server_minor_version;
9954
9955         /* Return result */
9956         *result = r.out.result;
9957
9958         return NT_STATUS_OK;
9959 }
9960
9961 struct dcerpc_spoolss_FindClosePrinterNotify_r_state {
9962         TALLOC_CTX *out_mem_ctx;
9963 };
9964
9965 static void dcerpc_spoolss_FindClosePrinterNotify_r_done(struct tevent_req *subreq);
9966
9967 struct tevent_req *dcerpc_spoolss_FindClosePrinterNotify_r_send(TALLOC_CTX *mem_ctx,
9968         struct tevent_context *ev,
9969         struct dcerpc_binding_handle *h,
9970         struct spoolss_FindClosePrinterNotify *r)
9971 {
9972         struct tevent_req *req;
9973         struct dcerpc_spoolss_FindClosePrinterNotify_r_state *state;
9974         struct tevent_req *subreq;
9975
9976         req = tevent_req_create(mem_ctx, &state,
9977                                 struct dcerpc_spoolss_FindClosePrinterNotify_r_state);
9978         if (req == NULL) {
9979                 return NULL;
9980         }
9981
9982         state->out_mem_ctx = NULL;
9983         subreq = dcerpc_binding_handle_call_send(state, ev, h,
9984                         NULL, &ndr_table_spoolss,
9985                         NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY, state, r);
9986         if (tevent_req_nomem(subreq, req)) {
9987                 return tevent_req_post(req, ev);
9988         }
9989         tevent_req_set_callback(subreq, dcerpc_spoolss_FindClosePrinterNotify_r_done, req);
9990
9991         return req;
9992 }
9993
9994 static void dcerpc_spoolss_FindClosePrinterNotify_r_done(struct tevent_req *subreq)
9995 {
9996         struct tevent_req *req =
9997                 tevent_req_callback_data(subreq,
9998                 struct tevent_req);
9999         NTSTATUS status;
10000
10001         status = dcerpc_binding_handle_call_recv(subreq);
10002         if (!NT_STATUS_IS_OK(status)) {
10003                 tevent_req_nterror(req, status);
10004                 return;
10005         }
10006
10007         tevent_req_done(req);
10008 }
10009
10010 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10011 {
10012         struct dcerpc_spoolss_FindClosePrinterNotify_r_state *state =
10013                 tevent_req_data(req,
10014                 struct dcerpc_spoolss_FindClosePrinterNotify_r_state);
10015         NTSTATUS status;
10016
10017         if (tevent_req_is_nterror(req, &status)) {
10018                 tevent_req_received(req);
10019                 return status;
10020         }
10021
10022         talloc_steal(mem_ctx, state->out_mem_ctx);
10023
10024         tevent_req_received(req);
10025         return NT_STATUS_OK;
10026 }
10027
10028 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_FindClosePrinterNotify *r)
10029 {
10030         NTSTATUS status;
10031
10032         status = dcerpc_binding_handle_call(h,
10033                         NULL, &ndr_table_spoolss,
10034                         NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY, mem_ctx, r);
10035
10036         return status;
10037 }
10038
10039 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_FindClosePrinterNotify *r)
10040 {
10041         NTSTATUS status;
10042
10043         status = dcerpc_spoolss_FindClosePrinterNotify_r(p->binding_handle, mem_ctx, r);
10044
10045         if (NT_STATUS_IS_RPC(status)) {
10046                 status = NT_STATUS_NET_WRITE_FAULT;
10047         }
10048
10049         return status;
10050 }
10051
10052 struct dcerpc_spoolss_FindClosePrinterNotify_state {
10053         struct spoolss_FindClosePrinterNotify orig;
10054         struct spoolss_FindClosePrinterNotify tmp;
10055         TALLOC_CTX *out_mem_ctx;
10056 };
10057
10058 static void dcerpc_spoolss_FindClosePrinterNotify_done(struct tevent_req *subreq);
10059
10060 struct tevent_req *dcerpc_spoolss_FindClosePrinterNotify_send(TALLOC_CTX *mem_ctx,
10061                                                               struct tevent_context *ev,
10062                                                               struct dcerpc_binding_handle *h,
10063                                                               struct policy_handle *_handle /* [in] [ref] */)
10064 {
10065         struct tevent_req *req;
10066         struct dcerpc_spoolss_FindClosePrinterNotify_state *state;
10067         struct tevent_req *subreq;
10068
10069         req = tevent_req_create(mem_ctx, &state,
10070                                 struct dcerpc_spoolss_FindClosePrinterNotify_state);
10071         if (req == NULL) {
10072                 return NULL;
10073         }
10074         state->out_mem_ctx = NULL;
10075
10076         /* In parameters */
10077         state->orig.in.handle = _handle;
10078
10079         /* Out parameters */
10080
10081         /* Result */
10082         ZERO_STRUCT(state->orig.out.result);
10083
10084         /* make a temporary copy, that we pass to the dispatch function */
10085         state->tmp = state->orig;
10086
10087         subreq = dcerpc_spoolss_FindClosePrinterNotify_r_send(state, ev, h, &state->tmp);
10088         if (tevent_req_nomem(subreq, req)) {
10089                 return tevent_req_post(req, ev);
10090         }
10091         tevent_req_set_callback(subreq, dcerpc_spoolss_FindClosePrinterNotify_done, req);
10092         return req;
10093 }
10094
10095 static void dcerpc_spoolss_FindClosePrinterNotify_done(struct tevent_req *subreq)
10096 {
10097         struct tevent_req *req = tevent_req_callback_data(
10098                 subreq, struct tevent_req);
10099         struct dcerpc_spoolss_FindClosePrinterNotify_state *state = tevent_req_data(
10100                 req, struct dcerpc_spoolss_FindClosePrinterNotify_state);
10101         NTSTATUS status;
10102         TALLOC_CTX *mem_ctx;
10103
10104         if (state->out_mem_ctx) {
10105                 mem_ctx = state->out_mem_ctx;
10106         } else {
10107                 mem_ctx = state;
10108         }
10109
10110         status = dcerpc_spoolss_FindClosePrinterNotify_r_recv(subreq, mem_ctx);
10111         TALLOC_FREE(subreq);
10112         if (!NT_STATUS_IS_OK(status)) {
10113                 tevent_req_nterror(req, status);
10114                 return;
10115         }
10116
10117         /* Copy out parameters */
10118
10119         /* Copy result */
10120         state->orig.out.result = state->tmp.out.result;
10121
10122         /* Reset temporary structure */
10123         ZERO_STRUCT(state->tmp);
10124
10125         tevent_req_done(req);
10126 }
10127
10128 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify_recv(struct tevent_req *req,
10129                                                     TALLOC_CTX *mem_ctx,
10130                                                     WERROR *result)
10131 {
10132         struct dcerpc_spoolss_FindClosePrinterNotify_state *state = tevent_req_data(
10133                 req, struct dcerpc_spoolss_FindClosePrinterNotify_state);
10134         NTSTATUS status;
10135
10136         if (tevent_req_is_nterror(req, &status)) {
10137                 tevent_req_received(req);
10138                 return status;
10139         }
10140
10141         /* Steal possible out parameters to the callers context */
10142         talloc_steal(mem_ctx, state->out_mem_ctx);
10143
10144         /* Return result */
10145         *result = state->orig.out.result;
10146
10147         tevent_req_received(req);
10148         return NT_STATUS_OK;
10149 }
10150
10151 NTSTATUS dcerpc_spoolss_FindClosePrinterNotify(struct dcerpc_binding_handle *h,
10152                                                TALLOC_CTX *mem_ctx,
10153                                                struct policy_handle *_handle /* [in] [ref] */,
10154                                                WERROR *result)
10155 {
10156         struct spoolss_FindClosePrinterNotify r;
10157         NTSTATUS status;
10158
10159         /* In parameters */
10160         r.in.handle = _handle;
10161
10162         status = dcerpc_spoolss_FindClosePrinterNotify_r(h, mem_ctx, &r);
10163         if (!NT_STATUS_IS_OK(status)) {
10164                 return status;
10165         }
10166
10167         /* Return variables */
10168
10169         /* Return result */
10170         *result = r.out.result;
10171
10172         return NT_STATUS_OK;
10173 }
10174
10175 struct dcerpc_spoolss_ReplyOpenPrinter_r_state {
10176         TALLOC_CTX *out_mem_ctx;
10177 };
10178
10179 static void dcerpc_spoolss_ReplyOpenPrinter_r_done(struct tevent_req *subreq);
10180
10181 struct tevent_req *dcerpc_spoolss_ReplyOpenPrinter_r_send(TALLOC_CTX *mem_ctx,
10182         struct tevent_context *ev,
10183         struct dcerpc_binding_handle *h,
10184         struct spoolss_ReplyOpenPrinter *r)
10185 {
10186         struct tevent_req *req;
10187         struct dcerpc_spoolss_ReplyOpenPrinter_r_state *state;
10188         struct tevent_req *subreq;
10189
10190         req = tevent_req_create(mem_ctx, &state,
10191                                 struct dcerpc_spoolss_ReplyOpenPrinter_r_state);
10192         if (req == NULL) {
10193                 return NULL;
10194         }
10195
10196         state->out_mem_ctx = talloc_new(state);
10197         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10198                 return tevent_req_post(req, ev);
10199         }
10200
10201         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10202                         NULL, &ndr_table_spoolss,
10203                         NDR_SPOOLSS_REPLYOPENPRINTER, state->out_mem_ctx, r);
10204         if (tevent_req_nomem(subreq, req)) {
10205                 return tevent_req_post(req, ev);
10206         }
10207         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyOpenPrinter_r_done, req);
10208
10209         return req;
10210 }
10211
10212 static void dcerpc_spoolss_ReplyOpenPrinter_r_done(struct tevent_req *subreq)
10213 {
10214         struct tevent_req *req =
10215                 tevent_req_callback_data(subreq,
10216                 struct tevent_req);
10217         NTSTATUS status;
10218
10219         status = dcerpc_binding_handle_call_recv(subreq);
10220         if (!NT_STATUS_IS_OK(status)) {
10221                 tevent_req_nterror(req, status);
10222                 return;
10223         }
10224
10225         tevent_req_done(req);
10226 }
10227
10228 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10229 {
10230         struct dcerpc_spoolss_ReplyOpenPrinter_r_state *state =
10231                 tevent_req_data(req,
10232                 struct dcerpc_spoolss_ReplyOpenPrinter_r_state);
10233         NTSTATUS status;
10234
10235         if (tevent_req_is_nterror(req, &status)) {
10236                 tevent_req_received(req);
10237                 return status;
10238         }
10239
10240         talloc_steal(mem_ctx, state->out_mem_ctx);
10241
10242         tevent_req_received(req);
10243         return NT_STATUS_OK;
10244 }
10245
10246 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ReplyOpenPrinter *r)
10247 {
10248         NTSTATUS status;
10249
10250         status = dcerpc_binding_handle_call(h,
10251                         NULL, &ndr_table_spoolss,
10252                         NDR_SPOOLSS_REPLYOPENPRINTER, mem_ctx, r);
10253
10254         return status;
10255 }
10256
10257 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ReplyOpenPrinter *r)
10258 {
10259         NTSTATUS status;
10260
10261         status = dcerpc_spoolss_ReplyOpenPrinter_r(p->binding_handle, mem_ctx, r);
10262
10263         if (NT_STATUS_IS_RPC(status)) {
10264                 status = NT_STATUS_NET_WRITE_FAULT;
10265         }
10266
10267         return status;
10268 }
10269
10270 struct dcerpc_spoolss_ReplyOpenPrinter_state {
10271         struct spoolss_ReplyOpenPrinter orig;
10272         struct spoolss_ReplyOpenPrinter tmp;
10273         TALLOC_CTX *out_mem_ctx;
10274 };
10275
10276 static void dcerpc_spoolss_ReplyOpenPrinter_done(struct tevent_req *subreq);
10277
10278 struct tevent_req *dcerpc_spoolss_ReplyOpenPrinter_send(TALLOC_CTX *mem_ctx,
10279                                                         struct tevent_context *ev,
10280                                                         struct dcerpc_binding_handle *h,
10281                                                         const char *_server_name /* [in] [charset(UTF16)] */,
10282                                                         uint32_t _printer_local /* [in]  */,
10283                                                         enum winreg_Type _type /* [in]  */,
10284                                                         uint32_t _bufsize /* [in] [range(0,512)] */,
10285                                                         uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */,
10286                                                         struct policy_handle *_handle /* [out] [ref] */)
10287 {
10288         struct tevent_req *req;
10289         struct dcerpc_spoolss_ReplyOpenPrinter_state *state;
10290         struct tevent_req *subreq;
10291
10292         req = tevent_req_create(mem_ctx, &state,
10293                                 struct dcerpc_spoolss_ReplyOpenPrinter_state);
10294         if (req == NULL) {
10295                 return NULL;
10296         }
10297         state->out_mem_ctx = NULL;
10298
10299         /* In parameters */
10300         state->orig.in.server_name = _server_name;
10301         state->orig.in.printer_local = _printer_local;
10302         state->orig.in.type = _type;
10303         state->orig.in.bufsize = _bufsize;
10304         state->orig.in.buffer = _buffer;
10305
10306         /* Out parameters */
10307         state->orig.out.handle = _handle;
10308
10309         /* Result */
10310         ZERO_STRUCT(state->orig.out.result);
10311
10312         state->out_mem_ctx = talloc_named_const(state, 0,
10313                              "dcerpc_spoolss_ReplyOpenPrinter_out_memory");
10314         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10315                 return tevent_req_post(req, ev);
10316         }
10317
10318         /* make a temporary copy, that we pass to the dispatch function */
10319         state->tmp = state->orig;
10320
10321         subreq = dcerpc_spoolss_ReplyOpenPrinter_r_send(state, ev, h, &state->tmp);
10322         if (tevent_req_nomem(subreq, req)) {
10323                 return tevent_req_post(req, ev);
10324         }
10325         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyOpenPrinter_done, req);
10326         return req;
10327 }
10328
10329 static void dcerpc_spoolss_ReplyOpenPrinter_done(struct tevent_req *subreq)
10330 {
10331         struct tevent_req *req = tevent_req_callback_data(
10332                 subreq, struct tevent_req);
10333         struct dcerpc_spoolss_ReplyOpenPrinter_state *state = tevent_req_data(
10334                 req, struct dcerpc_spoolss_ReplyOpenPrinter_state);
10335         NTSTATUS status;
10336         TALLOC_CTX *mem_ctx;
10337
10338         if (state->out_mem_ctx) {
10339                 mem_ctx = state->out_mem_ctx;
10340         } else {
10341                 mem_ctx = state;
10342         }
10343
10344         status = dcerpc_spoolss_ReplyOpenPrinter_r_recv(subreq, mem_ctx);
10345         TALLOC_FREE(subreq);
10346         if (!NT_STATUS_IS_OK(status)) {
10347                 tevent_req_nterror(req, status);
10348                 return;
10349         }
10350
10351         /* Copy out parameters */
10352         *state->orig.out.handle = *state->tmp.out.handle;
10353
10354         /* Copy result */
10355         state->orig.out.result = state->tmp.out.result;
10356
10357         /* Reset temporary structure */
10358         ZERO_STRUCT(state->tmp);
10359
10360         tevent_req_done(req);
10361 }
10362
10363 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter_recv(struct tevent_req *req,
10364                                               TALLOC_CTX *mem_ctx,
10365                                               WERROR *result)
10366 {
10367         struct dcerpc_spoolss_ReplyOpenPrinter_state *state = tevent_req_data(
10368                 req, struct dcerpc_spoolss_ReplyOpenPrinter_state);
10369         NTSTATUS status;
10370
10371         if (tevent_req_is_nterror(req, &status)) {
10372                 tevent_req_received(req);
10373                 return status;
10374         }
10375
10376         /* Steal possible out parameters to the callers context */
10377         talloc_steal(mem_ctx, state->out_mem_ctx);
10378
10379         /* Return result */
10380         *result = state->orig.out.result;
10381
10382         tevent_req_received(req);
10383         return NT_STATUS_OK;
10384 }
10385
10386 NTSTATUS dcerpc_spoolss_ReplyOpenPrinter(struct dcerpc_binding_handle *h,
10387                                          TALLOC_CTX *mem_ctx,
10388                                          const char *_server_name /* [in] [charset(UTF16)] */,
10389                                          uint32_t _printer_local /* [in]  */,
10390                                          enum winreg_Type _type /* [in]  */,
10391                                          uint32_t _bufsize /* [in] [range(0,512)] */,
10392                                          uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */,
10393                                          struct policy_handle *_handle /* [out] [ref] */,
10394                                          WERROR *result)
10395 {
10396         struct spoolss_ReplyOpenPrinter r;
10397         NTSTATUS status;
10398
10399         /* In parameters */
10400         r.in.server_name = _server_name;
10401         r.in.printer_local = _printer_local;
10402         r.in.type = _type;
10403         r.in.bufsize = _bufsize;
10404         r.in.buffer = _buffer;
10405
10406         status = dcerpc_spoolss_ReplyOpenPrinter_r(h, mem_ctx, &r);
10407         if (!NT_STATUS_IS_OK(status)) {
10408                 return status;
10409         }
10410
10411         /* Return variables */
10412         *_handle = *r.out.handle;
10413
10414         /* Return result */
10415         *result = r.out.result;
10416
10417         return NT_STATUS_OK;
10418 }
10419
10420 struct dcerpc_spoolss_RouterReplyPrinter_r_state {
10421         TALLOC_CTX *out_mem_ctx;
10422 };
10423
10424 static void dcerpc_spoolss_RouterReplyPrinter_r_done(struct tevent_req *subreq);
10425
10426 struct tevent_req *dcerpc_spoolss_RouterReplyPrinter_r_send(TALLOC_CTX *mem_ctx,
10427         struct tevent_context *ev,
10428         struct dcerpc_binding_handle *h,
10429         struct spoolss_RouterReplyPrinter *r)
10430 {
10431         struct tevent_req *req;
10432         struct dcerpc_spoolss_RouterReplyPrinter_r_state *state;
10433         struct tevent_req *subreq;
10434
10435         req = tevent_req_create(mem_ctx, &state,
10436                                 struct dcerpc_spoolss_RouterReplyPrinter_r_state);
10437         if (req == NULL) {
10438                 return NULL;
10439         }
10440
10441         state->out_mem_ctx = NULL;
10442         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10443                         NULL, &ndr_table_spoolss,
10444                         NDR_SPOOLSS_ROUTERREPLYPRINTER, state, r);
10445         if (tevent_req_nomem(subreq, req)) {
10446                 return tevent_req_post(req, ev);
10447         }
10448         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinter_r_done, req);
10449
10450         return req;
10451 }
10452
10453 static void dcerpc_spoolss_RouterReplyPrinter_r_done(struct tevent_req *subreq)
10454 {
10455         struct tevent_req *req =
10456                 tevent_req_callback_data(subreq,
10457                 struct tevent_req);
10458         NTSTATUS status;
10459
10460         status = dcerpc_binding_handle_call_recv(subreq);
10461         if (!NT_STATUS_IS_OK(status)) {
10462                 tevent_req_nterror(req, status);
10463                 return;
10464         }
10465
10466         tevent_req_done(req);
10467 }
10468
10469 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10470 {
10471         struct dcerpc_spoolss_RouterReplyPrinter_r_state *state =
10472                 tevent_req_data(req,
10473                 struct dcerpc_spoolss_RouterReplyPrinter_r_state);
10474         NTSTATUS status;
10475
10476         if (tevent_req_is_nterror(req, &status)) {
10477                 tevent_req_received(req);
10478                 return status;
10479         }
10480
10481         talloc_steal(mem_ctx, state->out_mem_ctx);
10482
10483         tevent_req_received(req);
10484         return NT_STATUS_OK;
10485 }
10486
10487 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinter *r)
10488 {
10489         NTSTATUS status;
10490
10491         status = dcerpc_binding_handle_call(h,
10492                         NULL, &ndr_table_spoolss,
10493                         NDR_SPOOLSS_ROUTERREPLYPRINTER, mem_ctx, r);
10494
10495         return status;
10496 }
10497
10498 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinter *r)
10499 {
10500         NTSTATUS status;
10501
10502         status = dcerpc_spoolss_RouterReplyPrinter_r(p->binding_handle, mem_ctx, r);
10503
10504         if (NT_STATUS_IS_RPC(status)) {
10505                 status = NT_STATUS_NET_WRITE_FAULT;
10506         }
10507
10508         return status;
10509 }
10510
10511 struct dcerpc_spoolss_RouterReplyPrinter_state {
10512         struct spoolss_RouterReplyPrinter orig;
10513         struct spoolss_RouterReplyPrinter tmp;
10514         TALLOC_CTX *out_mem_ctx;
10515 };
10516
10517 static void dcerpc_spoolss_RouterReplyPrinter_done(struct tevent_req *subreq);
10518
10519 struct tevent_req *dcerpc_spoolss_RouterReplyPrinter_send(TALLOC_CTX *mem_ctx,
10520                                                           struct tevent_context *ev,
10521                                                           struct dcerpc_binding_handle *h,
10522                                                           struct policy_handle *_handle /* [in] [ref] */,
10523                                                           uint32_t _flags /* [in]  */,
10524                                                           uint32_t _bufsize /* [in] [range(0,512)] */,
10525                                                           uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */)
10526 {
10527         struct tevent_req *req;
10528         struct dcerpc_spoolss_RouterReplyPrinter_state *state;
10529         struct tevent_req *subreq;
10530
10531         req = tevent_req_create(mem_ctx, &state,
10532                                 struct dcerpc_spoolss_RouterReplyPrinter_state);
10533         if (req == NULL) {
10534                 return NULL;
10535         }
10536         state->out_mem_ctx = NULL;
10537
10538         /* In parameters */
10539         state->orig.in.handle = _handle;
10540         state->orig.in.flags = _flags;
10541         state->orig.in.bufsize = _bufsize;
10542         state->orig.in.buffer = _buffer;
10543
10544         /* Out parameters */
10545
10546         /* Result */
10547         ZERO_STRUCT(state->orig.out.result);
10548
10549         /* make a temporary copy, that we pass to the dispatch function */
10550         state->tmp = state->orig;
10551
10552         subreq = dcerpc_spoolss_RouterReplyPrinter_r_send(state, ev, h, &state->tmp);
10553         if (tevent_req_nomem(subreq, req)) {
10554                 return tevent_req_post(req, ev);
10555         }
10556         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinter_done, req);
10557         return req;
10558 }
10559
10560 static void dcerpc_spoolss_RouterReplyPrinter_done(struct tevent_req *subreq)
10561 {
10562         struct tevent_req *req = tevent_req_callback_data(
10563                 subreq, struct tevent_req);
10564         struct dcerpc_spoolss_RouterReplyPrinter_state *state = tevent_req_data(
10565                 req, struct dcerpc_spoolss_RouterReplyPrinter_state);
10566         NTSTATUS status;
10567         TALLOC_CTX *mem_ctx;
10568
10569         if (state->out_mem_ctx) {
10570                 mem_ctx = state->out_mem_ctx;
10571         } else {
10572                 mem_ctx = state;
10573         }
10574
10575         status = dcerpc_spoolss_RouterReplyPrinter_r_recv(subreq, mem_ctx);
10576         TALLOC_FREE(subreq);
10577         if (!NT_STATUS_IS_OK(status)) {
10578                 tevent_req_nterror(req, status);
10579                 return;
10580         }
10581
10582         /* Copy out parameters */
10583
10584         /* Copy result */
10585         state->orig.out.result = state->tmp.out.result;
10586
10587         /* Reset temporary structure */
10588         ZERO_STRUCT(state->tmp);
10589
10590         tevent_req_done(req);
10591 }
10592
10593 NTSTATUS dcerpc_spoolss_RouterReplyPrinter_recv(struct tevent_req *req,
10594                                                 TALLOC_CTX *mem_ctx,
10595                                                 WERROR *result)
10596 {
10597         struct dcerpc_spoolss_RouterReplyPrinter_state *state = tevent_req_data(
10598                 req, struct dcerpc_spoolss_RouterReplyPrinter_state);
10599         NTSTATUS status;
10600
10601         if (tevent_req_is_nterror(req, &status)) {
10602                 tevent_req_received(req);
10603                 return status;
10604         }
10605
10606         /* Steal possible out parameters to the callers context */
10607         talloc_steal(mem_ctx, state->out_mem_ctx);
10608
10609         /* Return result */
10610         *result = state->orig.out.result;
10611
10612         tevent_req_received(req);
10613         return NT_STATUS_OK;
10614 }
10615
10616 NTSTATUS dcerpc_spoolss_RouterReplyPrinter(struct dcerpc_binding_handle *h,
10617                                            TALLOC_CTX *mem_ctx,
10618                                            struct policy_handle *_handle /* [in] [ref] */,
10619                                            uint32_t _flags /* [in]  */,
10620                                            uint32_t _bufsize /* [in] [range(0,512)] */,
10621                                            uint8_t *_buffer /* [in] [unique,size_is(bufsize)] */,
10622                                            WERROR *result)
10623 {
10624         struct spoolss_RouterReplyPrinter r;
10625         NTSTATUS status;
10626
10627         /* In parameters */
10628         r.in.handle = _handle;
10629         r.in.flags = _flags;
10630         r.in.bufsize = _bufsize;
10631         r.in.buffer = _buffer;
10632
10633         status = dcerpc_spoolss_RouterReplyPrinter_r(h, mem_ctx, &r);
10634         if (!NT_STATUS_IS_OK(status)) {
10635                 return status;
10636         }
10637
10638         /* Return variables */
10639
10640         /* Return result */
10641         *result = r.out.result;
10642
10643         return NT_STATUS_OK;
10644 }
10645
10646 struct dcerpc_spoolss_ReplyClosePrinter_r_state {
10647         TALLOC_CTX *out_mem_ctx;
10648 };
10649
10650 static void dcerpc_spoolss_ReplyClosePrinter_r_done(struct tevent_req *subreq);
10651
10652 struct tevent_req *dcerpc_spoolss_ReplyClosePrinter_r_send(TALLOC_CTX *mem_ctx,
10653         struct tevent_context *ev,
10654         struct dcerpc_binding_handle *h,
10655         struct spoolss_ReplyClosePrinter *r)
10656 {
10657         struct tevent_req *req;
10658         struct dcerpc_spoolss_ReplyClosePrinter_r_state *state;
10659         struct tevent_req *subreq;
10660
10661         req = tevent_req_create(mem_ctx, &state,
10662                                 struct dcerpc_spoolss_ReplyClosePrinter_r_state);
10663         if (req == NULL) {
10664                 return NULL;
10665         }
10666
10667         state->out_mem_ctx = talloc_new(state);
10668         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10669                 return tevent_req_post(req, ev);
10670         }
10671
10672         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10673                         NULL, &ndr_table_spoolss,
10674                         NDR_SPOOLSS_REPLYCLOSEPRINTER, state->out_mem_ctx, r);
10675         if (tevent_req_nomem(subreq, req)) {
10676                 return tevent_req_post(req, ev);
10677         }
10678         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyClosePrinter_r_done, req);
10679
10680         return req;
10681 }
10682
10683 static void dcerpc_spoolss_ReplyClosePrinter_r_done(struct tevent_req *subreq)
10684 {
10685         struct tevent_req *req =
10686                 tevent_req_callback_data(subreq,
10687                 struct tevent_req);
10688         NTSTATUS status;
10689
10690         status = dcerpc_binding_handle_call_recv(subreq);
10691         if (!NT_STATUS_IS_OK(status)) {
10692                 tevent_req_nterror(req, status);
10693                 return;
10694         }
10695
10696         tevent_req_done(req);
10697 }
10698
10699 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10700 {
10701         struct dcerpc_spoolss_ReplyClosePrinter_r_state *state =
10702                 tevent_req_data(req,
10703                 struct dcerpc_spoolss_ReplyClosePrinter_r_state);
10704         NTSTATUS status;
10705
10706         if (tevent_req_is_nterror(req, &status)) {
10707                 tevent_req_received(req);
10708                 return status;
10709         }
10710
10711         talloc_steal(mem_ctx, state->out_mem_ctx);
10712
10713         tevent_req_received(req);
10714         return NT_STATUS_OK;
10715 }
10716
10717 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_ReplyClosePrinter *r)
10718 {
10719         NTSTATUS status;
10720
10721         status = dcerpc_binding_handle_call(h,
10722                         NULL, &ndr_table_spoolss,
10723                         NDR_SPOOLSS_REPLYCLOSEPRINTER, mem_ctx, r);
10724
10725         return status;
10726 }
10727
10728 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_ReplyClosePrinter *r)
10729 {
10730         NTSTATUS status;
10731
10732         status = dcerpc_spoolss_ReplyClosePrinter_r(p->binding_handle, mem_ctx, r);
10733
10734         if (NT_STATUS_IS_RPC(status)) {
10735                 status = NT_STATUS_NET_WRITE_FAULT;
10736         }
10737
10738         return status;
10739 }
10740
10741 struct dcerpc_spoolss_ReplyClosePrinter_state {
10742         struct spoolss_ReplyClosePrinter orig;
10743         struct spoolss_ReplyClosePrinter tmp;
10744         TALLOC_CTX *out_mem_ctx;
10745 };
10746
10747 static void dcerpc_spoolss_ReplyClosePrinter_done(struct tevent_req *subreq);
10748
10749 struct tevent_req *dcerpc_spoolss_ReplyClosePrinter_send(TALLOC_CTX *mem_ctx,
10750                                                          struct tevent_context *ev,
10751                                                          struct dcerpc_binding_handle *h,
10752                                                          struct policy_handle *_handle /* [in,out] [ref] */)
10753 {
10754         struct tevent_req *req;
10755         struct dcerpc_spoolss_ReplyClosePrinter_state *state;
10756         struct tevent_req *subreq;
10757
10758         req = tevent_req_create(mem_ctx, &state,
10759                                 struct dcerpc_spoolss_ReplyClosePrinter_state);
10760         if (req == NULL) {
10761                 return NULL;
10762         }
10763         state->out_mem_ctx = NULL;
10764
10765         /* In parameters */
10766         state->orig.in.handle = _handle;
10767
10768         /* Out parameters */
10769         state->orig.out.handle = _handle;
10770
10771         /* Result */
10772         ZERO_STRUCT(state->orig.out.result);
10773
10774         state->out_mem_ctx = talloc_named_const(state, 0,
10775                              "dcerpc_spoolss_ReplyClosePrinter_out_memory");
10776         if (tevent_req_nomem(state->out_mem_ctx, req)) {
10777                 return tevent_req_post(req, ev);
10778         }
10779
10780         /* make a temporary copy, that we pass to the dispatch function */
10781         state->tmp = state->orig;
10782
10783         subreq = dcerpc_spoolss_ReplyClosePrinter_r_send(state, ev, h, &state->tmp);
10784         if (tevent_req_nomem(subreq, req)) {
10785                 return tevent_req_post(req, ev);
10786         }
10787         tevent_req_set_callback(subreq, dcerpc_spoolss_ReplyClosePrinter_done, req);
10788         return req;
10789 }
10790
10791 static void dcerpc_spoolss_ReplyClosePrinter_done(struct tevent_req *subreq)
10792 {
10793         struct tevent_req *req = tevent_req_callback_data(
10794                 subreq, struct tevent_req);
10795         struct dcerpc_spoolss_ReplyClosePrinter_state *state = tevent_req_data(
10796                 req, struct dcerpc_spoolss_ReplyClosePrinter_state);
10797         NTSTATUS status;
10798         TALLOC_CTX *mem_ctx;
10799
10800         if (state->out_mem_ctx) {
10801                 mem_ctx = state->out_mem_ctx;
10802         } else {
10803                 mem_ctx = state;
10804         }
10805
10806         status = dcerpc_spoolss_ReplyClosePrinter_r_recv(subreq, mem_ctx);
10807         TALLOC_FREE(subreq);
10808         if (!NT_STATUS_IS_OK(status)) {
10809                 tevent_req_nterror(req, status);
10810                 return;
10811         }
10812
10813         /* Copy out parameters */
10814         *state->orig.out.handle = *state->tmp.out.handle;
10815
10816         /* Copy result */
10817         state->orig.out.result = state->tmp.out.result;
10818
10819         /* Reset temporary structure */
10820         ZERO_STRUCT(state->tmp);
10821
10822         tevent_req_done(req);
10823 }
10824
10825 NTSTATUS dcerpc_spoolss_ReplyClosePrinter_recv(struct tevent_req *req,
10826                                                TALLOC_CTX *mem_ctx,
10827                                                WERROR *result)
10828 {
10829         struct dcerpc_spoolss_ReplyClosePrinter_state *state = tevent_req_data(
10830                 req, struct dcerpc_spoolss_ReplyClosePrinter_state);
10831         NTSTATUS status;
10832
10833         if (tevent_req_is_nterror(req, &status)) {
10834                 tevent_req_received(req);
10835                 return status;
10836         }
10837
10838         /* Steal possible out parameters to the callers context */
10839         talloc_steal(mem_ctx, state->out_mem_ctx);
10840
10841         /* Return result */
10842         *result = state->orig.out.result;
10843
10844         tevent_req_received(req);
10845         return NT_STATUS_OK;
10846 }
10847
10848 NTSTATUS dcerpc_spoolss_ReplyClosePrinter(struct dcerpc_binding_handle *h,
10849                                           TALLOC_CTX *mem_ctx,
10850                                           struct policy_handle *_handle /* [in,out] [ref] */,
10851                                           WERROR *result)
10852 {
10853         struct spoolss_ReplyClosePrinter r;
10854         NTSTATUS status;
10855
10856         /* In parameters */
10857         r.in.handle = _handle;
10858
10859         status = dcerpc_spoolss_ReplyClosePrinter_r(h, mem_ctx, &r);
10860         if (!NT_STATUS_IS_OK(status)) {
10861                 return status;
10862         }
10863
10864         /* Return variables */
10865         *_handle = *r.out.handle;
10866
10867         /* Return result */
10868         *result = r.out.result;
10869
10870         return NT_STATUS_OK;
10871 }
10872
10873 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state {
10874         TALLOC_CTX *out_mem_ctx;
10875 };
10876
10877 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_done(struct tevent_req *subreq);
10878
10879 struct tevent_req *dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_send(TALLOC_CTX *mem_ctx,
10880         struct tevent_context *ev,
10881         struct dcerpc_binding_handle *h,
10882         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
10883 {
10884         struct tevent_req *req;
10885         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state *state;
10886         struct tevent_req *subreq;
10887
10888         req = tevent_req_create(mem_ctx, &state,
10889                                 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state);
10890         if (req == NULL) {
10891                 return NULL;
10892         }
10893
10894         state->out_mem_ctx = NULL;
10895         subreq = dcerpc_binding_handle_call_send(state, ev, h,
10896                         NULL, &ndr_table_spoolss,
10897                         NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX, state, r);
10898         if (tevent_req_nomem(subreq, req)) {
10899                 return tevent_req_post(req, ev);
10900         }
10901         tevent_req_set_callback(subreq, dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_done, req);
10902
10903         return req;
10904 }
10905
10906 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_done(struct tevent_req *subreq)
10907 {
10908         struct tevent_req *req =
10909                 tevent_req_callback_data(subreq,
10910                 struct tevent_req);
10911         NTSTATUS status;
10912
10913         status = dcerpc_binding_handle_call_recv(subreq);
10914         if (!NT_STATUS_IS_OK(status)) {
10915                 tevent_req_nterror(req, status);
10916                 return;
10917         }
10918
10919         tevent_req_done(req);
10920 }
10921
10922 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
10923 {
10924         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state *state =
10925                 tevent_req_data(req,
10926                 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_state);
10927         NTSTATUS status;
10928
10929         if (tevent_req_is_nterror(req, &status)) {
10930                 tevent_req_received(req);
10931                 return status;
10932         }
10933
10934         talloc_steal(mem_ctx, state->out_mem_ctx);
10935
10936         tevent_req_received(req);
10937         return NT_STATUS_OK;
10938 }
10939
10940 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
10941 {
10942         NTSTATUS status;
10943
10944         status = dcerpc_binding_handle_call(h,
10945                         NULL, &ndr_table_spoolss,
10946                         NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX, mem_ctx, r);
10947
10948         return status;
10949 }
10950
10951 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
10952 {
10953         NTSTATUS status;
10954
10955         status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r(p->binding_handle, mem_ctx, r);
10956
10957         if (NT_STATUS_IS_RPC(status)) {
10958                 status = NT_STATUS_NET_WRITE_FAULT;
10959         }
10960
10961         return status;
10962 }
10963
10964 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state {
10965         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx orig;
10966         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx tmp;
10967         TALLOC_CTX *out_mem_ctx;
10968 };
10969
10970 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_done(struct tevent_req *subreq);
10971
10972 struct tevent_req *dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_send(TALLOC_CTX *mem_ctx,
10973                                                                             struct tevent_context *ev,
10974                                                                             struct dcerpc_binding_handle *h,
10975                                                                             struct policy_handle *_handle /* [in] [ref] */,
10976                                                                             uint32_t _flags /* [in]  */,
10977                                                                             uint32_t _options /* [in]  */,
10978                                                                             const char *_local_machine /* [in] [unique,charset(UTF16)] */,
10979                                                                             uint32_t _printer_local /* [in]  */,
10980                                                                             struct spoolss_NotifyOption *_notify_options /* [in] [unique] */)
10981 {
10982         struct tevent_req *req;
10983         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state *state;
10984         struct tevent_req *subreq;
10985
10986         req = tevent_req_create(mem_ctx, &state,
10987                                 struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state);
10988         if (req == NULL) {
10989                 return NULL;
10990         }
10991         state->out_mem_ctx = NULL;
10992
10993         /* In parameters */
10994         state->orig.in.handle = _handle;
10995         state->orig.in.flags = _flags;
10996         state->orig.in.options = _options;
10997         state->orig.in.local_machine = _local_machine;
10998         state->orig.in.printer_local = _printer_local;
10999         state->orig.in.notify_options = _notify_options;
11000
11001         /* Out parameters */
11002
11003         /* Result */
11004         ZERO_STRUCT(state->orig.out.result);
11005
11006         /* make a temporary copy, that we pass to the dispatch function */
11007         state->tmp = state->orig;
11008
11009         subreq = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_send(state, ev, h, &state->tmp);
11010         if (tevent_req_nomem(subreq, req)) {
11011                 return tevent_req_post(req, ev);
11012         }
11013         tevent_req_set_callback(subreq, dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_done, req);
11014         return req;
11015 }
11016
11017 static void dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_done(struct tevent_req *subreq)
11018 {
11019         struct tevent_req *req = tevent_req_callback_data(
11020                 subreq, struct tevent_req);
11021         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state *state = tevent_req_data(
11022                 req, struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state);
11023         NTSTATUS status;
11024         TALLOC_CTX *mem_ctx;
11025
11026         if (state->out_mem_ctx) {
11027                 mem_ctx = state->out_mem_ctx;
11028         } else {
11029                 mem_ctx = state;
11030         }
11031
11032         status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r_recv(subreq, mem_ctx);
11033         TALLOC_FREE(subreq);
11034         if (!NT_STATUS_IS_OK(status)) {
11035                 tevent_req_nterror(req, status);
11036                 return;
11037         }
11038
11039         /* Copy out parameters */
11040
11041         /* Copy result */
11042         state->orig.out.result = state->tmp.out.result;
11043
11044         /* Reset temporary structure */
11045         ZERO_STRUCT(state->tmp);
11046
11047         tevent_req_done(req);
11048 }
11049
11050 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_recv(struct tevent_req *req,
11051                                                                   TALLOC_CTX *mem_ctx,
11052                                                                   WERROR *result)
11053 {
11054         struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state *state = tevent_req_data(
11055                 req, struct dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_state);
11056         NTSTATUS status;
11057
11058         if (tevent_req_is_nterror(req, &status)) {
11059                 tevent_req_received(req);
11060                 return status;
11061         }
11062
11063         /* Steal possible out parameters to the callers context */
11064         talloc_steal(mem_ctx, state->out_mem_ctx);
11065
11066         /* Return result */
11067         *result = state->orig.out.result;
11068
11069         tevent_req_received(req);
11070         return NT_STATUS_OK;
11071 }
11072
11073 NTSTATUS dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcerpc_binding_handle *h,
11074                                                              TALLOC_CTX *mem_ctx,
11075                                                              struct policy_handle *_handle /* [in] [ref] */,
11076                                                              uint32_t _flags /* [in]  */,
11077                                                              uint32_t _options /* [in]  */,
11078                                                              const char *_local_machine /* [in] [unique,charset(UTF16)] */,
11079                                                              uint32_t _printer_local /* [in]  */,
11080                                                              struct spoolss_NotifyOption *_notify_options /* [in] [unique] */,
11081                                                              WERROR *result)
11082 {
11083         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r;
11084         NTSTATUS status;
11085
11086         /* In parameters */
11087         r.in.handle = _handle;
11088         r.in.flags = _flags;
11089         r.in.options = _options;
11090         r.in.local_machine = _local_machine;
11091         r.in.printer_local = _printer_local;
11092         r.in.notify_options = _notify_options;
11093
11094         status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r(h, mem_ctx, &r);
11095         if (!NT_STATUS_IS_OK(status)) {
11096                 return status;
11097         }
11098
11099         /* Return variables */
11100
11101         /* Return result */
11102         *result = r.out.result;
11103
11104         return NT_STATUS_OK;
11105 }
11106
11107 struct dcerpc_spoolss_RouterReplyPrinterEx_r_state {
11108         TALLOC_CTX *out_mem_ctx;
11109 };
11110
11111 static void dcerpc_spoolss_RouterReplyPrinterEx_r_done(struct tevent_req *subreq);
11112
11113 struct tevent_req *dcerpc_spoolss_RouterReplyPrinterEx_r_send(TALLOC_CTX *mem_ctx,
11114         struct tevent_context *ev,
11115         struct dcerpc_binding_handle *h,
11116         struct spoolss_RouterReplyPrinterEx *r)
11117 {
11118         struct tevent_req *req;
11119         struct dcerpc_spoolss_RouterReplyPrinterEx_r_state *state;
11120         struct tevent_req *subreq;
11121
11122         req = tevent_req_create(mem_ctx, &state,
11123                                 struct dcerpc_spoolss_RouterReplyPrinterEx_r_state);
11124         if (req == NULL) {
11125                 return NULL;
11126         }
11127
11128         state->out_mem_ctx = talloc_new(state);
11129         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11130                 return tevent_req_post(req, ev);
11131         }
11132
11133         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11134                         NULL, &ndr_table_spoolss,
11135                         NDR_SPOOLSS_ROUTERREPLYPRINTEREX, state->out_mem_ctx, r);
11136         if (tevent_req_nomem(subreq, req)) {
11137                 return tevent_req_post(req, ev);
11138         }
11139         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinterEx_r_done, req);
11140
11141         return req;
11142 }
11143
11144 static void dcerpc_spoolss_RouterReplyPrinterEx_r_done(struct tevent_req *subreq)
11145 {
11146         struct tevent_req *req =
11147                 tevent_req_callback_data(subreq,
11148                 struct tevent_req);
11149         NTSTATUS status;
11150
11151         status = dcerpc_binding_handle_call_recv(subreq);
11152         if (!NT_STATUS_IS_OK(status)) {
11153                 tevent_req_nterror(req, status);
11154                 return;
11155         }
11156
11157         tevent_req_done(req);
11158 }
11159
11160 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11161 {
11162         struct dcerpc_spoolss_RouterReplyPrinterEx_r_state *state =
11163                 tevent_req_data(req,
11164                 struct dcerpc_spoolss_RouterReplyPrinterEx_r_state);
11165         NTSTATUS status;
11166
11167         if (tevent_req_is_nterror(req, &status)) {
11168                 tevent_req_received(req);
11169                 return status;
11170         }
11171
11172         talloc_steal(mem_ctx, state->out_mem_ctx);
11173
11174         tevent_req_received(req);
11175         return NT_STATUS_OK;
11176 }
11177
11178 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinterEx *r)
11179 {
11180         NTSTATUS status;
11181
11182         status = dcerpc_binding_handle_call(h,
11183                         NULL, &ndr_table_spoolss,
11184                         NDR_SPOOLSS_ROUTERREPLYPRINTEREX, mem_ctx, r);
11185
11186         return status;
11187 }
11188
11189 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RouterReplyPrinterEx *r)
11190 {
11191         NTSTATUS status;
11192
11193         status = dcerpc_spoolss_RouterReplyPrinterEx_r(p->binding_handle, mem_ctx, r);
11194
11195         if (NT_STATUS_IS_RPC(status)) {
11196                 status = NT_STATUS_NET_WRITE_FAULT;
11197         }
11198
11199         return status;
11200 }
11201
11202 struct dcerpc_spoolss_RouterReplyPrinterEx_state {
11203         struct spoolss_RouterReplyPrinterEx orig;
11204         struct spoolss_RouterReplyPrinterEx tmp;
11205         TALLOC_CTX *out_mem_ctx;
11206 };
11207
11208 static void dcerpc_spoolss_RouterReplyPrinterEx_done(struct tevent_req *subreq);
11209
11210 struct tevent_req *dcerpc_spoolss_RouterReplyPrinterEx_send(TALLOC_CTX *mem_ctx,
11211                                                             struct tevent_context *ev,
11212                                                             struct dcerpc_binding_handle *h,
11213                                                             struct policy_handle *_handle /* [in] [ref] */,
11214                                                             uint32_t _color /* [in]  */,
11215                                                             uint32_t _flags /* [in]  */,
11216                                                             uint32_t *_reply_result /* [out] [ref] */,
11217                                                             uint32_t _reply_type /* [in]  */,
11218                                                             union spoolss_ReplyPrinterInfo _info /* [in] [switch_is(reply_type)] */)
11219 {
11220         struct tevent_req *req;
11221         struct dcerpc_spoolss_RouterReplyPrinterEx_state *state;
11222         struct tevent_req *subreq;
11223
11224         req = tevent_req_create(mem_ctx, &state,
11225                                 struct dcerpc_spoolss_RouterReplyPrinterEx_state);
11226         if (req == NULL) {
11227                 return NULL;
11228         }
11229         state->out_mem_ctx = NULL;
11230
11231         /* In parameters */
11232         state->orig.in.handle = _handle;
11233         state->orig.in.color = _color;
11234         state->orig.in.flags = _flags;
11235         state->orig.in.reply_type = _reply_type;
11236         state->orig.in.info = _info;
11237
11238         /* Out parameters */
11239         state->orig.out.reply_result = _reply_result;
11240
11241         /* Result */
11242         ZERO_STRUCT(state->orig.out.result);
11243
11244         state->out_mem_ctx = talloc_named_const(state, 0,
11245                              "dcerpc_spoolss_RouterReplyPrinterEx_out_memory");
11246         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11247                 return tevent_req_post(req, ev);
11248         }
11249
11250         /* make a temporary copy, that we pass to the dispatch function */
11251         state->tmp = state->orig;
11252
11253         subreq = dcerpc_spoolss_RouterReplyPrinterEx_r_send(state, ev, h, &state->tmp);
11254         if (tevent_req_nomem(subreq, req)) {
11255                 return tevent_req_post(req, ev);
11256         }
11257         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterReplyPrinterEx_done, req);
11258         return req;
11259 }
11260
11261 static void dcerpc_spoolss_RouterReplyPrinterEx_done(struct tevent_req *subreq)
11262 {
11263         struct tevent_req *req = tevent_req_callback_data(
11264                 subreq, struct tevent_req);
11265         struct dcerpc_spoolss_RouterReplyPrinterEx_state *state = tevent_req_data(
11266                 req, struct dcerpc_spoolss_RouterReplyPrinterEx_state);
11267         NTSTATUS status;
11268         TALLOC_CTX *mem_ctx;
11269
11270         if (state->out_mem_ctx) {
11271                 mem_ctx = state->out_mem_ctx;
11272         } else {
11273                 mem_ctx = state;
11274         }
11275
11276         status = dcerpc_spoolss_RouterReplyPrinterEx_r_recv(subreq, mem_ctx);
11277         TALLOC_FREE(subreq);
11278         if (!NT_STATUS_IS_OK(status)) {
11279                 tevent_req_nterror(req, status);
11280                 return;
11281         }
11282
11283         /* Copy out parameters */
11284         *state->orig.out.reply_result = *state->tmp.out.reply_result;
11285
11286         /* Copy result */
11287         state->orig.out.result = state->tmp.out.result;
11288
11289         /* Reset temporary structure */
11290         ZERO_STRUCT(state->tmp);
11291
11292         tevent_req_done(req);
11293 }
11294
11295 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx_recv(struct tevent_req *req,
11296                                                   TALLOC_CTX *mem_ctx,
11297                                                   WERROR *result)
11298 {
11299         struct dcerpc_spoolss_RouterReplyPrinterEx_state *state = tevent_req_data(
11300                 req, struct dcerpc_spoolss_RouterReplyPrinterEx_state);
11301         NTSTATUS status;
11302
11303         if (tevent_req_is_nterror(req, &status)) {
11304                 tevent_req_received(req);
11305                 return status;
11306         }
11307
11308         /* Steal possible out parameters to the callers context */
11309         talloc_steal(mem_ctx, state->out_mem_ctx);
11310
11311         /* Return result */
11312         *result = state->orig.out.result;
11313
11314         tevent_req_received(req);
11315         return NT_STATUS_OK;
11316 }
11317
11318 NTSTATUS dcerpc_spoolss_RouterReplyPrinterEx(struct dcerpc_binding_handle *h,
11319                                              TALLOC_CTX *mem_ctx,
11320                                              struct policy_handle *_handle /* [in] [ref] */,
11321                                              uint32_t _color /* [in]  */,
11322                                              uint32_t _flags /* [in]  */,
11323                                              uint32_t *_reply_result /* [out] [ref] */,
11324                                              uint32_t _reply_type /* [in]  */,
11325                                              union spoolss_ReplyPrinterInfo _info /* [in] [switch_is(reply_type)] */,
11326                                              WERROR *result)
11327 {
11328         struct spoolss_RouterReplyPrinterEx r;
11329         NTSTATUS status;
11330
11331         /* In parameters */
11332         r.in.handle = _handle;
11333         r.in.color = _color;
11334         r.in.flags = _flags;
11335         r.in.reply_type = _reply_type;
11336         r.in.info = _info;
11337
11338         status = dcerpc_spoolss_RouterReplyPrinterEx_r(h, mem_ctx, &r);
11339         if (!NT_STATUS_IS_OK(status)) {
11340                 return status;
11341         }
11342
11343         /* Return variables */
11344         *_reply_result = *r.out.reply_result;
11345
11346         /* Return result */
11347         *result = r.out.result;
11348
11349         return NT_STATUS_OK;
11350 }
11351
11352 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state {
11353         TALLOC_CTX *out_mem_ctx;
11354 };
11355
11356 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_done(struct tevent_req *subreq);
11357
11358 struct tevent_req *dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_send(TALLOC_CTX *mem_ctx,
11359         struct tevent_context *ev,
11360         struct dcerpc_binding_handle *h,
11361         struct spoolss_RouterRefreshPrinterChangeNotify *r)
11362 {
11363         struct tevent_req *req;
11364         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state *state;
11365         struct tevent_req *subreq;
11366
11367         req = tevent_req_create(mem_ctx, &state,
11368                                 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state);
11369         if (req == NULL) {
11370                 return NULL;
11371         }
11372
11373         state->out_mem_ctx = talloc_new(state);
11374         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11375                 return tevent_req_post(req, ev);
11376         }
11377
11378         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11379                         NULL, &ndr_table_spoolss,
11380                         NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFY, state->out_mem_ctx, r);
11381         if (tevent_req_nomem(subreq, req)) {
11382                 return tevent_req_post(req, ev);
11383         }
11384         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_done, req);
11385
11386         return req;
11387 }
11388
11389 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_done(struct tevent_req *subreq)
11390 {
11391         struct tevent_req *req =
11392                 tevent_req_callback_data(subreq,
11393                 struct tevent_req);
11394         NTSTATUS status;
11395
11396         status = dcerpc_binding_handle_call_recv(subreq);
11397         if (!NT_STATUS_IS_OK(status)) {
11398                 tevent_req_nterror(req, status);
11399                 return;
11400         }
11401
11402         tevent_req_done(req);
11403 }
11404
11405 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11406 {
11407         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state *state =
11408                 tevent_req_data(req,
11409                 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_state);
11410         NTSTATUS status;
11411
11412         if (tevent_req_is_nterror(req, &status)) {
11413                 tevent_req_received(req);
11414                 return status;
11415         }
11416
11417         talloc_steal(mem_ctx, state->out_mem_ctx);
11418
11419         tevent_req_received(req);
11420         return NT_STATUS_OK;
11421 }
11422
11423 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_RouterRefreshPrinterChangeNotify *r)
11424 {
11425         NTSTATUS status;
11426
11427         status = dcerpc_binding_handle_call(h,
11428                         NULL, &ndr_table_spoolss,
11429                         NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFY, mem_ctx, r);
11430
11431         return status;
11432 }
11433
11434 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_RouterRefreshPrinterChangeNotify *r)
11435 {
11436         NTSTATUS status;
11437
11438         status = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r(p->binding_handle, mem_ctx, r);
11439
11440         if (NT_STATUS_IS_RPC(status)) {
11441                 status = NT_STATUS_NET_WRITE_FAULT;
11442         }
11443
11444         return status;
11445 }
11446
11447 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state {
11448         struct spoolss_RouterRefreshPrinterChangeNotify orig;
11449         struct spoolss_RouterRefreshPrinterChangeNotify tmp;
11450         TALLOC_CTX *out_mem_ctx;
11451 };
11452
11453 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_done(struct tevent_req *subreq);
11454
11455 struct tevent_req *dcerpc_spoolss_RouterRefreshPrinterChangeNotify_send(TALLOC_CTX *mem_ctx,
11456                                                                         struct tevent_context *ev,
11457                                                                         struct dcerpc_binding_handle *h,
11458                                                                         struct policy_handle *_handle /* [in] [ref] */,
11459                                                                         uint32_t _change_low /* [in]  */,
11460                                                                         struct spoolss_NotifyOption *_options /* [in] [unique] */,
11461                                                                         struct spoolss_NotifyInfo **_info /* [out] [ref] */)
11462 {
11463         struct tevent_req *req;
11464         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state *state;
11465         struct tevent_req *subreq;
11466
11467         req = tevent_req_create(mem_ctx, &state,
11468                                 struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state);
11469         if (req == NULL) {
11470                 return NULL;
11471         }
11472         state->out_mem_ctx = NULL;
11473
11474         /* In parameters */
11475         state->orig.in.handle = _handle;
11476         state->orig.in.change_low = _change_low;
11477         state->orig.in.options = _options;
11478
11479         /* Out parameters */
11480         state->orig.out.info = _info;
11481
11482         /* Result */
11483         ZERO_STRUCT(state->orig.out.result);
11484
11485         state->out_mem_ctx = talloc_named_const(state, 0,
11486                              "dcerpc_spoolss_RouterRefreshPrinterChangeNotify_out_memory");
11487         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11488                 return tevent_req_post(req, ev);
11489         }
11490
11491         /* make a temporary copy, that we pass to the dispatch function */
11492         state->tmp = state->orig;
11493
11494         subreq = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_send(state, ev, h, &state->tmp);
11495         if (tevent_req_nomem(subreq, req)) {
11496                 return tevent_req_post(req, ev);
11497         }
11498         tevent_req_set_callback(subreq, dcerpc_spoolss_RouterRefreshPrinterChangeNotify_done, req);
11499         return req;
11500 }
11501
11502 static void dcerpc_spoolss_RouterRefreshPrinterChangeNotify_done(struct tevent_req *subreq)
11503 {
11504         struct tevent_req *req = tevent_req_callback_data(
11505                 subreq, struct tevent_req);
11506         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state *state = tevent_req_data(
11507                 req, struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state);
11508         NTSTATUS status;
11509         TALLOC_CTX *mem_ctx;
11510
11511         if (state->out_mem_ctx) {
11512                 mem_ctx = state->out_mem_ctx;
11513         } else {
11514                 mem_ctx = state;
11515         }
11516
11517         status = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r_recv(subreq, mem_ctx);
11518         TALLOC_FREE(subreq);
11519         if (!NT_STATUS_IS_OK(status)) {
11520                 tevent_req_nterror(req, status);
11521                 return;
11522         }
11523
11524         /* Copy out parameters */
11525         *state->orig.out.info = *state->tmp.out.info;
11526
11527         /* Copy result */
11528         state->orig.out.result = state->tmp.out.result;
11529
11530         /* Reset temporary structure */
11531         ZERO_STRUCT(state->tmp);
11532
11533         tevent_req_done(req);
11534 }
11535
11536 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify_recv(struct tevent_req *req,
11537                                                               TALLOC_CTX *mem_ctx,
11538                                                               WERROR *result)
11539 {
11540         struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state *state = tevent_req_data(
11541                 req, struct dcerpc_spoolss_RouterRefreshPrinterChangeNotify_state);
11542         NTSTATUS status;
11543
11544         if (tevent_req_is_nterror(req, &status)) {
11545                 tevent_req_received(req);
11546                 return status;
11547         }
11548
11549         /* Steal possible out parameters to the callers context */
11550         talloc_steal(mem_ctx, state->out_mem_ctx);
11551
11552         /* Return result */
11553         *result = state->orig.out.result;
11554
11555         tevent_req_received(req);
11556         return NT_STATUS_OK;
11557 }
11558
11559 NTSTATUS dcerpc_spoolss_RouterRefreshPrinterChangeNotify(struct dcerpc_binding_handle *h,
11560                                                          TALLOC_CTX *mem_ctx,
11561                                                          struct policy_handle *_handle /* [in] [ref] */,
11562                                                          uint32_t _change_low /* [in]  */,
11563                                                          struct spoolss_NotifyOption *_options /* [in] [unique] */,
11564                                                          struct spoolss_NotifyInfo **_info /* [out] [ref] */,
11565                                                          WERROR *result)
11566 {
11567         struct spoolss_RouterRefreshPrinterChangeNotify r;
11568         NTSTATUS status;
11569
11570         /* In parameters */
11571         r.in.handle = _handle;
11572         r.in.change_low = _change_low;
11573         r.in.options = _options;
11574
11575         status = dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r(h, mem_ctx, &r);
11576         if (!NT_STATUS_IS_OK(status)) {
11577                 return status;
11578         }
11579
11580         /* Return variables */
11581         *_info = *r.out.info;
11582
11583         /* Return result */
11584         *result = r.out.result;
11585
11586         return NT_STATUS_OK;
11587 }
11588
11589 struct dcerpc_spoolss_OpenPrinterEx_r_state {
11590         TALLOC_CTX *out_mem_ctx;
11591 };
11592
11593 static void dcerpc_spoolss_OpenPrinterEx_r_done(struct tevent_req *subreq);
11594
11595 struct tevent_req *dcerpc_spoolss_OpenPrinterEx_r_send(TALLOC_CTX *mem_ctx,
11596         struct tevent_context *ev,
11597         struct dcerpc_binding_handle *h,
11598         struct spoolss_OpenPrinterEx *r)
11599 {
11600         struct tevent_req *req;
11601         struct dcerpc_spoolss_OpenPrinterEx_r_state *state;
11602         struct tevent_req *subreq;
11603
11604         req = tevent_req_create(mem_ctx, &state,
11605                                 struct dcerpc_spoolss_OpenPrinterEx_r_state);
11606         if (req == NULL) {
11607                 return NULL;
11608         }
11609
11610         state->out_mem_ctx = talloc_new(state);
11611         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11612                 return tevent_req_post(req, ev);
11613         }
11614
11615         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11616                         NULL, &ndr_table_spoolss,
11617                         NDR_SPOOLSS_OPENPRINTEREX, state->out_mem_ctx, r);
11618         if (tevent_req_nomem(subreq, req)) {
11619                 return tevent_req_post(req, ev);
11620         }
11621         tevent_req_set_callback(subreq, dcerpc_spoolss_OpenPrinterEx_r_done, req);
11622
11623         return req;
11624 }
11625
11626 static void dcerpc_spoolss_OpenPrinterEx_r_done(struct tevent_req *subreq)
11627 {
11628         struct tevent_req *req =
11629                 tevent_req_callback_data(subreq,
11630                 struct tevent_req);
11631         NTSTATUS status;
11632
11633         status = dcerpc_binding_handle_call_recv(subreq);
11634         if (!NT_STATUS_IS_OK(status)) {
11635                 tevent_req_nterror(req, status);
11636                 return;
11637         }
11638
11639         tevent_req_done(req);
11640 }
11641
11642 NTSTATUS dcerpc_spoolss_OpenPrinterEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11643 {
11644         struct dcerpc_spoolss_OpenPrinterEx_r_state *state =
11645                 tevent_req_data(req,
11646                 struct dcerpc_spoolss_OpenPrinterEx_r_state);
11647         NTSTATUS status;
11648
11649         if (tevent_req_is_nterror(req, &status)) {
11650                 tevent_req_received(req);
11651                 return status;
11652         }
11653
11654         talloc_steal(mem_ctx, state->out_mem_ctx);
11655
11656         tevent_req_received(req);
11657         return NT_STATUS_OK;
11658 }
11659
11660 NTSTATUS dcerpc_spoolss_OpenPrinterEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r)
11661 {
11662         NTSTATUS status;
11663
11664         status = dcerpc_binding_handle_call(h,
11665                         NULL, &ndr_table_spoolss,
11666                         NDR_SPOOLSS_OPENPRINTEREX, mem_ctx, r);
11667
11668         return status;
11669 }
11670
11671 NTSTATUS dcerpc_spoolss_OpenPrinterEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r)
11672 {
11673         NTSTATUS status;
11674
11675         status = dcerpc_spoolss_OpenPrinterEx_r(p->binding_handle, mem_ctx, r);
11676
11677         if (NT_STATUS_IS_RPC(status)) {
11678                 status = NT_STATUS_NET_WRITE_FAULT;
11679         }
11680
11681         return status;
11682 }
11683
11684 struct dcerpc_spoolss_OpenPrinterEx_state {
11685         struct spoolss_OpenPrinterEx orig;
11686         struct spoolss_OpenPrinterEx tmp;
11687         TALLOC_CTX *out_mem_ctx;
11688 };
11689
11690 static void dcerpc_spoolss_OpenPrinterEx_done(struct tevent_req *subreq);
11691
11692 struct tevent_req *dcerpc_spoolss_OpenPrinterEx_send(TALLOC_CTX *mem_ctx,
11693                                                      struct tevent_context *ev,
11694                                                      struct dcerpc_binding_handle *h,
11695                                                      const char *_printername /* [in] [unique,charset(UTF16)] */,
11696                                                      const char *_datatype /* [in] [unique,charset(UTF16)] */,
11697                                                      struct spoolss_DevmodeContainer _devmode_ctr /* [in]  */,
11698                                                      uint32_t _access_mask /* [in]  */,
11699                                                      uint32_t _level /* [in]  */,
11700                                                      union spoolss_UserLevel _userlevel /* [in] [switch_is(level)] */,
11701                                                      struct policy_handle *_handle /* [out] [ref] */)
11702 {
11703         struct tevent_req *req;
11704         struct dcerpc_spoolss_OpenPrinterEx_state *state;
11705         struct tevent_req *subreq;
11706
11707         req = tevent_req_create(mem_ctx, &state,
11708                                 struct dcerpc_spoolss_OpenPrinterEx_state);
11709         if (req == NULL) {
11710                 return NULL;
11711         }
11712         state->out_mem_ctx = NULL;
11713
11714         /* In parameters */
11715         state->orig.in.printername = _printername;
11716         state->orig.in.datatype = _datatype;
11717         state->orig.in.devmode_ctr = _devmode_ctr;
11718         state->orig.in.access_mask = _access_mask;
11719         state->orig.in.level = _level;
11720         state->orig.in.userlevel = _userlevel;
11721
11722         /* Out parameters */
11723         state->orig.out.handle = _handle;
11724
11725         /* Result */
11726         ZERO_STRUCT(state->orig.out.result);
11727
11728         state->out_mem_ctx = talloc_named_const(state, 0,
11729                              "dcerpc_spoolss_OpenPrinterEx_out_memory");
11730         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11731                 return tevent_req_post(req, ev);
11732         }
11733
11734         /* make a temporary copy, that we pass to the dispatch function */
11735         state->tmp = state->orig;
11736
11737         subreq = dcerpc_spoolss_OpenPrinterEx_r_send(state, ev, h, &state->tmp);
11738         if (tevent_req_nomem(subreq, req)) {
11739                 return tevent_req_post(req, ev);
11740         }
11741         tevent_req_set_callback(subreq, dcerpc_spoolss_OpenPrinterEx_done, req);
11742         return req;
11743 }
11744
11745 static void dcerpc_spoolss_OpenPrinterEx_done(struct tevent_req *subreq)
11746 {
11747         struct tevent_req *req = tevent_req_callback_data(
11748                 subreq, struct tevent_req);
11749         struct dcerpc_spoolss_OpenPrinterEx_state *state = tevent_req_data(
11750                 req, struct dcerpc_spoolss_OpenPrinterEx_state);
11751         NTSTATUS status;
11752         TALLOC_CTX *mem_ctx;
11753
11754         if (state->out_mem_ctx) {
11755                 mem_ctx = state->out_mem_ctx;
11756         } else {
11757                 mem_ctx = state;
11758         }
11759
11760         status = dcerpc_spoolss_OpenPrinterEx_r_recv(subreq, mem_ctx);
11761         TALLOC_FREE(subreq);
11762         if (!NT_STATUS_IS_OK(status)) {
11763                 tevent_req_nterror(req, status);
11764                 return;
11765         }
11766
11767         /* Copy out parameters */
11768         *state->orig.out.handle = *state->tmp.out.handle;
11769
11770         /* Copy result */
11771         state->orig.out.result = state->tmp.out.result;
11772
11773         /* Reset temporary structure */
11774         ZERO_STRUCT(state->tmp);
11775
11776         tevent_req_done(req);
11777 }
11778
11779 NTSTATUS dcerpc_spoolss_OpenPrinterEx_recv(struct tevent_req *req,
11780                                            TALLOC_CTX *mem_ctx,
11781                                            WERROR *result)
11782 {
11783         struct dcerpc_spoolss_OpenPrinterEx_state *state = tevent_req_data(
11784                 req, struct dcerpc_spoolss_OpenPrinterEx_state);
11785         NTSTATUS status;
11786
11787         if (tevent_req_is_nterror(req, &status)) {
11788                 tevent_req_received(req);
11789                 return status;
11790         }
11791
11792         /* Steal possible out parameters to the callers context */
11793         talloc_steal(mem_ctx, state->out_mem_ctx);
11794
11795         /* Return result */
11796         *result = state->orig.out.result;
11797
11798         tevent_req_received(req);
11799         return NT_STATUS_OK;
11800 }
11801
11802 NTSTATUS dcerpc_spoolss_OpenPrinterEx(struct dcerpc_binding_handle *h,
11803                                       TALLOC_CTX *mem_ctx,
11804                                       const char *_printername /* [in] [unique,charset(UTF16)] */,
11805                                       const char *_datatype /* [in] [unique,charset(UTF16)] */,
11806                                       struct spoolss_DevmodeContainer _devmode_ctr /* [in]  */,
11807                                       uint32_t _access_mask /* [in]  */,
11808                                       uint32_t _level /* [in]  */,
11809                                       union spoolss_UserLevel _userlevel /* [in] [switch_is(level)] */,
11810                                       struct policy_handle *_handle /* [out] [ref] */,
11811                                       WERROR *result)
11812 {
11813         struct spoolss_OpenPrinterEx r;
11814         NTSTATUS status;
11815
11816         /* In parameters */
11817         r.in.printername = _printername;
11818         r.in.datatype = _datatype;
11819         r.in.devmode_ctr = _devmode_ctr;
11820         r.in.access_mask = _access_mask;
11821         r.in.level = _level;
11822         r.in.userlevel = _userlevel;
11823
11824         status = dcerpc_spoolss_OpenPrinterEx_r(h, mem_ctx, &r);
11825         if (!NT_STATUS_IS_OK(status)) {
11826                 return status;
11827         }
11828
11829         /* Return variables */
11830         *_handle = *r.out.handle;
11831
11832         /* Return result */
11833         *result = r.out.result;
11834
11835         return NT_STATUS_OK;
11836 }
11837
11838 struct dcerpc_spoolss_AddPrinterEx_r_state {
11839         TALLOC_CTX *out_mem_ctx;
11840 };
11841
11842 static void dcerpc_spoolss_AddPrinterEx_r_done(struct tevent_req *subreq);
11843
11844 struct tevent_req *dcerpc_spoolss_AddPrinterEx_r_send(TALLOC_CTX *mem_ctx,
11845         struct tevent_context *ev,
11846         struct dcerpc_binding_handle *h,
11847         struct spoolss_AddPrinterEx *r)
11848 {
11849         struct tevent_req *req;
11850         struct dcerpc_spoolss_AddPrinterEx_r_state *state;
11851         struct tevent_req *subreq;
11852
11853         req = tevent_req_create(mem_ctx, &state,
11854                                 struct dcerpc_spoolss_AddPrinterEx_r_state);
11855         if (req == NULL) {
11856                 return NULL;
11857         }
11858
11859         state->out_mem_ctx = talloc_new(state);
11860         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11861                 return tevent_req_post(req, ev);
11862         }
11863
11864         subreq = dcerpc_binding_handle_call_send(state, ev, h,
11865                         NULL, &ndr_table_spoolss,
11866                         NDR_SPOOLSS_ADDPRINTEREX, state->out_mem_ctx, r);
11867         if (tevent_req_nomem(subreq, req)) {
11868                 return tevent_req_post(req, ev);
11869         }
11870         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterEx_r_done, req);
11871
11872         return req;
11873 }
11874
11875 static void dcerpc_spoolss_AddPrinterEx_r_done(struct tevent_req *subreq)
11876 {
11877         struct tevent_req *req =
11878                 tevent_req_callback_data(subreq,
11879                 struct tevent_req);
11880         NTSTATUS status;
11881
11882         status = dcerpc_binding_handle_call_recv(subreq);
11883         if (!NT_STATUS_IS_OK(status)) {
11884                 tevent_req_nterror(req, status);
11885                 return;
11886         }
11887
11888         tevent_req_done(req);
11889 }
11890
11891 NTSTATUS dcerpc_spoolss_AddPrinterEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
11892 {
11893         struct dcerpc_spoolss_AddPrinterEx_r_state *state =
11894                 tevent_req_data(req,
11895                 struct dcerpc_spoolss_AddPrinterEx_r_state);
11896         NTSTATUS status;
11897
11898         if (tevent_req_is_nterror(req, &status)) {
11899                 tevent_req_received(req);
11900                 return status;
11901         }
11902
11903         talloc_steal(mem_ctx, state->out_mem_ctx);
11904
11905         tevent_req_received(req);
11906         return NT_STATUS_OK;
11907 }
11908
11909 NTSTATUS dcerpc_spoolss_AddPrinterEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterEx *r)
11910 {
11911         NTSTATUS status;
11912
11913         status = dcerpc_binding_handle_call(h,
11914                         NULL, &ndr_table_spoolss,
11915                         NDR_SPOOLSS_ADDPRINTEREX, mem_ctx, r);
11916
11917         return status;
11918 }
11919
11920 NTSTATUS dcerpc_spoolss_AddPrinterEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterEx *r)
11921 {
11922         NTSTATUS status;
11923
11924         status = dcerpc_spoolss_AddPrinterEx_r(p->binding_handle, mem_ctx, r);
11925
11926         if (NT_STATUS_IS_RPC(status)) {
11927                 status = NT_STATUS_NET_WRITE_FAULT;
11928         }
11929
11930         return status;
11931 }
11932
11933 struct dcerpc_spoolss_AddPrinterEx_state {
11934         struct spoolss_AddPrinterEx orig;
11935         struct spoolss_AddPrinterEx tmp;
11936         TALLOC_CTX *out_mem_ctx;
11937 };
11938
11939 static void dcerpc_spoolss_AddPrinterEx_done(struct tevent_req *subreq);
11940
11941 struct tevent_req *dcerpc_spoolss_AddPrinterEx_send(TALLOC_CTX *mem_ctx,
11942                                                     struct tevent_context *ev,
11943                                                     struct dcerpc_binding_handle *h,
11944                                                     const char *_server /* [in] [unique,charset(UTF16)] */,
11945                                                     struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
11946                                                     struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
11947                                                     struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
11948                                                     struct spoolss_UserLevelCtr *_userlevel_ctr /* [in] [ref] */,
11949                                                     struct policy_handle *_handle /* [out] [ref] */)
11950 {
11951         struct tevent_req *req;
11952         struct dcerpc_spoolss_AddPrinterEx_state *state;
11953         struct tevent_req *subreq;
11954
11955         req = tevent_req_create(mem_ctx, &state,
11956                                 struct dcerpc_spoolss_AddPrinterEx_state);
11957         if (req == NULL) {
11958                 return NULL;
11959         }
11960         state->out_mem_ctx = NULL;
11961
11962         /* In parameters */
11963         state->orig.in.server = _server;
11964         state->orig.in.info_ctr = _info_ctr;
11965         state->orig.in.devmode_ctr = _devmode_ctr;
11966         state->orig.in.secdesc_ctr = _secdesc_ctr;
11967         state->orig.in.userlevel_ctr = _userlevel_ctr;
11968
11969         /* Out parameters */
11970         state->orig.out.handle = _handle;
11971
11972         /* Result */
11973         ZERO_STRUCT(state->orig.out.result);
11974
11975         state->out_mem_ctx = talloc_named_const(state, 0,
11976                              "dcerpc_spoolss_AddPrinterEx_out_memory");
11977         if (tevent_req_nomem(state->out_mem_ctx, req)) {
11978                 return tevent_req_post(req, ev);
11979         }
11980
11981         /* make a temporary copy, that we pass to the dispatch function */
11982         state->tmp = state->orig;
11983
11984         subreq = dcerpc_spoolss_AddPrinterEx_r_send(state, ev, h, &state->tmp);
11985         if (tevent_req_nomem(subreq, req)) {
11986                 return tevent_req_post(req, ev);
11987         }
11988         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterEx_done, req);
11989         return req;
11990 }
11991
11992 static void dcerpc_spoolss_AddPrinterEx_done(struct tevent_req *subreq)
11993 {
11994         struct tevent_req *req = tevent_req_callback_data(
11995                 subreq, struct tevent_req);
11996         struct dcerpc_spoolss_AddPrinterEx_state *state = tevent_req_data(
11997                 req, struct dcerpc_spoolss_AddPrinterEx_state);
11998         NTSTATUS status;
11999         TALLOC_CTX *mem_ctx;
12000
12001         if (state->out_mem_ctx) {
12002                 mem_ctx = state->out_mem_ctx;
12003         } else {
12004                 mem_ctx = state;
12005         }
12006
12007         status = dcerpc_spoolss_AddPrinterEx_r_recv(subreq, mem_ctx);
12008         TALLOC_FREE(subreq);
12009         if (!NT_STATUS_IS_OK(status)) {
12010                 tevent_req_nterror(req, status);
12011                 return;
12012         }
12013
12014         /* Copy out parameters */
12015         *state->orig.out.handle = *state->tmp.out.handle;
12016
12017         /* Copy result */
12018         state->orig.out.result = state->tmp.out.result;
12019
12020         /* Reset temporary structure */
12021         ZERO_STRUCT(state->tmp);
12022
12023         tevent_req_done(req);
12024 }
12025
12026 NTSTATUS dcerpc_spoolss_AddPrinterEx_recv(struct tevent_req *req,
12027                                           TALLOC_CTX *mem_ctx,
12028                                           WERROR *result)
12029 {
12030         struct dcerpc_spoolss_AddPrinterEx_state *state = tevent_req_data(
12031                 req, struct dcerpc_spoolss_AddPrinterEx_state);
12032         NTSTATUS status;
12033
12034         if (tevent_req_is_nterror(req, &status)) {
12035                 tevent_req_received(req);
12036                 return status;
12037         }
12038
12039         /* Steal possible out parameters to the callers context */
12040         talloc_steal(mem_ctx, state->out_mem_ctx);
12041
12042         /* Return result */
12043         *result = state->orig.out.result;
12044
12045         tevent_req_received(req);
12046         return NT_STATUS_OK;
12047 }
12048
12049 NTSTATUS dcerpc_spoolss_AddPrinterEx(struct dcerpc_binding_handle *h,
12050                                      TALLOC_CTX *mem_ctx,
12051                                      const char *_server /* [in] [unique,charset(UTF16)] */,
12052                                      struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
12053                                      struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
12054                                      struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
12055                                      struct spoolss_UserLevelCtr *_userlevel_ctr /* [in] [ref] */,
12056                                      struct policy_handle *_handle /* [out] [ref] */,
12057                                      WERROR *result)
12058 {
12059         struct spoolss_AddPrinterEx r;
12060         NTSTATUS status;
12061
12062         /* In parameters */
12063         r.in.server = _server;
12064         r.in.info_ctr = _info_ctr;
12065         r.in.devmode_ctr = _devmode_ctr;
12066         r.in.secdesc_ctr = _secdesc_ctr;
12067         r.in.userlevel_ctr = _userlevel_ctr;
12068
12069         status = dcerpc_spoolss_AddPrinterEx_r(h, mem_ctx, &r);
12070         if (!NT_STATUS_IS_OK(status)) {
12071                 return status;
12072         }
12073
12074         /* Return variables */
12075         *_handle = *r.out.handle;
12076
12077         /* Return result */
12078         *result = r.out.result;
12079
12080         return NT_STATUS_OK;
12081 }
12082
12083 struct dcerpc_spoolss_EnumPrinterData_r_state {
12084         TALLOC_CTX *out_mem_ctx;
12085 };
12086
12087 static void dcerpc_spoolss_EnumPrinterData_r_done(struct tevent_req *subreq);
12088
12089 struct tevent_req *dcerpc_spoolss_EnumPrinterData_r_send(TALLOC_CTX *mem_ctx,
12090         struct tevent_context *ev,
12091         struct dcerpc_binding_handle *h,
12092         struct spoolss_EnumPrinterData *r)
12093 {
12094         struct tevent_req *req;
12095         struct dcerpc_spoolss_EnumPrinterData_r_state *state;
12096         struct tevent_req *subreq;
12097
12098         req = tevent_req_create(mem_ctx, &state,
12099                                 struct dcerpc_spoolss_EnumPrinterData_r_state);
12100         if (req == NULL) {
12101                 return NULL;
12102         }
12103
12104         state->out_mem_ctx = talloc_new(state);
12105         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12106                 return tevent_req_post(req, ev);
12107         }
12108
12109         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12110                         NULL, &ndr_table_spoolss,
12111                         NDR_SPOOLSS_ENUMPRINTERDATA, state->out_mem_ctx, r);
12112         if (tevent_req_nomem(subreq, req)) {
12113                 return tevent_req_post(req, ev);
12114         }
12115         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterData_r_done, req);
12116
12117         return req;
12118 }
12119
12120 static void dcerpc_spoolss_EnumPrinterData_r_done(struct tevent_req *subreq)
12121 {
12122         struct tevent_req *req =
12123                 tevent_req_callback_data(subreq,
12124                 struct tevent_req);
12125         NTSTATUS status;
12126
12127         status = dcerpc_binding_handle_call_recv(subreq);
12128         if (!NT_STATUS_IS_OK(status)) {
12129                 tevent_req_nterror(req, status);
12130                 return;
12131         }
12132
12133         tevent_req_done(req);
12134 }
12135
12136 NTSTATUS dcerpc_spoolss_EnumPrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12137 {
12138         struct dcerpc_spoolss_EnumPrinterData_r_state *state =
12139                 tevent_req_data(req,
12140                 struct dcerpc_spoolss_EnumPrinterData_r_state);
12141         NTSTATUS status;
12142
12143         if (tevent_req_is_nterror(req, &status)) {
12144                 tevent_req_received(req);
12145                 return status;
12146         }
12147
12148         talloc_steal(mem_ctx, state->out_mem_ctx);
12149
12150         tevent_req_received(req);
12151         return NT_STATUS_OK;
12152 }
12153
12154 NTSTATUS dcerpc_spoolss_EnumPrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterData *r)
12155 {
12156         NTSTATUS status;
12157
12158         status = dcerpc_binding_handle_call(h,
12159                         NULL, &ndr_table_spoolss,
12160                         NDR_SPOOLSS_ENUMPRINTERDATA, mem_ctx, r);
12161
12162         return status;
12163 }
12164
12165 NTSTATUS dcerpc_spoolss_EnumPrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterData *r)
12166 {
12167         NTSTATUS status;
12168
12169         status = dcerpc_spoolss_EnumPrinterData_r(p->binding_handle, mem_ctx, r);
12170
12171         if (NT_STATUS_IS_RPC(status)) {
12172                 status = NT_STATUS_NET_WRITE_FAULT;
12173         }
12174
12175         return status;
12176 }
12177
12178 struct dcerpc_spoolss_EnumPrinterData_state {
12179         struct spoolss_EnumPrinterData orig;
12180         struct spoolss_EnumPrinterData tmp;
12181         TALLOC_CTX *out_mem_ctx;
12182 };
12183
12184 static void dcerpc_spoolss_EnumPrinterData_done(struct tevent_req *subreq);
12185
12186 struct tevent_req *dcerpc_spoolss_EnumPrinterData_send(TALLOC_CTX *mem_ctx,
12187                                                        struct tevent_context *ev,
12188                                                        struct dcerpc_binding_handle *h,
12189                                                        struct policy_handle *_handle /* [in] [ref] */,
12190                                                        uint32_t _enum_index /* [in]  */,
12191                                                        const char *_value_name /* [out] [charset(UTF16),size_is(value_offered/2)] */,
12192                                                        uint32_t _value_offered /* [in]  */,
12193                                                        uint32_t *_value_needed /* [out] [ref] */,
12194                                                        enum winreg_Type *_type /* [out] [ref] */,
12195                                                        uint8_t *_data /* [out] [ref,flag(LIBNDR_PRINT_ARRAY_HEX),size_is(data_offered)] */,
12196                                                        uint32_t _data_offered /* [in]  */,
12197                                                        uint32_t *_data_needed /* [out] [ref] */)
12198 {
12199         struct tevent_req *req;
12200         struct dcerpc_spoolss_EnumPrinterData_state *state;
12201         struct tevent_req *subreq;
12202
12203         req = tevent_req_create(mem_ctx, &state,
12204                                 struct dcerpc_spoolss_EnumPrinterData_state);
12205         if (req == NULL) {
12206                 return NULL;
12207         }
12208         state->out_mem_ctx = NULL;
12209
12210         /* In parameters */
12211         state->orig.in.handle = _handle;
12212         state->orig.in.enum_index = _enum_index;
12213         state->orig.in.value_offered = _value_offered;
12214         state->orig.in.data_offered = _data_offered;
12215
12216         /* Out parameters */
12217         state->orig.out.value_name = _value_name;
12218         state->orig.out.value_needed = _value_needed;
12219         state->orig.out.type = _type;
12220         state->orig.out.data = _data;
12221         state->orig.out.data_needed = _data_needed;
12222
12223         /* Result */
12224         ZERO_STRUCT(state->orig.out.result);
12225
12226         state->out_mem_ctx = talloc_named_const(state, 0,
12227                              "dcerpc_spoolss_EnumPrinterData_out_memory");
12228         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12229                 return tevent_req_post(req, ev);
12230         }
12231
12232         /* make a temporary copy, that we pass to the dispatch function */
12233         state->tmp = state->orig;
12234
12235         subreq = dcerpc_spoolss_EnumPrinterData_r_send(state, ev, h, &state->tmp);
12236         if (tevent_req_nomem(subreq, req)) {
12237                 return tevent_req_post(req, ev);
12238         }
12239         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterData_done, req);
12240         return req;
12241 }
12242
12243 static void dcerpc_spoolss_EnumPrinterData_done(struct tevent_req *subreq)
12244 {
12245         struct tevent_req *req = tevent_req_callback_data(
12246                 subreq, struct tevent_req);
12247         struct dcerpc_spoolss_EnumPrinterData_state *state = tevent_req_data(
12248                 req, struct dcerpc_spoolss_EnumPrinterData_state);
12249         NTSTATUS status;
12250         TALLOC_CTX *mem_ctx;
12251
12252         if (state->out_mem_ctx) {
12253                 mem_ctx = state->out_mem_ctx;
12254         } else {
12255                 mem_ctx = state;
12256         }
12257
12258         status = dcerpc_spoolss_EnumPrinterData_r_recv(subreq, mem_ctx);
12259         TALLOC_FREE(subreq);
12260         if (!NT_STATUS_IS_OK(status)) {
12261                 tevent_req_nterror(req, status);
12262                 return;
12263         }
12264
12265         /* Copy out parameters */
12266         memcpy(discard_const_p(uint8_t *, state->orig.out.value_name), state->tmp.out.value_name, (state->tmp.in.value_offered / 2) * sizeof(*state->orig.out.value_name));
12267         *state->orig.out.value_needed = *state->tmp.out.value_needed;
12268         *state->orig.out.type = *state->tmp.out.type;
12269         memcpy(state->orig.out.data, state->tmp.out.data, (state->tmp.in.data_offered) * sizeof(*state->orig.out.data));
12270         *state->orig.out.data_needed = *state->tmp.out.data_needed;
12271
12272         /* Copy result */
12273         state->orig.out.result = state->tmp.out.result;
12274
12275         /* Reset temporary structure */
12276         ZERO_STRUCT(state->tmp);
12277
12278         tevent_req_done(req);
12279 }
12280
12281 NTSTATUS dcerpc_spoolss_EnumPrinterData_recv(struct tevent_req *req,
12282                                              TALLOC_CTX *mem_ctx,
12283                                              WERROR *result)
12284 {
12285         struct dcerpc_spoolss_EnumPrinterData_state *state = tevent_req_data(
12286                 req, struct dcerpc_spoolss_EnumPrinterData_state);
12287         NTSTATUS status;
12288
12289         if (tevent_req_is_nterror(req, &status)) {
12290                 tevent_req_received(req);
12291                 return status;
12292         }
12293
12294         /* Steal possible out parameters to the callers context */
12295         talloc_steal(mem_ctx, state->out_mem_ctx);
12296
12297         /* Return result */
12298         *result = state->orig.out.result;
12299
12300         tevent_req_received(req);
12301         return NT_STATUS_OK;
12302 }
12303
12304 NTSTATUS dcerpc_spoolss_EnumPrinterData(struct dcerpc_binding_handle *h,
12305                                         TALLOC_CTX *mem_ctx,
12306                                         struct policy_handle *_handle /* [in] [ref] */,
12307                                         uint32_t _enum_index /* [in]  */,
12308                                         const char *_value_name /* [out] [charset(UTF16),size_is(value_offered/2)] */,
12309                                         uint32_t _value_offered /* [in]  */,
12310                                         uint32_t *_value_needed /* [out] [ref] */,
12311                                         enum winreg_Type *_type /* [out] [ref] */,
12312                                         uint8_t *_data /* [out] [ref,flag(LIBNDR_PRINT_ARRAY_HEX),size_is(data_offered)] */,
12313                                         uint32_t _data_offered /* [in]  */,
12314                                         uint32_t *_data_needed /* [out] [ref] */,
12315                                         WERROR *result)
12316 {
12317         struct spoolss_EnumPrinterData r;
12318         NTSTATUS status;
12319
12320         /* In parameters */
12321         r.in.handle = _handle;
12322         r.in.enum_index = _enum_index;
12323         r.in.value_offered = _value_offered;
12324         r.in.data_offered = _data_offered;
12325
12326         status = dcerpc_spoolss_EnumPrinterData_r(h, mem_ctx, &r);
12327         if (!NT_STATUS_IS_OK(status)) {
12328                 return status;
12329         }
12330
12331         /* Return variables */
12332         memcpy(discard_const_p(uint8_t *, _value_name), r.out.value_name, (r.in.value_offered / 2) * sizeof(*_value_name));
12333         *_value_needed = *r.out.value_needed;
12334         *_type = *r.out.type;
12335         memcpy(_data, r.out.data, (r.in.data_offered) * sizeof(*_data));
12336         *_data_needed = *r.out.data_needed;
12337
12338         /* Return result */
12339         *result = r.out.result;
12340
12341         return NT_STATUS_OK;
12342 }
12343
12344 struct dcerpc_spoolss_DeletePrinterData_r_state {
12345         TALLOC_CTX *out_mem_ctx;
12346 };
12347
12348 static void dcerpc_spoolss_DeletePrinterData_r_done(struct tevent_req *subreq);
12349
12350 struct tevent_req *dcerpc_spoolss_DeletePrinterData_r_send(TALLOC_CTX *mem_ctx,
12351         struct tevent_context *ev,
12352         struct dcerpc_binding_handle *h,
12353         struct spoolss_DeletePrinterData *r)
12354 {
12355         struct tevent_req *req;
12356         struct dcerpc_spoolss_DeletePrinterData_r_state *state;
12357         struct tevent_req *subreq;
12358
12359         req = tevent_req_create(mem_ctx, &state,
12360                                 struct dcerpc_spoolss_DeletePrinterData_r_state);
12361         if (req == NULL) {
12362                 return NULL;
12363         }
12364
12365         state->out_mem_ctx = NULL;
12366         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12367                         NULL, &ndr_table_spoolss,
12368                         NDR_SPOOLSS_DELETEPRINTERDATA, state, r);
12369         if (tevent_req_nomem(subreq, req)) {
12370                 return tevent_req_post(req, ev);
12371         }
12372         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterData_r_done, req);
12373
12374         return req;
12375 }
12376
12377 static void dcerpc_spoolss_DeletePrinterData_r_done(struct tevent_req *subreq)
12378 {
12379         struct tevent_req *req =
12380                 tevent_req_callback_data(subreq,
12381                 struct tevent_req);
12382         NTSTATUS status;
12383
12384         status = dcerpc_binding_handle_call_recv(subreq);
12385         if (!NT_STATUS_IS_OK(status)) {
12386                 tevent_req_nterror(req, status);
12387                 return;
12388         }
12389
12390         tevent_req_done(req);
12391 }
12392
12393 NTSTATUS dcerpc_spoolss_DeletePrinterData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12394 {
12395         struct dcerpc_spoolss_DeletePrinterData_r_state *state =
12396                 tevent_req_data(req,
12397                 struct dcerpc_spoolss_DeletePrinterData_r_state);
12398         NTSTATUS status;
12399
12400         if (tevent_req_is_nterror(req, &status)) {
12401                 tevent_req_received(req);
12402                 return status;
12403         }
12404
12405         talloc_steal(mem_ctx, state->out_mem_ctx);
12406
12407         tevent_req_received(req);
12408         return NT_STATUS_OK;
12409 }
12410
12411 NTSTATUS dcerpc_spoolss_DeletePrinterData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterData *r)
12412 {
12413         NTSTATUS status;
12414
12415         status = dcerpc_binding_handle_call(h,
12416                         NULL, &ndr_table_spoolss,
12417                         NDR_SPOOLSS_DELETEPRINTERDATA, mem_ctx, r);
12418
12419         return status;
12420 }
12421
12422 NTSTATUS dcerpc_spoolss_DeletePrinterData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterData *r)
12423 {
12424         NTSTATUS status;
12425
12426         status = dcerpc_spoolss_DeletePrinterData_r(p->binding_handle, mem_ctx, r);
12427
12428         if (NT_STATUS_IS_RPC(status)) {
12429                 status = NT_STATUS_NET_WRITE_FAULT;
12430         }
12431
12432         return status;
12433 }
12434
12435 struct dcerpc_spoolss_DeletePrinterData_state {
12436         struct spoolss_DeletePrinterData orig;
12437         struct spoolss_DeletePrinterData tmp;
12438         TALLOC_CTX *out_mem_ctx;
12439 };
12440
12441 static void dcerpc_spoolss_DeletePrinterData_done(struct tevent_req *subreq);
12442
12443 struct tevent_req *dcerpc_spoolss_DeletePrinterData_send(TALLOC_CTX *mem_ctx,
12444                                                          struct tevent_context *ev,
12445                                                          struct dcerpc_binding_handle *h,
12446                                                          struct policy_handle *_handle /* [in] [ref] */,
12447                                                          const char *_value_name /* [in] [charset(UTF16)] */)
12448 {
12449         struct tevent_req *req;
12450         struct dcerpc_spoolss_DeletePrinterData_state *state;
12451         struct tevent_req *subreq;
12452
12453         req = tevent_req_create(mem_ctx, &state,
12454                                 struct dcerpc_spoolss_DeletePrinterData_state);
12455         if (req == NULL) {
12456                 return NULL;
12457         }
12458         state->out_mem_ctx = NULL;
12459
12460         /* In parameters */
12461         state->orig.in.handle = _handle;
12462         state->orig.in.value_name = _value_name;
12463
12464         /* Out parameters */
12465
12466         /* Result */
12467         ZERO_STRUCT(state->orig.out.result);
12468
12469         /* make a temporary copy, that we pass to the dispatch function */
12470         state->tmp = state->orig;
12471
12472         subreq = dcerpc_spoolss_DeletePrinterData_r_send(state, ev, h, &state->tmp);
12473         if (tevent_req_nomem(subreq, req)) {
12474                 return tevent_req_post(req, ev);
12475         }
12476         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterData_done, req);
12477         return req;
12478 }
12479
12480 static void dcerpc_spoolss_DeletePrinterData_done(struct tevent_req *subreq)
12481 {
12482         struct tevent_req *req = tevent_req_callback_data(
12483                 subreq, struct tevent_req);
12484         struct dcerpc_spoolss_DeletePrinterData_state *state = tevent_req_data(
12485                 req, struct dcerpc_spoolss_DeletePrinterData_state);
12486         NTSTATUS status;
12487         TALLOC_CTX *mem_ctx;
12488
12489         if (state->out_mem_ctx) {
12490                 mem_ctx = state->out_mem_ctx;
12491         } else {
12492                 mem_ctx = state;
12493         }
12494
12495         status = dcerpc_spoolss_DeletePrinterData_r_recv(subreq, mem_ctx);
12496         TALLOC_FREE(subreq);
12497         if (!NT_STATUS_IS_OK(status)) {
12498                 tevent_req_nterror(req, status);
12499                 return;
12500         }
12501
12502         /* Copy out parameters */
12503
12504         /* Copy result */
12505         state->orig.out.result = state->tmp.out.result;
12506
12507         /* Reset temporary structure */
12508         ZERO_STRUCT(state->tmp);
12509
12510         tevent_req_done(req);
12511 }
12512
12513 NTSTATUS dcerpc_spoolss_DeletePrinterData_recv(struct tevent_req *req,
12514                                                TALLOC_CTX *mem_ctx,
12515                                                WERROR *result)
12516 {
12517         struct dcerpc_spoolss_DeletePrinterData_state *state = tevent_req_data(
12518                 req, struct dcerpc_spoolss_DeletePrinterData_state);
12519         NTSTATUS status;
12520
12521         if (tevent_req_is_nterror(req, &status)) {
12522                 tevent_req_received(req);
12523                 return status;
12524         }
12525
12526         /* Steal possible out parameters to the callers context */
12527         talloc_steal(mem_ctx, state->out_mem_ctx);
12528
12529         /* Return result */
12530         *result = state->orig.out.result;
12531
12532         tevent_req_received(req);
12533         return NT_STATUS_OK;
12534 }
12535
12536 NTSTATUS dcerpc_spoolss_DeletePrinterData(struct dcerpc_binding_handle *h,
12537                                           TALLOC_CTX *mem_ctx,
12538                                           struct policy_handle *_handle /* [in] [ref] */,
12539                                           const char *_value_name /* [in] [charset(UTF16)] */,
12540                                           WERROR *result)
12541 {
12542         struct spoolss_DeletePrinterData r;
12543         NTSTATUS status;
12544
12545         /* In parameters */
12546         r.in.handle = _handle;
12547         r.in.value_name = _value_name;
12548
12549         status = dcerpc_spoolss_DeletePrinterData_r(h, mem_ctx, &r);
12550         if (!NT_STATUS_IS_OK(status)) {
12551                 return status;
12552         }
12553
12554         /* Return variables */
12555
12556         /* Return result */
12557         *result = r.out.result;
12558
12559         return NT_STATUS_OK;
12560 }
12561
12562 struct dcerpc_spoolss_SetPrinterDataEx_r_state {
12563         TALLOC_CTX *out_mem_ctx;
12564 };
12565
12566 static void dcerpc_spoolss_SetPrinterDataEx_r_done(struct tevent_req *subreq);
12567
12568 struct tevent_req *dcerpc_spoolss_SetPrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
12569         struct tevent_context *ev,
12570         struct dcerpc_binding_handle *h,
12571         struct spoolss_SetPrinterDataEx *r)
12572 {
12573         struct tevent_req *req;
12574         struct dcerpc_spoolss_SetPrinterDataEx_r_state *state;
12575         struct tevent_req *subreq;
12576
12577         req = tevent_req_create(mem_ctx, &state,
12578                                 struct dcerpc_spoolss_SetPrinterDataEx_r_state);
12579         if (req == NULL) {
12580                 return NULL;
12581         }
12582
12583         state->out_mem_ctx = NULL;
12584         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12585                         NULL, &ndr_table_spoolss,
12586                         NDR_SPOOLSS_SETPRINTERDATAEX, state, r);
12587         if (tevent_req_nomem(subreq, req)) {
12588                 return tevent_req_post(req, ev);
12589         }
12590         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterDataEx_r_done, req);
12591
12592         return req;
12593 }
12594
12595 static void dcerpc_spoolss_SetPrinterDataEx_r_done(struct tevent_req *subreq)
12596 {
12597         struct tevent_req *req =
12598                 tevent_req_callback_data(subreq,
12599                 struct tevent_req);
12600         NTSTATUS status;
12601
12602         status = dcerpc_binding_handle_call_recv(subreq);
12603         if (!NT_STATUS_IS_OK(status)) {
12604                 tevent_req_nterror(req, status);
12605                 return;
12606         }
12607
12608         tevent_req_done(req);
12609 }
12610
12611 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12612 {
12613         struct dcerpc_spoolss_SetPrinterDataEx_r_state *state =
12614                 tevent_req_data(req,
12615                 struct dcerpc_spoolss_SetPrinterDataEx_r_state);
12616         NTSTATUS status;
12617
12618         if (tevent_req_is_nterror(req, &status)) {
12619                 tevent_req_received(req);
12620                 return status;
12621         }
12622
12623         talloc_steal(mem_ctx, state->out_mem_ctx);
12624
12625         tevent_req_received(req);
12626         return NT_STATUS_OK;
12627 }
12628
12629 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterDataEx *r)
12630 {
12631         NTSTATUS status;
12632
12633         status = dcerpc_binding_handle_call(h,
12634                         NULL, &ndr_table_spoolss,
12635                         NDR_SPOOLSS_SETPRINTERDATAEX, mem_ctx, r);
12636
12637         return status;
12638 }
12639
12640 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_SetPrinterDataEx *r)
12641 {
12642         NTSTATUS status;
12643
12644         status = dcerpc_spoolss_SetPrinterDataEx_r(p->binding_handle, mem_ctx, r);
12645
12646         if (NT_STATUS_IS_RPC(status)) {
12647                 status = NT_STATUS_NET_WRITE_FAULT;
12648         }
12649
12650         return status;
12651 }
12652
12653 struct dcerpc_spoolss_SetPrinterDataEx_state {
12654         struct spoolss_SetPrinterDataEx orig;
12655         struct spoolss_SetPrinterDataEx tmp;
12656         TALLOC_CTX *out_mem_ctx;
12657 };
12658
12659 static void dcerpc_spoolss_SetPrinterDataEx_done(struct tevent_req *subreq);
12660
12661 struct tevent_req *dcerpc_spoolss_SetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
12662                                                         struct tevent_context *ev,
12663                                                         struct dcerpc_binding_handle *h,
12664                                                         struct policy_handle *_handle /* [in] [ref] */,
12665                                                         const char *_key_name /* [in] [charset(UTF16)] */,
12666                                                         const char *_value_name /* [in] [charset(UTF16)] */,
12667                                                         enum winreg_Type _type /* [in]  */,
12668                                                         uint8_t *_data /* [in] [ref,size_is(offered)] */,
12669                                                         uint32_t _offered /* [in]  */)
12670 {
12671         struct tevent_req *req;
12672         struct dcerpc_spoolss_SetPrinterDataEx_state *state;
12673         struct tevent_req *subreq;
12674
12675         req = tevent_req_create(mem_ctx, &state,
12676                                 struct dcerpc_spoolss_SetPrinterDataEx_state);
12677         if (req == NULL) {
12678                 return NULL;
12679         }
12680         state->out_mem_ctx = NULL;
12681
12682         /* In parameters */
12683         state->orig.in.handle = _handle;
12684         state->orig.in.key_name = _key_name;
12685         state->orig.in.value_name = _value_name;
12686         state->orig.in.type = _type;
12687         state->orig.in.data = _data;
12688         state->orig.in.offered = _offered;
12689
12690         /* Out parameters */
12691
12692         /* Result */
12693         ZERO_STRUCT(state->orig.out.result);
12694
12695         /* make a temporary copy, that we pass to the dispatch function */
12696         state->tmp = state->orig;
12697
12698         subreq = dcerpc_spoolss_SetPrinterDataEx_r_send(state, ev, h, &state->tmp);
12699         if (tevent_req_nomem(subreq, req)) {
12700                 return tevent_req_post(req, ev);
12701         }
12702         tevent_req_set_callback(subreq, dcerpc_spoolss_SetPrinterDataEx_done, req);
12703         return req;
12704 }
12705
12706 static void dcerpc_spoolss_SetPrinterDataEx_done(struct tevent_req *subreq)
12707 {
12708         struct tevent_req *req = tevent_req_callback_data(
12709                 subreq, struct tevent_req);
12710         struct dcerpc_spoolss_SetPrinterDataEx_state *state = tevent_req_data(
12711                 req, struct dcerpc_spoolss_SetPrinterDataEx_state);
12712         NTSTATUS status;
12713         TALLOC_CTX *mem_ctx;
12714
12715         if (state->out_mem_ctx) {
12716                 mem_ctx = state->out_mem_ctx;
12717         } else {
12718                 mem_ctx = state;
12719         }
12720
12721         status = dcerpc_spoolss_SetPrinterDataEx_r_recv(subreq, mem_ctx);
12722         TALLOC_FREE(subreq);
12723         if (!NT_STATUS_IS_OK(status)) {
12724                 tevent_req_nterror(req, status);
12725                 return;
12726         }
12727
12728         /* Copy out parameters */
12729
12730         /* Copy result */
12731         state->orig.out.result = state->tmp.out.result;
12732
12733         /* Reset temporary structure */
12734         ZERO_STRUCT(state->tmp);
12735
12736         tevent_req_done(req);
12737 }
12738
12739 NTSTATUS dcerpc_spoolss_SetPrinterDataEx_recv(struct tevent_req *req,
12740                                               TALLOC_CTX *mem_ctx,
12741                                               WERROR *result)
12742 {
12743         struct dcerpc_spoolss_SetPrinterDataEx_state *state = tevent_req_data(
12744                 req, struct dcerpc_spoolss_SetPrinterDataEx_state);
12745         NTSTATUS status;
12746
12747         if (tevent_req_is_nterror(req, &status)) {
12748                 tevent_req_received(req);
12749                 return status;
12750         }
12751
12752         /* Steal possible out parameters to the callers context */
12753         talloc_steal(mem_ctx, state->out_mem_ctx);
12754
12755         /* Return result */
12756         *result = state->orig.out.result;
12757
12758         tevent_req_received(req);
12759         return NT_STATUS_OK;
12760 }
12761
12762 NTSTATUS dcerpc_spoolss_SetPrinterDataEx(struct dcerpc_binding_handle *h,
12763                                          TALLOC_CTX *mem_ctx,
12764                                          struct policy_handle *_handle /* [in] [ref] */,
12765                                          const char *_key_name /* [in] [charset(UTF16)] */,
12766                                          const char *_value_name /* [in] [charset(UTF16)] */,
12767                                          enum winreg_Type _type /* [in]  */,
12768                                          uint8_t *_data /* [in] [ref,size_is(offered)] */,
12769                                          uint32_t _offered /* [in]  */,
12770                                          WERROR *result)
12771 {
12772         struct spoolss_SetPrinterDataEx r;
12773         NTSTATUS status;
12774
12775         /* In parameters */
12776         r.in.handle = _handle;
12777         r.in.key_name = _key_name;
12778         r.in.value_name = _value_name;
12779         r.in.type = _type;
12780         r.in.data = _data;
12781         r.in.offered = _offered;
12782
12783         status = dcerpc_spoolss_SetPrinterDataEx_r(h, mem_ctx, &r);
12784         if (!NT_STATUS_IS_OK(status)) {
12785                 return status;
12786         }
12787
12788         /* Return variables */
12789
12790         /* Return result */
12791         *result = r.out.result;
12792
12793         return NT_STATUS_OK;
12794 }
12795
12796 struct dcerpc_spoolss_GetPrinterDataEx_r_state {
12797         TALLOC_CTX *out_mem_ctx;
12798 };
12799
12800 static void dcerpc_spoolss_GetPrinterDataEx_r_done(struct tevent_req *subreq);
12801
12802 struct tevent_req *dcerpc_spoolss_GetPrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
12803         struct tevent_context *ev,
12804         struct dcerpc_binding_handle *h,
12805         struct spoolss_GetPrinterDataEx *r)
12806 {
12807         struct tevent_req *req;
12808         struct dcerpc_spoolss_GetPrinterDataEx_r_state *state;
12809         struct tevent_req *subreq;
12810
12811         req = tevent_req_create(mem_ctx, &state,
12812                                 struct dcerpc_spoolss_GetPrinterDataEx_r_state);
12813         if (req == NULL) {
12814                 return NULL;
12815         }
12816
12817         state->out_mem_ctx = talloc_new(state);
12818         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12819                 return tevent_req_post(req, ev);
12820         }
12821
12822         subreq = dcerpc_binding_handle_call_send(state, ev, h,
12823                         NULL, &ndr_table_spoolss,
12824                         NDR_SPOOLSS_GETPRINTERDATAEX, state->out_mem_ctx, r);
12825         if (tevent_req_nomem(subreq, req)) {
12826                 return tevent_req_post(req, ev);
12827         }
12828         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDataEx_r_done, req);
12829
12830         return req;
12831 }
12832
12833 static void dcerpc_spoolss_GetPrinterDataEx_r_done(struct tevent_req *subreq)
12834 {
12835         struct tevent_req *req =
12836                 tevent_req_callback_data(subreq,
12837                 struct tevent_req);
12838         NTSTATUS status;
12839
12840         status = dcerpc_binding_handle_call_recv(subreq);
12841         if (!NT_STATUS_IS_OK(status)) {
12842                 tevent_req_nterror(req, status);
12843                 return;
12844         }
12845
12846         tevent_req_done(req);
12847 }
12848
12849 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
12850 {
12851         struct dcerpc_spoolss_GetPrinterDataEx_r_state *state =
12852                 tevent_req_data(req,
12853                 struct dcerpc_spoolss_GetPrinterDataEx_r_state);
12854         NTSTATUS status;
12855
12856         if (tevent_req_is_nterror(req, &status)) {
12857                 tevent_req_received(req);
12858                 return status;
12859         }
12860
12861         talloc_steal(mem_ctx, state->out_mem_ctx);
12862
12863         tevent_req_received(req);
12864         return NT_STATUS_OK;
12865 }
12866
12867 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDataEx *r)
12868 {
12869         NTSTATUS status;
12870
12871         status = dcerpc_binding_handle_call(h,
12872                         NULL, &ndr_table_spoolss,
12873                         NDR_SPOOLSS_GETPRINTERDATAEX, mem_ctx, r);
12874
12875         return status;
12876 }
12877
12878 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDataEx *r)
12879 {
12880         NTSTATUS status;
12881
12882         status = dcerpc_spoolss_GetPrinterDataEx_r(p->binding_handle, mem_ctx, r);
12883
12884         if (NT_STATUS_IS_RPC(status)) {
12885                 status = NT_STATUS_NET_WRITE_FAULT;
12886         }
12887
12888         return status;
12889 }
12890
12891 struct dcerpc_spoolss_GetPrinterDataEx_state {
12892         struct spoolss_GetPrinterDataEx orig;
12893         struct spoolss_GetPrinterDataEx tmp;
12894         TALLOC_CTX *out_mem_ctx;
12895 };
12896
12897 static void dcerpc_spoolss_GetPrinterDataEx_done(struct tevent_req *subreq);
12898
12899 struct tevent_req *dcerpc_spoolss_GetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
12900                                                         struct tevent_context *ev,
12901                                                         struct dcerpc_binding_handle *h,
12902                                                         struct policy_handle *_handle /* [in] [ref] */,
12903                                                         const char *_key_name /* [in] [charset(UTF16)] */,
12904                                                         const char *_value_name /* [in] [charset(UTF16)] */,
12905                                                         enum winreg_Type *_type /* [out] [ref] */,
12906                                                         uint8_t *_data /* [out] [ref,size_is(offered)] */,
12907                                                         uint32_t _offered /* [in]  */,
12908                                                         uint32_t *_needed /* [out] [ref] */)
12909 {
12910         struct tevent_req *req;
12911         struct dcerpc_spoolss_GetPrinterDataEx_state *state;
12912         struct tevent_req *subreq;
12913
12914         req = tevent_req_create(mem_ctx, &state,
12915                                 struct dcerpc_spoolss_GetPrinterDataEx_state);
12916         if (req == NULL) {
12917                 return NULL;
12918         }
12919         state->out_mem_ctx = NULL;
12920
12921         /* In parameters */
12922         state->orig.in.handle = _handle;
12923         state->orig.in.key_name = _key_name;
12924         state->orig.in.value_name = _value_name;
12925         state->orig.in.offered = _offered;
12926
12927         /* Out parameters */
12928         state->orig.out.type = _type;
12929         state->orig.out.data = _data;
12930         state->orig.out.needed = _needed;
12931
12932         /* Result */
12933         ZERO_STRUCT(state->orig.out.result);
12934
12935         state->out_mem_ctx = talloc_named_const(state, 0,
12936                              "dcerpc_spoolss_GetPrinterDataEx_out_memory");
12937         if (tevent_req_nomem(state->out_mem_ctx, req)) {
12938                 return tevent_req_post(req, ev);
12939         }
12940
12941         /* make a temporary copy, that we pass to the dispatch function */
12942         state->tmp = state->orig;
12943
12944         subreq = dcerpc_spoolss_GetPrinterDataEx_r_send(state, ev, h, &state->tmp);
12945         if (tevent_req_nomem(subreq, req)) {
12946                 return tevent_req_post(req, ev);
12947         }
12948         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDataEx_done, req);
12949         return req;
12950 }
12951
12952 static void dcerpc_spoolss_GetPrinterDataEx_done(struct tevent_req *subreq)
12953 {
12954         struct tevent_req *req = tevent_req_callback_data(
12955                 subreq, struct tevent_req);
12956         struct dcerpc_spoolss_GetPrinterDataEx_state *state = tevent_req_data(
12957                 req, struct dcerpc_spoolss_GetPrinterDataEx_state);
12958         NTSTATUS status;
12959         TALLOC_CTX *mem_ctx;
12960
12961         if (state->out_mem_ctx) {
12962                 mem_ctx = state->out_mem_ctx;
12963         } else {
12964                 mem_ctx = state;
12965         }
12966
12967         status = dcerpc_spoolss_GetPrinterDataEx_r_recv(subreq, mem_ctx);
12968         TALLOC_FREE(subreq);
12969         if (!NT_STATUS_IS_OK(status)) {
12970                 tevent_req_nterror(req, status);
12971                 return;
12972         }
12973
12974         /* Copy out parameters */
12975         *state->orig.out.type = *state->tmp.out.type;
12976         memcpy(state->orig.out.data, state->tmp.out.data, (state->tmp.in.offered) * sizeof(*state->orig.out.data));
12977         *state->orig.out.needed = *state->tmp.out.needed;
12978
12979         /* Copy result */
12980         state->orig.out.result = state->tmp.out.result;
12981
12982         /* Reset temporary structure */
12983         ZERO_STRUCT(state->tmp);
12984
12985         tevent_req_done(req);
12986 }
12987
12988 NTSTATUS dcerpc_spoolss_GetPrinterDataEx_recv(struct tevent_req *req,
12989                                               TALLOC_CTX *mem_ctx,
12990                                               WERROR *result)
12991 {
12992         struct dcerpc_spoolss_GetPrinterDataEx_state *state = tevent_req_data(
12993                 req, struct dcerpc_spoolss_GetPrinterDataEx_state);
12994         NTSTATUS status;
12995
12996         if (tevent_req_is_nterror(req, &status)) {
12997                 tevent_req_received(req);
12998                 return status;
12999         }
13000
13001         /* Steal possible out parameters to the callers context */
13002         talloc_steal(mem_ctx, state->out_mem_ctx);
13003
13004         /* Return result */
13005         *result = state->orig.out.result;
13006
13007         tevent_req_received(req);
13008         return NT_STATUS_OK;
13009 }
13010
13011 NTSTATUS dcerpc_spoolss_GetPrinterDataEx(struct dcerpc_binding_handle *h,
13012                                          TALLOC_CTX *mem_ctx,
13013                                          struct policy_handle *_handle /* [in] [ref] */,
13014                                          const char *_key_name /* [in] [charset(UTF16)] */,
13015                                          const char *_value_name /* [in] [charset(UTF16)] */,
13016                                          enum winreg_Type *_type /* [out] [ref] */,
13017                                          uint8_t *_data /* [out] [ref,size_is(offered)] */,
13018                                          uint32_t _offered /* [in]  */,
13019                                          uint32_t *_needed /* [out] [ref] */,
13020                                          WERROR *result)
13021 {
13022         struct spoolss_GetPrinterDataEx r;
13023         NTSTATUS status;
13024
13025         /* In parameters */
13026         r.in.handle = _handle;
13027         r.in.key_name = _key_name;
13028         r.in.value_name = _value_name;
13029         r.in.offered = _offered;
13030
13031         status = dcerpc_spoolss_GetPrinterDataEx_r(h, mem_ctx, &r);
13032         if (!NT_STATUS_IS_OK(status)) {
13033                 return status;
13034         }
13035
13036         /* Return variables */
13037         *_type = *r.out.type;
13038         memcpy(_data, r.out.data, (r.in.offered) * sizeof(*_data));
13039         *_needed = *r.out.needed;
13040
13041         /* Return result */
13042         *result = r.out.result;
13043
13044         return NT_STATUS_OK;
13045 }
13046
13047 struct dcerpc_spoolss_EnumPrinterDataEx_r_state {
13048         TALLOC_CTX *out_mem_ctx;
13049 };
13050
13051 static void dcerpc_spoolss_EnumPrinterDataEx_r_done(struct tevent_req *subreq);
13052
13053 struct tevent_req *dcerpc_spoolss_EnumPrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
13054         struct tevent_context *ev,
13055         struct dcerpc_binding_handle *h,
13056         struct spoolss_EnumPrinterDataEx *r)
13057 {
13058         struct tevent_req *req;
13059         struct dcerpc_spoolss_EnumPrinterDataEx_r_state *state;
13060         struct tevent_req *subreq;
13061
13062         req = tevent_req_create(mem_ctx, &state,
13063                                 struct dcerpc_spoolss_EnumPrinterDataEx_r_state);
13064         if (req == NULL) {
13065                 return NULL;
13066         }
13067
13068         state->out_mem_ctx = talloc_new(state);
13069         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13070                 return tevent_req_post(req, ev);
13071         }
13072
13073         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13074                         NULL, &ndr_table_spoolss,
13075                         NDR_SPOOLSS_ENUMPRINTERDATAEX, state->out_mem_ctx, r);
13076         if (tevent_req_nomem(subreq, req)) {
13077                 return tevent_req_post(req, ev);
13078         }
13079         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterDataEx_r_done, req);
13080
13081         return req;
13082 }
13083
13084 static void dcerpc_spoolss_EnumPrinterDataEx_r_done(struct tevent_req *subreq)
13085 {
13086         struct tevent_req *req =
13087                 tevent_req_callback_data(subreq,
13088                 struct tevent_req);
13089         NTSTATUS status;
13090
13091         status = dcerpc_binding_handle_call_recv(subreq);
13092         if (!NT_STATUS_IS_OK(status)) {
13093                 tevent_req_nterror(req, status);
13094                 return;
13095         }
13096
13097         tevent_req_done(req);
13098 }
13099
13100 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13101 {
13102         struct dcerpc_spoolss_EnumPrinterDataEx_r_state *state =
13103                 tevent_req_data(req,
13104                 struct dcerpc_spoolss_EnumPrinterDataEx_r_state);
13105         NTSTATUS status;
13106
13107         if (tevent_req_is_nterror(req, &status)) {
13108                 tevent_req_received(req);
13109                 return status;
13110         }
13111
13112         talloc_steal(mem_ctx, state->out_mem_ctx);
13113
13114         tevent_req_received(req);
13115         return NT_STATUS_OK;
13116 }
13117
13118 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDataEx *r)
13119 {
13120         NTSTATUS status;
13121
13122         status = dcerpc_binding_handle_call(h,
13123                         NULL, &ndr_table_spoolss,
13124                         NDR_SPOOLSS_ENUMPRINTERDATAEX, mem_ctx, r);
13125
13126         return status;
13127 }
13128
13129 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDataEx *r)
13130 {
13131         NTSTATUS status;
13132
13133         status = dcerpc_spoolss_EnumPrinterDataEx_r(p->binding_handle, mem_ctx, r);
13134
13135         if (NT_STATUS_IS_RPC(status)) {
13136                 status = NT_STATUS_NET_WRITE_FAULT;
13137         }
13138
13139         return status;
13140 }
13141
13142 struct dcerpc_spoolss_EnumPrinterDataEx_state {
13143         struct spoolss_EnumPrinterDataEx orig;
13144         struct spoolss_EnumPrinterDataEx tmp;
13145         TALLOC_CTX *out_mem_ctx;
13146 };
13147
13148 static void dcerpc_spoolss_EnumPrinterDataEx_done(struct tevent_req *subreq);
13149
13150 struct tevent_req *dcerpc_spoolss_EnumPrinterDataEx_send(TALLOC_CTX *mem_ctx,
13151                                                          struct tevent_context *ev,
13152                                                          struct dcerpc_binding_handle *h,
13153                                                          struct policy_handle *_handle /* [in] [ref] */,
13154                                                          const char *_key_name /* [in] [charset(UTF16)] */,
13155                                                          uint32_t _offered /* [in]  */,
13156                                                          uint32_t *_count /* [out] [ref] */,
13157                                                          struct spoolss_PrinterEnumValues **_info /* [out] [ref,size_is(,*count)] */,
13158                                                          uint32_t *_needed /* [out] [ref] */)
13159 {
13160         struct tevent_req *req;
13161         struct dcerpc_spoolss_EnumPrinterDataEx_state *state;
13162         struct tevent_req *subreq;
13163
13164         req = tevent_req_create(mem_ctx, &state,
13165                                 struct dcerpc_spoolss_EnumPrinterDataEx_state);
13166         if (req == NULL) {
13167                 return NULL;
13168         }
13169         state->out_mem_ctx = NULL;
13170
13171         /* In parameters */
13172         state->orig.in.handle = _handle;
13173         state->orig.in.key_name = _key_name;
13174         state->orig.in.offered = _offered;
13175
13176         /* Out parameters */
13177         state->orig.out.count = _count;
13178         state->orig.out.info = _info;
13179         state->orig.out.needed = _needed;
13180
13181         /* Result */
13182         ZERO_STRUCT(state->orig.out.result);
13183
13184         state->out_mem_ctx = talloc_named_const(state, 0,
13185                              "dcerpc_spoolss_EnumPrinterDataEx_out_memory");
13186         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13187                 return tevent_req_post(req, ev);
13188         }
13189
13190         /* make a temporary copy, that we pass to the dispatch function */
13191         state->tmp = state->orig;
13192
13193         subreq = dcerpc_spoolss_EnumPrinterDataEx_r_send(state, ev, h, &state->tmp);
13194         if (tevent_req_nomem(subreq, req)) {
13195                 return tevent_req_post(req, ev);
13196         }
13197         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterDataEx_done, req);
13198         return req;
13199 }
13200
13201 static void dcerpc_spoolss_EnumPrinterDataEx_done(struct tevent_req *subreq)
13202 {
13203         struct tevent_req *req = tevent_req_callback_data(
13204                 subreq, struct tevent_req);
13205         struct dcerpc_spoolss_EnumPrinterDataEx_state *state = tevent_req_data(
13206                 req, struct dcerpc_spoolss_EnumPrinterDataEx_state);
13207         NTSTATUS status;
13208         TALLOC_CTX *mem_ctx;
13209
13210         if (state->out_mem_ctx) {
13211                 mem_ctx = state->out_mem_ctx;
13212         } else {
13213                 mem_ctx = state;
13214         }
13215
13216         status = dcerpc_spoolss_EnumPrinterDataEx_r_recv(subreq, mem_ctx);
13217         TALLOC_FREE(subreq);
13218         if (!NT_STATUS_IS_OK(status)) {
13219                 tevent_req_nterror(req, status);
13220                 return;
13221         }
13222
13223         /* Copy out parameters */
13224         *state->orig.out.count = *state->tmp.out.count;
13225         *state->orig.out.info = *state->tmp.out.info;
13226         *state->orig.out.needed = *state->tmp.out.needed;
13227
13228         /* Copy result */
13229         state->orig.out.result = state->tmp.out.result;
13230
13231         /* Reset temporary structure */
13232         ZERO_STRUCT(state->tmp);
13233
13234         tevent_req_done(req);
13235 }
13236
13237 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx_recv(struct tevent_req *req,
13238                                                TALLOC_CTX *mem_ctx,
13239                                                WERROR *result)
13240 {
13241         struct dcerpc_spoolss_EnumPrinterDataEx_state *state = tevent_req_data(
13242                 req, struct dcerpc_spoolss_EnumPrinterDataEx_state);
13243         NTSTATUS status;
13244
13245         if (tevent_req_is_nterror(req, &status)) {
13246                 tevent_req_received(req);
13247                 return status;
13248         }
13249
13250         /* Steal possible out parameters to the callers context */
13251         talloc_steal(mem_ctx, state->out_mem_ctx);
13252
13253         /* Return result */
13254         *result = state->orig.out.result;
13255
13256         tevent_req_received(req);
13257         return NT_STATUS_OK;
13258 }
13259
13260 NTSTATUS dcerpc_spoolss_EnumPrinterDataEx(struct dcerpc_binding_handle *h,
13261                                           TALLOC_CTX *mem_ctx,
13262                                           struct policy_handle *_handle /* [in] [ref] */,
13263                                           const char *_key_name /* [in] [charset(UTF16)] */,
13264                                           uint32_t _offered /* [in]  */,
13265                                           uint32_t *_count /* [out] [ref] */,
13266                                           struct spoolss_PrinterEnumValues **_info /* [out] [ref,size_is(,*count)] */,
13267                                           uint32_t *_needed /* [out] [ref] */,
13268                                           WERROR *result)
13269 {
13270         struct spoolss_EnumPrinterDataEx r;
13271         NTSTATUS status;
13272
13273         /* In parameters */
13274         r.in.handle = _handle;
13275         r.in.key_name = _key_name;
13276         r.in.offered = _offered;
13277
13278         status = dcerpc_spoolss_EnumPrinterDataEx_r(h, mem_ctx, &r);
13279         if (!NT_STATUS_IS_OK(status)) {
13280                 return status;
13281         }
13282
13283         /* Return variables */
13284         *_count = *r.out.count;
13285         *_info = *r.out.info;
13286         *_needed = *r.out.needed;
13287
13288         /* Return result */
13289         *result = r.out.result;
13290
13291         return NT_STATUS_OK;
13292 }
13293
13294 struct dcerpc_spoolss_EnumPrinterKey_r_state {
13295         TALLOC_CTX *out_mem_ctx;
13296 };
13297
13298 static void dcerpc_spoolss_EnumPrinterKey_r_done(struct tevent_req *subreq);
13299
13300 struct tevent_req *dcerpc_spoolss_EnumPrinterKey_r_send(TALLOC_CTX *mem_ctx,
13301         struct tevent_context *ev,
13302         struct dcerpc_binding_handle *h,
13303         struct spoolss_EnumPrinterKey *r)
13304 {
13305         struct tevent_req *req;
13306         struct dcerpc_spoolss_EnumPrinterKey_r_state *state;
13307         struct tevent_req *subreq;
13308
13309         req = tevent_req_create(mem_ctx, &state,
13310                                 struct dcerpc_spoolss_EnumPrinterKey_r_state);
13311         if (req == NULL) {
13312                 return NULL;
13313         }
13314
13315         state->out_mem_ctx = talloc_new(state);
13316         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13317                 return tevent_req_post(req, ev);
13318         }
13319
13320         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13321                         NULL, &ndr_table_spoolss,
13322                         NDR_SPOOLSS_ENUMPRINTERKEY, state->out_mem_ctx, r);
13323         if (tevent_req_nomem(subreq, req)) {
13324                 return tevent_req_post(req, ev);
13325         }
13326         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterKey_r_done, req);
13327
13328         return req;
13329 }
13330
13331 static void dcerpc_spoolss_EnumPrinterKey_r_done(struct tevent_req *subreq)
13332 {
13333         struct tevent_req *req =
13334                 tevent_req_callback_data(subreq,
13335                 struct tevent_req);
13336         NTSTATUS status;
13337
13338         status = dcerpc_binding_handle_call_recv(subreq);
13339         if (!NT_STATUS_IS_OK(status)) {
13340                 tevent_req_nterror(req, status);
13341                 return;
13342         }
13343
13344         tevent_req_done(req);
13345 }
13346
13347 NTSTATUS dcerpc_spoolss_EnumPrinterKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13348 {
13349         struct dcerpc_spoolss_EnumPrinterKey_r_state *state =
13350                 tevent_req_data(req,
13351                 struct dcerpc_spoolss_EnumPrinterKey_r_state);
13352         NTSTATUS status;
13353
13354         if (tevent_req_is_nterror(req, &status)) {
13355                 tevent_req_received(req);
13356                 return status;
13357         }
13358
13359         talloc_steal(mem_ctx, state->out_mem_ctx);
13360
13361         tevent_req_received(req);
13362         return NT_STATUS_OK;
13363 }
13364
13365 NTSTATUS dcerpc_spoolss_EnumPrinterKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterKey *r)
13366 {
13367         NTSTATUS status;
13368
13369         status = dcerpc_binding_handle_call(h,
13370                         NULL, &ndr_table_spoolss,
13371                         NDR_SPOOLSS_ENUMPRINTERKEY, mem_ctx, r);
13372
13373         return status;
13374 }
13375
13376 NTSTATUS dcerpc_spoolss_EnumPrinterKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterKey *r)
13377 {
13378         NTSTATUS status;
13379
13380         status = dcerpc_spoolss_EnumPrinterKey_r(p->binding_handle, mem_ctx, r);
13381
13382         if (NT_STATUS_IS_RPC(status)) {
13383                 status = NT_STATUS_NET_WRITE_FAULT;
13384         }
13385
13386         return status;
13387 }
13388
13389 struct dcerpc_spoolss_EnumPrinterKey_state {
13390         struct spoolss_EnumPrinterKey orig;
13391         struct spoolss_EnumPrinterKey tmp;
13392         TALLOC_CTX *out_mem_ctx;
13393 };
13394
13395 static void dcerpc_spoolss_EnumPrinterKey_done(struct tevent_req *subreq);
13396
13397 struct tevent_req *dcerpc_spoolss_EnumPrinterKey_send(TALLOC_CTX *mem_ctx,
13398                                                       struct tevent_context *ev,
13399                                                       struct dcerpc_binding_handle *h,
13400                                                       struct policy_handle *_handle /* [in] [ref] */,
13401                                                       const char *_key_name /* [in] [charset(UTF16)] */,
13402                                                       uint32_t *__ndr_size /* [out] [ref] */,
13403                                                       union spoolss_KeyNames *_key_buffer /* [out] [subcontext_size(*_ndr_size*2),ref,subcontext(0),switch_is(*_ndr_size)] */,
13404                                                       uint32_t _offered /* [in]  */,
13405                                                       uint32_t *_needed /* [out] [ref] */)
13406 {
13407         struct tevent_req *req;
13408         struct dcerpc_spoolss_EnumPrinterKey_state *state;
13409         struct tevent_req *subreq;
13410
13411         req = tevent_req_create(mem_ctx, &state,
13412                                 struct dcerpc_spoolss_EnumPrinterKey_state);
13413         if (req == NULL) {
13414                 return NULL;
13415         }
13416         state->out_mem_ctx = NULL;
13417
13418         /* In parameters */
13419         state->orig.in.handle = _handle;
13420         state->orig.in.key_name = _key_name;
13421         state->orig.in.offered = _offered;
13422
13423         /* Out parameters */
13424         state->orig.out._ndr_size = __ndr_size;
13425         state->orig.out.key_buffer = _key_buffer;
13426         state->orig.out.needed = _needed;
13427
13428         /* Result */
13429         ZERO_STRUCT(state->orig.out.result);
13430
13431         state->out_mem_ctx = talloc_named_const(state, 0,
13432                              "dcerpc_spoolss_EnumPrinterKey_out_memory");
13433         if (tevent_req_nomem(state->out_mem_ctx, req)) {
13434                 return tevent_req_post(req, ev);
13435         }
13436
13437         /* make a temporary copy, that we pass to the dispatch function */
13438         state->tmp = state->orig;
13439
13440         subreq = dcerpc_spoolss_EnumPrinterKey_r_send(state, ev, h, &state->tmp);
13441         if (tevent_req_nomem(subreq, req)) {
13442                 return tevent_req_post(req, ev);
13443         }
13444         tevent_req_set_callback(subreq, dcerpc_spoolss_EnumPrinterKey_done, req);
13445         return req;
13446 }
13447
13448 static void dcerpc_spoolss_EnumPrinterKey_done(struct tevent_req *subreq)
13449 {
13450         struct tevent_req *req = tevent_req_callback_data(
13451                 subreq, struct tevent_req);
13452         struct dcerpc_spoolss_EnumPrinterKey_state *state = tevent_req_data(
13453                 req, struct dcerpc_spoolss_EnumPrinterKey_state);
13454         NTSTATUS status;
13455         TALLOC_CTX *mem_ctx;
13456
13457         if (state->out_mem_ctx) {
13458                 mem_ctx = state->out_mem_ctx;
13459         } else {
13460                 mem_ctx = state;
13461         }
13462
13463         status = dcerpc_spoolss_EnumPrinterKey_r_recv(subreq, mem_ctx);
13464         TALLOC_FREE(subreq);
13465         if (!NT_STATUS_IS_OK(status)) {
13466                 tevent_req_nterror(req, status);
13467                 return;
13468         }
13469
13470         /* Copy out parameters */
13471         *state->orig.out._ndr_size = *state->tmp.out._ndr_size;
13472         *state->orig.out.key_buffer = *state->tmp.out.key_buffer;
13473         *state->orig.out.needed = *state->tmp.out.needed;
13474
13475         /* Copy result */
13476         state->orig.out.result = state->tmp.out.result;
13477
13478         /* Reset temporary structure */
13479         ZERO_STRUCT(state->tmp);
13480
13481         tevent_req_done(req);
13482 }
13483
13484 NTSTATUS dcerpc_spoolss_EnumPrinterKey_recv(struct tevent_req *req,
13485                                             TALLOC_CTX *mem_ctx,
13486                                             WERROR *result)
13487 {
13488         struct dcerpc_spoolss_EnumPrinterKey_state *state = tevent_req_data(
13489                 req, struct dcerpc_spoolss_EnumPrinterKey_state);
13490         NTSTATUS status;
13491
13492         if (tevent_req_is_nterror(req, &status)) {
13493                 tevent_req_received(req);
13494                 return status;
13495         }
13496
13497         /* Steal possible out parameters to the callers context */
13498         talloc_steal(mem_ctx, state->out_mem_ctx);
13499
13500         /* Return result */
13501         *result = state->orig.out.result;
13502
13503         tevent_req_received(req);
13504         return NT_STATUS_OK;
13505 }
13506
13507 NTSTATUS dcerpc_spoolss_EnumPrinterKey(struct dcerpc_binding_handle *h,
13508                                        TALLOC_CTX *mem_ctx,
13509                                        struct policy_handle *_handle /* [in] [ref] */,
13510                                        const char *_key_name /* [in] [charset(UTF16)] */,
13511                                        uint32_t *__ndr_size /* [out] [ref] */,
13512                                        union spoolss_KeyNames *_key_buffer /* [out] [subcontext_size(*_ndr_size*2),ref,subcontext(0),switch_is(*_ndr_size)] */,
13513                                        uint32_t _offered /* [in]  */,
13514                                        uint32_t *_needed /* [out] [ref] */,
13515                                        WERROR *result)
13516 {
13517         struct spoolss_EnumPrinterKey r;
13518         NTSTATUS status;
13519
13520         /* In parameters */
13521         r.in.handle = _handle;
13522         r.in.key_name = _key_name;
13523         r.in.offered = _offered;
13524
13525         status = dcerpc_spoolss_EnumPrinterKey_r(h, mem_ctx, &r);
13526         if (!NT_STATUS_IS_OK(status)) {
13527                 return status;
13528         }
13529
13530         /* Return variables */
13531         *__ndr_size = *r.out._ndr_size;
13532         *_key_buffer = *r.out.key_buffer;
13533         *_needed = *r.out.needed;
13534
13535         /* Return result */
13536         *result = r.out.result;
13537
13538         return NT_STATUS_OK;
13539 }
13540
13541 struct dcerpc_spoolss_DeletePrinterDataEx_r_state {
13542         TALLOC_CTX *out_mem_ctx;
13543 };
13544
13545 static void dcerpc_spoolss_DeletePrinterDataEx_r_done(struct tevent_req *subreq);
13546
13547 struct tevent_req *dcerpc_spoolss_DeletePrinterDataEx_r_send(TALLOC_CTX *mem_ctx,
13548         struct tevent_context *ev,
13549         struct dcerpc_binding_handle *h,
13550         struct spoolss_DeletePrinterDataEx *r)
13551 {
13552         struct tevent_req *req;
13553         struct dcerpc_spoolss_DeletePrinterDataEx_r_state *state;
13554         struct tevent_req *subreq;
13555
13556         req = tevent_req_create(mem_ctx, &state,
13557                                 struct dcerpc_spoolss_DeletePrinterDataEx_r_state);
13558         if (req == NULL) {
13559                 return NULL;
13560         }
13561
13562         state->out_mem_ctx = NULL;
13563         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13564                         NULL, &ndr_table_spoolss,
13565                         NDR_SPOOLSS_DELETEPRINTERDATAEX, state, r);
13566         if (tevent_req_nomem(subreq, req)) {
13567                 return tevent_req_post(req, ev);
13568         }
13569         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDataEx_r_done, req);
13570
13571         return req;
13572 }
13573
13574 static void dcerpc_spoolss_DeletePrinterDataEx_r_done(struct tevent_req *subreq)
13575 {
13576         struct tevent_req *req =
13577                 tevent_req_callback_data(subreq,
13578                 struct tevent_req);
13579         NTSTATUS status;
13580
13581         status = dcerpc_binding_handle_call_recv(subreq);
13582         if (!NT_STATUS_IS_OK(status)) {
13583                 tevent_req_nterror(req, status);
13584                 return;
13585         }
13586
13587         tevent_req_done(req);
13588 }
13589
13590 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13591 {
13592         struct dcerpc_spoolss_DeletePrinterDataEx_r_state *state =
13593                 tevent_req_data(req,
13594                 struct dcerpc_spoolss_DeletePrinterDataEx_r_state);
13595         NTSTATUS status;
13596
13597         if (tevent_req_is_nterror(req, &status)) {
13598                 tevent_req_received(req);
13599                 return status;
13600         }
13601
13602         talloc_steal(mem_ctx, state->out_mem_ctx);
13603
13604         tevent_req_received(req);
13605         return NT_STATUS_OK;
13606 }
13607
13608 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDataEx *r)
13609 {
13610         NTSTATUS status;
13611
13612         status = dcerpc_binding_handle_call(h,
13613                         NULL, &ndr_table_spoolss,
13614                         NDR_SPOOLSS_DELETEPRINTERDATAEX, mem_ctx, r);
13615
13616         return status;
13617 }
13618
13619 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDataEx *r)
13620 {
13621         NTSTATUS status;
13622
13623         status = dcerpc_spoolss_DeletePrinterDataEx_r(p->binding_handle, mem_ctx, r);
13624
13625         if (NT_STATUS_IS_RPC(status)) {
13626                 status = NT_STATUS_NET_WRITE_FAULT;
13627         }
13628
13629         return status;
13630 }
13631
13632 struct dcerpc_spoolss_DeletePrinterDataEx_state {
13633         struct spoolss_DeletePrinterDataEx orig;
13634         struct spoolss_DeletePrinterDataEx tmp;
13635         TALLOC_CTX *out_mem_ctx;
13636 };
13637
13638 static void dcerpc_spoolss_DeletePrinterDataEx_done(struct tevent_req *subreq);
13639
13640 struct tevent_req *dcerpc_spoolss_DeletePrinterDataEx_send(TALLOC_CTX *mem_ctx,
13641                                                            struct tevent_context *ev,
13642                                                            struct dcerpc_binding_handle *h,
13643                                                            struct policy_handle *_handle /* [in] [ref] */,
13644                                                            const char *_key_name /* [in] [charset(UTF16)] */,
13645                                                            const char *_value_name /* [in] [charset(UTF16)] */)
13646 {
13647         struct tevent_req *req;
13648         struct dcerpc_spoolss_DeletePrinterDataEx_state *state;
13649         struct tevent_req *subreq;
13650
13651         req = tevent_req_create(mem_ctx, &state,
13652                                 struct dcerpc_spoolss_DeletePrinterDataEx_state);
13653         if (req == NULL) {
13654                 return NULL;
13655         }
13656         state->out_mem_ctx = NULL;
13657
13658         /* In parameters */
13659         state->orig.in.handle = _handle;
13660         state->orig.in.key_name = _key_name;
13661         state->orig.in.value_name = _value_name;
13662
13663         /* Out parameters */
13664
13665         /* Result */
13666         ZERO_STRUCT(state->orig.out.result);
13667
13668         /* make a temporary copy, that we pass to the dispatch function */
13669         state->tmp = state->orig;
13670
13671         subreq = dcerpc_spoolss_DeletePrinterDataEx_r_send(state, ev, h, &state->tmp);
13672         if (tevent_req_nomem(subreq, req)) {
13673                 return tevent_req_post(req, ev);
13674         }
13675         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDataEx_done, req);
13676         return req;
13677 }
13678
13679 static void dcerpc_spoolss_DeletePrinterDataEx_done(struct tevent_req *subreq)
13680 {
13681         struct tevent_req *req = tevent_req_callback_data(
13682                 subreq, struct tevent_req);
13683         struct dcerpc_spoolss_DeletePrinterDataEx_state *state = tevent_req_data(
13684                 req, struct dcerpc_spoolss_DeletePrinterDataEx_state);
13685         NTSTATUS status;
13686         TALLOC_CTX *mem_ctx;
13687
13688         if (state->out_mem_ctx) {
13689                 mem_ctx = state->out_mem_ctx;
13690         } else {
13691                 mem_ctx = state;
13692         }
13693
13694         status = dcerpc_spoolss_DeletePrinterDataEx_r_recv(subreq, mem_ctx);
13695         TALLOC_FREE(subreq);
13696         if (!NT_STATUS_IS_OK(status)) {
13697                 tevent_req_nterror(req, status);
13698                 return;
13699         }
13700
13701         /* Copy out parameters */
13702
13703         /* Copy result */
13704         state->orig.out.result = state->tmp.out.result;
13705
13706         /* Reset temporary structure */
13707         ZERO_STRUCT(state->tmp);
13708
13709         tevent_req_done(req);
13710 }
13711
13712 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx_recv(struct tevent_req *req,
13713                                                  TALLOC_CTX *mem_ctx,
13714                                                  WERROR *result)
13715 {
13716         struct dcerpc_spoolss_DeletePrinterDataEx_state *state = tevent_req_data(
13717                 req, struct dcerpc_spoolss_DeletePrinterDataEx_state);
13718         NTSTATUS status;
13719
13720         if (tevent_req_is_nterror(req, &status)) {
13721                 tevent_req_received(req);
13722                 return status;
13723         }
13724
13725         /* Steal possible out parameters to the callers context */
13726         talloc_steal(mem_ctx, state->out_mem_ctx);
13727
13728         /* Return result */
13729         *result = state->orig.out.result;
13730
13731         tevent_req_received(req);
13732         return NT_STATUS_OK;
13733 }
13734
13735 NTSTATUS dcerpc_spoolss_DeletePrinterDataEx(struct dcerpc_binding_handle *h,
13736                                             TALLOC_CTX *mem_ctx,
13737                                             struct policy_handle *_handle /* [in] [ref] */,
13738                                             const char *_key_name /* [in] [charset(UTF16)] */,
13739                                             const char *_value_name /* [in] [charset(UTF16)] */,
13740                                             WERROR *result)
13741 {
13742         struct spoolss_DeletePrinterDataEx r;
13743         NTSTATUS status;
13744
13745         /* In parameters */
13746         r.in.handle = _handle;
13747         r.in.key_name = _key_name;
13748         r.in.value_name = _value_name;
13749
13750         status = dcerpc_spoolss_DeletePrinterDataEx_r(h, mem_ctx, &r);
13751         if (!NT_STATUS_IS_OK(status)) {
13752                 return status;
13753         }
13754
13755         /* Return variables */
13756
13757         /* Return result */
13758         *result = r.out.result;
13759
13760         return NT_STATUS_OK;
13761 }
13762
13763 struct dcerpc_spoolss_DeletePrinterKey_r_state {
13764         TALLOC_CTX *out_mem_ctx;
13765 };
13766
13767 static void dcerpc_spoolss_DeletePrinterKey_r_done(struct tevent_req *subreq);
13768
13769 struct tevent_req *dcerpc_spoolss_DeletePrinterKey_r_send(TALLOC_CTX *mem_ctx,
13770         struct tevent_context *ev,
13771         struct dcerpc_binding_handle *h,
13772         struct spoolss_DeletePrinterKey *r)
13773 {
13774         struct tevent_req *req;
13775         struct dcerpc_spoolss_DeletePrinterKey_r_state *state;
13776         struct tevent_req *subreq;
13777
13778         req = tevent_req_create(mem_ctx, &state,
13779                                 struct dcerpc_spoolss_DeletePrinterKey_r_state);
13780         if (req == NULL) {
13781                 return NULL;
13782         }
13783
13784         state->out_mem_ctx = NULL;
13785         subreq = dcerpc_binding_handle_call_send(state, ev, h,
13786                         NULL, &ndr_table_spoolss,
13787                         NDR_SPOOLSS_DELETEPRINTERKEY, state, r);
13788         if (tevent_req_nomem(subreq, req)) {
13789                 return tevent_req_post(req, ev);
13790         }
13791         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterKey_r_done, req);
13792
13793         return req;
13794 }
13795
13796 static void dcerpc_spoolss_DeletePrinterKey_r_done(struct tevent_req *subreq)
13797 {
13798         struct tevent_req *req =
13799                 tevent_req_callback_data(subreq,
13800                 struct tevent_req);
13801         NTSTATUS status;
13802
13803         status = dcerpc_binding_handle_call_recv(subreq);
13804         if (!NT_STATUS_IS_OK(status)) {
13805                 tevent_req_nterror(req, status);
13806                 return;
13807         }
13808
13809         tevent_req_done(req);
13810 }
13811
13812 NTSTATUS dcerpc_spoolss_DeletePrinterKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
13813 {
13814         struct dcerpc_spoolss_DeletePrinterKey_r_state *state =
13815                 tevent_req_data(req,
13816                 struct dcerpc_spoolss_DeletePrinterKey_r_state);
13817         NTSTATUS status;
13818
13819         if (tevent_req_is_nterror(req, &status)) {
13820                 tevent_req_received(req);
13821                 return status;
13822         }
13823
13824         talloc_steal(mem_ctx, state->out_mem_ctx);
13825
13826         tevent_req_received(req);
13827         return NT_STATUS_OK;
13828 }
13829
13830 NTSTATUS dcerpc_spoolss_DeletePrinterKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterKey *r)
13831 {
13832         NTSTATUS status;
13833
13834         status = dcerpc_binding_handle_call(h,
13835                         NULL, &ndr_table_spoolss,
13836                         NDR_SPOOLSS_DELETEPRINTERKEY, mem_ctx, r);
13837
13838         return status;
13839 }
13840
13841 NTSTATUS dcerpc_spoolss_DeletePrinterKey_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterKey *r)
13842 {
13843         NTSTATUS status;
13844
13845         status = dcerpc_spoolss_DeletePrinterKey_r(p->binding_handle, mem_ctx, r);
13846
13847         if (NT_STATUS_IS_RPC(status)) {
13848                 status = NT_STATUS_NET_WRITE_FAULT;
13849         }
13850
13851         return status;
13852 }
13853
13854 struct dcerpc_spoolss_DeletePrinterKey_state {
13855         struct spoolss_DeletePrinterKey orig;
13856         struct spoolss_DeletePrinterKey tmp;
13857         TALLOC_CTX *out_mem_ctx;
13858 };
13859
13860 static void dcerpc_spoolss_DeletePrinterKey_done(struct tevent_req *subreq);
13861
13862 struct tevent_req *dcerpc_spoolss_DeletePrinterKey_send(TALLOC_CTX *mem_ctx,
13863                                                         struct tevent_context *ev,
13864                                                         struct dcerpc_binding_handle *h,
13865                                                         struct policy_handle *_handle /* [in] [ref] */,
13866                                                         const char *_key_name /* [in] [charset(UTF16)] */)
13867 {
13868         struct tevent_req *req;
13869         struct dcerpc_spoolss_DeletePrinterKey_state *state;
13870         struct tevent_req *subreq;
13871
13872         req = tevent_req_create(mem_ctx, &state,
13873                                 struct dcerpc_spoolss_DeletePrinterKey_state);
13874         if (req == NULL) {
13875                 return NULL;
13876         }
13877         state->out_mem_ctx = NULL;
13878
13879         /* In parameters */
13880         state->orig.in.handle = _handle;
13881         state->orig.in.key_name = _key_name;
13882
13883         /* Out parameters */
13884
13885         /* Result */
13886         ZERO_STRUCT(state->orig.out.result);
13887
13888         /* make a temporary copy, that we pass to the dispatch function */
13889         state->tmp = state->orig;
13890
13891         subreq = dcerpc_spoolss_DeletePrinterKey_r_send(state, ev, h, &state->tmp);
13892         if (tevent_req_nomem(subreq, req)) {
13893                 return tevent_req_post(req, ev);
13894         }
13895         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterKey_done, req);
13896         return req;
13897 }
13898
13899 static void dcerpc_spoolss_DeletePrinterKey_done(struct tevent_req *subreq)
13900 {
13901         struct tevent_req *req = tevent_req_callback_data(
13902                 subreq, struct tevent_req);
13903         struct dcerpc_spoolss_DeletePrinterKey_state *state = tevent_req_data(
13904                 req, struct dcerpc_spoolss_DeletePrinterKey_state);
13905         NTSTATUS status;
13906         TALLOC_CTX *mem_ctx;
13907
13908         if (state->out_mem_ctx) {
13909                 mem_ctx = state->out_mem_ctx;
13910         } else {
13911                 mem_ctx = state;
13912         }
13913
13914         status = dcerpc_spoolss_DeletePrinterKey_r_recv(subreq, mem_ctx);
13915         TALLOC_FREE(subreq);
13916         if (!NT_STATUS_IS_OK(status)) {
13917                 tevent_req_nterror(req, status);
13918                 return;
13919         }
13920
13921         /* Copy out parameters */
13922
13923         /* Copy result */
13924         state->orig.out.result = state->tmp.out.result;
13925
13926         /* Reset temporary structure */
13927         ZERO_STRUCT(state->tmp);
13928
13929         tevent_req_done(req);
13930 }
13931
13932 NTSTATUS dcerpc_spoolss_DeletePrinterKey_recv(struct tevent_req *req,
13933                                               TALLOC_CTX *mem_ctx,
13934                                               WERROR *result)
13935 {
13936         struct dcerpc_spoolss_DeletePrinterKey_state *state = tevent_req_data(
13937                 req, struct dcerpc_spoolss_DeletePrinterKey_state);
13938         NTSTATUS status;
13939
13940         if (tevent_req_is_nterror(req, &status)) {
13941                 tevent_req_received(req);
13942                 return status;
13943         }
13944
13945         /* Steal possible out parameters to the callers context */
13946         talloc_steal(mem_ctx, state->out_mem_ctx);
13947
13948         /* Return result */
13949         *result = state->orig.out.result;
13950
13951         tevent_req_received(req);
13952         return NT_STATUS_OK;
13953 }
13954
13955 NTSTATUS dcerpc_spoolss_DeletePrinterKey(struct dcerpc_binding_handle *h,
13956                                          TALLOC_CTX *mem_ctx,
13957                                          struct policy_handle *_handle /* [in] [ref] */,
13958                                          const char *_key_name /* [in] [charset(UTF16)] */,
13959                                          WERROR *result)
13960 {
13961         struct spoolss_DeletePrinterKey r;
13962         NTSTATUS status;
13963
13964         /* In parameters */
13965         r.in.handle = _handle;
13966         r.in.key_name = _key_name;
13967
13968         status = dcerpc_spoolss_DeletePrinterKey_r(h, mem_ctx, &r);
13969         if (!NT_STATUS_IS_OK(status)) {
13970                 return status;
13971         }
13972
13973         /* Return variables */
13974
13975         /* Return result */
13976         *result = r.out.result;
13977
13978         return NT_STATUS_OK;
13979 }
13980
13981 struct dcerpc_spoolss_DeletePrinterDriverEx_r_state {
13982         TALLOC_CTX *out_mem_ctx;
13983 };
13984
13985 static void dcerpc_spoolss_DeletePrinterDriverEx_r_done(struct tevent_req *subreq);
13986
13987 struct tevent_req *dcerpc_spoolss_DeletePrinterDriverEx_r_send(TALLOC_CTX *mem_ctx,
13988         struct tevent_context *ev,
13989         struct dcerpc_binding_handle *h,
13990         struct spoolss_DeletePrinterDriverEx *r)
13991 {
13992         struct tevent_req *req;
13993         struct dcerpc_spoolss_DeletePrinterDriverEx_r_state *state;
13994         struct tevent_req *subreq;
13995
13996         req = tevent_req_create(mem_ctx, &state,
13997                                 struct dcerpc_spoolss_DeletePrinterDriverEx_r_state);
13998         if (req == NULL) {
13999                 return NULL;
14000         }
14001
14002         state->out_mem_ctx = NULL;
14003         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14004                         NULL, &ndr_table_spoolss,
14005                         NDR_SPOOLSS_DELETEPRINTERDRIVEREX, state, r);
14006         if (tevent_req_nomem(subreq, req)) {
14007                 return tevent_req_post(req, ev);
14008         }
14009         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDriverEx_r_done, req);
14010
14011         return req;
14012 }
14013
14014 static void dcerpc_spoolss_DeletePrinterDriverEx_r_done(struct tevent_req *subreq)
14015 {
14016         struct tevent_req *req =
14017                 tevent_req_callback_data(subreq,
14018                 struct tevent_req);
14019         NTSTATUS status;
14020
14021         status = dcerpc_binding_handle_call_recv(subreq);
14022         if (!NT_STATUS_IS_OK(status)) {
14023                 tevent_req_nterror(req, status);
14024                 return;
14025         }
14026
14027         tevent_req_done(req);
14028 }
14029
14030 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14031 {
14032         struct dcerpc_spoolss_DeletePrinterDriverEx_r_state *state =
14033                 tevent_req_data(req,
14034                 struct dcerpc_spoolss_DeletePrinterDriverEx_r_state);
14035         NTSTATUS status;
14036
14037         if (tevent_req_is_nterror(req, &status)) {
14038                 tevent_req_received(req);
14039                 return status;
14040         }
14041
14042         talloc_steal(mem_ctx, state->out_mem_ctx);
14043
14044         tevent_req_received(req);
14045         return NT_STATUS_OK;
14046 }
14047
14048 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDriverEx *r)
14049 {
14050         NTSTATUS status;
14051
14052         status = dcerpc_binding_handle_call(h,
14053                         NULL, &ndr_table_spoolss,
14054                         NDR_SPOOLSS_DELETEPRINTERDRIVEREX, mem_ctx, r);
14055
14056         return status;
14057 }
14058
14059 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_DeletePrinterDriverEx *r)
14060 {
14061         NTSTATUS status;
14062
14063         status = dcerpc_spoolss_DeletePrinterDriverEx_r(p->binding_handle, mem_ctx, r);
14064
14065         if (NT_STATUS_IS_RPC(status)) {
14066                 status = NT_STATUS_NET_WRITE_FAULT;
14067         }
14068
14069         return status;
14070 }
14071
14072 struct dcerpc_spoolss_DeletePrinterDriverEx_state {
14073         struct spoolss_DeletePrinterDriverEx orig;
14074         struct spoolss_DeletePrinterDriverEx tmp;
14075         TALLOC_CTX *out_mem_ctx;
14076 };
14077
14078 static void dcerpc_spoolss_DeletePrinterDriverEx_done(struct tevent_req *subreq);
14079
14080 struct tevent_req *dcerpc_spoolss_DeletePrinterDriverEx_send(TALLOC_CTX *mem_ctx,
14081                                                              struct tevent_context *ev,
14082                                                              struct dcerpc_binding_handle *h,
14083                                                              const char *_server /* [in] [unique,charset(UTF16)] */,
14084                                                              const char *_architecture /* [in] [charset(UTF16)] */,
14085                                                              const char *_driver /* [in] [charset(UTF16)] */,
14086                                                              uint32_t _delete_flags /* [in]  */,
14087                                                              uint32_t _version /* [in]  */)
14088 {
14089         struct tevent_req *req;
14090         struct dcerpc_spoolss_DeletePrinterDriverEx_state *state;
14091         struct tevent_req *subreq;
14092
14093         req = tevent_req_create(mem_ctx, &state,
14094                                 struct dcerpc_spoolss_DeletePrinterDriverEx_state);
14095         if (req == NULL) {
14096                 return NULL;
14097         }
14098         state->out_mem_ctx = NULL;
14099
14100         /* In parameters */
14101         state->orig.in.server = _server;
14102         state->orig.in.architecture = _architecture;
14103         state->orig.in.driver = _driver;
14104         state->orig.in.delete_flags = _delete_flags;
14105         state->orig.in.version = _version;
14106
14107         /* Out parameters */
14108
14109         /* Result */
14110         ZERO_STRUCT(state->orig.out.result);
14111
14112         /* make a temporary copy, that we pass to the dispatch function */
14113         state->tmp = state->orig;
14114
14115         subreq = dcerpc_spoolss_DeletePrinterDriverEx_r_send(state, ev, h, &state->tmp);
14116         if (tevent_req_nomem(subreq, req)) {
14117                 return tevent_req_post(req, ev);
14118         }
14119         tevent_req_set_callback(subreq, dcerpc_spoolss_DeletePrinterDriverEx_done, req);
14120         return req;
14121 }
14122
14123 static void dcerpc_spoolss_DeletePrinterDriverEx_done(struct tevent_req *subreq)
14124 {
14125         struct tevent_req *req = tevent_req_callback_data(
14126                 subreq, struct tevent_req);
14127         struct dcerpc_spoolss_DeletePrinterDriverEx_state *state = tevent_req_data(
14128                 req, struct dcerpc_spoolss_DeletePrinterDriverEx_state);
14129         NTSTATUS status;
14130         TALLOC_CTX *mem_ctx;
14131
14132         if (state->out_mem_ctx) {
14133                 mem_ctx = state->out_mem_ctx;
14134         } else {
14135                 mem_ctx = state;
14136         }
14137
14138         status = dcerpc_spoolss_DeletePrinterDriverEx_r_recv(subreq, mem_ctx);
14139         TALLOC_FREE(subreq);
14140         if (!NT_STATUS_IS_OK(status)) {
14141                 tevent_req_nterror(req, status);
14142                 return;
14143         }
14144
14145         /* Copy out parameters */
14146
14147         /* Copy result */
14148         state->orig.out.result = state->tmp.out.result;
14149
14150         /* Reset temporary structure */
14151         ZERO_STRUCT(state->tmp);
14152
14153         tevent_req_done(req);
14154 }
14155
14156 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx_recv(struct tevent_req *req,
14157                                                    TALLOC_CTX *mem_ctx,
14158                                                    WERROR *result)
14159 {
14160         struct dcerpc_spoolss_DeletePrinterDriverEx_state *state = tevent_req_data(
14161                 req, struct dcerpc_spoolss_DeletePrinterDriverEx_state);
14162         NTSTATUS status;
14163
14164         if (tevent_req_is_nterror(req, &status)) {
14165                 tevent_req_received(req);
14166                 return status;
14167         }
14168
14169         /* Steal possible out parameters to the callers context */
14170         talloc_steal(mem_ctx, state->out_mem_ctx);
14171
14172         /* Return result */
14173         *result = state->orig.out.result;
14174
14175         tevent_req_received(req);
14176         return NT_STATUS_OK;
14177 }
14178
14179 NTSTATUS dcerpc_spoolss_DeletePrinterDriverEx(struct dcerpc_binding_handle *h,
14180                                               TALLOC_CTX *mem_ctx,
14181                                               const char *_server /* [in] [unique,charset(UTF16)] */,
14182                                               const char *_architecture /* [in] [charset(UTF16)] */,
14183                                               const char *_driver /* [in] [charset(UTF16)] */,
14184                                               uint32_t _delete_flags /* [in]  */,
14185                                               uint32_t _version /* [in]  */,
14186                                               WERROR *result)
14187 {
14188         struct spoolss_DeletePrinterDriverEx r;
14189         NTSTATUS status;
14190
14191         /* In parameters */
14192         r.in.server = _server;
14193         r.in.architecture = _architecture;
14194         r.in.driver = _driver;
14195         r.in.delete_flags = _delete_flags;
14196         r.in.version = _version;
14197
14198         status = dcerpc_spoolss_DeletePrinterDriverEx_r(h, mem_ctx, &r);
14199         if (!NT_STATUS_IS_OK(status)) {
14200                 return status;
14201         }
14202
14203         /* Return variables */
14204
14205         /* Return result */
14206         *result = r.out.result;
14207
14208         return NT_STATUS_OK;
14209 }
14210
14211 struct dcerpc_spoolss_XcvData_r_state {
14212         TALLOC_CTX *out_mem_ctx;
14213 };
14214
14215 static void dcerpc_spoolss_XcvData_r_done(struct tevent_req *subreq);
14216
14217 struct tevent_req *dcerpc_spoolss_XcvData_r_send(TALLOC_CTX *mem_ctx,
14218         struct tevent_context *ev,
14219         struct dcerpc_binding_handle *h,
14220         struct spoolss_XcvData *r)
14221 {
14222         struct tevent_req *req;
14223         struct dcerpc_spoolss_XcvData_r_state *state;
14224         struct tevent_req *subreq;
14225
14226         req = tevent_req_create(mem_ctx, &state,
14227                                 struct dcerpc_spoolss_XcvData_r_state);
14228         if (req == NULL) {
14229                 return NULL;
14230         }
14231
14232         state->out_mem_ctx = talloc_new(state);
14233         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14234                 return tevent_req_post(req, ev);
14235         }
14236
14237         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14238                         NULL, &ndr_table_spoolss,
14239                         NDR_SPOOLSS_XCVDATA, state->out_mem_ctx, r);
14240         if (tevent_req_nomem(subreq, req)) {
14241                 return tevent_req_post(req, ev);
14242         }
14243         tevent_req_set_callback(subreq, dcerpc_spoolss_XcvData_r_done, req);
14244
14245         return req;
14246 }
14247
14248 static void dcerpc_spoolss_XcvData_r_done(struct tevent_req *subreq)
14249 {
14250         struct tevent_req *req =
14251                 tevent_req_callback_data(subreq,
14252                 struct tevent_req);
14253         NTSTATUS status;
14254
14255         status = dcerpc_binding_handle_call_recv(subreq);
14256         if (!NT_STATUS_IS_OK(status)) {
14257                 tevent_req_nterror(req, status);
14258                 return;
14259         }
14260
14261         tevent_req_done(req);
14262 }
14263
14264 NTSTATUS dcerpc_spoolss_XcvData_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14265 {
14266         struct dcerpc_spoolss_XcvData_r_state *state =
14267                 tevent_req_data(req,
14268                 struct dcerpc_spoolss_XcvData_r_state);
14269         NTSTATUS status;
14270
14271         if (tevent_req_is_nterror(req, &status)) {
14272                 tevent_req_received(req);
14273                 return status;
14274         }
14275
14276         talloc_steal(mem_ctx, state->out_mem_ctx);
14277
14278         tevent_req_received(req);
14279         return NT_STATUS_OK;
14280 }
14281
14282 NTSTATUS dcerpc_spoolss_XcvData_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_XcvData *r)
14283 {
14284         NTSTATUS status;
14285
14286         status = dcerpc_binding_handle_call(h,
14287                         NULL, &ndr_table_spoolss,
14288                         NDR_SPOOLSS_XCVDATA, mem_ctx, r);
14289
14290         return status;
14291 }
14292
14293 NTSTATUS dcerpc_spoolss_XcvData_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_XcvData *r)
14294 {
14295         NTSTATUS status;
14296
14297         status = dcerpc_spoolss_XcvData_r(p->binding_handle, mem_ctx, r);
14298
14299         if (NT_STATUS_IS_RPC(status)) {
14300                 status = NT_STATUS_NET_WRITE_FAULT;
14301         }
14302
14303         return status;
14304 }
14305
14306 struct dcerpc_spoolss_XcvData_state {
14307         struct spoolss_XcvData orig;
14308         struct spoolss_XcvData tmp;
14309         TALLOC_CTX *out_mem_ctx;
14310 };
14311
14312 static void dcerpc_spoolss_XcvData_done(struct tevent_req *subreq);
14313
14314 struct tevent_req *dcerpc_spoolss_XcvData_send(TALLOC_CTX *mem_ctx,
14315                                                struct tevent_context *ev,
14316                                                struct dcerpc_binding_handle *h,
14317                                                struct policy_handle *_handle /* [in] [ref] */,
14318                                                const char *_function_name /* [in] [charset(UTF16)] */,
14319                                                DATA_BLOB _in_data /* [in]  */,
14320                                                uint32_t __in_data_length /* [in] [value(r->in.in_data.length)] */,
14321                                                uint8_t *_out_data /* [out] [ref,size_is(out_data_size)] */,
14322                                                uint32_t _out_data_size /* [in]  */,
14323                                                uint32_t *_needed /* [out] [ref] */,
14324                                                uint32_t *_status_code /* [in,out] [ref] */)
14325 {
14326         struct tevent_req *req;
14327         struct dcerpc_spoolss_XcvData_state *state;
14328         struct tevent_req *subreq;
14329
14330         req = tevent_req_create(mem_ctx, &state,
14331                                 struct dcerpc_spoolss_XcvData_state);
14332         if (req == NULL) {
14333                 return NULL;
14334         }
14335         state->out_mem_ctx = NULL;
14336
14337         /* In parameters */
14338         state->orig.in.handle = _handle;
14339         state->orig.in.function_name = _function_name;
14340         state->orig.in.in_data = _in_data;
14341         state->orig.in._in_data_length = __in_data_length;
14342         state->orig.in.out_data_size = _out_data_size;
14343         state->orig.in.status_code = _status_code;
14344
14345         /* Out parameters */
14346         state->orig.out.out_data = _out_data;
14347         state->orig.out.needed = _needed;
14348         state->orig.out.status_code = _status_code;
14349
14350         /* Result */
14351         ZERO_STRUCT(state->orig.out.result);
14352
14353         state->out_mem_ctx = talloc_named_const(state, 0,
14354                              "dcerpc_spoolss_XcvData_out_memory");
14355         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14356                 return tevent_req_post(req, ev);
14357         }
14358
14359         /* make a temporary copy, that we pass to the dispatch function */
14360         state->tmp = state->orig;
14361
14362         subreq = dcerpc_spoolss_XcvData_r_send(state, ev, h, &state->tmp);
14363         if (tevent_req_nomem(subreq, req)) {
14364                 return tevent_req_post(req, ev);
14365         }
14366         tevent_req_set_callback(subreq, dcerpc_spoolss_XcvData_done, req);
14367         return req;
14368 }
14369
14370 static void dcerpc_spoolss_XcvData_done(struct tevent_req *subreq)
14371 {
14372         struct tevent_req *req = tevent_req_callback_data(
14373                 subreq, struct tevent_req);
14374         struct dcerpc_spoolss_XcvData_state *state = tevent_req_data(
14375                 req, struct dcerpc_spoolss_XcvData_state);
14376         NTSTATUS status;
14377         TALLOC_CTX *mem_ctx;
14378
14379         if (state->out_mem_ctx) {
14380                 mem_ctx = state->out_mem_ctx;
14381         } else {
14382                 mem_ctx = state;
14383         }
14384
14385         status = dcerpc_spoolss_XcvData_r_recv(subreq, mem_ctx);
14386         TALLOC_FREE(subreq);
14387         if (!NT_STATUS_IS_OK(status)) {
14388                 tevent_req_nterror(req, status);
14389                 return;
14390         }
14391
14392         /* Copy out parameters */
14393         memcpy(state->orig.out.out_data, state->tmp.out.out_data, (state->tmp.in.out_data_size) * sizeof(*state->orig.out.out_data));
14394         *state->orig.out.needed = *state->tmp.out.needed;
14395         *state->orig.out.status_code = *state->tmp.out.status_code;
14396
14397         /* Copy result */
14398         state->orig.out.result = state->tmp.out.result;
14399
14400         /* Reset temporary structure */
14401         ZERO_STRUCT(state->tmp);
14402
14403         tevent_req_done(req);
14404 }
14405
14406 NTSTATUS dcerpc_spoolss_XcvData_recv(struct tevent_req *req,
14407                                      TALLOC_CTX *mem_ctx,
14408                                      WERROR *result)
14409 {
14410         struct dcerpc_spoolss_XcvData_state *state = tevent_req_data(
14411                 req, struct dcerpc_spoolss_XcvData_state);
14412         NTSTATUS status;
14413
14414         if (tevent_req_is_nterror(req, &status)) {
14415                 tevent_req_received(req);
14416                 return status;
14417         }
14418
14419         /* Steal possible out parameters to the callers context */
14420         talloc_steal(mem_ctx, state->out_mem_ctx);
14421
14422         /* Return result */
14423         *result = state->orig.out.result;
14424
14425         tevent_req_received(req);
14426         return NT_STATUS_OK;
14427 }
14428
14429 NTSTATUS dcerpc_spoolss_XcvData(struct dcerpc_binding_handle *h,
14430                                 TALLOC_CTX *mem_ctx,
14431                                 struct policy_handle *_handle /* [in] [ref] */,
14432                                 const char *_function_name /* [in] [charset(UTF16)] */,
14433                                 DATA_BLOB _in_data /* [in]  */,
14434                                 uint32_t __in_data_length /* [in] [value(r->in.in_data.length)] */,
14435                                 uint8_t *_out_data /* [out] [ref,size_is(out_data_size)] */,
14436                                 uint32_t _out_data_size /* [in]  */,
14437                                 uint32_t *_needed /* [out] [ref] */,
14438                                 uint32_t *_status_code /* [in,out] [ref] */,
14439                                 WERROR *result)
14440 {
14441         struct spoolss_XcvData r;
14442         NTSTATUS status;
14443
14444         /* In parameters */
14445         r.in.handle = _handle;
14446         r.in.function_name = _function_name;
14447         r.in.in_data = _in_data;
14448         r.in._in_data_length = __in_data_length;
14449         r.in.out_data_size = _out_data_size;
14450         r.in.status_code = _status_code;
14451
14452         status = dcerpc_spoolss_XcvData_r(h, mem_ctx, &r);
14453         if (!NT_STATUS_IS_OK(status)) {
14454                 return status;
14455         }
14456
14457         /* Return variables */
14458         memcpy(_out_data, r.out.out_data, (r.in.out_data_size) * sizeof(*_out_data));
14459         *_needed = *r.out.needed;
14460         *_status_code = *r.out.status_code;
14461
14462         /* Return result */
14463         *result = r.out.result;
14464
14465         return NT_STATUS_OK;
14466 }
14467
14468 struct dcerpc_spoolss_AddPrinterDriverEx_r_state {
14469         TALLOC_CTX *out_mem_ctx;
14470 };
14471
14472 static void dcerpc_spoolss_AddPrinterDriverEx_r_done(struct tevent_req *subreq);
14473
14474 struct tevent_req *dcerpc_spoolss_AddPrinterDriverEx_r_send(TALLOC_CTX *mem_ctx,
14475         struct tevent_context *ev,
14476         struct dcerpc_binding_handle *h,
14477         struct spoolss_AddPrinterDriverEx *r)
14478 {
14479         struct tevent_req *req;
14480         struct dcerpc_spoolss_AddPrinterDriverEx_r_state *state;
14481         struct tevent_req *subreq;
14482
14483         req = tevent_req_create(mem_ctx, &state,
14484                                 struct dcerpc_spoolss_AddPrinterDriverEx_r_state);
14485         if (req == NULL) {
14486                 return NULL;
14487         }
14488
14489         state->out_mem_ctx = NULL;
14490         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14491                         NULL, &ndr_table_spoolss,
14492                         NDR_SPOOLSS_ADDPRINTERDRIVEREX, state, r);
14493         if (tevent_req_nomem(subreq, req)) {
14494                 return tevent_req_post(req, ev);
14495         }
14496         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterDriverEx_r_done, req);
14497
14498         return req;
14499 }
14500
14501 static void dcerpc_spoolss_AddPrinterDriverEx_r_done(struct tevent_req *subreq)
14502 {
14503         struct tevent_req *req =
14504                 tevent_req_callback_data(subreq,
14505                 struct tevent_req);
14506         NTSTATUS status;
14507
14508         status = dcerpc_binding_handle_call_recv(subreq);
14509         if (!NT_STATUS_IS_OK(status)) {
14510                 tevent_req_nterror(req, status);
14511                 return;
14512         }
14513
14514         tevent_req_done(req);
14515 }
14516
14517 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14518 {
14519         struct dcerpc_spoolss_AddPrinterDriverEx_r_state *state =
14520                 tevent_req_data(req,
14521                 struct dcerpc_spoolss_AddPrinterDriverEx_r_state);
14522         NTSTATUS status;
14523
14524         if (tevent_req_is_nterror(req, &status)) {
14525                 tevent_req_received(req);
14526                 return status;
14527         }
14528
14529         talloc_steal(mem_ctx, state->out_mem_ctx);
14530
14531         tevent_req_received(req);
14532         return NT_STATUS_OK;
14533 }
14534
14535 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterDriverEx *r)
14536 {
14537         NTSTATUS status;
14538
14539         status = dcerpc_binding_handle_call(h,
14540                         NULL, &ndr_table_spoolss,
14541                         NDR_SPOOLSS_ADDPRINTERDRIVEREX, mem_ctx, r);
14542
14543         return status;
14544 }
14545
14546 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_AddPrinterDriverEx *r)
14547 {
14548         NTSTATUS status;
14549
14550         status = dcerpc_spoolss_AddPrinterDriverEx_r(p->binding_handle, mem_ctx, r);
14551
14552         if (NT_STATUS_IS_RPC(status)) {
14553                 status = NT_STATUS_NET_WRITE_FAULT;
14554         }
14555
14556         return status;
14557 }
14558
14559 struct dcerpc_spoolss_AddPrinterDriverEx_state {
14560         struct spoolss_AddPrinterDriverEx orig;
14561         struct spoolss_AddPrinterDriverEx tmp;
14562         TALLOC_CTX *out_mem_ctx;
14563 };
14564
14565 static void dcerpc_spoolss_AddPrinterDriverEx_done(struct tevent_req *subreq);
14566
14567 struct tevent_req *dcerpc_spoolss_AddPrinterDriverEx_send(TALLOC_CTX *mem_ctx,
14568                                                           struct tevent_context *ev,
14569                                                           struct dcerpc_binding_handle *h,
14570                                                           const char *_servername /* [in] [unique,charset(UTF16)] */,
14571                                                           struct spoolss_AddDriverInfoCtr *_info_ctr /* [in] [ref] */,
14572                                                           uint32_t _flags /* [in]  */)
14573 {
14574         struct tevent_req *req;
14575         struct dcerpc_spoolss_AddPrinterDriverEx_state *state;
14576         struct tevent_req *subreq;
14577
14578         req = tevent_req_create(mem_ctx, &state,
14579                                 struct dcerpc_spoolss_AddPrinterDriverEx_state);
14580         if (req == NULL) {
14581                 return NULL;
14582         }
14583         state->out_mem_ctx = NULL;
14584
14585         /* In parameters */
14586         state->orig.in.servername = _servername;
14587         state->orig.in.info_ctr = _info_ctr;
14588         state->orig.in.flags = _flags;
14589
14590         /* Out parameters */
14591
14592         /* Result */
14593         ZERO_STRUCT(state->orig.out.result);
14594
14595         /* make a temporary copy, that we pass to the dispatch function */
14596         state->tmp = state->orig;
14597
14598         subreq = dcerpc_spoolss_AddPrinterDriverEx_r_send(state, ev, h, &state->tmp);
14599         if (tevent_req_nomem(subreq, req)) {
14600                 return tevent_req_post(req, ev);
14601         }
14602         tevent_req_set_callback(subreq, dcerpc_spoolss_AddPrinterDriverEx_done, req);
14603         return req;
14604 }
14605
14606 static void dcerpc_spoolss_AddPrinterDriverEx_done(struct tevent_req *subreq)
14607 {
14608         struct tevent_req *req = tevent_req_callback_data(
14609                 subreq, struct tevent_req);
14610         struct dcerpc_spoolss_AddPrinterDriverEx_state *state = tevent_req_data(
14611                 req, struct dcerpc_spoolss_AddPrinterDriverEx_state);
14612         NTSTATUS status;
14613         TALLOC_CTX *mem_ctx;
14614
14615         if (state->out_mem_ctx) {
14616                 mem_ctx = state->out_mem_ctx;
14617         } else {
14618                 mem_ctx = state;
14619         }
14620
14621         status = dcerpc_spoolss_AddPrinterDriverEx_r_recv(subreq, mem_ctx);
14622         TALLOC_FREE(subreq);
14623         if (!NT_STATUS_IS_OK(status)) {
14624                 tevent_req_nterror(req, status);
14625                 return;
14626         }
14627
14628         /* Copy out parameters */
14629
14630         /* Copy result */
14631         state->orig.out.result = state->tmp.out.result;
14632
14633         /* Reset temporary structure */
14634         ZERO_STRUCT(state->tmp);
14635
14636         tevent_req_done(req);
14637 }
14638
14639 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx_recv(struct tevent_req *req,
14640                                                 TALLOC_CTX *mem_ctx,
14641                                                 WERROR *result)
14642 {
14643         struct dcerpc_spoolss_AddPrinterDriverEx_state *state = tevent_req_data(
14644                 req, struct dcerpc_spoolss_AddPrinterDriverEx_state);
14645         NTSTATUS status;
14646
14647         if (tevent_req_is_nterror(req, &status)) {
14648                 tevent_req_received(req);
14649                 return status;
14650         }
14651
14652         /* Steal possible out parameters to the callers context */
14653         talloc_steal(mem_ctx, state->out_mem_ctx);
14654
14655         /* Return result */
14656         *result = state->orig.out.result;
14657
14658         tevent_req_received(req);
14659         return NT_STATUS_OK;
14660 }
14661
14662 NTSTATUS dcerpc_spoolss_AddPrinterDriverEx(struct dcerpc_binding_handle *h,
14663                                            TALLOC_CTX *mem_ctx,
14664                                            const char *_servername /* [in] [unique,charset(UTF16)] */,
14665                                            struct spoolss_AddDriverInfoCtr *_info_ctr /* [in] [ref] */,
14666                                            uint32_t _flags /* [in]  */,
14667                                            WERROR *result)
14668 {
14669         struct spoolss_AddPrinterDriverEx r;
14670         NTSTATUS status;
14671
14672         /* In parameters */
14673         r.in.servername = _servername;
14674         r.in.info_ctr = _info_ctr;
14675         r.in.flags = _flags;
14676
14677         status = dcerpc_spoolss_AddPrinterDriverEx_r(h, mem_ctx, &r);
14678         if (!NT_STATUS_IS_OK(status)) {
14679                 return status;
14680         }
14681
14682         /* Return variables */
14683
14684         /* Return result */
14685         *result = r.out.result;
14686
14687         return NT_STATUS_OK;
14688 }
14689
14690 struct dcerpc_spoolss_GetCorePrinterDrivers_r_state {
14691         TALLOC_CTX *out_mem_ctx;
14692 };
14693
14694 static void dcerpc_spoolss_GetCorePrinterDrivers_r_done(struct tevent_req *subreq);
14695
14696 struct tevent_req *dcerpc_spoolss_GetCorePrinterDrivers_r_send(TALLOC_CTX *mem_ctx,
14697         struct tevent_context *ev,
14698         struct dcerpc_binding_handle *h,
14699         struct spoolss_GetCorePrinterDrivers *r)
14700 {
14701         struct tevent_req *req;
14702         struct dcerpc_spoolss_GetCorePrinterDrivers_r_state *state;
14703         struct tevent_req *subreq;
14704
14705         req = tevent_req_create(mem_ctx, &state,
14706                                 struct dcerpc_spoolss_GetCorePrinterDrivers_r_state);
14707         if (req == NULL) {
14708                 return NULL;
14709         }
14710
14711         state->out_mem_ctx = talloc_new(state);
14712         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14713                 return tevent_req_post(req, ev);
14714         }
14715
14716         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14717                         NULL, &ndr_table_spoolss,
14718                         NDR_SPOOLSS_GETCOREPRINTERDRIVERS, state->out_mem_ctx, r);
14719         if (tevent_req_nomem(subreq, req)) {
14720                 return tevent_req_post(req, ev);
14721         }
14722         tevent_req_set_callback(subreq, dcerpc_spoolss_GetCorePrinterDrivers_r_done, req);
14723
14724         return req;
14725 }
14726
14727 static void dcerpc_spoolss_GetCorePrinterDrivers_r_done(struct tevent_req *subreq)
14728 {
14729         struct tevent_req *req =
14730                 tevent_req_callback_data(subreq,
14731                 struct tevent_req);
14732         NTSTATUS status;
14733
14734         status = dcerpc_binding_handle_call_recv(subreq);
14735         if (!NT_STATUS_IS_OK(status)) {
14736                 tevent_req_nterror(req, status);
14737                 return;
14738         }
14739
14740         tevent_req_done(req);
14741 }
14742
14743 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14744 {
14745         struct dcerpc_spoolss_GetCorePrinterDrivers_r_state *state =
14746                 tevent_req_data(req,
14747                 struct dcerpc_spoolss_GetCorePrinterDrivers_r_state);
14748         NTSTATUS status;
14749
14750         if (tevent_req_is_nterror(req, &status)) {
14751                 tevent_req_received(req);
14752                 return status;
14753         }
14754
14755         talloc_steal(mem_ctx, state->out_mem_ctx);
14756
14757         tevent_req_received(req);
14758         return NT_STATUS_OK;
14759 }
14760
14761 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetCorePrinterDrivers *r)
14762 {
14763         NTSTATUS status;
14764
14765         status = dcerpc_binding_handle_call(h,
14766                         NULL, &ndr_table_spoolss,
14767                         NDR_SPOOLSS_GETCOREPRINTERDRIVERS, mem_ctx, r);
14768
14769         return status;
14770 }
14771
14772 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetCorePrinterDrivers *r)
14773 {
14774         NTSTATUS status;
14775
14776         status = dcerpc_spoolss_GetCorePrinterDrivers_r(p->binding_handle, mem_ctx, r);
14777
14778         if (NT_STATUS_IS_RPC(status)) {
14779                 status = NT_STATUS_NET_WRITE_FAULT;
14780         }
14781
14782         return status;
14783 }
14784
14785 struct dcerpc_spoolss_GetCorePrinterDrivers_state {
14786         struct spoolss_GetCorePrinterDrivers orig;
14787         struct spoolss_GetCorePrinterDrivers tmp;
14788         TALLOC_CTX *out_mem_ctx;
14789 };
14790
14791 static void dcerpc_spoolss_GetCorePrinterDrivers_done(struct tevent_req *subreq);
14792
14793 struct tevent_req *dcerpc_spoolss_GetCorePrinterDrivers_send(TALLOC_CTX *mem_ctx,
14794                                                              struct tevent_context *ev,
14795                                                              struct dcerpc_binding_handle *h,
14796                                                              const char *_servername /* [in] [unique,charset(UTF16)] */,
14797                                                              const char *_architecture /* [in] [ref,charset(UTF16)] */,
14798                                                              uint32_t _core_driver_size /* [in]  */,
14799                                                              const char *_core_driver_dependencies /* [in] [ref,charset(UTF16),size_is(core_driver_size)] */,
14800                                                              uint32_t _core_printer_driver_count /* [in]  */,
14801                                                              struct spoolss_CorePrinterDriver *_core_printer_drivers /* [out] [ref,size_is(core_printer_driver_count)] */)
14802 {
14803         struct tevent_req *req;
14804         struct dcerpc_spoolss_GetCorePrinterDrivers_state *state;
14805         struct tevent_req *subreq;
14806
14807         req = tevent_req_create(mem_ctx, &state,
14808                                 struct dcerpc_spoolss_GetCorePrinterDrivers_state);
14809         if (req == NULL) {
14810                 return NULL;
14811         }
14812         state->out_mem_ctx = NULL;
14813
14814         /* In parameters */
14815         state->orig.in.servername = _servername;
14816         state->orig.in.architecture = _architecture;
14817         state->orig.in.core_driver_size = _core_driver_size;
14818         state->orig.in.core_driver_dependencies = _core_driver_dependencies;
14819         state->orig.in.core_printer_driver_count = _core_printer_driver_count;
14820
14821         /* Out parameters */
14822         state->orig.out.core_printer_drivers = _core_printer_drivers;
14823
14824         /* Result */
14825         ZERO_STRUCT(state->orig.out.result);
14826
14827         state->out_mem_ctx = talloc_named_const(state, 0,
14828                              "dcerpc_spoolss_GetCorePrinterDrivers_out_memory");
14829         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14830                 return tevent_req_post(req, ev);
14831         }
14832
14833         /* make a temporary copy, that we pass to the dispatch function */
14834         state->tmp = state->orig;
14835
14836         subreq = dcerpc_spoolss_GetCorePrinterDrivers_r_send(state, ev, h, &state->tmp);
14837         if (tevent_req_nomem(subreq, req)) {
14838                 return tevent_req_post(req, ev);
14839         }
14840         tevent_req_set_callback(subreq, dcerpc_spoolss_GetCorePrinterDrivers_done, req);
14841         return req;
14842 }
14843
14844 static void dcerpc_spoolss_GetCorePrinterDrivers_done(struct tevent_req *subreq)
14845 {
14846         struct tevent_req *req = tevent_req_callback_data(
14847                 subreq, struct tevent_req);
14848         struct dcerpc_spoolss_GetCorePrinterDrivers_state *state = tevent_req_data(
14849                 req, struct dcerpc_spoolss_GetCorePrinterDrivers_state);
14850         NTSTATUS status;
14851         TALLOC_CTX *mem_ctx;
14852
14853         if (state->out_mem_ctx) {
14854                 mem_ctx = state->out_mem_ctx;
14855         } else {
14856                 mem_ctx = state;
14857         }
14858
14859         status = dcerpc_spoolss_GetCorePrinterDrivers_r_recv(subreq, mem_ctx);
14860         TALLOC_FREE(subreq);
14861         if (!NT_STATUS_IS_OK(status)) {
14862                 tevent_req_nterror(req, status);
14863                 return;
14864         }
14865
14866         /* Copy out parameters */
14867         memcpy(state->orig.out.core_printer_drivers, state->tmp.out.core_printer_drivers, (state->tmp.in.core_printer_driver_count) * sizeof(*state->orig.out.core_printer_drivers));
14868
14869         /* Copy result */
14870         state->orig.out.result = state->tmp.out.result;
14871
14872         /* Reset temporary structure */
14873         ZERO_STRUCT(state->tmp);
14874
14875         tevent_req_done(req);
14876 }
14877
14878 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers_recv(struct tevent_req *req,
14879                                                    TALLOC_CTX *mem_ctx,
14880                                                    WERROR *result)
14881 {
14882         struct dcerpc_spoolss_GetCorePrinterDrivers_state *state = tevent_req_data(
14883                 req, struct dcerpc_spoolss_GetCorePrinterDrivers_state);
14884         NTSTATUS status;
14885
14886         if (tevent_req_is_nterror(req, &status)) {
14887                 tevent_req_received(req);
14888                 return status;
14889         }
14890
14891         /* Steal possible out parameters to the callers context */
14892         talloc_steal(mem_ctx, state->out_mem_ctx);
14893
14894         /* Return result */
14895         *result = state->orig.out.result;
14896
14897         tevent_req_received(req);
14898         return NT_STATUS_OK;
14899 }
14900
14901 NTSTATUS dcerpc_spoolss_GetCorePrinterDrivers(struct dcerpc_binding_handle *h,
14902                                               TALLOC_CTX *mem_ctx,
14903                                               const char *_servername /* [in] [unique,charset(UTF16)] */,
14904                                               const char *_architecture /* [in] [ref,charset(UTF16)] */,
14905                                               uint32_t _core_driver_size /* [in]  */,
14906                                               const char *_core_driver_dependencies /* [in] [ref,charset(UTF16),size_is(core_driver_size)] */,
14907                                               uint32_t _core_printer_driver_count /* [in]  */,
14908                                               struct spoolss_CorePrinterDriver *_core_printer_drivers /* [out] [ref,size_is(core_printer_driver_count)] */,
14909                                               WERROR *result)
14910 {
14911         struct spoolss_GetCorePrinterDrivers r;
14912         NTSTATUS status;
14913
14914         /* In parameters */
14915         r.in.servername = _servername;
14916         r.in.architecture = _architecture;
14917         r.in.core_driver_size = _core_driver_size;
14918         r.in.core_driver_dependencies = _core_driver_dependencies;
14919         r.in.core_printer_driver_count = _core_printer_driver_count;
14920
14921         status = dcerpc_spoolss_GetCorePrinterDrivers_r(h, mem_ctx, &r);
14922         if (!NT_STATUS_IS_OK(status)) {
14923                 return status;
14924         }
14925
14926         /* Return variables */
14927         memcpy(_core_printer_drivers, r.out.core_printer_drivers, (r.in.core_printer_driver_count) * sizeof(*_core_printer_drivers));
14928
14929         /* Return result */
14930         *result = r.out.result;
14931
14932         return NT_STATUS_OK;
14933 }
14934
14935 struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state {
14936         TALLOC_CTX *out_mem_ctx;
14937 };
14938
14939 static void dcerpc_spoolss_GetPrinterDriverPackagePath_r_done(struct tevent_req *subreq);
14940
14941 struct tevent_req *dcerpc_spoolss_GetPrinterDriverPackagePath_r_send(TALLOC_CTX *mem_ctx,
14942         struct tevent_context *ev,
14943         struct dcerpc_binding_handle *h,
14944         struct spoolss_GetPrinterDriverPackagePath *r)
14945 {
14946         struct tevent_req *req;
14947         struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state *state;
14948         struct tevent_req *subreq;
14949
14950         req = tevent_req_create(mem_ctx, &state,
14951                                 struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state);
14952         if (req == NULL) {
14953                 return NULL;
14954         }
14955
14956         state->out_mem_ctx = talloc_new(state);
14957         if (tevent_req_nomem(state->out_mem_ctx, req)) {
14958                 return tevent_req_post(req, ev);
14959         }
14960
14961         subreq = dcerpc_binding_handle_call_send(state, ev, h,
14962                         NULL, &ndr_table_spoolss,
14963                         NDR_SPOOLSS_GETPRINTERDRIVERPACKAGEPATH, state->out_mem_ctx, r);
14964         if (tevent_req_nomem(subreq, req)) {
14965                 return tevent_req_post(req, ev);
14966         }
14967         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriverPackagePath_r_done, req);
14968
14969         return req;
14970 }
14971
14972 static void dcerpc_spoolss_GetPrinterDriverPackagePath_r_done(struct tevent_req *subreq)
14973 {
14974         struct tevent_req *req =
14975                 tevent_req_callback_data(subreq,
14976                 struct tevent_req);
14977         NTSTATUS status;
14978
14979         status = dcerpc_binding_handle_call_recv(subreq);
14980         if (!NT_STATUS_IS_OK(status)) {
14981                 tevent_req_nterror(req, status);
14982                 return;
14983         }
14984
14985         tevent_req_done(req);
14986 }
14987
14988 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
14989 {
14990         struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state *state =
14991                 tevent_req_data(req,
14992                 struct dcerpc_spoolss_GetPrinterDriverPackagePath_r_state);
14993         NTSTATUS status;
14994
14995         if (tevent_req_is_nterror(req, &status)) {
14996                 tevent_req_received(req);
14997                 return status;
14998         }
14999
15000         talloc_steal(mem_ctx, state->out_mem_ctx);
15001
15002         tevent_req_received(req);
15003         return NT_STATUS_OK;
15004 }
15005
15006 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverPackagePath *r)
15007 {
15008         NTSTATUS status;
15009
15010         status = dcerpc_binding_handle_call(h,
15011                         NULL, &ndr_table_spoolss,
15012                         NDR_SPOOLSS_GETPRINTERDRIVERPACKAGEPATH, mem_ctx, r);
15013
15014         return status;
15015 }
15016
15017 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverPackagePath *r)
15018 {
15019         NTSTATUS status;
15020
15021         status = dcerpc_spoolss_GetPrinterDriverPackagePath_r(p->binding_handle, mem_ctx, r);
15022
15023         if (NT_STATUS_IS_RPC(status)) {
15024                 status = NT_STATUS_NET_WRITE_FAULT;
15025         }
15026
15027         return status;
15028 }
15029
15030 struct dcerpc_spoolss_GetPrinterDriverPackagePath_state {
15031         struct spoolss_GetPrinterDriverPackagePath orig;
15032         struct spoolss_GetPrinterDriverPackagePath tmp;
15033         TALLOC_CTX *out_mem_ctx;
15034 };
15035
15036 static void dcerpc_spoolss_GetPrinterDriverPackagePath_done(struct tevent_req *subreq);
15037
15038 struct tevent_req *dcerpc_spoolss_GetPrinterDriverPackagePath_send(TALLOC_CTX *mem_ctx,
15039                                                                    struct tevent_context *ev,
15040                                                                    struct dcerpc_binding_handle *h,
15041                                                                    const char *_servername /* [in] [unique,charset(UTF16)] */,
15042                                                                    const char *_architecture /* [in] [ref,charset(UTF16)] */,
15043                                                                    const char *_language /* [in] [unique,charset(UTF16)] */,
15044                                                                    const char *_package_id /* [in] [ref,charset(UTF16)] */,
15045                                                                    const char *_driver_package_cab /* [in,out] [unique,charset(UTF16),size_is(driver_package_cab_size)] */,
15046                                                                    uint32_t _driver_package_cab_size /* [in]  */,
15047                                                                    uint32_t *_required /* [out] [ref] */)
15048 {
15049         struct tevent_req *req;
15050         struct dcerpc_spoolss_GetPrinterDriverPackagePath_state *state;
15051         struct tevent_req *subreq;
15052
15053         req = tevent_req_create(mem_ctx, &state,
15054                                 struct dcerpc_spoolss_GetPrinterDriverPackagePath_state);
15055         if (req == NULL) {
15056                 return NULL;
15057         }
15058         state->out_mem_ctx = NULL;
15059
15060         /* In parameters */
15061         state->orig.in.servername = _servername;
15062         state->orig.in.architecture = _architecture;
15063         state->orig.in.language = _language;
15064         state->orig.in.package_id = _package_id;
15065         state->orig.in.driver_package_cab = _driver_package_cab;
15066         state->orig.in.driver_package_cab_size = _driver_package_cab_size;
15067
15068         /* Out parameters */
15069         state->orig.out.driver_package_cab = _driver_package_cab;
15070         state->orig.out.required = _required;
15071
15072         /* Result */
15073         ZERO_STRUCT(state->orig.out.result);
15074
15075         state->out_mem_ctx = talloc_named_const(state, 0,
15076                              "dcerpc_spoolss_GetPrinterDriverPackagePath_out_memory");
15077         if (tevent_req_nomem(state->out_mem_ctx, req)) {
15078                 return tevent_req_post(req, ev);
15079         }
15080
15081         /* make a temporary copy, that we pass to the dispatch function */
15082         state->tmp = state->orig;
15083
15084         subreq = dcerpc_spoolss_GetPrinterDriverPackagePath_r_send(state, ev, h, &state->tmp);
15085         if (tevent_req_nomem(subreq, req)) {
15086                 return tevent_req_post(req, ev);
15087         }
15088         tevent_req_set_callback(subreq, dcerpc_spoolss_GetPrinterDriverPackagePath_done, req);
15089         return req;
15090 }
15091
15092 static void dcerpc_spoolss_GetPrinterDriverPackagePath_done(struct tevent_req *subreq)
15093 {
15094         struct tevent_req *req = tevent_req_callback_data(
15095                 subreq, struct tevent_req);
15096         struct dcerpc_spoolss_GetPrinterDriverPackagePath_state *state = tevent_req_data(
15097                 req, struct dcerpc_spoolss_GetPrinterDriverPackagePath_state);
15098         NTSTATUS status;
15099         TALLOC_CTX *mem_ctx;
15100
15101         if (state->out_mem_ctx) {
15102                 mem_ctx = state->out_mem_ctx;
15103         } else {
15104                 mem_ctx = state;
15105         }
15106
15107         status = dcerpc_spoolss_GetPrinterDriverPackagePath_r_recv(subreq, mem_ctx);
15108         TALLOC_FREE(subreq);
15109         if (!NT_STATUS_IS_OK(status)) {
15110                 tevent_req_nterror(req, status);
15111                 return;
15112         }
15113
15114         /* Copy out parameters */
15115         if (state->orig.out.driver_package_cab && state->tmp.out.driver_package_cab) {
15116                 memcpy(discard_const_p(uint8_t *, state->orig.out.driver_package_cab), state->tmp.out.driver_package_cab, (state->tmp.in.driver_package_cab_size) * sizeof(*state->orig.out.driver_package_cab));
15117         }
15118         *state->orig.out.required = *state->tmp.out.required;
15119
15120         /* Copy result */
15121         state->orig.out.result = state->tmp.out.result;
15122
15123         /* Reset temporary structure */
15124         ZERO_STRUCT(state->tmp);
15125
15126         tevent_req_done(req);
15127 }
15128
15129 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath_recv(struct tevent_req *req,
15130                                                          TALLOC_CTX *mem_ctx,
15131                                                          WERROR *result)
15132 {
15133         struct dcerpc_spoolss_GetPrinterDriverPackagePath_state *state = tevent_req_data(
15134                 req, struct dcerpc_spoolss_GetPrinterDriverPackagePath_state);
15135         NTSTATUS status;
15136
15137         if (tevent_req_is_nterror(req, &status)) {
15138                 tevent_req_received(req);
15139                 return status;
15140         }
15141
15142         /* Steal possible out parameters to the callers context */
15143         talloc_steal(mem_ctx, state->out_mem_ctx);
15144
15145         /* Return result */
15146         *result = state->orig.out.result;
15147
15148         tevent_req_received(req);
15149         return NT_STATUS_OK;
15150 }
15151
15152 NTSTATUS dcerpc_spoolss_GetPrinterDriverPackagePath(struct dcerpc_binding_handle *h,
15153                                                     TALLOC_CTX *mem_ctx,
15154                                                     const char *_servername /* [in] [unique,charset(UTF16)] */,
15155                                                     const char *_architecture /* [in] [ref,charset(UTF16)] */,
15156                                                     const char *_language /* [in] [unique,charset(UTF16)] */,
15157                                                     const char *_package_id /* [in] [ref,charset(UTF16)] */,
15158                                                     const char *_driver_package_cab /* [in,out] [unique,charset(UTF16),size_is(driver_package_cab_size)] */,
15159                                                     uint32_t _driver_package_cab_size /* [in]  */,
15160                                                     uint32_t *_required /* [out] [ref] */,
15161                                                     WERROR *result)
15162 {
15163         struct spoolss_GetPrinterDriverPackagePath r;
15164         NTSTATUS status;
15165
15166         /* In parameters */
15167         r.in.servername = _servername;
15168         r.in.architecture = _architecture;
15169         r.in.language = _language;
15170         r.in.package_id = _package_id;
15171         r.in.driver_package_cab = _driver_package_cab;
15172         r.in.driver_package_cab_size = _driver_package_cab_size;
15173
15174         status = dcerpc_spoolss_GetPrinterDriverPackagePath_r(h, mem_ctx, &r);
15175         if (!NT_STATUS_IS_OK(status)) {
15176                 return status;
15177         }
15178
15179         /* Return variables */
15180         if (_driver_package_cab && r.out.driver_package_cab) {
15181                 memcpy(discard_const_p(uint8_t *, _driver_package_cab), r.out.driver_package_cab, (r.in.driver_package_cab_size) * sizeof(*_driver_package_cab));
15182         }
15183         *_required = *r.out.required;
15184
15185         /* Return result */
15186         *result = r.out.result;
15187
15188         return NT_STATUS_OK;
15189 }
15190