635a817f23ace719b0b49709e1735b2795491536
[ira/wip.git] / librpc / gen_ndr / cli_spoolss.c
1 /*
2  * Unix SMB/CIFS implementation.
3  * client auto-generated by pidl. DO NOT MODIFY!
4  */
5
6 #include "includes.h"
7 #include "../librpc/gen_ndr/cli_spoolss.h"
8
9 struct rpccli_spoolss_EnumPrinters_state {
10         struct spoolss_EnumPrinters orig;
11         struct spoolss_EnumPrinters tmp;
12         TALLOC_CTX *out_mem_ctx;
13         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
14 };
15
16 static void rpccli_spoolss_EnumPrinters_done(struct tevent_req *subreq);
17
18 struct tevent_req *rpccli_spoolss_EnumPrinters_send(TALLOC_CTX *mem_ctx,
19                                                     struct tevent_context *ev,
20                                                     struct rpc_pipe_client *cli,
21                                                     uint32_t _flags /* [in]  */,
22                                                     const char *_server /* [in] [unique,charset(UTF16)] */,
23                                                     uint32_t _level /* [in]  */,
24                                                     DATA_BLOB *_buffer /* [in] [unique] */,
25                                                     uint32_t _offered /* [in]  */,
26                                                     uint32_t *_count /* [out] [ref] */,
27                                                     union spoolss_PrinterInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
28                                                     uint32_t *_needed /* [out] [ref] */)
29 {
30         struct tevent_req *req;
31         struct rpccli_spoolss_EnumPrinters_state *state;
32         struct tevent_req *subreq;
33
34         req = tevent_req_create(mem_ctx, &state,
35                                 struct rpccli_spoolss_EnumPrinters_state);
36         if (req == NULL) {
37                 return NULL;
38         }
39         state->out_mem_ctx = NULL;
40         state->dispatch_recv = cli->dispatch_recv;
41
42         /* In parameters */
43         state->orig.in.flags = _flags;
44         state->orig.in.server = _server;
45         state->orig.in.level = _level;
46         state->orig.in.buffer = _buffer;
47         state->orig.in.offered = _offered;
48
49         /* Out parameters */
50         state->orig.out.count = _count;
51         state->orig.out.info = _info;
52         state->orig.out.needed = _needed;
53
54         /* Result */
55         ZERO_STRUCT(state->orig.out.result);
56
57         state->out_mem_ctx = talloc_named_const(state, 0,
58                              "rpccli_spoolss_EnumPrinters_out_memory");
59         if (tevent_req_nomem(state->out_mem_ctx, req)) {
60                 return tevent_req_post(req, ev);
61         }
62
63         /* make a temporary copy, that we pass to the dispatch function */
64         state->tmp = state->orig;
65
66         subreq = cli->dispatch_send(state, ev, cli,
67                                     &ndr_table_spoolss,
68                                     NDR_SPOOLSS_ENUMPRINTERS,
69                                     &state->tmp);
70         if (tevent_req_nomem(subreq, req)) {
71                 return tevent_req_post(req, ev);
72         }
73         tevent_req_set_callback(subreq, rpccli_spoolss_EnumPrinters_done, req);
74         return req;
75 }
76
77 static void rpccli_spoolss_EnumPrinters_done(struct tevent_req *subreq)
78 {
79         struct tevent_req *req = tevent_req_callback_data(
80                 subreq, struct tevent_req);
81         struct rpccli_spoolss_EnumPrinters_state *state = tevent_req_data(
82                 req, struct rpccli_spoolss_EnumPrinters_state);
83         NTSTATUS status;
84         TALLOC_CTX *mem_ctx;
85
86         if (state->out_mem_ctx) {
87                 mem_ctx = state->out_mem_ctx;
88         } else {
89                 mem_ctx = state;
90         }
91
92         status = state->dispatch_recv(subreq, mem_ctx);
93         TALLOC_FREE(subreq);
94         if (!NT_STATUS_IS_OK(status)) {
95                 tevent_req_nterror(req, status);
96                 return;
97         }
98
99         /* Copy out parameters */
100         *state->orig.out.count = *state->tmp.out.count;
101         *state->orig.out.info = *state->tmp.out.info;
102         *state->orig.out.needed = *state->tmp.out.needed;
103
104         /* Copy result */
105         state->orig.out.result = state->tmp.out.result;
106
107         /* Reset temporary structure */
108         ZERO_STRUCT(state->tmp);
109
110         tevent_req_done(req);
111 }
112
113 NTSTATUS rpccli_spoolss_EnumPrinters_recv(struct tevent_req *req,
114                                           TALLOC_CTX *mem_ctx,
115                                           WERROR *result)
116 {
117         struct rpccli_spoolss_EnumPrinters_state *state = tevent_req_data(
118                 req, struct rpccli_spoolss_EnumPrinters_state);
119         NTSTATUS status;
120
121         if (tevent_req_is_nterror(req, &status)) {
122                 tevent_req_received(req);
123                 return status;
124         }
125
126         /* Steal possbile out parameters to the callers context */
127         talloc_steal(mem_ctx, state->out_mem_ctx);
128
129         /* Return result */
130         *result = state->orig.out.result;
131
132         tevent_req_received(req);
133         return NT_STATUS_OK;
134 }
135
136 NTSTATUS rpccli_spoolss_EnumPrinters(struct rpc_pipe_client *cli,
137                                      TALLOC_CTX *mem_ctx,
138                                      uint32_t flags /* [in]  */,
139                                      const char *server /* [in] [unique,charset(UTF16)] */,
140                                      uint32_t level /* [in]  */,
141                                      DATA_BLOB *buffer /* [in] [unique] */,
142                                      uint32_t offered /* [in]  */,
143                                      uint32_t *count /* [out] [ref] */,
144                                      union spoolss_PrinterInfo **info /* [out] [ref,switch_is(level),size_is(,*count)] */,
145                                      uint32_t *needed /* [out] [ref] */,
146                                      WERROR *werror)
147 {
148         struct spoolss_EnumPrinters r;
149         NTSTATUS status;
150
151         /* In parameters */
152         r.in.flags = flags;
153         r.in.server = server;
154         r.in.level = level;
155         r.in.buffer = buffer;
156         r.in.offered = offered;
157
158         status = cli->dispatch(cli,
159                                 mem_ctx,
160                                 &ndr_table_spoolss,
161                                 NDR_SPOOLSS_ENUMPRINTERS,
162                                 &r);
163
164         if (!NT_STATUS_IS_OK(status)) {
165                 return status;
166         }
167
168         if (NT_STATUS_IS_ERR(status)) {
169                 return status;
170         }
171
172         /* Return variables */
173         *count = *r.out.count;
174         *info = *r.out.info;
175         *needed = *r.out.needed;
176
177         /* Return result */
178         if (werror) {
179                 *werror = r.out.result;
180         }
181
182         return werror_to_ntstatus(r.out.result);
183 }
184
185 struct rpccli_spoolss_OpenPrinter_state {
186         struct spoolss_OpenPrinter orig;
187         struct spoolss_OpenPrinter tmp;
188         TALLOC_CTX *out_mem_ctx;
189         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
190 };
191
192 static void rpccli_spoolss_OpenPrinter_done(struct tevent_req *subreq);
193
194 struct tevent_req *rpccli_spoolss_OpenPrinter_send(TALLOC_CTX *mem_ctx,
195                                                    struct tevent_context *ev,
196                                                    struct rpc_pipe_client *cli,
197                                                    const char *_printername /* [in] [unique,charset(UTF16)] */,
198                                                    const char *_datatype /* [in] [unique,charset(UTF16)] */,
199                                                    struct spoolss_DevmodeContainer _devmode_ctr /* [in]  */,
200                                                    uint32_t _access_mask /* [in]  */,
201                                                    struct policy_handle *_handle /* [out] [ref] */)
202 {
203         struct tevent_req *req;
204         struct rpccli_spoolss_OpenPrinter_state *state;
205         struct tevent_req *subreq;
206
207         req = tevent_req_create(mem_ctx, &state,
208                                 struct rpccli_spoolss_OpenPrinter_state);
209         if (req == NULL) {
210                 return NULL;
211         }
212         state->out_mem_ctx = NULL;
213         state->dispatch_recv = cli->dispatch_recv;
214
215         /* In parameters */
216         state->orig.in.printername = _printername;
217         state->orig.in.datatype = _datatype;
218         state->orig.in.devmode_ctr = _devmode_ctr;
219         state->orig.in.access_mask = _access_mask;
220
221         /* Out parameters */
222         state->orig.out.handle = _handle;
223
224         /* Result */
225         ZERO_STRUCT(state->orig.out.result);
226
227         state->out_mem_ctx = talloc_named_const(state, 0,
228                              "rpccli_spoolss_OpenPrinter_out_memory");
229         if (tevent_req_nomem(state->out_mem_ctx, req)) {
230                 return tevent_req_post(req, ev);
231         }
232
233         /* make a temporary copy, that we pass to the dispatch function */
234         state->tmp = state->orig;
235
236         subreq = cli->dispatch_send(state, ev, cli,
237                                     &ndr_table_spoolss,
238                                     NDR_SPOOLSS_OPENPRINTER,
239                                     &state->tmp);
240         if (tevent_req_nomem(subreq, req)) {
241                 return tevent_req_post(req, ev);
242         }
243         tevent_req_set_callback(subreq, rpccli_spoolss_OpenPrinter_done, req);
244         return req;
245 }
246
247 static void rpccli_spoolss_OpenPrinter_done(struct tevent_req *subreq)
248 {
249         struct tevent_req *req = tevent_req_callback_data(
250                 subreq, struct tevent_req);
251         struct rpccli_spoolss_OpenPrinter_state *state = tevent_req_data(
252                 req, struct rpccli_spoolss_OpenPrinter_state);
253         NTSTATUS status;
254         TALLOC_CTX *mem_ctx;
255
256         if (state->out_mem_ctx) {
257                 mem_ctx = state->out_mem_ctx;
258         } else {
259                 mem_ctx = state;
260         }
261
262         status = state->dispatch_recv(subreq, mem_ctx);
263         TALLOC_FREE(subreq);
264         if (!NT_STATUS_IS_OK(status)) {
265                 tevent_req_nterror(req, status);
266                 return;
267         }
268
269         /* Copy out parameters */
270         *state->orig.out.handle = *state->tmp.out.handle;
271
272         /* Copy result */
273         state->orig.out.result = state->tmp.out.result;
274
275         /* Reset temporary structure */
276         ZERO_STRUCT(state->tmp);
277
278         tevent_req_done(req);
279 }
280
281 NTSTATUS rpccli_spoolss_OpenPrinter_recv(struct tevent_req *req,
282                                          TALLOC_CTX *mem_ctx,
283                                          WERROR *result)
284 {
285         struct rpccli_spoolss_OpenPrinter_state *state = tevent_req_data(
286                 req, struct rpccli_spoolss_OpenPrinter_state);
287         NTSTATUS status;
288
289         if (tevent_req_is_nterror(req, &status)) {
290                 tevent_req_received(req);
291                 return status;
292         }
293
294         /* Steal possbile out parameters to the callers context */
295         talloc_steal(mem_ctx, state->out_mem_ctx);
296
297         /* Return result */
298         *result = state->orig.out.result;
299
300         tevent_req_received(req);
301         return NT_STATUS_OK;
302 }
303
304 NTSTATUS rpccli_spoolss_OpenPrinter(struct rpc_pipe_client *cli,
305                                     TALLOC_CTX *mem_ctx,
306                                     const char *printername /* [in] [unique,charset(UTF16)] */,
307                                     const char *datatype /* [in] [unique,charset(UTF16)] */,
308                                     struct spoolss_DevmodeContainer devmode_ctr /* [in]  */,
309                                     uint32_t access_mask /* [in]  */,
310                                     struct policy_handle *handle /* [out] [ref] */,
311                                     WERROR *werror)
312 {
313         struct spoolss_OpenPrinter r;
314         NTSTATUS status;
315
316         /* In parameters */
317         r.in.printername = printername;
318         r.in.datatype = datatype;
319         r.in.devmode_ctr = devmode_ctr;
320         r.in.access_mask = access_mask;
321
322         status = cli->dispatch(cli,
323                                 mem_ctx,
324                                 &ndr_table_spoolss,
325                                 NDR_SPOOLSS_OPENPRINTER,
326                                 &r);
327
328         if (!NT_STATUS_IS_OK(status)) {
329                 return status;
330         }
331
332         if (NT_STATUS_IS_ERR(status)) {
333                 return status;
334         }
335
336         /* Return variables */
337         *handle = *r.out.handle;
338
339         /* Return result */
340         if (werror) {
341                 *werror = r.out.result;
342         }
343
344         return werror_to_ntstatus(r.out.result);
345 }
346
347 struct rpccli_spoolss_SetJob_state {
348         struct spoolss_SetJob orig;
349         struct spoolss_SetJob tmp;
350         TALLOC_CTX *out_mem_ctx;
351         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
352 };
353
354 static void rpccli_spoolss_SetJob_done(struct tevent_req *subreq);
355
356 struct tevent_req *rpccli_spoolss_SetJob_send(TALLOC_CTX *mem_ctx,
357                                               struct tevent_context *ev,
358                                               struct rpc_pipe_client *cli,
359                                               struct policy_handle *_handle /* [in] [ref] */,
360                                               uint32_t _job_id /* [in]  */,
361                                               struct spoolss_JobInfoContainer *_ctr /* [in] [unique] */,
362                                               enum spoolss_JobControl _command /* [in]  */)
363 {
364         struct tevent_req *req;
365         struct rpccli_spoolss_SetJob_state *state;
366         struct tevent_req *subreq;
367
368         req = tevent_req_create(mem_ctx, &state,
369                                 struct rpccli_spoolss_SetJob_state);
370         if (req == NULL) {
371                 return NULL;
372         }
373         state->out_mem_ctx = NULL;
374         state->dispatch_recv = cli->dispatch_recv;
375
376         /* In parameters */
377         state->orig.in.handle = _handle;
378         state->orig.in.job_id = _job_id;
379         state->orig.in.ctr = _ctr;
380         state->orig.in.command = _command;
381
382         /* Out parameters */
383
384         /* Result */
385         ZERO_STRUCT(state->orig.out.result);
386
387         /* make a temporary copy, that we pass to the dispatch function */
388         state->tmp = state->orig;
389
390         subreq = cli->dispatch_send(state, ev, cli,
391                                     &ndr_table_spoolss,
392                                     NDR_SPOOLSS_SETJOB,
393                                     &state->tmp);
394         if (tevent_req_nomem(subreq, req)) {
395                 return tevent_req_post(req, ev);
396         }
397         tevent_req_set_callback(subreq, rpccli_spoolss_SetJob_done, req);
398         return req;
399 }
400
401 static void rpccli_spoolss_SetJob_done(struct tevent_req *subreq)
402 {
403         struct tevent_req *req = tevent_req_callback_data(
404                 subreq, struct tevent_req);
405         struct rpccli_spoolss_SetJob_state *state = tevent_req_data(
406                 req, struct rpccli_spoolss_SetJob_state);
407         NTSTATUS status;
408         TALLOC_CTX *mem_ctx;
409
410         if (state->out_mem_ctx) {
411                 mem_ctx = state->out_mem_ctx;
412         } else {
413                 mem_ctx = state;
414         }
415
416         status = state->dispatch_recv(subreq, mem_ctx);
417         TALLOC_FREE(subreq);
418         if (!NT_STATUS_IS_OK(status)) {
419                 tevent_req_nterror(req, status);
420                 return;
421         }
422
423         /* Copy out parameters */
424
425         /* Copy result */
426         state->orig.out.result = state->tmp.out.result;
427
428         /* Reset temporary structure */
429         ZERO_STRUCT(state->tmp);
430
431         tevent_req_done(req);
432 }
433
434 NTSTATUS rpccli_spoolss_SetJob_recv(struct tevent_req *req,
435                                     TALLOC_CTX *mem_ctx,
436                                     WERROR *result)
437 {
438         struct rpccli_spoolss_SetJob_state *state = tevent_req_data(
439                 req, struct rpccli_spoolss_SetJob_state);
440         NTSTATUS status;
441
442         if (tevent_req_is_nterror(req, &status)) {
443                 tevent_req_received(req);
444                 return status;
445         }
446
447         /* Steal possbile out parameters to the callers context */
448         talloc_steal(mem_ctx, state->out_mem_ctx);
449
450         /* Return result */
451         *result = state->orig.out.result;
452
453         tevent_req_received(req);
454         return NT_STATUS_OK;
455 }
456
457 NTSTATUS rpccli_spoolss_SetJob(struct rpc_pipe_client *cli,
458                                TALLOC_CTX *mem_ctx,
459                                struct policy_handle *handle /* [in] [ref] */,
460                                uint32_t job_id /* [in]  */,
461                                struct spoolss_JobInfoContainer *ctr /* [in] [unique] */,
462                                enum spoolss_JobControl command /* [in]  */,
463                                WERROR *werror)
464 {
465         struct spoolss_SetJob r;
466         NTSTATUS status;
467
468         /* In parameters */
469         r.in.handle = handle;
470         r.in.job_id = job_id;
471         r.in.ctr = ctr;
472         r.in.command = command;
473
474         status = cli->dispatch(cli,
475                                 mem_ctx,
476                                 &ndr_table_spoolss,
477                                 NDR_SPOOLSS_SETJOB,
478                                 &r);
479
480         if (!NT_STATUS_IS_OK(status)) {
481                 return status;
482         }
483
484         if (NT_STATUS_IS_ERR(status)) {
485                 return status;
486         }
487
488         /* Return variables */
489
490         /* Return result */
491         if (werror) {
492                 *werror = r.out.result;
493         }
494
495         return werror_to_ntstatus(r.out.result);
496 }
497
498 struct rpccli_spoolss_GetJob_state {
499         struct spoolss_GetJob orig;
500         struct spoolss_GetJob tmp;
501         TALLOC_CTX *out_mem_ctx;
502         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
503 };
504
505 static void rpccli_spoolss_GetJob_done(struct tevent_req *subreq);
506
507 struct tevent_req *rpccli_spoolss_GetJob_send(TALLOC_CTX *mem_ctx,
508                                               struct tevent_context *ev,
509                                               struct rpc_pipe_client *cli,
510                                               struct policy_handle *_handle /* [in] [ref] */,
511                                               uint32_t _job_id /* [in]  */,
512                                               uint32_t _level /* [in]  */,
513                                               DATA_BLOB *_buffer /* [in] [unique] */,
514                                               uint32_t _offered /* [in]  */,
515                                               union spoolss_JobInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
516                                               uint32_t *_needed /* [out] [ref] */)
517 {
518         struct tevent_req *req;
519         struct rpccli_spoolss_GetJob_state *state;
520         struct tevent_req *subreq;
521
522         req = tevent_req_create(mem_ctx, &state,
523                                 struct rpccli_spoolss_GetJob_state);
524         if (req == NULL) {
525                 return NULL;
526         }
527         state->out_mem_ctx = NULL;
528         state->dispatch_recv = cli->dispatch_recv;
529
530         /* In parameters */
531         state->orig.in.handle = _handle;
532         state->orig.in.job_id = _job_id;
533         state->orig.in.level = _level;
534         state->orig.in.buffer = _buffer;
535         state->orig.in.offered = _offered;
536
537         /* Out parameters */
538         state->orig.out.info = _info;
539         state->orig.out.needed = _needed;
540
541         /* Result */
542         ZERO_STRUCT(state->orig.out.result);
543
544         state->out_mem_ctx = talloc_named_const(state, 0,
545                              "rpccli_spoolss_GetJob_out_memory");
546         if (tevent_req_nomem(state->out_mem_ctx, req)) {
547                 return tevent_req_post(req, ev);
548         }
549
550         /* make a temporary copy, that we pass to the dispatch function */
551         state->tmp = state->orig;
552
553         subreq = cli->dispatch_send(state, ev, cli,
554                                     &ndr_table_spoolss,
555                                     NDR_SPOOLSS_GETJOB,
556                                     &state->tmp);
557         if (tevent_req_nomem(subreq, req)) {
558                 return tevent_req_post(req, ev);
559         }
560         tevent_req_set_callback(subreq, rpccli_spoolss_GetJob_done, req);
561         return req;
562 }
563
564 static void rpccli_spoolss_GetJob_done(struct tevent_req *subreq)
565 {
566         struct tevent_req *req = tevent_req_callback_data(
567                 subreq, struct tevent_req);
568         struct rpccli_spoolss_GetJob_state *state = tevent_req_data(
569                 req, struct rpccli_spoolss_GetJob_state);
570         NTSTATUS status;
571         TALLOC_CTX *mem_ctx;
572
573         if (state->out_mem_ctx) {
574                 mem_ctx = state->out_mem_ctx;
575         } else {
576                 mem_ctx = state;
577         }
578
579         status = state->dispatch_recv(subreq, mem_ctx);
580         TALLOC_FREE(subreq);
581         if (!NT_STATUS_IS_OK(status)) {
582                 tevent_req_nterror(req, status);
583                 return;
584         }
585
586         /* Copy out parameters */
587         if (state->orig.out.info && state->tmp.out.info) {
588                 *state->orig.out.info = *state->tmp.out.info;
589         }
590         *state->orig.out.needed = *state->tmp.out.needed;
591
592         /* Copy result */
593         state->orig.out.result = state->tmp.out.result;
594
595         /* Reset temporary structure */
596         ZERO_STRUCT(state->tmp);
597
598         tevent_req_done(req);
599 }
600
601 NTSTATUS rpccli_spoolss_GetJob_recv(struct tevent_req *req,
602                                     TALLOC_CTX *mem_ctx,
603                                     WERROR *result)
604 {
605         struct rpccli_spoolss_GetJob_state *state = tevent_req_data(
606                 req, struct rpccli_spoolss_GetJob_state);
607         NTSTATUS status;
608
609         if (tevent_req_is_nterror(req, &status)) {
610                 tevent_req_received(req);
611                 return status;
612         }
613
614         /* Steal possbile out parameters to the callers context */
615         talloc_steal(mem_ctx, state->out_mem_ctx);
616
617         /* Return result */
618         *result = state->orig.out.result;
619
620         tevent_req_received(req);
621         return NT_STATUS_OK;
622 }
623
624 NTSTATUS rpccli_spoolss_GetJob(struct rpc_pipe_client *cli,
625                                TALLOC_CTX *mem_ctx,
626                                struct policy_handle *handle /* [in] [ref] */,
627                                uint32_t job_id /* [in]  */,
628                                uint32_t level /* [in]  */,
629                                DATA_BLOB *buffer /* [in] [unique] */,
630                                uint32_t offered /* [in]  */,
631                                union spoolss_JobInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
632                                uint32_t *needed /* [out] [ref] */,
633                                WERROR *werror)
634 {
635         struct spoolss_GetJob r;
636         NTSTATUS status;
637
638         /* In parameters */
639         r.in.handle = handle;
640         r.in.job_id = job_id;
641         r.in.level = level;
642         r.in.buffer = buffer;
643         r.in.offered = offered;
644
645         status = cli->dispatch(cli,
646                                 mem_ctx,
647                                 &ndr_table_spoolss,
648                                 NDR_SPOOLSS_GETJOB,
649                                 &r);
650
651         if (!NT_STATUS_IS_OK(status)) {
652                 return status;
653         }
654
655         if (NT_STATUS_IS_ERR(status)) {
656                 return status;
657         }
658
659         /* Return variables */
660         if (info && r.out.info) {
661                 *info = *r.out.info;
662         }
663         *needed = *r.out.needed;
664
665         /* Return result */
666         if (werror) {
667                 *werror = r.out.result;
668         }
669
670         return werror_to_ntstatus(r.out.result);
671 }
672
673 struct rpccli_spoolss_EnumJobs_state {
674         struct spoolss_EnumJobs orig;
675         struct spoolss_EnumJobs tmp;
676         TALLOC_CTX *out_mem_ctx;
677         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
678 };
679
680 static void rpccli_spoolss_EnumJobs_done(struct tevent_req *subreq);
681
682 struct tevent_req *rpccli_spoolss_EnumJobs_send(TALLOC_CTX *mem_ctx,
683                                                 struct tevent_context *ev,
684                                                 struct rpc_pipe_client *cli,
685                                                 struct policy_handle *_handle /* [in] [ref] */,
686                                                 uint32_t _firstjob /* [in]  */,
687                                                 uint32_t _numjobs /* [in]  */,
688                                                 uint32_t _level /* [in]  */,
689                                                 DATA_BLOB *_buffer /* [in] [unique] */,
690                                                 uint32_t _offered /* [in]  */,
691                                                 uint32_t *_count /* [out] [ref] */,
692                                                 union spoolss_JobInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
693                                                 uint32_t *_needed /* [out] [ref] */)
694 {
695         struct tevent_req *req;
696         struct rpccli_spoolss_EnumJobs_state *state;
697         struct tevent_req *subreq;
698
699         req = tevent_req_create(mem_ctx, &state,
700                                 struct rpccli_spoolss_EnumJobs_state);
701         if (req == NULL) {
702                 return NULL;
703         }
704         state->out_mem_ctx = NULL;
705         state->dispatch_recv = cli->dispatch_recv;
706
707         /* In parameters */
708         state->orig.in.handle = _handle;
709         state->orig.in.firstjob = _firstjob;
710         state->orig.in.numjobs = _numjobs;
711         state->orig.in.level = _level;
712         state->orig.in.buffer = _buffer;
713         state->orig.in.offered = _offered;
714
715         /* Out parameters */
716         state->orig.out.count = _count;
717         state->orig.out.info = _info;
718         state->orig.out.needed = _needed;
719
720         /* Result */
721         ZERO_STRUCT(state->orig.out.result);
722
723         state->out_mem_ctx = talloc_named_const(state, 0,
724                              "rpccli_spoolss_EnumJobs_out_memory");
725         if (tevent_req_nomem(state->out_mem_ctx, req)) {
726                 return tevent_req_post(req, ev);
727         }
728
729         /* make a temporary copy, that we pass to the dispatch function */
730         state->tmp = state->orig;
731
732         subreq = cli->dispatch_send(state, ev, cli,
733                                     &ndr_table_spoolss,
734                                     NDR_SPOOLSS_ENUMJOBS,
735                                     &state->tmp);
736         if (tevent_req_nomem(subreq, req)) {
737                 return tevent_req_post(req, ev);
738         }
739         tevent_req_set_callback(subreq, rpccli_spoolss_EnumJobs_done, req);
740         return req;
741 }
742
743 static void rpccli_spoolss_EnumJobs_done(struct tevent_req *subreq)
744 {
745         struct tevent_req *req = tevent_req_callback_data(
746                 subreq, struct tevent_req);
747         struct rpccli_spoolss_EnumJobs_state *state = tevent_req_data(
748                 req, struct rpccli_spoolss_EnumJobs_state);
749         NTSTATUS status;
750         TALLOC_CTX *mem_ctx;
751
752         if (state->out_mem_ctx) {
753                 mem_ctx = state->out_mem_ctx;
754         } else {
755                 mem_ctx = state;
756         }
757
758         status = state->dispatch_recv(subreq, mem_ctx);
759         TALLOC_FREE(subreq);
760         if (!NT_STATUS_IS_OK(status)) {
761                 tevent_req_nterror(req, status);
762                 return;
763         }
764
765         /* Copy out parameters */
766         *state->orig.out.count = *state->tmp.out.count;
767         *state->orig.out.info = *state->tmp.out.info;
768         *state->orig.out.needed = *state->tmp.out.needed;
769
770         /* Copy result */
771         state->orig.out.result = state->tmp.out.result;
772
773         /* Reset temporary structure */
774         ZERO_STRUCT(state->tmp);
775
776         tevent_req_done(req);
777 }
778
779 NTSTATUS rpccli_spoolss_EnumJobs_recv(struct tevent_req *req,
780                                       TALLOC_CTX *mem_ctx,
781                                       WERROR *result)
782 {
783         struct rpccli_spoolss_EnumJobs_state *state = tevent_req_data(
784                 req, struct rpccli_spoolss_EnumJobs_state);
785         NTSTATUS status;
786
787         if (tevent_req_is_nterror(req, &status)) {
788                 tevent_req_received(req);
789                 return status;
790         }
791
792         /* Steal possbile out parameters to the callers context */
793         talloc_steal(mem_ctx, state->out_mem_ctx);
794
795         /* Return result */
796         *result = state->orig.out.result;
797
798         tevent_req_received(req);
799         return NT_STATUS_OK;
800 }
801
802 NTSTATUS rpccli_spoolss_EnumJobs(struct rpc_pipe_client *cli,
803                                  TALLOC_CTX *mem_ctx,
804                                  struct policy_handle *handle /* [in] [ref] */,
805                                  uint32_t firstjob /* [in]  */,
806                                  uint32_t numjobs /* [in]  */,
807                                  uint32_t level /* [in]  */,
808                                  DATA_BLOB *buffer /* [in] [unique] */,
809                                  uint32_t offered /* [in]  */,
810                                  uint32_t *count /* [out] [ref] */,
811                                  union spoolss_JobInfo **info /* [out] [ref,switch_is(level),size_is(,*count)] */,
812                                  uint32_t *needed /* [out] [ref] */,
813                                  WERROR *werror)
814 {
815         struct spoolss_EnumJobs r;
816         NTSTATUS status;
817
818         /* In parameters */
819         r.in.handle = handle;
820         r.in.firstjob = firstjob;
821         r.in.numjobs = numjobs;
822         r.in.level = level;
823         r.in.buffer = buffer;
824         r.in.offered = offered;
825
826         status = cli->dispatch(cli,
827                                 mem_ctx,
828                                 &ndr_table_spoolss,
829                                 NDR_SPOOLSS_ENUMJOBS,
830                                 &r);
831
832         if (!NT_STATUS_IS_OK(status)) {
833                 return status;
834         }
835
836         if (NT_STATUS_IS_ERR(status)) {
837                 return status;
838         }
839
840         /* Return variables */
841         *count = *r.out.count;
842         *info = *r.out.info;
843         *needed = *r.out.needed;
844
845         /* Return result */
846         if (werror) {
847                 *werror = r.out.result;
848         }
849
850         return werror_to_ntstatus(r.out.result);
851 }
852
853 struct rpccli_spoolss_AddPrinter_state {
854         struct spoolss_AddPrinter orig;
855         struct spoolss_AddPrinter tmp;
856         TALLOC_CTX *out_mem_ctx;
857         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
858 };
859
860 static void rpccli_spoolss_AddPrinter_done(struct tevent_req *subreq);
861
862 struct tevent_req *rpccli_spoolss_AddPrinter_send(TALLOC_CTX *mem_ctx,
863                                                   struct tevent_context *ev,
864                                                   struct rpc_pipe_client *cli,
865                                                   const char *_server /* [in] [unique,charset(UTF16)] */,
866                                                   struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
867                                                   struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
868                                                   struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
869                                                   struct policy_handle *_handle /* [out] [ref] */)
870 {
871         struct tevent_req *req;
872         struct rpccli_spoolss_AddPrinter_state *state;
873         struct tevent_req *subreq;
874
875         req = tevent_req_create(mem_ctx, &state,
876                                 struct rpccli_spoolss_AddPrinter_state);
877         if (req == NULL) {
878                 return NULL;
879         }
880         state->out_mem_ctx = NULL;
881         state->dispatch_recv = cli->dispatch_recv;
882
883         /* In parameters */
884         state->orig.in.server = _server;
885         state->orig.in.info_ctr = _info_ctr;
886         state->orig.in.devmode_ctr = _devmode_ctr;
887         state->orig.in.secdesc_ctr = _secdesc_ctr;
888
889         /* Out parameters */
890         state->orig.out.handle = _handle;
891
892         /* Result */
893         ZERO_STRUCT(state->orig.out.result);
894
895         state->out_mem_ctx = talloc_named_const(state, 0,
896                              "rpccli_spoolss_AddPrinter_out_memory");
897         if (tevent_req_nomem(state->out_mem_ctx, req)) {
898                 return tevent_req_post(req, ev);
899         }
900
901         /* make a temporary copy, that we pass to the dispatch function */
902         state->tmp = state->orig;
903
904         subreq = cli->dispatch_send(state, ev, cli,
905                                     &ndr_table_spoolss,
906                                     NDR_SPOOLSS_ADDPRINTER,
907                                     &state->tmp);
908         if (tevent_req_nomem(subreq, req)) {
909                 return tevent_req_post(req, ev);
910         }
911         tevent_req_set_callback(subreq, rpccli_spoolss_AddPrinter_done, req);
912         return req;
913 }
914
915 static void rpccli_spoolss_AddPrinter_done(struct tevent_req *subreq)
916 {
917         struct tevent_req *req = tevent_req_callback_data(
918                 subreq, struct tevent_req);
919         struct rpccli_spoolss_AddPrinter_state *state = tevent_req_data(
920                 req, struct rpccli_spoolss_AddPrinter_state);
921         NTSTATUS status;
922         TALLOC_CTX *mem_ctx;
923
924         if (state->out_mem_ctx) {
925                 mem_ctx = state->out_mem_ctx;
926         } else {
927                 mem_ctx = state;
928         }
929
930         status = state->dispatch_recv(subreq, mem_ctx);
931         TALLOC_FREE(subreq);
932         if (!NT_STATUS_IS_OK(status)) {
933                 tevent_req_nterror(req, status);
934                 return;
935         }
936
937         /* Copy out parameters */
938         *state->orig.out.handle = *state->tmp.out.handle;
939
940         /* Copy result */
941         state->orig.out.result = state->tmp.out.result;
942
943         /* Reset temporary structure */
944         ZERO_STRUCT(state->tmp);
945
946         tevent_req_done(req);
947 }
948
949 NTSTATUS rpccli_spoolss_AddPrinter_recv(struct tevent_req *req,
950                                         TALLOC_CTX *mem_ctx,
951                                         WERROR *result)
952 {
953         struct rpccli_spoolss_AddPrinter_state *state = tevent_req_data(
954                 req, struct rpccli_spoolss_AddPrinter_state);
955         NTSTATUS status;
956
957         if (tevent_req_is_nterror(req, &status)) {
958                 tevent_req_received(req);
959                 return status;
960         }
961
962         /* Steal possbile out parameters to the callers context */
963         talloc_steal(mem_ctx, state->out_mem_ctx);
964
965         /* Return result */
966         *result = state->orig.out.result;
967
968         tevent_req_received(req);
969         return NT_STATUS_OK;
970 }
971
972 NTSTATUS rpccli_spoolss_AddPrinter(struct rpc_pipe_client *cli,
973                                    TALLOC_CTX *mem_ctx,
974                                    const char *server /* [in] [unique,charset(UTF16)] */,
975                                    struct spoolss_SetPrinterInfoCtr *info_ctr /* [in] [ref] */,
976                                    struct spoolss_DevmodeContainer *devmode_ctr /* [in] [ref] */,
977                                    struct sec_desc_buf *secdesc_ctr /* [in] [ref] */,
978                                    struct policy_handle *handle /* [out] [ref] */,
979                                    WERROR *werror)
980 {
981         struct spoolss_AddPrinter r;
982         NTSTATUS status;
983
984         /* In parameters */
985         r.in.server = server;
986         r.in.info_ctr = info_ctr;
987         r.in.devmode_ctr = devmode_ctr;
988         r.in.secdesc_ctr = secdesc_ctr;
989
990         status = cli->dispatch(cli,
991                                 mem_ctx,
992                                 &ndr_table_spoolss,
993                                 NDR_SPOOLSS_ADDPRINTER,
994                                 &r);
995
996         if (!NT_STATUS_IS_OK(status)) {
997                 return status;
998         }
999
1000         if (NT_STATUS_IS_ERR(status)) {
1001                 return status;
1002         }
1003
1004         /* Return variables */
1005         *handle = *r.out.handle;
1006
1007         /* Return result */
1008         if (werror) {
1009                 *werror = r.out.result;
1010         }
1011
1012         return werror_to_ntstatus(r.out.result);
1013 }
1014
1015 struct rpccli_spoolss_DeletePrinter_state {
1016         struct spoolss_DeletePrinter orig;
1017         struct spoolss_DeletePrinter tmp;
1018         TALLOC_CTX *out_mem_ctx;
1019         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1020 };
1021
1022 static void rpccli_spoolss_DeletePrinter_done(struct tevent_req *subreq);
1023
1024 struct tevent_req *rpccli_spoolss_DeletePrinter_send(TALLOC_CTX *mem_ctx,
1025                                                      struct tevent_context *ev,
1026                                                      struct rpc_pipe_client *cli,
1027                                                      struct policy_handle *_handle /* [in] [ref] */)
1028 {
1029         struct tevent_req *req;
1030         struct rpccli_spoolss_DeletePrinter_state *state;
1031         struct tevent_req *subreq;
1032
1033         req = tevent_req_create(mem_ctx, &state,
1034                                 struct rpccli_spoolss_DeletePrinter_state);
1035         if (req == NULL) {
1036                 return NULL;
1037         }
1038         state->out_mem_ctx = NULL;
1039         state->dispatch_recv = cli->dispatch_recv;
1040
1041         /* In parameters */
1042         state->orig.in.handle = _handle;
1043
1044         /* Out parameters */
1045
1046         /* Result */
1047         ZERO_STRUCT(state->orig.out.result);
1048
1049         /* make a temporary copy, that we pass to the dispatch function */
1050         state->tmp = state->orig;
1051
1052         subreq = cli->dispatch_send(state, ev, cli,
1053                                     &ndr_table_spoolss,
1054                                     NDR_SPOOLSS_DELETEPRINTER,
1055                                     &state->tmp);
1056         if (tevent_req_nomem(subreq, req)) {
1057                 return tevent_req_post(req, ev);
1058         }
1059         tevent_req_set_callback(subreq, rpccli_spoolss_DeletePrinter_done, req);
1060         return req;
1061 }
1062
1063 static void rpccli_spoolss_DeletePrinter_done(struct tevent_req *subreq)
1064 {
1065         struct tevent_req *req = tevent_req_callback_data(
1066                 subreq, struct tevent_req);
1067         struct rpccli_spoolss_DeletePrinter_state *state = tevent_req_data(
1068                 req, struct rpccli_spoolss_DeletePrinter_state);
1069         NTSTATUS status;
1070         TALLOC_CTX *mem_ctx;
1071
1072         if (state->out_mem_ctx) {
1073                 mem_ctx = state->out_mem_ctx;
1074         } else {
1075                 mem_ctx = state;
1076         }
1077
1078         status = state->dispatch_recv(subreq, mem_ctx);
1079         TALLOC_FREE(subreq);
1080         if (!NT_STATUS_IS_OK(status)) {
1081                 tevent_req_nterror(req, status);
1082                 return;
1083         }
1084
1085         /* Copy out parameters */
1086
1087         /* Copy result */
1088         state->orig.out.result = state->tmp.out.result;
1089
1090         /* Reset temporary structure */
1091         ZERO_STRUCT(state->tmp);
1092
1093         tevent_req_done(req);
1094 }
1095
1096 NTSTATUS rpccli_spoolss_DeletePrinter_recv(struct tevent_req *req,
1097                                            TALLOC_CTX *mem_ctx,
1098                                            WERROR *result)
1099 {
1100         struct rpccli_spoolss_DeletePrinter_state *state = tevent_req_data(
1101                 req, struct rpccli_spoolss_DeletePrinter_state);
1102         NTSTATUS status;
1103
1104         if (tevent_req_is_nterror(req, &status)) {
1105                 tevent_req_received(req);
1106                 return status;
1107         }
1108
1109         /* Steal possbile out parameters to the callers context */
1110         talloc_steal(mem_ctx, state->out_mem_ctx);
1111
1112         /* Return result */
1113         *result = state->orig.out.result;
1114
1115         tevent_req_received(req);
1116         return NT_STATUS_OK;
1117 }
1118
1119 NTSTATUS rpccli_spoolss_DeletePrinter(struct rpc_pipe_client *cli,
1120                                       TALLOC_CTX *mem_ctx,
1121                                       struct policy_handle *handle /* [in] [ref] */,
1122                                       WERROR *werror)
1123 {
1124         struct spoolss_DeletePrinter r;
1125         NTSTATUS status;
1126
1127         /* In parameters */
1128         r.in.handle = handle;
1129
1130         status = cli->dispatch(cli,
1131                                 mem_ctx,
1132                                 &ndr_table_spoolss,
1133                                 NDR_SPOOLSS_DELETEPRINTER,
1134                                 &r);
1135
1136         if (!NT_STATUS_IS_OK(status)) {
1137                 return status;
1138         }
1139
1140         if (NT_STATUS_IS_ERR(status)) {
1141                 return status;
1142         }
1143
1144         /* Return variables */
1145
1146         /* Return result */
1147         if (werror) {
1148                 *werror = r.out.result;
1149         }
1150
1151         return werror_to_ntstatus(r.out.result);
1152 }
1153
1154 struct rpccli_spoolss_SetPrinter_state {
1155         struct spoolss_SetPrinter orig;
1156         struct spoolss_SetPrinter tmp;
1157         TALLOC_CTX *out_mem_ctx;
1158         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1159 };
1160
1161 static void rpccli_spoolss_SetPrinter_done(struct tevent_req *subreq);
1162
1163 struct tevent_req *rpccli_spoolss_SetPrinter_send(TALLOC_CTX *mem_ctx,
1164                                                   struct tevent_context *ev,
1165                                                   struct rpc_pipe_client *cli,
1166                                                   struct policy_handle *_handle /* [in] [ref] */,
1167                                                   struct spoolss_SetPrinterInfoCtr *_info_ctr /* [in] [ref] */,
1168                                                   struct spoolss_DevmodeContainer *_devmode_ctr /* [in] [ref] */,
1169                                                   struct sec_desc_buf *_secdesc_ctr /* [in] [ref] */,
1170                                                   enum spoolss_PrinterControl _command /* [in]  */)
1171 {
1172         struct tevent_req *req;
1173         struct rpccli_spoolss_SetPrinter_state *state;
1174         struct tevent_req *subreq;
1175
1176         req = tevent_req_create(mem_ctx, &state,
1177                                 struct rpccli_spoolss_SetPrinter_state);
1178         if (req == NULL) {
1179                 return NULL;
1180         }
1181         state->out_mem_ctx = NULL;
1182         state->dispatch_recv = cli->dispatch_recv;
1183
1184         /* In parameters */
1185         state->orig.in.handle = _handle;
1186         state->orig.in.info_ctr = _info_ctr;
1187         state->orig.in.devmode_ctr = _devmode_ctr;
1188         state->orig.in.secdesc_ctr = _secdesc_ctr;
1189         state->orig.in.command = _command;
1190
1191         /* Out parameters */
1192
1193         /* Result */
1194         ZERO_STRUCT(state->orig.out.result);
1195
1196         /* make a temporary copy, that we pass to the dispatch function */
1197         state->tmp = state->orig;
1198
1199         subreq = cli->dispatch_send(state, ev, cli,
1200                                     &ndr_table_spoolss,
1201                                     NDR_SPOOLSS_SETPRINTER,
1202                                     &state->tmp);
1203         if (tevent_req_nomem(subreq, req)) {
1204                 return tevent_req_post(req, ev);
1205         }
1206         tevent_req_set_callback(subreq, rpccli_spoolss_SetPrinter_done, req);
1207         return req;
1208 }
1209
1210 static void rpccli_spoolss_SetPrinter_done(struct tevent_req *subreq)
1211 {
1212         struct tevent_req *req = tevent_req_callback_data(
1213                 subreq, struct tevent_req);
1214         struct rpccli_spoolss_SetPrinter_state *state = tevent_req_data(
1215                 req, struct rpccli_spoolss_SetPrinter_state);
1216         NTSTATUS status;
1217         TALLOC_CTX *mem_ctx;
1218
1219         if (state->out_mem_ctx) {
1220                 mem_ctx = state->out_mem_ctx;
1221         } else {
1222                 mem_ctx = state;
1223         }
1224
1225         status = state->dispatch_recv(subreq, mem_ctx);
1226         TALLOC_FREE(subreq);
1227         if (!NT_STATUS_IS_OK(status)) {
1228                 tevent_req_nterror(req, status);
1229                 return;
1230         }
1231
1232         /* Copy out parameters */
1233
1234         /* Copy result */
1235         state->orig.out.result = state->tmp.out.result;
1236
1237         /* Reset temporary structure */
1238         ZERO_STRUCT(state->tmp);
1239
1240         tevent_req_done(req);
1241 }
1242
1243 NTSTATUS rpccli_spoolss_SetPrinter_recv(struct tevent_req *req,
1244                                         TALLOC_CTX *mem_ctx,
1245                                         WERROR *result)
1246 {
1247         struct rpccli_spoolss_SetPrinter_state *state = tevent_req_data(
1248                 req, struct rpccli_spoolss_SetPrinter_state);
1249         NTSTATUS status;
1250
1251         if (tevent_req_is_nterror(req, &status)) {
1252                 tevent_req_received(req);
1253                 return status;
1254         }
1255
1256         /* Steal possbile out parameters to the callers context */
1257         talloc_steal(mem_ctx, state->out_mem_ctx);
1258
1259         /* Return result */
1260         *result = state->orig.out.result;
1261
1262         tevent_req_received(req);
1263         return NT_STATUS_OK;
1264 }
1265
1266 NTSTATUS rpccli_spoolss_SetPrinter(struct rpc_pipe_client *cli,
1267                                    TALLOC_CTX *mem_ctx,
1268                                    struct policy_handle *handle /* [in] [ref] */,
1269                                    struct spoolss_SetPrinterInfoCtr *info_ctr /* [in] [ref] */,
1270                                    struct spoolss_DevmodeContainer *devmode_ctr /* [in] [ref] */,
1271                                    struct sec_desc_buf *secdesc_ctr /* [in] [ref] */,
1272                                    enum spoolss_PrinterControl command /* [in]  */,
1273                                    WERROR *werror)
1274 {
1275         struct spoolss_SetPrinter r;
1276         NTSTATUS status;
1277
1278         /* In parameters */
1279         r.in.handle = handle;
1280         r.in.info_ctr = info_ctr;
1281         r.in.devmode_ctr = devmode_ctr;
1282         r.in.secdesc_ctr = secdesc_ctr;
1283         r.in.command = command;
1284
1285         status = cli->dispatch(cli,
1286                                 mem_ctx,
1287                                 &ndr_table_spoolss,
1288                                 NDR_SPOOLSS_SETPRINTER,
1289                                 &r);
1290
1291         if (!NT_STATUS_IS_OK(status)) {
1292                 return status;
1293         }
1294
1295         if (NT_STATUS_IS_ERR(status)) {
1296                 return status;
1297         }
1298
1299         /* Return variables */
1300
1301         /* Return result */
1302         if (werror) {
1303                 *werror = r.out.result;
1304         }
1305
1306         return werror_to_ntstatus(r.out.result);
1307 }
1308
1309 struct rpccli_spoolss_GetPrinter_state {
1310         struct spoolss_GetPrinter orig;
1311         struct spoolss_GetPrinter tmp;
1312         TALLOC_CTX *out_mem_ctx;
1313         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1314 };
1315
1316 static void rpccli_spoolss_GetPrinter_done(struct tevent_req *subreq);
1317
1318 struct tevent_req *rpccli_spoolss_GetPrinter_send(TALLOC_CTX *mem_ctx,
1319                                                   struct tevent_context *ev,
1320                                                   struct rpc_pipe_client *cli,
1321                                                   struct policy_handle *_handle /* [in] [ref] */,
1322                                                   uint32_t _level /* [in]  */,
1323                                                   DATA_BLOB *_buffer /* [in] [unique] */,
1324                                                   uint32_t _offered /* [in]  */,
1325                                                   union spoolss_PrinterInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
1326                                                   uint32_t *_needed /* [out] [ref] */)
1327 {
1328         struct tevent_req *req;
1329         struct rpccli_spoolss_GetPrinter_state *state;
1330         struct tevent_req *subreq;
1331
1332         req = tevent_req_create(mem_ctx, &state,
1333                                 struct rpccli_spoolss_GetPrinter_state);
1334         if (req == NULL) {
1335                 return NULL;
1336         }
1337         state->out_mem_ctx = NULL;
1338         state->dispatch_recv = cli->dispatch_recv;
1339
1340         /* In parameters */
1341         state->orig.in.handle = _handle;
1342         state->orig.in.level = _level;
1343         state->orig.in.buffer = _buffer;
1344         state->orig.in.offered = _offered;
1345
1346         /* Out parameters */
1347         state->orig.out.info = _info;
1348         state->orig.out.needed = _needed;
1349
1350         /* Result */
1351         ZERO_STRUCT(state->orig.out.result);
1352
1353         state->out_mem_ctx = talloc_named_const(state, 0,
1354                              "rpccli_spoolss_GetPrinter_out_memory");
1355         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1356                 return tevent_req_post(req, ev);
1357         }
1358
1359         /* make a temporary copy, that we pass to the dispatch function */
1360         state->tmp = state->orig;
1361
1362         subreq = cli->dispatch_send(state, ev, cli,
1363                                     &ndr_table_spoolss,
1364                                     NDR_SPOOLSS_GETPRINTER,
1365                                     &state->tmp);
1366         if (tevent_req_nomem(subreq, req)) {
1367                 return tevent_req_post(req, ev);
1368         }
1369         tevent_req_set_callback(subreq, rpccli_spoolss_GetPrinter_done, req);
1370         return req;
1371 }
1372
1373 static void rpccli_spoolss_GetPrinter_done(struct tevent_req *subreq)
1374 {
1375         struct tevent_req *req = tevent_req_callback_data(
1376                 subreq, struct tevent_req);
1377         struct rpccli_spoolss_GetPrinter_state *state = tevent_req_data(
1378                 req, struct rpccli_spoolss_GetPrinter_state);
1379         NTSTATUS status;
1380         TALLOC_CTX *mem_ctx;
1381
1382         if (state->out_mem_ctx) {
1383                 mem_ctx = state->out_mem_ctx;
1384         } else {
1385                 mem_ctx = state;
1386         }
1387
1388         status = state->dispatch_recv(subreq, mem_ctx);
1389         TALLOC_FREE(subreq);
1390         if (!NT_STATUS_IS_OK(status)) {
1391                 tevent_req_nterror(req, status);
1392                 return;
1393         }
1394
1395         /* Copy out parameters */
1396         if (state->orig.out.info && state->tmp.out.info) {
1397                 *state->orig.out.info = *state->tmp.out.info;
1398         }
1399         *state->orig.out.needed = *state->tmp.out.needed;
1400
1401         /* Copy result */
1402         state->orig.out.result = state->tmp.out.result;
1403
1404         /* Reset temporary structure */
1405         ZERO_STRUCT(state->tmp);
1406
1407         tevent_req_done(req);
1408 }
1409
1410 NTSTATUS rpccli_spoolss_GetPrinter_recv(struct tevent_req *req,
1411                                         TALLOC_CTX *mem_ctx,
1412                                         WERROR *result)
1413 {
1414         struct rpccli_spoolss_GetPrinter_state *state = tevent_req_data(
1415                 req, struct rpccli_spoolss_GetPrinter_state);
1416         NTSTATUS status;
1417
1418         if (tevent_req_is_nterror(req, &status)) {
1419                 tevent_req_received(req);
1420                 return status;
1421         }
1422
1423         /* Steal possbile out parameters to the callers context */
1424         talloc_steal(mem_ctx, state->out_mem_ctx);
1425
1426         /* Return result */
1427         *result = state->orig.out.result;
1428
1429         tevent_req_received(req);
1430         return NT_STATUS_OK;
1431 }
1432
1433 NTSTATUS rpccli_spoolss_GetPrinter(struct rpc_pipe_client *cli,
1434                                    TALLOC_CTX *mem_ctx,
1435                                    struct policy_handle *handle /* [in] [ref] */,
1436                                    uint32_t level /* [in]  */,
1437                                    DATA_BLOB *buffer /* [in] [unique] */,
1438                                    uint32_t offered /* [in]  */,
1439                                    union spoolss_PrinterInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
1440                                    uint32_t *needed /* [out] [ref] */,
1441                                    WERROR *werror)
1442 {
1443         struct spoolss_GetPrinter r;
1444         NTSTATUS status;
1445
1446         /* In parameters */
1447         r.in.handle = handle;
1448         r.in.level = level;
1449         r.in.buffer = buffer;
1450         r.in.offered = offered;
1451
1452         status = cli->dispatch(cli,
1453                                 mem_ctx,
1454                                 &ndr_table_spoolss,
1455                                 NDR_SPOOLSS_GETPRINTER,
1456                                 &r);
1457
1458         if (!NT_STATUS_IS_OK(status)) {
1459                 return status;
1460         }
1461
1462         if (NT_STATUS_IS_ERR(status)) {
1463                 return status;
1464         }
1465
1466         /* Return variables */
1467         if (info && r.out.info) {
1468                 *info = *r.out.info;
1469         }
1470         *needed = *r.out.needed;
1471
1472         /* Return result */
1473         if (werror) {
1474                 *werror = r.out.result;
1475         }
1476
1477         return werror_to_ntstatus(r.out.result);
1478 }
1479
1480 struct rpccli_spoolss_AddPrinterDriver_state {
1481         struct spoolss_AddPrinterDriver orig;
1482         struct spoolss_AddPrinterDriver tmp;
1483         TALLOC_CTX *out_mem_ctx;
1484         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1485 };
1486
1487 static void rpccli_spoolss_AddPrinterDriver_done(struct tevent_req *subreq);
1488
1489 struct tevent_req *rpccli_spoolss_AddPrinterDriver_send(TALLOC_CTX *mem_ctx,
1490                                                         struct tevent_context *ev,
1491                                                         struct rpc_pipe_client *cli,
1492                                                         const char *_servername /* [in] [unique,charset(UTF16)] */,
1493                                                         struct spoolss_AddDriverInfoCtr *_info_ctr /* [in] [ref] */)
1494 {
1495         struct tevent_req *req;
1496         struct rpccli_spoolss_AddPrinterDriver_state *state;
1497         struct tevent_req *subreq;
1498
1499         req = tevent_req_create(mem_ctx, &state,
1500                                 struct rpccli_spoolss_AddPrinterDriver_state);
1501         if (req == NULL) {
1502                 return NULL;
1503         }
1504         state->out_mem_ctx = NULL;
1505         state->dispatch_recv = cli->dispatch_recv;
1506
1507         /* In parameters */
1508         state->orig.in.servername = _servername;
1509         state->orig.in.info_ctr = _info_ctr;
1510
1511         /* Out parameters */
1512
1513         /* Result */
1514         ZERO_STRUCT(state->orig.out.result);
1515
1516         /* make a temporary copy, that we pass to the dispatch function */
1517         state->tmp = state->orig;
1518
1519         subreq = cli->dispatch_send(state, ev, cli,
1520                                     &ndr_table_spoolss,
1521                                     NDR_SPOOLSS_ADDPRINTERDRIVER,
1522                                     &state->tmp);
1523         if (tevent_req_nomem(subreq, req)) {
1524                 return tevent_req_post(req, ev);
1525         }
1526         tevent_req_set_callback(subreq, rpccli_spoolss_AddPrinterDriver_done, req);
1527         return req;
1528 }
1529
1530 static void rpccli_spoolss_AddPrinterDriver_done(struct tevent_req *subreq)
1531 {
1532         struct tevent_req *req = tevent_req_callback_data(
1533                 subreq, struct tevent_req);
1534         struct rpccli_spoolss_AddPrinterDriver_state *state = tevent_req_data(
1535                 req, struct rpccli_spoolss_AddPrinterDriver_state);
1536         NTSTATUS status;
1537         TALLOC_CTX *mem_ctx;
1538
1539         if (state->out_mem_ctx) {
1540                 mem_ctx = state->out_mem_ctx;
1541         } else {
1542                 mem_ctx = state;
1543         }
1544
1545         status = state->dispatch_recv(subreq, mem_ctx);
1546         TALLOC_FREE(subreq);
1547         if (!NT_STATUS_IS_OK(status)) {
1548                 tevent_req_nterror(req, status);
1549                 return;
1550         }
1551
1552         /* Copy out parameters */
1553
1554         /* Copy result */
1555         state->orig.out.result = state->tmp.out.result;
1556
1557         /* Reset temporary structure */
1558         ZERO_STRUCT(state->tmp);
1559
1560         tevent_req_done(req);
1561 }
1562
1563 NTSTATUS rpccli_spoolss_AddPrinterDriver_recv(struct tevent_req *req,
1564                                               TALLOC_CTX *mem_ctx,
1565                                               WERROR *result)
1566 {
1567         struct rpccli_spoolss_AddPrinterDriver_state *state = tevent_req_data(
1568                 req, struct rpccli_spoolss_AddPrinterDriver_state);
1569         NTSTATUS status;
1570
1571         if (tevent_req_is_nterror(req, &status)) {
1572                 tevent_req_received(req);
1573                 return status;
1574         }
1575
1576         /* Steal possbile out parameters to the callers context */
1577         talloc_steal(mem_ctx, state->out_mem_ctx);
1578
1579         /* Return result */
1580         *result = state->orig.out.result;
1581
1582         tevent_req_received(req);
1583         return NT_STATUS_OK;
1584 }
1585
1586 NTSTATUS rpccli_spoolss_AddPrinterDriver(struct rpc_pipe_client *cli,
1587                                          TALLOC_CTX *mem_ctx,
1588                                          const char *servername /* [in] [unique,charset(UTF16)] */,
1589                                          struct spoolss_AddDriverInfoCtr *info_ctr /* [in] [ref] */,
1590                                          WERROR *werror)
1591 {
1592         struct spoolss_AddPrinterDriver r;
1593         NTSTATUS status;
1594
1595         /* In parameters */
1596         r.in.servername = servername;
1597         r.in.info_ctr = info_ctr;
1598
1599         status = cli->dispatch(cli,
1600                                 mem_ctx,
1601                                 &ndr_table_spoolss,
1602                                 NDR_SPOOLSS_ADDPRINTERDRIVER,
1603                                 &r);
1604
1605         if (!NT_STATUS_IS_OK(status)) {
1606                 return status;
1607         }
1608
1609         if (NT_STATUS_IS_ERR(status)) {
1610                 return status;
1611         }
1612
1613         /* Return variables */
1614
1615         /* Return result */
1616         if (werror) {
1617                 *werror = r.out.result;
1618         }
1619
1620         return werror_to_ntstatus(r.out.result);
1621 }
1622
1623 struct rpccli_spoolss_EnumPrinterDrivers_state {
1624         struct spoolss_EnumPrinterDrivers orig;
1625         struct spoolss_EnumPrinterDrivers tmp;
1626         TALLOC_CTX *out_mem_ctx;
1627         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1628 };
1629
1630 static void rpccli_spoolss_EnumPrinterDrivers_done(struct tevent_req *subreq);
1631
1632 struct tevent_req *rpccli_spoolss_EnumPrinterDrivers_send(TALLOC_CTX *mem_ctx,
1633                                                           struct tevent_context *ev,
1634                                                           struct rpc_pipe_client *cli,
1635                                                           const char *_server /* [in] [unique,charset(UTF16)] */,
1636                                                           const char *_environment /* [in] [unique,charset(UTF16)] */,
1637                                                           uint32_t _level /* [in]  */,
1638                                                           DATA_BLOB *_buffer /* [in] [unique] */,
1639                                                           uint32_t _offered /* [in]  */,
1640                                                           uint32_t *_count /* [out] [ref] */,
1641                                                           union spoolss_DriverInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
1642                                                           uint32_t *_needed /* [out] [ref] */)
1643 {
1644         struct tevent_req *req;
1645         struct rpccli_spoolss_EnumPrinterDrivers_state *state;
1646         struct tevent_req *subreq;
1647
1648         req = tevent_req_create(mem_ctx, &state,
1649                                 struct rpccli_spoolss_EnumPrinterDrivers_state);
1650         if (req == NULL) {
1651                 return NULL;
1652         }
1653         state->out_mem_ctx = NULL;
1654         state->dispatch_recv = cli->dispatch_recv;
1655
1656         /* In parameters */
1657         state->orig.in.server = _server;
1658         state->orig.in.environment = _environment;
1659         state->orig.in.level = _level;
1660         state->orig.in.buffer = _buffer;
1661         state->orig.in.offered = _offered;
1662
1663         /* Out parameters */
1664         state->orig.out.count = _count;
1665         state->orig.out.info = _info;
1666         state->orig.out.needed = _needed;
1667
1668         /* Result */
1669         ZERO_STRUCT(state->orig.out.result);
1670
1671         state->out_mem_ctx = talloc_named_const(state, 0,
1672                              "rpccli_spoolss_EnumPrinterDrivers_out_memory");
1673         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1674                 return tevent_req_post(req, ev);
1675         }
1676
1677         /* make a temporary copy, that we pass to the dispatch function */
1678         state->tmp = state->orig;
1679
1680         subreq = cli->dispatch_send(state, ev, cli,
1681                                     &ndr_table_spoolss,
1682                                     NDR_SPOOLSS_ENUMPRINTERDRIVERS,
1683                                     &state->tmp);
1684         if (tevent_req_nomem(subreq, req)) {
1685                 return tevent_req_post(req, ev);
1686         }
1687         tevent_req_set_callback(subreq, rpccli_spoolss_EnumPrinterDrivers_done, req);
1688         return req;
1689 }
1690
1691 static void rpccli_spoolss_EnumPrinterDrivers_done(struct tevent_req *subreq)
1692 {
1693         struct tevent_req *req = tevent_req_callback_data(
1694                 subreq, struct tevent_req);
1695         struct rpccli_spoolss_EnumPrinterDrivers_state *state = tevent_req_data(
1696                 req, struct rpccli_spoolss_EnumPrinterDrivers_state);
1697         NTSTATUS status;
1698         TALLOC_CTX *mem_ctx;
1699
1700         if (state->out_mem_ctx) {
1701                 mem_ctx = state->out_mem_ctx;
1702         } else {
1703                 mem_ctx = state;
1704         }
1705
1706         status = state->dispatch_recv(subreq, mem_ctx);
1707         TALLOC_FREE(subreq);
1708         if (!NT_STATUS_IS_OK(status)) {
1709                 tevent_req_nterror(req, status);
1710                 return;
1711         }
1712
1713         /* Copy out parameters */
1714         *state->orig.out.count = *state->tmp.out.count;
1715         *state->orig.out.info = *state->tmp.out.info;
1716         *state->orig.out.needed = *state->tmp.out.needed;
1717
1718         /* Copy result */
1719         state->orig.out.result = state->tmp.out.result;
1720
1721         /* Reset temporary structure */
1722         ZERO_STRUCT(state->tmp);
1723
1724         tevent_req_done(req);
1725 }
1726
1727 NTSTATUS rpccli_spoolss_EnumPrinterDrivers_recv(struct tevent_req *req,
1728                                                 TALLOC_CTX *mem_ctx,
1729                                                 WERROR *result)
1730 {
1731         struct rpccli_spoolss_EnumPrinterDrivers_state *state = tevent_req_data(
1732                 req, struct rpccli_spoolss_EnumPrinterDrivers_state);
1733         NTSTATUS status;
1734
1735         if (tevent_req_is_nterror(req, &status)) {
1736                 tevent_req_received(req);
1737                 return status;
1738         }
1739
1740         /* Steal possbile out parameters to the callers context */
1741         talloc_steal(mem_ctx, state->out_mem_ctx);
1742
1743         /* Return result */
1744         *result = state->orig.out.result;
1745
1746         tevent_req_received(req);
1747         return NT_STATUS_OK;
1748 }
1749
1750 NTSTATUS rpccli_spoolss_EnumPrinterDrivers(struct rpc_pipe_client *cli,
1751                                            TALLOC_CTX *mem_ctx,
1752                                            const char *server /* [in] [unique,charset(UTF16)] */,
1753                                            const char *environment /* [in] [unique,charset(UTF16)] */,
1754                                            uint32_t level /* [in]  */,
1755                                            DATA_BLOB *buffer /* [in] [unique] */,
1756                                            uint32_t offered /* [in]  */,
1757                                            uint32_t *count /* [out] [ref] */,
1758                                            union spoolss_DriverInfo **info /* [out] [ref,switch_is(level),size_is(,*count)] */,
1759                                            uint32_t *needed /* [out] [ref] */,
1760                                            WERROR *werror)
1761 {
1762         struct spoolss_EnumPrinterDrivers r;
1763         NTSTATUS status;
1764
1765         /* In parameters */
1766         r.in.server = server;
1767         r.in.environment = environment;
1768         r.in.level = level;
1769         r.in.buffer = buffer;
1770         r.in.offered = offered;
1771
1772         status = cli->dispatch(cli,
1773                                 mem_ctx,
1774                                 &ndr_table_spoolss,
1775                                 NDR_SPOOLSS_ENUMPRINTERDRIVERS,
1776                                 &r);
1777
1778         if (!NT_STATUS_IS_OK(status)) {
1779                 return status;
1780         }
1781
1782         if (NT_STATUS_IS_ERR(status)) {
1783                 return status;
1784         }
1785
1786         /* Return variables */
1787         *count = *r.out.count;
1788         *info = *r.out.info;
1789         *needed = *r.out.needed;
1790
1791         /* Return result */
1792         if (werror) {
1793                 *werror = r.out.result;
1794         }
1795
1796         return werror_to_ntstatus(r.out.result);
1797 }
1798
1799 struct rpccli_spoolss_GetPrinterDriver_state {
1800         struct spoolss_GetPrinterDriver orig;
1801         struct spoolss_GetPrinterDriver tmp;
1802         TALLOC_CTX *out_mem_ctx;
1803         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1804 };
1805
1806 static void rpccli_spoolss_GetPrinterDriver_done(struct tevent_req *subreq);
1807
1808 struct tevent_req *rpccli_spoolss_GetPrinterDriver_send(TALLOC_CTX *mem_ctx,
1809                                                         struct tevent_context *ev,
1810                                                         struct rpc_pipe_client *cli,
1811                                                         struct policy_handle *_handle /* [in] [ref] */,
1812                                                         const char *_architecture /* [in] [unique,charset(UTF16)] */,
1813                                                         uint32_t _level /* [in]  */,
1814                                                         DATA_BLOB *_buffer /* [in] [unique] */,
1815                                                         uint32_t _offered /* [in]  */,
1816                                                         union spoolss_DriverInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
1817                                                         uint32_t *_needed /* [out] [ref] */)
1818 {
1819         struct tevent_req *req;
1820         struct rpccli_spoolss_GetPrinterDriver_state *state;
1821         struct tevent_req *subreq;
1822
1823         req = tevent_req_create(mem_ctx, &state,
1824                                 struct rpccli_spoolss_GetPrinterDriver_state);
1825         if (req == NULL) {
1826                 return NULL;
1827         }
1828         state->out_mem_ctx = NULL;
1829         state->dispatch_recv = cli->dispatch_recv;
1830
1831         /* In parameters */
1832         state->orig.in.handle = _handle;
1833         state->orig.in.architecture = _architecture;
1834         state->orig.in.level = _level;
1835         state->orig.in.buffer = _buffer;
1836         state->orig.in.offered = _offered;
1837
1838         /* Out parameters */
1839         state->orig.out.info = _info;
1840         state->orig.out.needed = _needed;
1841
1842         /* Result */
1843         ZERO_STRUCT(state->orig.out.result);
1844
1845         state->out_mem_ctx = talloc_named_const(state, 0,
1846                              "rpccli_spoolss_GetPrinterDriver_out_memory");
1847         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1848                 return tevent_req_post(req, ev);
1849         }
1850
1851         /* make a temporary copy, that we pass to the dispatch function */
1852         state->tmp = state->orig;
1853
1854         subreq = cli->dispatch_send(state, ev, cli,
1855                                     &ndr_table_spoolss,
1856                                     NDR_SPOOLSS_GETPRINTERDRIVER,
1857                                     &state->tmp);
1858         if (tevent_req_nomem(subreq, req)) {
1859                 return tevent_req_post(req, ev);
1860         }
1861         tevent_req_set_callback(subreq, rpccli_spoolss_GetPrinterDriver_done, req);
1862         return req;
1863 }
1864
1865 static void rpccli_spoolss_GetPrinterDriver_done(struct tevent_req *subreq)
1866 {
1867         struct tevent_req *req = tevent_req_callback_data(
1868                 subreq, struct tevent_req);
1869         struct rpccli_spoolss_GetPrinterDriver_state *state = tevent_req_data(
1870                 req, struct rpccli_spoolss_GetPrinterDriver_state);
1871         NTSTATUS status;
1872         TALLOC_CTX *mem_ctx;
1873
1874         if (state->out_mem_ctx) {
1875                 mem_ctx = state->out_mem_ctx;
1876         } else {
1877                 mem_ctx = state;
1878         }
1879
1880         status = state->dispatch_recv(subreq, mem_ctx);
1881         TALLOC_FREE(subreq);
1882         if (!NT_STATUS_IS_OK(status)) {
1883                 tevent_req_nterror(req, status);
1884                 return;
1885         }
1886
1887         /* Copy out parameters */
1888         if (state->orig.out.info && state->tmp.out.info) {
1889                 *state->orig.out.info = *state->tmp.out.info;
1890         }
1891         *state->orig.out.needed = *state->tmp.out.needed;
1892
1893         /* Copy result */
1894         state->orig.out.result = state->tmp.out.result;
1895
1896         /* Reset temporary structure */
1897         ZERO_STRUCT(state->tmp);
1898
1899         tevent_req_done(req);
1900 }
1901
1902 NTSTATUS rpccli_spoolss_GetPrinterDriver_recv(struct tevent_req *req,
1903                                               TALLOC_CTX *mem_ctx,
1904                                               WERROR *result)
1905 {
1906         struct rpccli_spoolss_GetPrinterDriver_state *state = tevent_req_data(
1907                 req, struct rpccli_spoolss_GetPrinterDriver_state);
1908         NTSTATUS status;
1909
1910         if (tevent_req_is_nterror(req, &status)) {
1911                 tevent_req_received(req);
1912                 return status;
1913         }
1914
1915         /* Steal possbile out parameters to the callers context */
1916         talloc_steal(mem_ctx, state->out_mem_ctx);
1917
1918         /* Return result */
1919         *result = state->orig.out.result;
1920
1921         tevent_req_received(req);
1922         return NT_STATUS_OK;
1923 }
1924
1925 NTSTATUS rpccli_spoolss_GetPrinterDriver(struct rpc_pipe_client *cli,
1926                                          TALLOC_CTX *mem_ctx,
1927                                          struct policy_handle *handle /* [in] [ref] */,
1928                                          const char *architecture /* [in] [unique,charset(UTF16)] */,
1929                                          uint32_t level /* [in]  */,
1930                                          DATA_BLOB *buffer /* [in] [unique] */,
1931                                          uint32_t offered /* [in]  */,
1932                                          union spoolss_DriverInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
1933                                          uint32_t *needed /* [out] [ref] */,
1934                                          WERROR *werror)
1935 {
1936         struct spoolss_GetPrinterDriver r;
1937         NTSTATUS status;
1938
1939         /* In parameters */
1940         r.in.handle = handle;
1941         r.in.architecture = architecture;
1942         r.in.level = level;
1943         r.in.buffer = buffer;
1944         r.in.offered = offered;
1945
1946         status = cli->dispatch(cli,
1947                                 mem_ctx,
1948                                 &ndr_table_spoolss,
1949                                 NDR_SPOOLSS_GETPRINTERDRIVER,
1950                                 &r);
1951
1952         if (!NT_STATUS_IS_OK(status)) {
1953                 return status;
1954         }
1955
1956         if (NT_STATUS_IS_ERR(status)) {
1957                 return status;
1958         }
1959
1960         /* Return variables */
1961         if (info && r.out.info) {
1962                 *info = *r.out.info;
1963         }
1964         *needed = *r.out.needed;
1965
1966         /* Return result */
1967         if (werror) {
1968                 *werror = r.out.result;
1969         }
1970
1971         return werror_to_ntstatus(r.out.result);
1972 }
1973
1974 struct rpccli_spoolss_GetPrinterDriverDirectory_state {
1975         struct spoolss_GetPrinterDriverDirectory orig;
1976         struct spoolss_GetPrinterDriverDirectory tmp;
1977         TALLOC_CTX *out_mem_ctx;
1978         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1979 };
1980
1981 static void rpccli_spoolss_GetPrinterDriverDirectory_done(struct tevent_req *subreq);
1982
1983 struct tevent_req *rpccli_spoolss_GetPrinterDriverDirectory_send(TALLOC_CTX *mem_ctx,
1984                                                                  struct tevent_context *ev,
1985                                                                  struct rpc_pipe_client *cli,
1986                                                                  const char *_server /* [in] [unique,charset(UTF16)] */,
1987                                                                  const char *_environment /* [in] [unique,charset(UTF16)] */,
1988                                                                  uint32_t _level /* [in]  */,
1989                                                                  DATA_BLOB *_buffer /* [in] [unique] */,
1990                                                                  uint32_t _offered /* [in]  */,
1991                                                                  union spoolss_DriverDirectoryInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
1992                                                                  uint32_t *_needed /* [out] [ref] */)
1993 {
1994         struct tevent_req *req;
1995         struct rpccli_spoolss_GetPrinterDriverDirectory_state *state;
1996         struct tevent_req *subreq;
1997
1998         req = tevent_req_create(mem_ctx, &state,
1999                                 struct rpccli_spoolss_GetPrinterDriverDirectory_state);
2000         if (req == NULL) {
2001                 return NULL;
2002         }
2003         state->out_mem_ctx = NULL;
2004         state->dispatch_recv = cli->dispatch_recv;
2005
2006         /* In parameters */
2007         state->orig.in.server = _server;
2008         state->orig.in.environment = _environment;
2009         state->orig.in.level = _level;
2010         state->orig.in.buffer = _buffer;
2011         state->orig.in.offered = _offered;
2012
2013         /* Out parameters */
2014         state->orig.out.info = _info;
2015         state->orig.out.needed = _needed;
2016
2017         /* Result */
2018         ZERO_STRUCT(state->orig.out.result);
2019
2020         state->out_mem_ctx = talloc_named_const(state, 0,
2021                              "rpccli_spoolss_GetPrinterDriverDirectory_out_memory");
2022         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2023                 return tevent_req_post(req, ev);
2024         }
2025
2026         /* make a temporary copy, that we pass to the dispatch function */
2027         state->tmp = state->orig;
2028
2029         subreq = cli->dispatch_send(state, ev, cli,
2030                                     &ndr_table_spoolss,
2031                                     NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY,
2032                                     &state->tmp);
2033         if (tevent_req_nomem(subreq, req)) {
2034                 return tevent_req_post(req, ev);
2035         }
2036         tevent_req_set_callback(subreq, rpccli_spoolss_GetPrinterDriverDirectory_done, req);
2037         return req;
2038 }
2039
2040 static void rpccli_spoolss_GetPrinterDriverDirectory_done(struct tevent_req *subreq)
2041 {
2042         struct tevent_req *req = tevent_req_callback_data(
2043                 subreq, struct tevent_req);
2044         struct rpccli_spoolss_GetPrinterDriverDirectory_state *state = tevent_req_data(
2045                 req, struct rpccli_spoolss_GetPrinterDriverDirectory_state);
2046         NTSTATUS status;
2047         TALLOC_CTX *mem_ctx;
2048
2049         if (state->out_mem_ctx) {
2050                 mem_ctx = state->out_mem_ctx;
2051         } else {
2052                 mem_ctx = state;
2053         }
2054
2055         status = state->dispatch_recv(subreq, mem_ctx);
2056         TALLOC_FREE(subreq);
2057         if (!NT_STATUS_IS_OK(status)) {
2058                 tevent_req_nterror(req, status);
2059                 return;
2060         }
2061
2062         /* Copy out parameters */
2063         if (state->orig.out.info && state->tmp.out.info) {
2064                 *state->orig.out.info = *state->tmp.out.info;
2065         }
2066         *state->orig.out.needed = *state->tmp.out.needed;
2067
2068         /* Copy result */
2069         state->orig.out.result = state->tmp.out.result;
2070
2071         /* Reset temporary structure */
2072         ZERO_STRUCT(state->tmp);
2073
2074         tevent_req_done(req);
2075 }
2076
2077 NTSTATUS rpccli_spoolss_GetPrinterDriverDirectory_recv(struct tevent_req *req,
2078                                                        TALLOC_CTX *mem_ctx,
2079                                                        WERROR *result)
2080 {
2081         struct rpccli_spoolss_GetPrinterDriverDirectory_state *state = tevent_req_data(
2082                 req, struct rpccli_spoolss_GetPrinterDriverDirectory_state);
2083         NTSTATUS status;
2084
2085         if (tevent_req_is_nterror(req, &status)) {
2086                 tevent_req_received(req);
2087                 return status;
2088         }
2089
2090         /* Steal possbile out parameters to the callers context */
2091         talloc_steal(mem_ctx, state->out_mem_ctx);
2092
2093         /* Return result */
2094         *result = state->orig.out.result;
2095
2096         tevent_req_received(req);
2097         return NT_STATUS_OK;
2098 }
2099
2100 NTSTATUS rpccli_spoolss_GetPrinterDriverDirectory(struct rpc_pipe_client *cli,
2101                                                   TALLOC_CTX *mem_ctx,
2102                                                   const char *server /* [in] [unique,charset(UTF16)] */,
2103                                                   const char *environment /* [in] [unique,charset(UTF16)] */,
2104                                                   uint32_t level /* [in]  */,
2105                                                   DATA_BLOB *buffer /* [in] [unique] */,
2106                                                   uint32_t offered /* [in]  */,
2107                                                   union spoolss_DriverDirectoryInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
2108                                                   uint32_t *needed /* [out] [ref] */,
2109                                                   WERROR *werror)
2110 {
2111         struct spoolss_GetPrinterDriverDirectory r;
2112         NTSTATUS status;
2113
2114         /* In parameters */
2115         r.in.server = server;
2116         r.in.environment = environment;
2117         r.in.level = level;
2118         r.in.buffer = buffer;
2119         r.in.offered = offered;
2120
2121         status = cli->dispatch(cli,
2122                                 mem_ctx,
2123                                 &ndr_table_spoolss,
2124                                 NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY,
2125                                 &r);
2126
2127         if (!NT_STATUS_IS_OK(status)) {
2128                 return status;
2129         }
2130
2131         if (NT_STATUS_IS_ERR(status)) {
2132                 return status;
2133         }
2134
2135         /* Return variables */
2136         if (info && r.out.info) {
2137                 *info = *r.out.info;
2138         }
2139         *needed = *r.out.needed;
2140
2141         /* Return result */
2142         if (werror) {
2143                 *werror = r.out.result;
2144         }
2145
2146         return werror_to_ntstatus(r.out.result);
2147 }
2148
2149 struct rpccli_spoolss_DeletePrinterDriver_state {
2150         struct spoolss_DeletePrinterDriver orig;
2151         struct spoolss_DeletePrinterDriver tmp;
2152         TALLOC_CTX *out_mem_ctx;
2153         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2154 };
2155
2156 static void rpccli_spoolss_DeletePrinterDriver_done(struct tevent_req *subreq);
2157
2158 struct tevent_req *rpccli_spoolss_DeletePrinterDriver_send(TALLOC_CTX *mem_ctx,
2159                                                            struct tevent_context *ev,
2160                                                            struct rpc_pipe_client *cli,
2161                                                            const char *_server /* [in] [unique,charset(UTF16)] */,
2162                                                            const char *_architecture /* [in] [charset(UTF16)] */,
2163                                                            const char *_driver /* [in] [charset(UTF16)] */)
2164 {
2165         struct tevent_req *req;
2166         struct rpccli_spoolss_DeletePrinterDriver_state *state;
2167         struct tevent_req *subreq;
2168
2169         req = tevent_req_create(mem_ctx, &state,
2170                                 struct rpccli_spoolss_DeletePrinterDriver_state);
2171         if (req == NULL) {
2172                 return NULL;
2173         }
2174         state->out_mem_ctx = NULL;
2175         state->dispatch_recv = cli->dispatch_recv;
2176
2177         /* In parameters */
2178         state->orig.in.server = _server;
2179         state->orig.in.architecture = _architecture;
2180         state->orig.in.driver = _driver;
2181
2182         /* Out parameters */
2183
2184         /* Result */
2185         ZERO_STRUCT(state->orig.out.result);
2186
2187         /* make a temporary copy, that we pass to the dispatch function */
2188         state->tmp = state->orig;
2189
2190         subreq = cli->dispatch_send(state, ev, cli,
2191                                     &ndr_table_spoolss,
2192                                     NDR_SPOOLSS_DELETEPRINTERDRIVER,
2193                                     &state->tmp);
2194         if (tevent_req_nomem(subreq, req)) {
2195                 return tevent_req_post(req, ev);
2196         }
2197         tevent_req_set_callback(subreq, rpccli_spoolss_DeletePrinterDriver_done, req);
2198         return req;
2199 }
2200
2201 static void rpccli_spoolss_DeletePrinterDriver_done(struct tevent_req *subreq)
2202 {
2203         struct tevent_req *req = tevent_req_callback_data(
2204                 subreq, struct tevent_req);
2205         struct rpccli_spoolss_DeletePrinterDriver_state *state = tevent_req_data(
2206                 req, struct rpccli_spoolss_DeletePrinterDriver_state);
2207         NTSTATUS status;
2208         TALLOC_CTX *mem_ctx;
2209
2210         if (state->out_mem_ctx) {
2211                 mem_ctx = state->out_mem_ctx;
2212         } else {
2213                 mem_ctx = state;
2214         }
2215
2216         status = state->dispatch_recv(subreq, mem_ctx);
2217         TALLOC_FREE(subreq);
2218         if (!NT_STATUS_IS_OK(status)) {
2219                 tevent_req_nterror(req, status);
2220                 return;
2221         }
2222
2223         /* Copy out parameters */
2224
2225         /* Copy result */
2226         state->orig.out.result = state->tmp.out.result;
2227
2228         /* Reset temporary structure */
2229         ZERO_STRUCT(state->tmp);
2230
2231         tevent_req_done(req);
2232 }
2233
2234 NTSTATUS rpccli_spoolss_DeletePrinterDriver_recv(struct tevent_req *req,
2235                                                  TALLOC_CTX *mem_ctx,
2236                                                  WERROR *result)
2237 {
2238         struct rpccli_spoolss_DeletePrinterDriver_state *state = tevent_req_data(
2239                 req, struct rpccli_spoolss_DeletePrinterDriver_state);
2240         NTSTATUS status;
2241
2242         if (tevent_req_is_nterror(req, &status)) {
2243                 tevent_req_received(req);
2244                 return status;
2245         }
2246
2247         /* Steal possbile out parameters to the callers context */
2248         talloc_steal(mem_ctx, state->out_mem_ctx);
2249
2250         /* Return result */
2251         *result = state->orig.out.result;
2252
2253         tevent_req_received(req);
2254         return NT_STATUS_OK;
2255 }
2256
2257 NTSTATUS rpccli_spoolss_DeletePrinterDriver(struct rpc_pipe_client *cli,
2258                                             TALLOC_CTX *mem_ctx,
2259                                             const char *server /* [in] [unique,charset(UTF16)] */,
2260                                             const char *architecture /* [in] [charset(UTF16)] */,
2261                                             const char *driver /* [in] [charset(UTF16)] */,
2262                                             WERROR *werror)
2263 {
2264         struct spoolss_DeletePrinterDriver r;
2265         NTSTATUS status;
2266
2267         /* In parameters */
2268         r.in.server = server;
2269         r.in.architecture = architecture;
2270         r.in.driver = driver;
2271
2272         status = cli->dispatch(cli,
2273                                 mem_ctx,
2274                                 &ndr_table_spoolss,
2275                                 NDR_SPOOLSS_DELETEPRINTERDRIVER,
2276                                 &r);
2277
2278         if (!NT_STATUS_IS_OK(status)) {
2279                 return status;
2280         }
2281
2282         if (NT_STATUS_IS_ERR(status)) {
2283                 return status;
2284         }
2285
2286         /* Return variables */
2287
2288         /* Return result */
2289         if (werror) {
2290                 *werror = r.out.result;
2291         }
2292
2293         return werror_to_ntstatus(r.out.result);
2294 }
2295
2296 struct rpccli_spoolss_AddPrintProcessor_state {
2297         struct spoolss_AddPrintProcessor orig;
2298         struct spoolss_AddPrintProcessor tmp;
2299         TALLOC_CTX *out_mem_ctx;
2300         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2301 };
2302
2303 static void rpccli_spoolss_AddPrintProcessor_done(struct tevent_req *subreq);
2304
2305 struct tevent_req *rpccli_spoolss_AddPrintProcessor_send(TALLOC_CTX *mem_ctx,
2306                                                          struct tevent_context *ev,
2307                                                          struct rpc_pipe_client *cli,
2308                                                          const char *_server /* [in] [unique,charset(UTF16)] */,
2309                                                          const char *_architecture /* [in] [charset(UTF16)] */,
2310                                                          const char *_path_name /* [in] [charset(UTF16)] */,
2311                                                          const char *_print_processor_name /* [in] [charset(UTF16)] */)
2312 {
2313         struct tevent_req *req;
2314         struct rpccli_spoolss_AddPrintProcessor_state *state;
2315         struct tevent_req *subreq;
2316
2317         req = tevent_req_create(mem_ctx, &state,
2318                                 struct rpccli_spoolss_AddPrintProcessor_state);
2319         if (req == NULL) {
2320                 return NULL;
2321         }
2322         state->out_mem_ctx = NULL;
2323         state->dispatch_recv = cli->dispatch_recv;
2324
2325         /* In parameters */
2326         state->orig.in.server = _server;
2327         state->orig.in.architecture = _architecture;
2328         state->orig.in.path_name = _path_name;
2329         state->orig.in.print_processor_name = _print_processor_name;
2330
2331         /* Out parameters */
2332
2333         /* Result */
2334         ZERO_STRUCT(state->orig.out.result);
2335
2336         /* make a temporary copy, that we pass to the dispatch function */
2337         state->tmp = state->orig;
2338
2339         subreq = cli->dispatch_send(state, ev, cli,
2340                                     &ndr_table_spoolss,
2341                                     NDR_SPOOLSS_ADDPRINTPROCESSOR,
2342                                     &state->tmp);
2343         if (tevent_req_nomem(subreq, req)) {
2344                 return tevent_req_post(req, ev);
2345         }
2346         tevent_req_set_callback(subreq, rpccli_spoolss_AddPrintProcessor_done, req);
2347         return req;
2348 }
2349
2350 static void rpccli_spoolss_AddPrintProcessor_done(struct tevent_req *subreq)
2351 {
2352         struct tevent_req *req = tevent_req_callback_data(
2353                 subreq, struct tevent_req);
2354         struct rpccli_spoolss_AddPrintProcessor_state *state = tevent_req_data(
2355                 req, struct rpccli_spoolss_AddPrintProcessor_state);
2356         NTSTATUS status;
2357         TALLOC_CTX *mem_ctx;
2358
2359         if (state->out_mem_ctx) {
2360                 mem_ctx = state->out_mem_ctx;
2361         } else {
2362                 mem_ctx = state;
2363         }
2364
2365         status = state->dispatch_recv(subreq, mem_ctx);
2366         TALLOC_FREE(subreq);
2367         if (!NT_STATUS_IS_OK(status)) {
2368                 tevent_req_nterror(req, status);
2369                 return;
2370         }
2371
2372         /* Copy out parameters */
2373
2374         /* Copy result */
2375         state->orig.out.result = state->tmp.out.result;
2376
2377         /* Reset temporary structure */
2378         ZERO_STRUCT(state->tmp);
2379
2380         tevent_req_done(req);
2381 }
2382
2383 NTSTATUS rpccli_spoolss_AddPrintProcessor_recv(struct tevent_req *req,
2384                                                TALLOC_CTX *mem_ctx,
2385                                                WERROR *result)
2386 {
2387         struct rpccli_spoolss_AddPrintProcessor_state *state = tevent_req_data(
2388                 req, struct rpccli_spoolss_AddPrintProcessor_state);
2389         NTSTATUS status;
2390
2391         if (tevent_req_is_nterror(req, &status)) {
2392                 tevent_req_received(req);
2393                 return status;
2394         }
2395
2396         /* Steal possbile out parameters to the callers context */
2397         talloc_steal(mem_ctx, state->out_mem_ctx);
2398
2399         /* Return result */
2400         *result = state->orig.out.result;
2401
2402         tevent_req_received(req);
2403         return NT_STATUS_OK;
2404 }
2405
2406 NTSTATUS rpccli_spoolss_AddPrintProcessor(struct rpc_pipe_client *cli,
2407                                           TALLOC_CTX *mem_ctx,
2408                                           const char *server /* [in] [unique,charset(UTF16)] */,
2409                                           const char *architecture /* [in] [charset(UTF16)] */,
2410                                           const char *path_name /* [in] [charset(UTF16)] */,
2411                                           const char *print_processor_name /* [in] [charset(UTF16)] */,
2412                                           WERROR *werror)
2413 {
2414         struct spoolss_AddPrintProcessor r;
2415         NTSTATUS status;
2416
2417         /* In parameters */
2418         r.in.server = server;
2419         r.in.architecture = architecture;
2420         r.in.path_name = path_name;
2421         r.in.print_processor_name = print_processor_name;
2422
2423         status = cli->dispatch(cli,
2424                                 mem_ctx,
2425                                 &ndr_table_spoolss,
2426                                 NDR_SPOOLSS_ADDPRINTPROCESSOR,
2427                                 &r);
2428
2429         if (!NT_STATUS_IS_OK(status)) {
2430                 return status;
2431         }
2432
2433         if (NT_STATUS_IS_ERR(status)) {
2434                 return status;
2435         }
2436
2437         /* Return variables */
2438
2439         /* Return result */
2440         if (werror) {
2441                 *werror = r.out.result;
2442         }
2443
2444         return werror_to_ntstatus(r.out.result);
2445 }
2446
2447 struct rpccli_spoolss_EnumPrintProcessors_state {
2448         struct spoolss_EnumPrintProcessors orig;
2449         struct spoolss_EnumPrintProcessors tmp;
2450         TALLOC_CTX *out_mem_ctx;
2451         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2452 };
2453
2454 static void rpccli_spoolss_EnumPrintProcessors_done(struct tevent_req *subreq);
2455
2456 struct tevent_req *rpccli_spoolss_EnumPrintProcessors_send(TALLOC_CTX *mem_ctx,
2457                                                            struct tevent_context *ev,
2458                                                            struct rpc_pipe_client *cli,
2459                                                            const char *_servername /* [in] [unique,charset(UTF16)] */,
2460                                                            const char *_environment /* [in] [unique,charset(UTF16)] */,
2461                                                            uint32_t _level /* [in]  */,
2462                                                            DATA_BLOB *_buffer /* [in] [unique] */,
2463                                                            uint32_t _offered /* [in]  */,
2464                                                            uint32_t *_count /* [out] [ref] */,
2465                                                            union spoolss_PrintProcessorInfo **_info /* [out] [ref,switch_is(level),size_is(,*count)] */,
2466                                                            uint32_t *_needed /* [out] [ref] */)
2467 {
2468         struct tevent_req *req;
2469         struct rpccli_spoolss_EnumPrintProcessors_state *state;
2470         struct tevent_req *subreq;
2471
2472         req = tevent_req_create(mem_ctx, &state,
2473                                 struct rpccli_spoolss_EnumPrintProcessors_state);
2474         if (req == NULL) {
2475                 return NULL;
2476         }
2477         state->out_mem_ctx = NULL;
2478         state->dispatch_recv = cli->dispatch_recv;
2479
2480         /* In parameters */
2481         state->orig.in.servername = _servername;
2482         state->orig.in.environment = _environment;
2483         state->orig.in.level = _level;
2484         state->orig.in.buffer = _buffer;
2485         state->orig.in.offered = _offered;
2486
2487         /* Out parameters */
2488         state->orig.out.count = _count;
2489         state->orig.out.info = _info;
2490         state->orig.out.needed = _needed;
2491
2492         /* Result */
2493         ZERO_STRUCT(state->orig.out.result);
2494
2495         state->out_mem_ctx = talloc_named_const(state, 0,
2496                              "rpccli_spoolss_EnumPrintProcessors_out_memory");
2497         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2498                 return tevent_req_post(req, ev);
2499         }
2500
2501         /* make a temporary copy, that we pass to the dispatch function */
2502         state->tmp = state->orig;
2503
2504         subreq = cli->dispatch_send(state, ev, cli,
2505                                     &ndr_table_spoolss,
2506                                     NDR_SPOOLSS_ENUMPRINTPROCESSORS,
2507                                     &state->tmp);
2508         if (tevent_req_nomem(subreq, req)) {
2509                 return tevent_req_post(req, ev);
2510         }
2511         tevent_req_set_callback(subreq, rpccli_spoolss_EnumPrintProcessors_done, req);
2512         return req;
2513 }
2514
2515 static void rpccli_spoolss_EnumPrintProcessors_done(struct tevent_req *subreq)
2516 {
2517         struct tevent_req *req = tevent_req_callback_data(
2518                 subreq, struct tevent_req);
2519         struct rpccli_spoolss_EnumPrintProcessors_state *state = tevent_req_data(
2520                 req, struct rpccli_spoolss_EnumPrintProcessors_state);
2521         NTSTATUS status;
2522         TALLOC_CTX *mem_ctx;
2523
2524         if (state->out_mem_ctx) {
2525                 mem_ctx = state->out_mem_ctx;
2526         } else {
2527                 mem_ctx = state;
2528         }
2529
2530         status = state->dispatch_recv(subreq, mem_ctx);
2531         TALLOC_FREE(subreq);
2532         if (!NT_STATUS_IS_OK(status)) {
2533                 tevent_req_nterror(req, status);
2534                 return;
2535         }
2536
2537         /* Copy out parameters */
2538         *state->orig.out.count = *state->tmp.out.count;
2539         *state->orig.out.info = *state->tmp.out.info;
2540         *state->orig.out.needed = *state->tmp.out.needed;
2541
2542         /* Copy result */
2543         state->orig.out.result = state->tmp.out.result;
2544
2545         /* Reset temporary structure */
2546         ZERO_STRUCT(state->tmp);
2547
2548         tevent_req_done(req);
2549 }
2550
2551 NTSTATUS rpccli_spoolss_EnumPrintProcessors_recv(struct tevent_req *req,
2552                                                  TALLOC_CTX *mem_ctx,
2553                                                  WERROR *result)
2554 {
2555         struct rpccli_spoolss_EnumPrintProcessors_state *state = tevent_req_data(
2556                 req, struct rpccli_spoolss_EnumPrintProcessors_state);
2557         NTSTATUS status;
2558
2559         if (tevent_req_is_nterror(req, &status)) {
2560                 tevent_req_received(req);
2561                 return status;
2562         }
2563
2564         /* Steal possbile out parameters to the callers context */
2565         talloc_steal(mem_ctx, state->out_mem_ctx);
2566
2567         /* Return result */
2568         *result = state->orig.out.result;
2569
2570         tevent_req_received(req);
2571         return NT_STATUS_OK;
2572 }
2573
2574 NTSTATUS rpccli_spoolss_EnumPrintProcessors(struct rpc_pipe_client *cli,
2575                                             TALLOC_CTX *mem_ctx,
2576                                             const char *servername /* [in] [unique,charset(UTF16)] */,
2577                                             const char *environment /* [in] [unique,charset(UTF16)] */,
2578                                             uint32_t level /* [in]  */,
2579                                             DATA_BLOB *buffer /* [in] [unique] */,
2580                                             uint32_t offered /* [in]  */,
2581                                             uint32_t *count /* [out] [ref] */,
2582                                             union spoolss_PrintProcessorInfo **info /* [out] [ref,switch_is(level),size_is(,*count)] */,
2583                                             uint32_t *needed /* [out] [ref] */,
2584                                             WERROR *werror)
2585 {
2586         struct spoolss_EnumPrintProcessors r;
2587         NTSTATUS status;
2588
2589         /* In parameters */
2590         r.in.servername = servername;
2591         r.in.environment = environment;
2592         r.in.level = level;
2593         r.in.buffer = buffer;
2594         r.in.offered = offered;
2595
2596         status = cli->dispatch(cli,
2597                                 mem_ctx,
2598                                 &ndr_table_spoolss,
2599                                 NDR_SPOOLSS_ENUMPRINTPROCESSORS,
2600                                 &r);
2601
2602         if (!NT_STATUS_IS_OK(status)) {
2603                 return status;
2604         }
2605
2606         if (NT_STATUS_IS_ERR(status)) {
2607                 return status;
2608         }
2609
2610         /* Return variables */
2611         *count = *r.out.count;
2612         *info = *r.out.info;
2613         *needed = *r.out.needed;
2614
2615         /* Return result */
2616         if (werror) {
2617                 *werror = r.out.result;
2618         }
2619
2620         return werror_to_ntstatus(r.out.result);
2621 }
2622
2623 struct rpccli_spoolss_GetPrintProcessorDirectory_state {
2624         struct spoolss_GetPrintProcessorDirectory orig;
2625         struct spoolss_GetPrintProcessorDirectory tmp;
2626         TALLOC_CTX *out_mem_ctx;
2627         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2628 };
2629
2630 static void rpccli_spoolss_GetPrintProcessorDirectory_done(struct tevent_req *subreq);
2631
2632 struct tevent_req *rpccli_spoolss_GetPrintProcessorDirectory_send(TALLOC_CTX *mem_ctx,
2633                                                                   struct tevent_context *ev,
2634                                                                   struct rpc_pipe_client *cli,
2635                                                                   const char *_server /* [in] [unique,charset(UTF16)] */,
2636                                                                   const char *_environment /* [in] [unique,charset(UTF16)] */,
2637                                                                   uint32_t _level /* [in]  */,
2638                                                                   DATA_BLOB *_buffer /* [in] [unique] */,
2639                                                                   uint32_t _offered /* [in]  */,
2640                                                                   union spoolss_PrintProcessorDirectoryInfo *_info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
2641                                                                   uint32_t *_needed /* [out] [ref] */)
2642 {
2643         struct tevent_req *req;
2644         struct rpccli_spoolss_GetPrintProcessorDirectory_state *state;
2645         struct tevent_req *subreq;
2646
2647         req = tevent_req_create(mem_ctx, &state,
2648                                 struct rpccli_spoolss_GetPrintProcessorDirectory_state);
2649         if (req == NULL) {
2650                 return NULL;
2651         }
2652         state->out_mem_ctx = NULL;
2653         state->dispatch_recv = cli->dispatch_recv;
2654
2655         /* In parameters */
2656         state->orig.in.server = _server;
2657         state->orig.in.environment = _environment;
2658         state->orig.in.level = _level;
2659         state->orig.in.buffer = _buffer;
2660         state->orig.in.offered = _offered;
2661
2662         /* Out parameters */
2663         state->orig.out.info = _info;
2664         state->orig.out.needed = _needed;
2665
2666         /* Result */
2667         ZERO_STRUCT(state->orig.out.result);
2668
2669         state->out_mem_ctx = talloc_named_const(state, 0,
2670                              "rpccli_spoolss_GetPrintProcessorDirectory_out_memory");
2671         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2672                 return tevent_req_post(req, ev);
2673         }
2674
2675         /* make a temporary copy, that we pass to the dispatch function */
2676         state->tmp = state->orig;
2677
2678         subreq = cli->dispatch_send(state, ev, cli,
2679                                     &ndr_table_spoolss,
2680                                     NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY,
2681                                     &state->tmp);
2682         if (tevent_req_nomem(subreq, req)) {
2683                 return tevent_req_post(req, ev);
2684         }
2685         tevent_req_set_callback(subreq, rpccli_spoolss_GetPrintProcessorDirectory_done, req);
2686         return req;
2687 }
2688
2689 static void rpccli_spoolss_GetPrintProcessorDirectory_done(struct tevent_req *subreq)
2690 {
2691         struct tevent_req *req = tevent_req_callback_data(
2692                 subreq, struct tevent_req);
2693         struct rpccli_spoolss_GetPrintProcessorDirectory_state *state = tevent_req_data(
2694                 req, struct rpccli_spoolss_GetPrintProcessorDirectory_state);
2695         NTSTATUS status;
2696         TALLOC_CTX *mem_ctx;
2697
2698         if (state->out_mem_ctx) {
2699                 mem_ctx = state->out_mem_ctx;
2700         } else {
2701                 mem_ctx = state;
2702         }
2703
2704         status = state->dispatch_recv(subreq, mem_ctx);
2705         TALLOC_FREE(subreq);
2706         if (!NT_STATUS_IS_OK(status)) {
2707                 tevent_req_nterror(req, status);
2708                 return;
2709         }
2710
2711         /* Copy out parameters */
2712         if (state->orig.out.info && state->tmp.out.info) {
2713                 *state->orig.out.info = *state->tmp.out.info;
2714         }
2715         *state->orig.out.needed = *state->tmp.out.needed;
2716
2717         /* Copy result */
2718         state->orig.out.result = state->tmp.out.result;
2719
2720         /* Reset temporary structure */
2721         ZERO_STRUCT(state->tmp);
2722
2723         tevent_req_done(req);
2724 }
2725
2726 NTSTATUS rpccli_spoolss_GetPrintProcessorDirectory_recv(struct tevent_req *req,
2727                                                         TALLOC_CTX *mem_ctx,
2728                                                         WERROR *result)
2729 {
2730         struct rpccli_spoolss_GetPrintProcessorDirectory_state *state = tevent_req_data(
2731                 req, struct rpccli_spoolss_GetPrintProcessorDirectory_state);
2732         NTSTATUS status;
2733
2734         if (tevent_req_is_nterror(req, &status)) {
2735                 tevent_req_received(req);
2736                 return status;
2737         }
2738
2739         /* Steal possbile out parameters to the callers context */
2740         talloc_steal(mem_ctx, state->out_mem_ctx);
2741
2742         /* Return result */
2743         *result = state->orig.out.result;
2744
2745         tevent_req_received(req);
2746         return NT_STATUS_OK;
2747 }
2748
2749 NTSTATUS rpccli_spoolss_GetPrintProcessorDirectory(struct rpc_pipe_client *cli,
2750                                                    TALLOC_CTX *mem_ctx,
2751                                                    const char *server /* [in] [unique,charset(UTF16)] */,
2752                                                    const char *environment /* [in] [unique,charset(UTF16)] */,
2753                                                    uint32_t level /* [in]  */,
2754                                                    DATA_BLOB *buffer /* [in] [unique] */,
2755                                                    uint32_t offered /* [in]  */,
2756                                                    union spoolss_PrintProcessorDirectoryInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
2757                                                    uint32_t *needed /* [out] [ref] */,
2758                                                    WERROR *werror)
2759 {
2760         struct spoolss_GetPrintProcessorDirectory r;
2761         NTSTATUS status;
2762
2763         /* In parameters */
2764         r.in.server = server;
2765         r.in.environment = environment;
2766         r.in.level = level;
2767         r.in.buffer = buffer;
2768         r.in.offered = offered;
2769
2770         status = cli->dispatch(cli,
2771                                 mem_ctx,
2772                                 &ndr_table_spoolss,
2773                                 NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY,
2774                                 &r);
2775
2776         if (!NT_STATUS_IS_OK(status)) {
2777                 return status;
2778         }
2779
2780         if (NT_STATUS_IS_ERR(status)) {
2781                 return status;
2782         }
2783
2784         /* Return variables */
2785         if (info && r.out.info) {
2786                 *info = *r.out.info;
2787         }
2788         *needed = *r.out.needed;
2789
2790         /* Return result */
2791         if (werror) {
2792                 *werror = r.out.result;
2793         }
2794
2795         return werror_to_ntstatus(r.out.result);
2796 }
2797
2798 struct rpccli_spoolss_StartDocPrinter_state {
2799         struct spoolss_StartDocPrinter orig;
2800         struct spoolss_StartDocPrinter tmp;
2801         TALLOC_CTX *out_mem_ctx;
2802         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2803 };
2804
2805 static void rpccli_spoolss_StartDocPrinter_done(struct tevent_req *subreq);
2806
2807 struct tevent_req *rpccli_spoolss_StartDocPrinter_send(TALLOC_CTX *mem_ctx,
2808                                                        struct tevent_context *ev,
2809                                                        struct rpc_pipe_client *cli,
2810                                                        struct policy_handle *_handle /* [in] [ref] */,
2811                                                        uint32_t _level /* [in]  */,
2812                                                        union spoolss_DocumentInfo _info /* [in] [switch_is(level)] */,
2813                                                        uint32_t *_job_id /* [out] [ref] */)
2814 {
2815         struct tevent_req *req;
2816         struct rpccli_spoolss_StartDocPrinter_state *state;
2817         struct tevent_req *subreq;
2818
2819         req = tevent_req_create(mem_ctx, &state,
2820                                 struct rpccli_spoolss_StartDocPrinter_state);
2821         if (req == NULL) {
2822                 return NULL;
2823         }
2824         state->out_mem_ctx = NULL;
2825         state->dispatch_recv = cli->dispatch_recv;
2826
2827         /* In parameters */
2828         state->orig.in.handle = _handle;
2829         state->orig.in.level = _level;
2830         state->orig.in.info = _info;
2831
2832         /* Out parameters */
2833         state->orig.out.job_id = _job_id;
2834
2835         /* Result */
2836         ZERO_STRUCT(state->orig.out.result);
2837
2838         state->out_mem_ctx = talloc_named_const(state, 0,
2839                              "rpccli_spoolss_StartDocPrinter_out_memory");
2840         if (tevent_req_nomem(state->out_mem_ctx, req)) {
2841                 return tevent_req_post(req, ev);
2842         }
2843
2844         /* make a temporary copy, that we pass to the dispatch function */
2845         state->tmp = state->orig;
2846
2847         subreq = cli->dispatch_send(state, ev, cli,
2848                                     &ndr_table_spoolss,
2849                                     NDR_SPOOLSS_STARTDOCPRINTER,
2850                                     &state->tmp);
2851         if (tevent_req_nomem(subreq, req)) {
2852                 return tevent_req_post(req, ev);
2853         }
2854         tevent_req_set_callback(subreq, rpccli_spoolss_StartDocPrinter_done, req);
2855         return req;
2856 }
2857
2858 static void rpccli_spoolss_StartDocPrinter_done(struct tevent_req *subreq)
2859 {
2860         struct tevent_req *req = tevent_req_callback_data(
2861                 subreq, struct tevent_req);
2862         struct rpccli_spoolss_StartDocPrinter_state *state = tevent_req_data(
2863                 req, struct rpccli_spoolss_StartDocPrinter_state);
2864         NTSTATUS status;
2865         TALLOC_CTX *mem_ctx;
2866
2867         if (state->out_mem_ctx) {
2868                 mem_ctx = state->out_mem_ctx;
2869         } else {
2870                 mem_ctx = state;
2871         }
2872
2873         status = state->dispatch_recv(subreq, mem_ctx);
2874         TALLOC_FREE(subreq);
2875         if (!NT_STATUS_IS_OK(status)) {
2876                 tevent_req_nterror(req, status);
2877                 return;
2878         }
2879
2880         /* Copy out parameters */
2881         *state->orig.out.job_id = *state->tmp.out.job_id;
2882
2883         /* Copy result */
2884         state->orig.out.result = state->tmp.out.result;
2885
2886         /* Reset temporary structure */
2887         ZERO_STRUCT(state->tmp);
2888
2889         tevent_req_done(req);
2890 }
2891
2892 NTSTATUS rpccli_spoolss_StartDocPrinter_recv(struct tevent_req *req,
2893                                              TALLOC_CTX *mem_ctx,
2894                                              WERROR *result)
2895 {
2896         struct rpccli_spoolss_StartDocPrinter_state *state = tevent_req_data(
2897                 req, struct rpccli_spoolss_StartDocPrinter_state);
2898         NTSTATUS status;
2899
2900         if (tevent_req_is_nterror(req, &status)) {
2901                 tevent_req_received(req);
2902                 return status;
2903         }
2904
2905         /* Steal possbile out parameters to the callers context */
2906         talloc_steal(mem_ctx, state->out_mem_ctx);
2907
2908         /* Return result */
2909         *result = state->orig.out.result;
2910
2911         tevent_req_received(req);
2912         return NT_STATUS_OK;
2913 }
2914
2915 NTSTATUS rpccli_spoolss_StartDocPrinter(struct rpc_pipe_client *cli,
2916                                         TALLOC_CTX *mem_ctx,
2917                                         struct policy_handle *handle /* [in] [ref] */,
2918                                         uint32_t level /* [in]  */,
2919                                         union spoolss_DocumentInfo info /* [in] [switch_is(level)] */,
2920                                         uint32_t *job_id /* [out] [ref] */,
2921                                         WERROR *werror)
2922 {
2923         struct spoolss_StartDocPrinter r;
2924         NTSTATUS status;
2925
2926         /* In parameters */
2927         r.in.handle = handle;
2928         r.in.level = level;
2929         r.in.info = info;
2930
2931         status = cli->dispatch(cli,
2932                                 mem_ctx,
2933                                 &ndr_table_spoolss,
2934                                 NDR_SPOOLSS_STARTDOCPRINTER,
2935                                 &r);
2936
2937         if (!NT_STATUS_IS_OK(status)) {
2938                 return status;
2939         }
2940
2941         if (NT_STATUS_IS_ERR(status)) {
2942                 return status;
2943         }
2944
2945         /* Return variables */
2946         *job_id = *r.out.job_id;
2947
2948         /* Return result */
2949         if (werror) {
2950                 *werror = r.out.result;
2951         }
2952
2953         return werror_to_ntstatus(r.out.result);
2954 }
2955
2956 struct rpccli_spoolss_StartPagePrinter_state {
2957         struct spoolss_StartPagePrinter orig;
2958         struct spoolss_StartPagePrinter tmp;
2959         TALLOC_CTX *out_mem_ctx;
2960         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2961 };
2962
2963 static void rpccli_spoolss_StartPagePrinter_done(struct tevent_req *subreq);
2964
2965 struct tevent_req *rpccli_spoolss_StartPagePrinter_send(TALLOC_CTX *mem_ctx,
2966                                                         struct tevent_context *ev,
2967                                                         struct rpc_pipe_client *cli,
2968                                                         struct policy_handle *_handle /* [in] [ref] */)
2969 {
2970         struct tevent_req *req;
2971         struct rpccli_spoolss_StartPagePrinter_state *state;
2972         struct tevent_req *subreq;
2973
2974         req = tevent_req_create(mem_ctx, &state,
2975                                 struct rpccli_spoolss_StartPagePrinter_state);
2976         if (req == NULL) {
2977                 return NULL;
2978         }
2979         state->out_mem_ctx = NULL;
2980         state->dispatch_recv = cli->dispatch_recv;
2981
2982         /* In parameters */
2983         state->orig.in.handle = _handle;
2984
2985         /* Out parameters */
2986
2987         /* Result */
2988         ZERO_STRUCT(state->orig.out.result);
2989
2990         /* make a temporary copy, that we pass to the dispatch function */
2991         state->tmp = state->orig;
2992
2993         subreq = cli->dispatch_send(state, ev, cli,
2994                                     &ndr_table_spoolss,
2995                                     NDR_SPOOLSS_STARTPAGEPRINTER,
2996                                     &state->tmp);
2997         if (tevent_req_nomem(subreq, req)) {
2998                 return tevent_req_post(req, ev);
2999         }
3000         tevent_req_set_callback(subreq, rpccli_spoolss_StartPagePrinter_done, req);
3001         return req;
3002 }
3003
3004 static void rpccli_spoolss_StartPagePrinter_done(struct tevent_req *subreq)
3005 {
3006         struct tevent_req *req = tevent_req_callback_data(
3007                 subreq, struct tevent_req);
3008         struct rpccli_spoolss_StartPagePrinter_state *state = tevent_req_data(
3009                 req, struct rpccli_spoolss_StartPagePrinter_state);
3010         NTSTATUS status;
3011         TALLOC_CTX *mem_ctx;
3012
3013         if (state->out_mem_ctx) {
3014                 mem_ctx = state->out_mem_ctx;
3015         } else {
3016                 mem_ctx = state;
3017         }
3018
3019         status = state->dispatch_recv(subreq, mem_ctx);
3020         TALLOC_FREE(subreq);
3021         if (!NT_STATUS_IS_OK(status)) {
3022                 tevent_req_nterror(req, status);
3023                 return;
3024         }
3025
3026         /* Copy out parameters */
3027
3028         /* Copy result */
3029         state->orig.out.result = state->tmp.out.result;
3030
3031         /* Reset temporary structure */
3032         ZERO_STRUCT(state->tmp);
3033
3034         tevent_req_done(req);
3035 }
3036
3037 NTSTATUS rpccli_spoolss_StartPagePrinter_recv(struct tevent_req *req,
3038                                               TALLOC_CTX *mem_ctx,
3039                                               WERROR *result)
3040 {
3041         struct rpccli_spoolss_StartPagePrinter_state *state = tevent_req_data(
3042                 req, struct rpccli_spoolss_StartPagePrinter_state);
3043         NTSTATUS status;
3044
3045         if (tevent_req_is_nterror(req, &status)) {
3046                 tevent_req_received(req);
3047                 return status;
3048         }
3049
3050         /* Steal possbile out parameters to the callers context */
3051         talloc_steal(mem_ctx, state->out_mem_ctx);
3052
3053         /* Return result */
3054         *result = state->orig.out.result;
3055
3056         tevent_req_received(req);
3057         return NT_STATUS_OK;
3058 }
3059
3060 NTSTATUS rpccli_spoolss_StartPagePrinter(struct rpc_pipe_client *cli,
3061                                          TALLOC_CTX *mem_ctx,
3062                                          struct policy_handle *handle /* [in] [ref] */,
3063                                          WERROR *werror)
3064 {
3065         struct spoolss_StartPagePrinter r;
3066         NTSTATUS status;
3067
3068         /* In parameters */
3069         r.in.handle = handle;
3070
3071         status = cli->dispatch(cli,
3072                                 mem_ctx,
3073                                 &ndr_table_spoolss,
3074                                 NDR_SPOOLSS_STARTPAGEPRINTER,
3075                                 &r);
3076
3077         if (!NT_STATUS_IS_OK(status)) {
3078                 return status;
3079         }
3080
3081         if (NT_STATUS_IS_ERR(status)) {
3082                 return status;
3083         }
3084
3085         /* Return variables */
3086
3087         /* Return result */
3088         if (werror) {
3089                 *werror = r.out.result;
3090         }
3091
3092         return werror_to_ntstatus(r.out.result);
3093 }
3094
3095 struct rpccli_spoolss_WritePrinter_state {
3096         struct spoolss_WritePrinter orig;
3097         struct spoolss_WritePrinter tmp;
3098         TALLOC_CTX *out_mem_ctx;
3099         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3100 };
3101
3102 static void rpccli_spoolss_WritePrinter_done(struct tevent_req *subreq);
3103
3104 struct tevent_req *rpccli_spoolss_WritePrinter_send(TALLOC_CTX *mem_ctx,
3105                                                     struct tevent_context *ev,
3106                                                     struct rpc_pipe_client *cli,
3107                                                     struct policy_handle *_handle /* [in] [ref] */,
3108                                                     DATA_BLOB _data /* [in]  */,
3109                                                     uint32_t __data_size /* [in] [value(r->in.data.length)] */,
3110                                                     uint32_t *_num_written /* [out] [ref] */)
3111 {
3112         struct tevent_req *req;
3113         struct rpccli_spoolss_WritePrinter_state *state;
3114         struct tevent_req *subreq;
3115
3116         req = tevent_req_create(mem_ctx, &state,
3117                                 struct rpccli_spoolss_WritePrinter_state);
3118         if (req == NULL) {
3119                 return NULL;
3120         }
3121         state->out_mem_ctx = NULL;
3122         state->dispatch_recv = cli->dispatch_recv;
3123
3124         /* In parameters */
3125         state->orig.in.handle = _handle;
3126         state->orig.in.data = _data;
3127         state->orig.in._data_size = __data_size;
3128
3129         /* Out parameters */
3130         state->orig.out.num_written = _num_written;
3131
3132         /* Result */
3133         ZERO_STRUCT(state->orig.out.result);
3134
3135         state->out_mem_ctx = talloc_named_const(state, 0,
3136                              "rpccli_spoolss_WritePrinter_out_memory");
3137         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3138                 return tevent_req_post(req, ev);
3139         }
3140
3141         /* make a temporary copy, that we pass to the dispatch function */
3142         state->tmp = state->orig;
3143
3144         subreq = cli->dispatch_send(state, ev, cli,
3145                                     &ndr_table_spoolss,
3146                                     NDR_SPOOLSS_WRITEPRINTER,
3147                                     &state->tmp);
3148         if (tevent_req_nomem(subreq, req)) {
3149                 return tevent_req_post(req, ev);
3150         }
3151         tevent_req_set_callback(subreq, rpccli_spoolss_WritePrinter_done, req);
3152         return req;
3153 }
3154
3155 static void rpccli_spoolss_WritePrinter_done(struct tevent_req *subreq)
3156 {
3157         struct tevent_req *req = tevent_req_callback_data(
3158                 subreq, struct tevent_req);
3159         struct rpccli_spoolss_WritePrinter_state *state = tevent_req_data(
3160                 req, struct rpccli_spoolss_WritePrinter_state);
3161         NTSTATUS status;
3162         TALLOC_CTX *mem_ctx;
3163
3164         if (state->out_mem_ctx) {
3165                 mem_ctx = state->out_mem_ctx;
3166         } else {
3167                 mem_ctx = state;
3168         }
3169
3170         status = state->dispatch_recv(subreq, mem_ctx);
3171         TALLOC_FREE(subreq);
3172         if (!NT_STATUS_IS_OK(status)) {
3173                 tevent_req_nterror(req, status);
3174                 return;
3175         }
3176
3177         /* Copy out parameters */
3178         *state->orig.out.num_written = *state->tmp.out.num_written;
3179
3180         /* Copy result */
3181         state->orig.out.result = state->tmp.out.result;
3182
3183         /* Reset temporary structure */
3184         ZERO_STRUCT(state->tmp);
3185
3186         tevent_req_done(req);
3187 }
3188
3189 NTSTATUS rpccli_spoolss_WritePrinter_recv(struct tevent_req *req,
3190                                           TALLOC_CTX *mem_ctx,
3191                                           WERROR *result)
3192 {
3193         struct rpccli_spoolss_WritePrinter_state *state = tevent_req_data(
3194                 req, struct rpccli_spoolss_WritePrinter_state);
3195         NTSTATUS status;
3196
3197         if (tevent_req_is_nterror(req, &status)) {
3198                 tevent_req_received(req);
3199                 return status;
3200         }
3201
3202         /* Steal possbile out parameters to the callers context */
3203         talloc_steal(mem_ctx, state->out_mem_ctx);
3204
3205         /* Return result */
3206         *result = state->orig.out.result;
3207
3208         tevent_req_received(req);
3209         return NT_STATUS_OK;
3210 }
3211
3212 NTSTATUS rpccli_spoolss_WritePrinter(struct rpc_pipe_client *cli,
3213                                      TALLOC_CTX *mem_ctx,
3214                                      struct policy_handle *handle /* [in] [ref] */,
3215                                      DATA_BLOB data /* [in]  */,
3216                                      uint32_t _data_size /* [in] [value(r->in.data.length)] */,
3217                                      uint32_t *num_written /* [out] [ref] */,
3218                                      WERROR *werror)
3219 {
3220         struct spoolss_WritePrinter r;
3221         NTSTATUS status;
3222
3223         /* In parameters */
3224         r.in.handle = handle;
3225         r.in.data = data;
3226         r.in._data_size = _data_size;
3227
3228         status = cli->dispatch(cli,
3229                                 mem_ctx,
3230                                 &ndr_table_spoolss,
3231                                 NDR_SPOOLSS_WRITEPRINTER,
3232                                 &r);
3233
3234         if (!NT_STATUS_IS_OK(status)) {
3235                 return status;
3236         }
3237
3238         if (NT_STATUS_IS_ERR(status)) {
3239                 return status;
3240         }
3241
3242         /* Return variables */
3243         *num_written = *r.out.num_written;
3244
3245         /* Return result */
3246         if (werror) {
3247                 *werror = r.out.result;
3248         }
3249
3250         return werror_to_ntstatus(r.out.result);
3251 }
3252
3253 struct rpccli_spoolss_EndPagePrinter_state {
3254         struct spoolss_EndPagePrinter orig;
3255         struct spoolss_EndPagePrinter tmp;
3256         TALLOC_CTX *out_mem_ctx;
3257         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3258 };
3259
3260 static void rpccli_spoolss_EndPagePrinter_done(struct tevent_req *subreq);
3261
3262 struct tevent_req *rpccli_spoolss_EndPagePrinter_send(TALLOC_CTX *mem_ctx,
3263                                                       struct tevent_context *ev,
3264                                                       struct rpc_pipe_client *cli,
3265                                                       struct policy_handle *_handle /* [in] [ref] */)
3266 {
3267         struct tevent_req *req;
3268         struct rpccli_spoolss_EndPagePrinter_state *state;
3269         struct tevent_req *subreq;
3270
3271         req = tevent_req_create(mem_ctx, &state,
3272                                 struct rpccli_spoolss_EndPagePrinter_state);
3273         if (req == NULL) {
3274                 return NULL;
3275         }
3276         state->out_mem_ctx = NULL;
3277         state->dispatch_recv = cli->dispatch_recv;
3278
3279         /* In parameters */
3280         state->orig.in.handle = _handle;
3281
3282         /* Out parameters */
3283
3284         /* Result */
3285         ZERO_STRUCT(state->orig.out.result);
3286
3287         /* make a temporary copy, that we pass to the dispatch function */
3288         state->tmp = state->orig;
3289
3290         subreq = cli->dispatch_send(state, ev, cli,
3291                                     &ndr_table_spoolss,
3292                                     NDR_SPOOLSS_ENDPAGEPRINTER,
3293                                     &state->tmp);
3294         if (tevent_req_nomem(subreq, req)) {
3295                 return tevent_req_post(req, ev);
3296         }
3297         tevent_req_set_callback(subreq, rpccli_spoolss_EndPagePrinter_done, req);
3298         return req;
3299 }
3300
3301 static void rpccli_spoolss_EndPagePrinter_done(struct tevent_req *subreq)
3302 {
3303         struct tevent_req *req = tevent_req_callback_data(
3304                 subreq, struct tevent_req);
3305         struct rpccli_spoolss_EndPagePrinter_state *state = tevent_req_data(
3306                 req, struct rpccli_spoolss_EndPagePrinter_state);
3307         NTSTATUS status;
3308         TALLOC_CTX *mem_ctx;
3309
3310         if (state->out_mem_ctx) {
3311                 mem_ctx = state->out_mem_ctx;
3312         } else {
3313                 mem_ctx = state;
3314         }
3315
3316         status = state->dispatch_recv(subreq, mem_ctx);
3317         TALLOC_FREE(subreq);
3318         if (!NT_STATUS_IS_OK(status)) {
3319                 tevent_req_nterror(req, status);
3320                 return;
3321         }
3322
3323         /* Copy out parameters */
3324
3325         /* Copy result */
3326         state->orig.out.result = state->tmp.out.result;
3327
3328         /* Reset temporary structure */
3329         ZERO_STRUCT(state->tmp);
3330
3331         tevent_req_done(req);
3332 }
3333
3334 NTSTATUS rpccli_spoolss_EndPagePrinter_recv(struct tevent_req *req,
3335                                             TALLOC_CTX *mem_ctx,
3336                                             WERROR *result)
3337 {
3338         struct rpccli_spoolss_EndPagePrinter_state *state = tevent_req_data(
3339                 req, struct rpccli_spoolss_EndPagePrinter_state);
3340         NTSTATUS status;
3341
3342         if (tevent_req_is_nterror(req, &status)) {
3343                 tevent_req_received(req);
3344                 return status;
3345         }
3346
3347         /* Steal possbile out parameters to the callers context */
3348         talloc_steal(mem_ctx, state->out_mem_ctx);
3349
3350         /* Return result */
3351         *result = state->orig.out.result;
3352
3353         tevent_req_received(req);
3354         return NT_STATUS_OK;
3355 }
3356
3357 NTSTATUS rpccli_spoolss_EndPagePrinter(struct rpc_pipe_client *cli,
3358                                        TALLOC_CTX *mem_ctx,
3359                                        struct policy_handle *handle /* [in] [ref] */,
3360                                        WERROR *werror)
3361 {
3362         struct spoolss_EndPagePrinter r;
3363         NTSTATUS status;
3364
3365         /* In parameters */
3366         r.in.handle = handle;
3367
3368         status = cli->dispatch(cli,
3369                                 mem_ctx,
3370                                 &ndr_table_spoolss,
3371                                 NDR_SPOOLSS_ENDPAGEPRINTER,
3372                                 &r);
3373
3374         if (!NT_STATUS_IS_OK(status)) {
3375                 return status;
3376         }
3377
3378         if (NT_STATUS_IS_ERR(status)) {
3379                 return status;
3380         }
3381
3382         /* Return variables */
3383
3384         /* Return result */
3385         if (werror) {
3386                 *werror = r.out.result;
3387         }
3388
3389         return werror_to_ntstatus(r.out.result);
3390 }
3391
3392 struct rpccli_spoolss_AbortPrinter_state {
3393         struct spoolss_AbortPrinter orig;
3394         struct spoolss_AbortPrinter tmp;
3395         TALLOC_CTX *out_mem_ctx;
3396         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3397 };
3398
3399 static void rpccli_spoolss_AbortPrinter_done(struct tevent_req *subreq);
3400
3401 struct tevent_req *rpccli_spoolss_AbortPrinter_send(TALLOC_CTX *mem_ctx,
3402                                                     struct tevent_context *ev,
3403                                                     struct rpc_pipe_client *cli,
3404                                                     struct policy_handle *_handle /* [in] [ref] */)
3405 {
3406         struct tevent_req *req;
3407         struct rpccli_spoolss_AbortPrinter_state *state;
3408         struct tevent_req *subreq;
3409
3410         req = tevent_req_create(mem_ctx, &state,
3411                                 struct rpccli_spoolss_AbortPrinter_state);
3412         if (req == NULL) {
3413                 return NULL;
3414         }
3415         state->out_mem_ctx = NULL;
3416         state->dispatch_recv = cli->dispatch_recv;
3417
3418         /* In parameters */
3419         state->orig.in.handle = _handle;
3420
3421         /* Out parameters */
3422
3423         /* Result */
3424         ZERO_STRUCT(state->orig.out.result);
3425
3426         /* make a temporary copy, that we pass to the dispatch function */
3427         state->tmp = state->orig;
3428
3429         subreq = cli->dispatch_send(state, ev, cli,
3430                                     &ndr_table_spoolss,
3431                                     NDR_SPOOLSS_ABORTPRINTER,
3432                                     &state->tmp);
3433         if (tevent_req_nomem(subreq, req)) {
3434                 return tevent_req_post(req, ev);
3435         }
3436         tevent_req_set_callback(subreq, rpccli_spoolss_AbortPrinter_done, req);
3437         return req;
3438 }
3439
3440 static void rpccli_spoolss_AbortPrinter_done(struct tevent_req *subreq)
3441 {
3442         struct tevent_req *req = tevent_req_callback_data(
3443                 subreq, struct tevent_req);
3444         struct rpccli_spoolss_AbortPrinter_state *state = tevent_req_data(
3445                 req, struct rpccli_spoolss_AbortPrinter_state);
3446         NTSTATUS status;
3447         TALLOC_CTX *mem_ctx;
3448
3449         if (state->out_mem_ctx) {
3450                 mem_ctx = state->out_mem_ctx;
3451         } else {
3452                 mem_ctx = state;
3453         }
3454
3455         status = state->dispatch_recv(subreq, mem_ctx);
3456         TALLOC_FREE(subreq);
3457         if (!NT_STATUS_IS_OK(status)) {
3458                 tevent_req_nterror(req, status);
3459                 return;
3460         }
3461
3462         /* Copy out parameters */
3463
3464         /* Copy result */
3465         state->orig.out.result = state->tmp.out.result;
3466
3467         /* Reset temporary structure */
3468         ZERO_STRUCT(state->tmp);
3469
3470         tevent_req_done(req);
3471 }
3472
3473 NTSTATUS rpccli_spoolss_AbortPrinter_recv(struct tevent_req *req,
3474                                           TALLOC_CTX *mem_ctx,
3475                                           WERROR *result)
3476 {
3477         struct rpccli_spoolss_AbortPrinter_state *state = tevent_req_data(
3478                 req, struct rpccli_spoolss_AbortPrinter_state);
3479         NTSTATUS status;
3480
3481         if (tevent_req_is_nterror(req, &status)) {
3482                 tevent_req_received(req);
3483                 return status;
3484         }
3485
3486         /* Steal possbile out parameters to the callers context */
3487         talloc_steal(mem_ctx, state->out_mem_ctx);
3488
3489         /* Return result */
3490         *result = state->orig.out.result;
3491
3492         tevent_req_received(req);
3493         return NT_STATUS_OK;
3494 }
3495
3496 NTSTATUS rpccli_spoolss_AbortPrinter(struct rpc_pipe_client *cli,
3497                                      TALLOC_CTX *mem_ctx,
3498                                      struct policy_handle *handle /* [in] [ref] */,
3499                                      WERROR *werror)
3500 {
3501         struct spoolss_AbortPrinter r;
3502         NTSTATUS status;
3503
3504         /* In parameters */
3505         r.in.handle = handle;
3506
3507         status = cli->dispatch(cli,
3508                                 mem_ctx,
3509                                 &ndr_table_spoolss,
3510                                 NDR_SPOOLSS_ABORTPRINTER,
3511                                 &r);
3512
3513         if (!NT_STATUS_IS_OK(status)) {
3514                 return status;
3515         }
3516
3517         if (NT_STATUS_IS_ERR(status)) {
3518                 return status;
3519         }
3520
3521         /* Return variables */
3522
3523         /* Return result */
3524         if (werror) {
3525                 *werror = r.out.result;
3526         }
3527
3528         return werror_to_ntstatus(r.out.result);
3529 }
3530
3531 struct rpccli_spoolss_ReadPrinter_state {
3532         struct spoolss_ReadPrinter orig;
3533         struct spoolss_ReadPrinter tmp;
3534         TALLOC_CTX *out_mem_ctx;
3535         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
3536 };
3537
3538 static void rpccli_spoolss_ReadPrinter_done(struct tevent_req *subreq);
3539
3540 struct tevent_req *rpccli_spoolss_ReadPrinter_send(TALLOC_CTX *mem_ctx,
3541                                                    struct tevent_context *ev,
3542                                                    struct rpc_pipe_client *cli,
3543                                                    struct policy_handle *_handle /* [in] [ref] */,
3544                                                    uint8_t *_data /* [out] [ref,size_is(data_size)] */,
3545                                                    uint32_t _data_size /* [in]  */,
3546                                                    uint32_t *__data_size /* [out] [ref] */)
3547 {
3548         struct tevent_req *req;
3549         struct rpccli_spoolss_ReadPrinter_state *state;
3550         struct tevent_req *subreq;
3551
3552         req = tevent_req_create(mem_ctx, &state,
3553                                 struct rpccli_spoolss_ReadPrinter_state);
3554         if (req == NULL) {
3555                 return NULL;
3556         }
3557         state->out_mem_ctx = NULL;
3558         state->dispatch_recv = cli->dispatch_recv;
3559
3560         /* In parameters */
3561         state->orig.in.handle = _handle;
3562         state->orig.in.data_size = _data_size;
3563
3564         /* Out parameters */
3565         state->orig.out.data = _data;
3566         state->orig.out._data_size = __data_size;
3567
3568         /* Result */
3569         ZERO_STRUCT(state->orig.out.result);
3570
3571         state->out_mem_ctx = talloc_named_const(state, 0,
3572                              "rpccli_spoolss_ReadPrinter_out_memory");
3573         if (tevent_req_nomem(state->out_mem_ctx, req)) {
3574                 return tevent_req_post(req, ev);
3575         }
3576
3577         /* make a temporary copy, that we pass to the dispatch function */
3578         state->tmp = state->orig;
3579
3580         subreq = cli->dispatch_send(state, ev, cli,
3581                                     &ndr_table_spoolss,
3582                                     NDR_SPOOLSS_READPRINTER,
3583                                     &state->tmp);
3584         if (tevent_req_nomem(subreq, req)) {
3585                 return tevent_req_post(req, ev);
3586         }
3587         tevent_req_set_callback(subreq, rpccli_spoolss_ReadPrinter_done, req);
3588         return req;
3589 }
3590
3591 static void rpccli_spoolss_ReadPrinter_done(struct tevent_req *subreq)
3592 {
3593         struct tevent_req *req = tevent_req_callback_data(
3594                 subreq, struct tevent_req);
3595         struct rpccli_spoolss_ReadPrinter_state *state = tevent_req_data(
3596                 req, struct rpccli_spoolss_ReadPrinter_state);
3597         NTSTATUS status;
3598         TALLOC_CTX *mem_ctx;
3599
3600         if (state->out_mem_ctx) {
3601                 mem_ctx = state->out_mem_ctx;
3602         } else {
3603                 mem_ctx = state;
3604         }
3605
3606         status = state->dispatch_recv(subreq, mem_ctx);
3607         TALLOC_FREE(subreq);
3608         if (!NT_STATUS_IS_OK(status)) {
3609                 tevent_req_nterror(req, status);
3610                 return;
3611         }
3612
3613         /* Copy out parameters */
3614         memcpy(state->orig.out.data, state->tmp.out.data, (state->tmp.in.data_size) * sizeof(*state->orig.out.data));
3615         *state->orig.out._data_size = *state->tmp.out._data_size;
3616
3617         /* Copy result */
3618         state->orig.out.result = state->tmp.out.result;
3619
3620         /* Reset temporary structure */
3621         ZERO_STRUCT(state->tmp);
3622
3623         tevent_req_done(req);
3624 }
3625
3626 NTSTATUS rpccli_spoolss_ReadPrinter_recv(struct tevent_req *req,
3627                                          TALLOC_CTX *mem_ctx,
3628                                          WERROR *result)
3629 {
3630         struct rpccli_spoolss_ReadPrinter_state *state = tevent_req_data(
3631                 req, struct rpccli_spoolss_ReadPrinter_state);
3632         NTSTATUS status;
3633
3634         if (tevent_req_is_nterror(req, &status)) {
3635                 tevent_req_received(req);
3636                 return status;
3637         }
3638
3639         /* Steal possbile out parameters to the callers context */
3640         talloc_steal(mem_ctx, state->out_mem_ctx);
3641
3642         /* Return result */
3643         *result = state->orig.out.result;
3644
3645         tevent_req_received(req);
3646         return NT_STATUS_OK;
3647 }
3648
3649 NTSTATUS rpccli_spoolss_ReadPrinter(struct rpc_pipe_client *cli,
3650                                     TALLOC_CTX *mem_ctx,
3651                                     struct policy_handle *handle /* [in] [ref] */,
3652                                     uint8_t *data /* [out] [ref,size_is(data_size)] */,
3653                                     uint32_t data_size /* [in]  */,
3654                                     uint32_t *_data_size /* [out] [ref] */,
3655                                     WERROR *werror)
3656 {
3657         struct spoolss_ReadPrinter r;
3658         NTSTATUS status;
3659
3660         /* In parameters */
3661         r.in.handle = handle;
3662         r.in.data_size = data_size;
3663
3664         status = cli->dispatch(cli,
3665                                 mem_ctx,
3666                                 &ndr_table_spoolss,
3667                                 NDR_SPOOLSS_READPRINTER,
3668                                 &r);
3669
3670         if (!NT_STATUS_IS_OK(status)) {
3671                 return status;
3672         }
3673
3674         if (NT_STATUS_IS_ERR(status)) {
3675                 return status;
3676         }
3677
3678         /* Return variables */
3679         memcpy(data, r.out.data, (r.in.data_size) * sizeof(*data));
3680         *_data_size = *r.out._data_size;
3681
3682         /* Return result */
3683         if (werror) {
3684                 *werror = r.out.result;
3685         }
3686
3687         return werror_to_ntstatus(r.out.result);
3688 }
3689
3690 struct rpccli_spoolss_EndDocPrinter_state {
3691         struct spoolss_EndDo