s3-spoolss: use pidl for _spoolss_DeletePrinterKey.
[ira/wip.git] / source3 / rpc_server / srv_spoolss.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-2000,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6  *  Copyright (C) Jean François Micouleau      1998-2000,
7  *  Copyright (C) Jeremy Allison                    2001,
8  *  Copyright (C) Gerald Carter                2001-2002,
9  *  Copyright (C) Jim McDonough <jmcd@us.ibm.com>   2003.
10  *  
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 3 of the License, or
14  *  (at your option) any later version.
15  *  
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *  
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
23  */
24
25 #include "includes.h"
26
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_RPC_SRV
29
30 /*******************************************************************
31  ********************************************************************/
32
33 static bool proxy_spoolss_call(pipes_struct *p, uint8_t opnum)
34 {
35         struct api_struct *fns;
36         int n_fns;
37
38         spoolss_get_pipe_fns(&fns, &n_fns);
39
40         if (opnum >= n_fns) {
41                 return false;
42         }
43
44         if (fns[opnum].opnum != opnum) {
45                 smb_panic("SPOOLSS function table not sorted");
46         }
47
48         return fns[opnum].fn(p);
49 }
50
51 /********************************************************************
52  * api_spoolss_open_printer_ex (rarely seen - older call)
53  ********************************************************************/
54
55 static bool api_spoolss_open_printer(pipes_struct *p)
56 {
57         SPOOL_Q_OPEN_PRINTER q_u;
58         SPOOL_R_OPEN_PRINTER r_u;
59         prs_struct *data = &p->in_data.data;
60         prs_struct *rdata = &p->out_data.rdata;
61
62         ZERO_STRUCT(q_u);
63         ZERO_STRUCT(r_u);
64
65         if (!spoolss_io_q_open_printer("", &q_u, data, 0)) {
66                 DEBUG(0,("spoolss_io_q_open_printer: unable to unmarshall SPOOL_Q_OPEN_PRINTER.\n"));
67                 return False;
68         }
69
70         r_u.status = _spoolss_open_printer( p, &q_u, &r_u);
71         
72         if (!spoolss_io_r_open_printer("",&r_u,rdata,0)){
73                 DEBUG(0,("spoolss_io_r_open_printer: unable to marshall SPOOL_R_OPEN_PRINTER.\n"));
74                 return False;
75         }
76
77         return True;
78 }
79
80
81 /********************************************************************
82  * api_spoolss_open_printer_ex
83  ********************************************************************/
84
85 static bool api_spoolss_open_printer_ex(pipes_struct *p)
86 {
87         SPOOL_Q_OPEN_PRINTER_EX q_u;
88         SPOOL_R_OPEN_PRINTER_EX r_u;
89         prs_struct *data = &p->in_data.data;
90         prs_struct *rdata = &p->out_data.rdata;
91
92         ZERO_STRUCT(q_u);
93         ZERO_STRUCT(r_u);
94
95         if (!spoolss_io_q_open_printer_ex("", &q_u, data, 0)) {
96                 DEBUG(0,("spoolss_io_q_open_printer_ex: unable to unmarshall SPOOL_Q_OPEN_PRINTER_EX.\n"));
97                 return False;
98         }
99
100         r_u.status = _spoolss_open_printer_ex( p, &q_u, &r_u);
101
102         if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){
103                 DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n"));
104                 return False;
105         }
106
107         return True;
108 }
109
110 /********************************************************************
111  * api_spoolss_getprinterdata
112  *
113  * called from the spoolss dispatcher
114  ********************************************************************/
115
116 static bool api_spoolss_getprinterdata(pipes_struct *p)
117 {
118         SPOOL_Q_GETPRINTERDATA q_u;
119         SPOOL_R_GETPRINTERDATA r_u;
120         prs_struct *data = &p->in_data.data;
121         prs_struct *rdata = &p->out_data.rdata;
122
123         ZERO_STRUCT(q_u);
124         ZERO_STRUCT(r_u);
125
126         /* read the stream and fill the struct */
127         if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) {
128                 DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n"));
129                 return False;
130         }
131         
132         r_u.status = _spoolss_getprinterdata( p, &q_u, &r_u);
133
134         if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) {
135                 DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n"));
136                 return False;
137         }
138
139         return True;
140 }
141
142 /********************************************************************
143  * api_spoolss_deleteprinterdata
144  *
145  * called from the spoolss dispatcher
146  ********************************************************************/
147
148 static bool api_spoolss_deleteprinterdata(pipes_struct *p)
149 {
150         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATA);
151 }
152
153 /********************************************************************
154  * api_spoolss_closeprinter
155  *
156  * called from the spoolss dispatcher
157  ********************************************************************/
158
159 static bool api_spoolss_closeprinter(pipes_struct *p)
160 {
161         return proxy_spoolss_call(p, NDR_SPOOLSS_CLOSEPRINTER);
162 }
163
164 /********************************************************************
165  * api_spoolss_abortprinter
166  *
167  * called from the spoolss dispatcher
168  ********************************************************************/
169
170 static bool api_spoolss_abortprinter(pipes_struct *p)
171 {
172         return proxy_spoolss_call(p, NDR_SPOOLSS_ABORTPRINTER);
173 }
174
175 /********************************************************************
176  * api_spoolss_deleteprinter
177  *
178  * called from the spoolss dispatcher
179  ********************************************************************/
180
181 static bool api_spoolss_deleteprinter(pipes_struct *p)
182 {
183         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTER);
184 }
185
186 /********************************************************************
187  * api_spoolss_deleteprinterdriver
188  *
189  * called from the spoolss dispatcher
190  ********************************************************************/
191
192 static bool api_spoolss_deleteprinterdriver(pipes_struct *p)
193 {
194         SPOOL_Q_DELETEPRINTERDRIVER q_u;
195         SPOOL_R_DELETEPRINTERDRIVER r_u;
196         prs_struct *data = &p->in_data.data;
197         prs_struct *rdata = &p->out_data.rdata;
198
199         ZERO_STRUCT(q_u);
200         ZERO_STRUCT(r_u);
201
202         if (!spoolss_io_q_deleteprinterdriver("", &q_u, data, 0)) {
203                 DEBUG(0,("spoolss_io_q_deleteprinterdriver: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVER.\n"));
204                 return False;
205         }
206
207         r_u.status = _spoolss_deleteprinterdriver(p, &q_u, &r_u);
208
209         if (!spoolss_io_r_deleteprinterdriver("",&r_u,rdata,0)) {
210                 DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
211                 return False;
212         }
213
214         return True;
215 }
216
217
218 /********************************************************************
219  * api_spoolss_rffpcnex
220  * ReplyFindFirstPrinterChangeNotifyEx
221  ********************************************************************/
222
223 static bool api_spoolss_rffpcnex(pipes_struct *p)
224 {
225         SPOOL_Q_RFFPCNEX q_u;
226         SPOOL_R_RFFPCNEX r_u;
227         prs_struct *data = &p->in_data.data;
228         prs_struct *rdata = &p->out_data.rdata;
229
230         ZERO_STRUCT(q_u);
231         ZERO_STRUCT(r_u);
232
233         if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
234                 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
235                 return False;
236         }
237
238         r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u);
239
240         if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
241                 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
242                 return False;
243         }
244
245         return True;
246 }
247
248
249 /********************************************************************
250  * api_spoolss_rfnpcnex
251  * ReplyFindNextPrinterChangeNotifyEx
252  * called from the spoolss dispatcher
253
254  * Note - this is the *ONLY* function that breaks the RPC call
255  * symmetry in all the other calls. We need to do this to fix
256  * the massive memory allocation problem with thousands of jobs...
257  * JRA.
258  ********************************************************************/
259
260 static bool api_spoolss_rfnpcnex(pipes_struct *p)
261 {
262         SPOOL_Q_RFNPCNEX q_u;
263         SPOOL_R_RFNPCNEX r_u;
264         prs_struct *data = &p->in_data.data;
265         prs_struct *rdata = &p->out_data.rdata;
266
267         ZERO_STRUCT(q_u);
268         ZERO_STRUCT(r_u);
269
270         if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
271                 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
272                 return False;
273         }
274
275         r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u);
276
277         if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
278                 SAFE_FREE(r_u.info.data);
279                 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
280                 return False;
281         }
282
283         SAFE_FREE(r_u.info.data);
284
285         return True;
286 }
287
288
289 /********************************************************************
290  * api_spoolss_enumprinters
291  * called from the spoolss dispatcher
292  *
293  ********************************************************************/
294
295 static bool api_spoolss_enumprinters(pipes_struct *p)
296 {
297         SPOOL_Q_ENUMPRINTERS q_u;
298         SPOOL_R_ENUMPRINTERS r_u;
299         prs_struct *data = &p->in_data.data;
300         prs_struct *rdata = &p->out_data.rdata;
301
302         ZERO_STRUCT(q_u);
303         ZERO_STRUCT(r_u);
304
305         if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
306                 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
307                 return False;
308         }
309
310         r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
311
312         if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
313                 DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
314                 return False;
315         }
316
317         return True;
318 }
319
320 /********************************************************************
321  * api_spoolss_getprinter
322  * called from the spoolss dispatcher
323  *
324  ********************************************************************/
325
326 static bool api_spoolss_getprinter(pipes_struct *p)
327 {
328         SPOOL_Q_GETPRINTER q_u;
329         SPOOL_R_GETPRINTER r_u;
330         prs_struct *data = &p->in_data.data;
331         prs_struct *rdata = &p->out_data.rdata;
332
333         ZERO_STRUCT(q_u);
334         ZERO_STRUCT(r_u);
335
336         if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
337                 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
338                 return False;
339         }
340
341         r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
342
343         if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
344                 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
345                 return False;
346         }
347
348         return True;
349 }
350
351 /********************************************************************
352  * api_spoolss_getprinter
353  * called from the spoolss dispatcher
354  *
355  ********************************************************************/
356
357 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
358 {
359         SPOOL_Q_GETPRINTERDRIVER2 q_u;
360         SPOOL_R_GETPRINTERDRIVER2 r_u;
361         prs_struct *data = &p->in_data.data;
362         prs_struct *rdata = &p->out_data.rdata;
363
364         ZERO_STRUCT(q_u);
365         ZERO_STRUCT(r_u);
366
367         if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
368                 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
369                 return False;
370         }
371
372         r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
373         
374         if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
375                 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
376                 return False;
377         }
378         
379         return True;
380 }
381
382 /********************************************************************
383  * api_spoolss_getprinter
384  * called from the spoolss dispatcher
385  *
386  ********************************************************************/
387
388 static bool api_spoolss_startpageprinter(pipes_struct *p)
389 {
390         return proxy_spoolss_call(p, NDR_SPOOLSS_STARTPAGEPRINTER);
391 }
392
393 /********************************************************************
394  * api_spoolss_getprinter
395  * called from the spoolss dispatcher
396  *
397  ********************************************************************/
398
399 static bool api_spoolss_endpageprinter(pipes_struct *p)
400 {
401         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDPAGEPRINTER);
402 }
403
404 /********************************************************************
405 ********************************************************************/
406
407 static bool api_spoolss_startdocprinter(pipes_struct *p)
408 {
409         SPOOL_Q_STARTDOCPRINTER q_u;
410         SPOOL_R_STARTDOCPRINTER r_u;
411         prs_struct *data = &p->in_data.data;
412         prs_struct *rdata = &p->out_data.rdata;
413
414         ZERO_STRUCT(q_u);
415         ZERO_STRUCT(r_u);
416
417         if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) {
418                 DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
419                 return False;
420         }
421
422         r_u.status = _spoolss_startdocprinter(p, &q_u, &r_u);
423
424         if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
425                 DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
426                 return False;
427         }
428
429         return True;
430 }
431
432 /********************************************************************
433 ********************************************************************/
434
435 static bool api_spoolss_enddocprinter(pipes_struct *p)
436 {
437         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDDOCPRINTER);
438 }
439
440 /********************************************************************
441 ********************************************************************/
442
443 static bool api_spoolss_writeprinter(pipes_struct *p)
444 {
445         return proxy_spoolss_call(p, NDR_SPOOLSS_WRITEPRINTER);
446 }
447
448 /****************************************************************************
449
450 ****************************************************************************/
451
452 static bool api_spoolss_setprinter(pipes_struct *p)
453 {
454         SPOOL_Q_SETPRINTER q_u;
455         SPOOL_R_SETPRINTER r_u;
456         prs_struct *data = &p->in_data.data;
457         prs_struct *rdata = &p->out_data.rdata;
458
459         ZERO_STRUCT(q_u);
460         ZERO_STRUCT(r_u);
461
462         if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
463                 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
464                 return False;
465         }
466         
467         r_u.status = _spoolss_setprinter(p, &q_u, &r_u);
468         
469         if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
470                 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
471                 return False;
472         }
473
474         return True;
475 }
476
477 /****************************************************************************
478 ****************************************************************************/
479
480 static bool api_spoolss_fcpn(pipes_struct *p)
481 {
482         SPOOL_Q_FCPN q_u;
483         SPOOL_R_FCPN r_u;
484         prs_struct *data = &p->in_data.data;
485         prs_struct *rdata = &p->out_data.rdata;
486
487         ZERO_STRUCT(q_u);
488         ZERO_STRUCT(r_u);
489
490         if(!spoolss_io_q_fcpn("", &q_u, data, 0)) {
491                 DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n"));
492                 return False;
493         }
494
495         r_u.status = _spoolss_fcpn(p, &q_u, &r_u);
496
497         if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) {
498                 DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n"));
499                 return False;
500         }
501
502         return True;
503 }
504
505 /****************************************************************************
506 ****************************************************************************/
507
508 static bool api_spoolss_addjob(pipes_struct *p)
509 {
510         SPOOL_Q_ADDJOB q_u;
511         SPOOL_R_ADDJOB r_u;
512         prs_struct *data = &p->in_data.data;
513         prs_struct *rdata = &p->out_data.rdata;
514
515         ZERO_STRUCT(q_u);
516         ZERO_STRUCT(r_u);
517
518         if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
519                 DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
520                 return False;
521         }
522
523         r_u.status = _spoolss_addjob(p, &q_u, &r_u);
524                 
525         if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
526                 DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
527                 return False;
528         }
529
530         return True;            
531 }
532
533 /****************************************************************************
534 ****************************************************************************/
535
536 static bool api_spoolss_enumjobs(pipes_struct *p)
537 {
538         SPOOL_Q_ENUMJOBS q_u;
539         SPOOL_R_ENUMJOBS r_u;
540         prs_struct *data = &p->in_data.data;
541         prs_struct *rdata = &p->out_data.rdata;
542
543         ZERO_STRUCT(q_u);
544         ZERO_STRUCT(r_u);
545
546         if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
547                 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
548                 return False;
549         }
550
551         r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
552
553         if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
554                 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
555                 return False;
556         }
557
558         return True;
559 }
560
561 /****************************************************************************
562 ****************************************************************************/
563
564 static bool api_spoolss_schedulejob(pipes_struct *p)
565 {
566         SPOOL_Q_SCHEDULEJOB q_u;
567         SPOOL_R_SCHEDULEJOB r_u;
568         prs_struct *data = &p->in_data.data;
569         prs_struct *rdata = &p->out_data.rdata;
570
571         ZERO_STRUCT(q_u);
572         ZERO_STRUCT(r_u);
573
574         if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
575                 DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
576                 return False;
577         }
578
579         r_u.status = _spoolss_schedulejob(p, &q_u, &r_u);
580
581         if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
582                 DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
583                 return False;
584         }
585
586         return True;
587 }
588
589 /****************************************************************************
590 ****************************************************************************/
591
592 static bool api_spoolss_setjob(pipes_struct *p)
593 {
594         SPOOL_Q_SETJOB q_u;
595         SPOOL_R_SETJOB r_u;
596         prs_struct *data = &p->in_data.data;
597         prs_struct *rdata = &p->out_data.rdata;
598
599         ZERO_STRUCT(q_u);
600         ZERO_STRUCT(r_u);
601
602         if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
603                 DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
604                 return False;
605         }
606
607         r_u.status = _spoolss_setjob(p, &q_u, &r_u);
608
609         if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
610                 DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
611                 return False;
612         }
613
614         return True;
615 }
616
617 /****************************************************************************
618 ****************************************************************************/
619
620 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
621 {
622         SPOOL_Q_ENUMPRINTERDRIVERS q_u;
623         SPOOL_R_ENUMPRINTERDRIVERS r_u;
624         prs_struct *data = &p->in_data.data;
625         prs_struct *rdata = &p->out_data.rdata;
626
627         ZERO_STRUCT(q_u);
628         ZERO_STRUCT(r_u);
629
630         if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
631                 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
632                 return False;
633         }
634
635         r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
636
637         if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
638                 DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
639                 return False;
640         }
641
642         return True;
643 }
644
645 /****************************************************************************
646 ****************************************************************************/
647
648 static bool api_spoolss_getform(pipes_struct *p)
649 {
650         return proxy_spoolss_call(p, NDR_SPOOLSS_GETFORM);
651 }
652
653 /****************************************************************************
654 ****************************************************************************/
655
656 static bool api_spoolss_enumforms(pipes_struct *p)
657 {
658         SPOOL_Q_ENUMFORMS q_u;
659         SPOOL_R_ENUMFORMS r_u;
660         prs_struct *data = &p->in_data.data;
661         prs_struct *rdata = &p->out_data.rdata;
662
663         ZERO_STRUCT(q_u);
664         ZERO_STRUCT(r_u);
665
666         if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
667                 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
668                 return False;
669         }
670
671         r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
672
673         if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
674                 DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
675                 return False;
676         }
677
678         return True;
679 }
680
681 /****************************************************************************
682 ****************************************************************************/
683
684 static bool api_spoolss_enumports(pipes_struct *p)
685 {
686         SPOOL_Q_ENUMPORTS q_u;
687         SPOOL_R_ENUMPORTS r_u;
688         prs_struct *data = &p->in_data.data;
689         prs_struct *rdata = &p->out_data.rdata;
690
691         ZERO_STRUCT(q_u);
692         ZERO_STRUCT(r_u);
693
694         if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
695                 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
696                 return False;
697         }
698
699         r_u.status = _spoolss_enumports(p, &q_u, &r_u);
700
701         if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
702                 DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
703                 return False;
704         }
705
706         return True;
707 }
708
709 /****************************************************************************
710 ****************************************************************************/
711
712 static bool api_spoolss_addprinterex(pipes_struct *p)
713 {
714         SPOOL_Q_ADDPRINTEREX q_u;
715         SPOOL_R_ADDPRINTEREX r_u;
716         prs_struct *data = &p->in_data.data;
717         prs_struct *rdata = &p->out_data.rdata;
718         
719         ZERO_STRUCT(q_u);
720         ZERO_STRUCT(r_u);
721         
722         if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
723                 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
724                 return False;
725         }
726         
727         r_u.status = _spoolss_addprinterex(p, &q_u, &r_u);
728                                 
729         if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
730                 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
731                 return False;
732         }
733         
734         return True;
735 }
736
737 /****************************************************************************
738 ****************************************************************************/
739
740 static bool api_spoolss_addprinterdriver(pipes_struct *p)
741 {
742         SPOOL_Q_ADDPRINTERDRIVER q_u;
743         SPOOL_R_ADDPRINTERDRIVER r_u;
744         prs_struct *data = &p->in_data.data;
745         prs_struct *rdata = &p->out_data.rdata;
746         
747         ZERO_STRUCT(q_u);
748         ZERO_STRUCT(r_u);
749         
750         if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
751                 if (q_u.level != 3 && q_u.level != 6) {
752                         /* Clever hack from Martin Zielinski <mz@seh.de>
753                          * to allow downgrade from level 8 (Vista).
754                          */
755                         DEBUG(3,("api_spoolss_addprinterdriver: unknown SPOOL_Q_ADDPRINTERDRIVER level %u.\n",
756                                 (unsigned int)q_u.level ));
757                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
758                         return True;
759                 }
760                 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
761                 return False;
762         }
763         
764         r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u);
765                                 
766         if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
767                 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
768                 return False;
769         }
770         
771         return True;
772 }
773
774 /****************************************************************************
775 ****************************************************************************/
776
777 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
778 {
779         SPOOL_Q_GETPRINTERDRIVERDIR q_u;
780         SPOOL_R_GETPRINTERDRIVERDIR r_u;
781         prs_struct *data = &p->in_data.data;
782         prs_struct *rdata = &p->out_data.rdata;
783
784         ZERO_STRUCT(q_u);
785         ZERO_STRUCT(r_u);
786
787         if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
788                 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
789                 return False;
790         }
791
792         r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
793
794         if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
795                 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
796                 return False;
797         }
798
799         return True;
800 }
801
802 /****************************************************************************
803 ****************************************************************************/
804
805 static bool api_spoolss_enumprinterdata(pipes_struct *p)
806 {
807         SPOOL_Q_ENUMPRINTERDATA q_u;
808         SPOOL_R_ENUMPRINTERDATA r_u;
809         prs_struct *data = &p->in_data.data;
810         prs_struct *rdata = &p->out_data.rdata;
811         
812         ZERO_STRUCT(q_u);
813         ZERO_STRUCT(r_u);
814         
815         if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
816                 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
817                 return False;
818         }
819         
820         r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
821                                 
822         if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
823                 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
824                 return False;
825         }
826
827         return True;
828 }
829
830 /****************************************************************************
831 ****************************************************************************/
832
833 static bool api_spoolss_setprinterdata(pipes_struct *p)
834 {
835         SPOOL_Q_SETPRINTERDATA q_u;
836         SPOOL_R_SETPRINTERDATA r_u;
837         prs_struct *data = &p->in_data.data;
838         prs_struct *rdata = &p->out_data.rdata;
839         
840         ZERO_STRUCT(q_u);
841         ZERO_STRUCT(r_u);
842         
843         if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
844                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
845                 return False;
846         }
847         
848         r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
849                                 
850         if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
851                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
852                 return False;
853         }
854
855         return True;
856 }
857
858 /****************************************************************************
859 ****************************************************************************/
860 static bool api_spoolss_reset_printer(pipes_struct *p)
861 {
862         SPOOL_Q_RESETPRINTER q_u;
863         SPOOL_R_RESETPRINTER r_u;
864         prs_struct *data = &p->in_data.data;
865         prs_struct *rdata = &p->out_data.rdata;
866
867         ZERO_STRUCT(q_u);
868         ZERO_STRUCT(r_u);
869
870         if(!spoolss_io_q_resetprinter("", &q_u, data, 0)) {
871                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
872                 return False;
873         }
874         
875         r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
876
877         if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) {
878                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n"));
879                 return False;
880         }
881
882         return True;
883 }
884
885 /****************************************************************************
886 ****************************************************************************/
887 static bool api_spoolss_addform(pipes_struct *p)
888 {
889         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDFORM);
890 }
891
892 /****************************************************************************
893 ****************************************************************************/
894
895 static bool api_spoolss_deleteform(pipes_struct *p)
896 {
897         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEFORM);
898 }
899
900 /****************************************************************************
901 ****************************************************************************/
902
903 static bool api_spoolss_setform(pipes_struct *p)
904 {
905         return proxy_spoolss_call(p, NDR_SPOOLSS_SETFORM);
906 }
907
908 /****************************************************************************
909 ****************************************************************************/
910
911 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
912 {
913         SPOOL_Q_ENUMPRINTPROCESSORS q_u;
914         SPOOL_R_ENUMPRINTPROCESSORS r_u;
915         prs_struct *data = &p->in_data.data;
916         prs_struct *rdata = &p->out_data.rdata;
917
918         ZERO_STRUCT(q_u);
919         ZERO_STRUCT(r_u);
920         
921         if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
922                 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
923                 return False;
924         }
925         
926         r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
927
928         if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
929                 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
930                 return False;
931         }
932         
933         return True;
934 }
935
936 /****************************************************************************
937 ****************************************************************************/
938
939 static bool api_spoolss_addprintprocessor(pipes_struct *p)
940 {
941         SPOOL_Q_ADDPRINTPROCESSOR q_u;
942         SPOOL_R_ADDPRINTPROCESSOR r_u;
943         prs_struct *data = &p->in_data.data;
944         prs_struct *rdata = &p->out_data.rdata;
945
946         ZERO_STRUCT(q_u);
947         ZERO_STRUCT(r_u);
948         
949         if(!spoolss_io_q_addprintprocessor("", &q_u, data, 0)) {
950                 DEBUG(0,("spoolss_io_q_addprintprocessor: unable to unmarshall SPOOL_Q_ADDPRINTPROCESSOR.\n"));
951                 return False;
952         }
953         
954         /* for now, just indicate success and ignore the add.  We'll
955            automatically set the winprint processor for printer
956            entries later.  Used to debug the LexMark Optra S 1855 PCL
957            driver --jerry */
958         r_u.status = WERR_OK;
959
960         if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) {
961                 DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n"));
962                 return False;
963         }
964         
965         return True;
966 }
967
968 /****************************************************************************
969 ****************************************************************************/
970
971 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
972 {
973         SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
974         SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
975         prs_struct *data = &p->in_data.data;
976         prs_struct *rdata = &p->out_data.rdata;
977
978         ZERO_STRUCT(q_u);
979         ZERO_STRUCT(r_u);
980         
981         if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
982                 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
983                 return False;
984         }
985         
986         r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
987
988         if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
989                 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
990                 return False;
991         }
992         
993         return True;
994 }
995
996 /****************************************************************************
997 ****************************************************************************/
998
999 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
1000 {
1001         SPOOL_Q_ENUMPRINTMONITORS q_u;
1002         SPOOL_R_ENUMPRINTMONITORS r_u;
1003         prs_struct *data = &p->in_data.data;
1004         prs_struct *rdata = &p->out_data.rdata;
1005
1006         ZERO_STRUCT(q_u);
1007         ZERO_STRUCT(r_u);
1008         
1009         if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
1010                 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
1011                 return False;
1012         }
1013                 
1014         r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
1015
1016         if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
1017                 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
1018                 return False;
1019         }
1020         
1021         return True;
1022 }
1023
1024 /****************************************************************************
1025 ****************************************************************************/
1026
1027 static bool api_spoolss_getjob(pipes_struct *p)
1028 {
1029         SPOOL_Q_GETJOB q_u;
1030         SPOOL_R_GETJOB r_u;
1031         prs_struct *data = &p->in_data.data;
1032         prs_struct *rdata = &p->out_data.rdata;
1033         
1034         ZERO_STRUCT(q_u);
1035         ZERO_STRUCT(r_u);
1036         
1037         if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
1038                 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
1039                 return False;
1040         }
1041
1042         r_u.status = _spoolss_getjob(p, &q_u, &r_u);
1043         
1044         if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1045                 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1046                 return False;
1047         }
1048                 
1049         return True;
1050 }
1051
1052 /********************************************************************
1053  * api_spoolss_getprinterdataex
1054  *
1055  * called from the spoolss dispatcher
1056  ********************************************************************/
1057
1058 static bool api_spoolss_getprinterdataex(pipes_struct *p)
1059 {
1060         SPOOL_Q_GETPRINTERDATAEX q_u;
1061         SPOOL_R_GETPRINTERDATAEX r_u;
1062         prs_struct *data = &p->in_data.data;
1063         prs_struct *rdata = &p->out_data.rdata;
1064
1065         ZERO_STRUCT(q_u);
1066         ZERO_STRUCT(r_u);
1067
1068         /* read the stream and fill the struct */
1069         if (!spoolss_io_q_getprinterdataex("", &q_u, data, 0)) {
1070                 DEBUG(0,("spoolss_io_q_getprinterdataex: unable to unmarshall SPOOL_Q_GETPRINTERDATAEX.\n"));
1071                 return False;
1072         }
1073         
1074         r_u.status = _spoolss_getprinterdataex( p, &q_u, &r_u);
1075
1076         if (!spoolss_io_r_getprinterdataex("", &r_u, rdata, 0)) {
1077                 DEBUG(0,("spoolss_io_r_getprinterdataex: unable to marshall SPOOL_R_GETPRINTERDATAEX.\n"));
1078                 return False;
1079         }
1080
1081         return True;
1082 }
1083
1084 /****************************************************************************
1085 ****************************************************************************/
1086
1087 static bool api_spoolss_setprinterdataex(pipes_struct *p)
1088 {
1089         SPOOL_Q_SETPRINTERDATAEX q_u;
1090         SPOOL_R_SETPRINTERDATAEX r_u;
1091         prs_struct *data = &p->in_data.data;
1092         prs_struct *rdata = &p->out_data.rdata;
1093         
1094         ZERO_STRUCT(q_u);
1095         ZERO_STRUCT(r_u);
1096         
1097         if(!spoolss_io_q_setprinterdataex("", &q_u, data, 0)) {
1098                 DEBUG(0,("spoolss_io_q_setprinterdataex: unable to unmarshall SPOOL_Q_SETPRINTERDATAEX.\n"));
1099                 return False;
1100         }
1101         
1102         r_u.status = _spoolss_setprinterdataex(p, &q_u, &r_u);
1103                                 
1104         if(!spoolss_io_r_setprinterdataex("", &r_u, rdata, 0)) {
1105                 DEBUG(0,("spoolss_io_r_setprinterdataex: unable to marshall SPOOL_R_SETPRINTERDATAEX.\n"));
1106                 return False;
1107         }
1108
1109         return True;
1110 }
1111
1112
1113 /****************************************************************************
1114 ****************************************************************************/
1115
1116 static bool api_spoolss_enumprinterkey(pipes_struct *p)
1117 {
1118         SPOOL_Q_ENUMPRINTERKEY q_u;
1119         SPOOL_R_ENUMPRINTERKEY r_u;
1120         prs_struct *data = &p->in_data.data;
1121         prs_struct *rdata = &p->out_data.rdata;
1122         
1123         ZERO_STRUCT(q_u);
1124         ZERO_STRUCT(r_u);
1125         
1126         if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
1127                 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
1128                 return False;
1129         }
1130         
1131         r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
1132                                 
1133         if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
1134                 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
1135                 return False;
1136         }
1137
1138         return True;
1139 }
1140
1141 /****************************************************************************
1142 ****************************************************************************/
1143
1144 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
1145 {
1146         SPOOL_Q_ENUMPRINTERDATAEX q_u;
1147         SPOOL_R_ENUMPRINTERDATAEX r_u;
1148         prs_struct *data = &p->in_data.data;
1149         prs_struct *rdata = &p->out_data.rdata;
1150         
1151         ZERO_STRUCT(q_u);
1152         ZERO_STRUCT(r_u);
1153         
1154         if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
1155                 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
1156                 return False;
1157         }
1158         
1159         r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
1160                                 
1161         if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
1162                 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
1163                 return False;
1164         }
1165
1166         return True;
1167 }
1168
1169 /****************************************************************************
1170 ****************************************************************************/
1171
1172 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
1173 {
1174         SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u;
1175         SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u;
1176         prs_struct *data = &p->in_data.data;
1177         prs_struct *rdata = &p->out_data.rdata;
1178         
1179         ZERO_STRUCT(q_u);
1180         ZERO_STRUCT(r_u);
1181         
1182         if(!spoolss_io_q_getprintprocessordirectory("", &q_u, data, 0)) {
1183                 DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n"));
1184                 return False;
1185         }
1186         
1187         r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
1188                                 
1189         if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) {
1190                 DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n"));
1191                 return False;
1192         }
1193         
1194         return True;
1195 }
1196
1197 /****************************************************************************
1198 ****************************************************************************/
1199
1200 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
1201 {
1202         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATAEX);
1203 }
1204
1205 /****************************************************************************
1206 ****************************************************************************/
1207
1208 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
1209 {
1210         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERKEY);
1211 }
1212
1213 /****************************************************************************
1214 ****************************************************************************/
1215
1216 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
1217 {
1218         SPOOL_Q_ADDPRINTERDRIVEREX q_u;
1219         SPOOL_R_ADDPRINTERDRIVEREX r_u;
1220         prs_struct *data = &p->in_data.data;
1221         prs_struct *rdata = &p->out_data.rdata;
1222         
1223         ZERO_STRUCT(q_u);
1224         ZERO_STRUCT(r_u);
1225         
1226         if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) {
1227                 if (q_u.level != 3 && q_u.level != 6) {
1228                         /* Clever hack from Martin Zielinski <mz@seh.de>
1229                          * to allow downgrade from level 8 (Vista).
1230                          */
1231                         DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n",
1232                                 (unsigned int)q_u.level ));
1233                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
1234                         return True;
1235                 }
1236                 DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
1237                 return False;
1238         }
1239         
1240         r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
1241                                 
1242         if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) {
1243                 DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n"));
1244                 return False;
1245         }
1246         
1247         return True;
1248 }
1249
1250 /****************************************************************************
1251 ****************************************************************************/
1252
1253 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
1254 {
1255         SPOOL_Q_DELETEPRINTERDRIVEREX q_u;
1256         SPOOL_R_DELETEPRINTERDRIVEREX r_u;
1257         prs_struct *data = &p->in_data.data;
1258         prs_struct *rdata = &p->out_data.rdata;
1259         
1260         ZERO_STRUCT(q_u);
1261         ZERO_STRUCT(r_u);
1262         
1263         if(!spoolss_io_q_deleteprinterdriverex("", &q_u, data, 0)) {
1264                 DEBUG(0,("spoolss_io_q_deleteprinterdriverex: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVEREX.\n"));
1265                 return False;
1266         }
1267         
1268         r_u.status = _spoolss_deleteprinterdriverex(p, &q_u, &r_u);
1269                                 
1270         if(!spoolss_io_r_deleteprinterdriverex("", &r_u, rdata, 0)) {
1271                 DEBUG(0,("spoolss_io_r_deleteprinterdriverex: unable to marshall SPOOL_R_DELETEPRINTERDRIVEREX.\n"));
1272                 return False;
1273         }
1274         
1275         return True;
1276 }
1277
1278 /****************************************************************************
1279 ****************************************************************************/
1280
1281 static bool api_spoolss_xcvdataport(pipes_struct *p)
1282 {
1283         SPOOL_Q_XCVDATAPORT q_u;
1284         SPOOL_R_XCVDATAPORT r_u;
1285         prs_struct *data = &p->in_data.data;
1286         prs_struct *rdata = &p->out_data.rdata;
1287         
1288         ZERO_STRUCT(q_u);
1289         ZERO_STRUCT(r_u);
1290         
1291         if(!spoolss_io_q_xcvdataport("", &q_u, data, 0)) {
1292                 DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_XCVDATAPORT.\n"));
1293                 return False;
1294         }
1295         
1296         r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u);
1297                                 
1298         if(!spoolss_io_r_xcvdataport("", &r_u, rdata, 0)) {
1299                 DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_XCVDATAPORT.\n"));
1300                 return False;
1301         }
1302         
1303         return True;
1304 }
1305
1306 /*******************************************************************
1307 \pipe\spoolss commands
1308 ********************************************************************/
1309
1310   struct api_struct api_spoolss_cmds[] = 
1311     {
1312  {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
1313  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
1314  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
1315  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
1316  {"SPOOLSS_DELETEPRINTER",             SPOOLSS_DELETEPRINTER,             api_spoolss_deleteprinter             },
1317  {"SPOOLSS_ABORTPRINTER",              SPOOLSS_ABORTPRINTER,              api_spoolss_abortprinter              },
1318  {"SPOOLSS_RFFPCNEX",                  SPOOLSS_RFFPCNEX,                  api_spoolss_rffpcnex                  },
1319  {"SPOOLSS_RFNPCNEX",                  SPOOLSS_RFNPCNEX,                  api_spoolss_rfnpcnex                  },
1320  {"SPOOLSS_ENUMPRINTERS",              SPOOLSS_ENUMPRINTERS,              api_spoolss_enumprinters              },
1321  {"SPOOLSS_GETPRINTER",                SPOOLSS_GETPRINTER,                api_spoolss_getprinter                },
1322  {"SPOOLSS_GETPRINTERDRIVER2",         SPOOLSS_GETPRINTERDRIVER2,         api_spoolss_getprinterdriver2         }, 
1323  {"SPOOLSS_STARTPAGEPRINTER",          SPOOLSS_STARTPAGEPRINTER,          api_spoolss_startpageprinter          },
1324  {"SPOOLSS_ENDPAGEPRINTER",            SPOOLSS_ENDPAGEPRINTER,            api_spoolss_endpageprinter            }, 
1325  {"SPOOLSS_STARTDOCPRINTER",           SPOOLSS_STARTDOCPRINTER,           api_spoolss_startdocprinter           },
1326  {"SPOOLSS_ENDDOCPRINTER",             SPOOLSS_ENDDOCPRINTER,             api_spoolss_enddocprinter             },
1327  {"SPOOLSS_WRITEPRINTER",              SPOOLSS_WRITEPRINTER,              api_spoolss_writeprinter              },
1328  {"SPOOLSS_SETPRINTER",                SPOOLSS_SETPRINTER,                api_spoolss_setprinter                },
1329  {"SPOOLSS_FCPN",                      SPOOLSS_FCPN,                      api_spoolss_fcpn                      },
1330  {"SPOOLSS_ADDJOB",                    SPOOLSS_ADDJOB,                    api_spoolss_addjob                    },
1331  {"SPOOLSS_ENUMJOBS",                  SPOOLSS_ENUMJOBS,                  api_spoolss_enumjobs                  },
1332  {"SPOOLSS_SCHEDULEJOB",               SPOOLSS_SCHEDULEJOB,               api_spoolss_schedulejob               },
1333  {"SPOOLSS_SETJOB",                    SPOOLSS_SETJOB,                    api_spoolss_setjob                    },
1334  {"SPOOLSS_ENUMFORMS",                 SPOOLSS_ENUMFORMS,                 api_spoolss_enumforms                 },
1335  {"SPOOLSS_ENUMPORTS",                 SPOOLSS_ENUMPORTS,                 api_spoolss_enumports                 },
1336  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
1337  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
1338  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
1339  {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
1340  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1341  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
1342  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
1343  {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
1344  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
1345  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
1346  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
1347  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
1348  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
1349  {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
1350  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
1351  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
1352  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
1353  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
1354  {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
1355  {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
1356  {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
1357  {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
1358  {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
1359  {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
1360  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
1361  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
1362  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
1363  {"SPOOLSS_XCVDATAPORT",               SPOOLSS_XCVDATAPORT,               api_spoolss_xcvdataport               },
1364 };
1365
1366 void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns )
1367 {
1368         *fns = api_spoolss_cmds;
1369         *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
1370 }
1371
1372 NTSTATUS rpc_spoolss2_init(void)
1373 {
1374         return rpc_srv_register(
1375                 SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss",
1376                 &ndr_table_spoolss,
1377                 api_spoolss_cmds,
1378                 sizeof(api_spoolss_cmds) / sizeof(struct api_struct));
1379 }