Merge branch 'master' of ssh://git.samba.org/data/git/samba
[amitay/samba.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         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVER);
195 }
196
197
198 /********************************************************************
199  * api_spoolss_rffpcnex
200  * ReplyFindFirstPrinterChangeNotifyEx
201  ********************************************************************/
202
203 static bool api_spoolss_rffpcnex(pipes_struct *p)
204 {
205         SPOOL_Q_RFFPCNEX q_u;
206         SPOOL_R_RFFPCNEX r_u;
207         prs_struct *data = &p->in_data.data;
208         prs_struct *rdata = &p->out_data.rdata;
209
210         ZERO_STRUCT(q_u);
211         ZERO_STRUCT(r_u);
212
213         if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
214                 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
215                 return False;
216         }
217
218         r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u);
219
220         if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
221                 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
222                 return False;
223         }
224
225         return True;
226 }
227
228
229 /********************************************************************
230  * api_spoolss_rfnpcnex
231  * ReplyFindNextPrinterChangeNotifyEx
232  * called from the spoolss dispatcher
233
234  * Note - this is the *ONLY* function that breaks the RPC call
235  * symmetry in all the other calls. We need to do this to fix
236  * the massive memory allocation problem with thousands of jobs...
237  * JRA.
238  ********************************************************************/
239
240 static bool api_spoolss_rfnpcnex(pipes_struct *p)
241 {
242         SPOOL_Q_RFNPCNEX q_u;
243         SPOOL_R_RFNPCNEX r_u;
244         prs_struct *data = &p->in_data.data;
245         prs_struct *rdata = &p->out_data.rdata;
246
247         ZERO_STRUCT(q_u);
248         ZERO_STRUCT(r_u);
249
250         if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
251                 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
252                 return False;
253         }
254
255         r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u);
256
257         if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
258                 SAFE_FREE(r_u.info.data);
259                 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
260                 return False;
261         }
262
263         SAFE_FREE(r_u.info.data);
264
265         return True;
266 }
267
268
269 /********************************************************************
270  * api_spoolss_enumprinters
271  * called from the spoolss dispatcher
272  *
273  ********************************************************************/
274
275 static bool api_spoolss_enumprinters(pipes_struct *p)
276 {
277         SPOOL_Q_ENUMPRINTERS q_u;
278         SPOOL_R_ENUMPRINTERS r_u;
279         prs_struct *data = &p->in_data.data;
280         prs_struct *rdata = &p->out_data.rdata;
281
282         ZERO_STRUCT(q_u);
283         ZERO_STRUCT(r_u);
284
285         if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
286                 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
287                 return False;
288         }
289
290         r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
291
292         if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
293                 DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
294                 return False;
295         }
296
297         return True;
298 }
299
300 /********************************************************************
301  * api_spoolss_getprinter
302  * called from the spoolss dispatcher
303  *
304  ********************************************************************/
305
306 static bool api_spoolss_getprinter(pipes_struct *p)
307 {
308         SPOOL_Q_GETPRINTER q_u;
309         SPOOL_R_GETPRINTER r_u;
310         prs_struct *data = &p->in_data.data;
311         prs_struct *rdata = &p->out_data.rdata;
312
313         ZERO_STRUCT(q_u);
314         ZERO_STRUCT(r_u);
315
316         if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
317                 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
318                 return False;
319         }
320
321         r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
322
323         if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
324                 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
325                 return False;
326         }
327
328         return True;
329 }
330
331 /********************************************************************
332  * api_spoolss_getprinter
333  * called from the spoolss dispatcher
334  *
335  ********************************************************************/
336
337 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
338 {
339         SPOOL_Q_GETPRINTERDRIVER2 q_u;
340         SPOOL_R_GETPRINTERDRIVER2 r_u;
341         prs_struct *data = &p->in_data.data;
342         prs_struct *rdata = &p->out_data.rdata;
343
344         ZERO_STRUCT(q_u);
345         ZERO_STRUCT(r_u);
346
347         if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
348                 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
349                 return False;
350         }
351
352         r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
353         
354         if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
355                 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
356                 return False;
357         }
358         
359         return True;
360 }
361
362 /********************************************************************
363  * api_spoolss_getprinter
364  * called from the spoolss dispatcher
365  *
366  ********************************************************************/
367
368 static bool api_spoolss_startpageprinter(pipes_struct *p)
369 {
370         return proxy_spoolss_call(p, NDR_SPOOLSS_STARTPAGEPRINTER);
371 }
372
373 /********************************************************************
374  * api_spoolss_getprinter
375  * called from the spoolss dispatcher
376  *
377  ********************************************************************/
378
379 static bool api_spoolss_endpageprinter(pipes_struct *p)
380 {
381         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDPAGEPRINTER);
382 }
383
384 /********************************************************************
385 ********************************************************************/
386
387 static bool api_spoolss_startdocprinter(pipes_struct *p)
388 {
389         SPOOL_Q_STARTDOCPRINTER q_u;
390         SPOOL_R_STARTDOCPRINTER r_u;
391         prs_struct *data = &p->in_data.data;
392         prs_struct *rdata = &p->out_data.rdata;
393
394         ZERO_STRUCT(q_u);
395         ZERO_STRUCT(r_u);
396
397         if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) {
398                 DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
399                 return False;
400         }
401
402         r_u.status = _spoolss_startdocprinter(p, &q_u, &r_u);
403
404         if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
405                 DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
406                 return False;
407         }
408
409         return True;
410 }
411
412 /********************************************************************
413 ********************************************************************/
414
415 static bool api_spoolss_enddocprinter(pipes_struct *p)
416 {
417         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDDOCPRINTER);
418 }
419
420 /********************************************************************
421 ********************************************************************/
422
423 static bool api_spoolss_writeprinter(pipes_struct *p)
424 {
425         return proxy_spoolss_call(p, NDR_SPOOLSS_WRITEPRINTER);
426 }
427
428 /****************************************************************************
429
430 ****************************************************************************/
431
432 static bool api_spoolss_setprinter(pipes_struct *p)
433 {
434         SPOOL_Q_SETPRINTER q_u;
435         SPOOL_R_SETPRINTER r_u;
436         prs_struct *data = &p->in_data.data;
437         prs_struct *rdata = &p->out_data.rdata;
438
439         ZERO_STRUCT(q_u);
440         ZERO_STRUCT(r_u);
441
442         if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
443                 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
444                 return False;
445         }
446         
447         r_u.status = _spoolss_setprinter(p, &q_u, &r_u);
448         
449         if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
450                 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
451                 return False;
452         }
453
454         return True;
455 }
456
457 /****************************************************************************
458 ****************************************************************************/
459
460 static bool api_spoolss_fcpn(pipes_struct *p)
461 {
462         return proxy_spoolss_call(p, NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY);
463 }
464
465 /****************************************************************************
466 ****************************************************************************/
467
468 static bool api_spoolss_addjob(pipes_struct *p)
469 {
470         SPOOL_Q_ADDJOB q_u;
471         SPOOL_R_ADDJOB r_u;
472         prs_struct *data = &p->in_data.data;
473         prs_struct *rdata = &p->out_data.rdata;
474
475         ZERO_STRUCT(q_u);
476         ZERO_STRUCT(r_u);
477
478         if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
479                 DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
480                 return False;
481         }
482
483         r_u.status = _spoolss_addjob(p, &q_u, &r_u);
484                 
485         if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
486                 DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
487                 return False;
488         }
489
490         return True;            
491 }
492
493 /****************************************************************************
494 ****************************************************************************/
495
496 static bool api_spoolss_enumjobs(pipes_struct *p)
497 {
498         SPOOL_Q_ENUMJOBS q_u;
499         SPOOL_R_ENUMJOBS r_u;
500         prs_struct *data = &p->in_data.data;
501         prs_struct *rdata = &p->out_data.rdata;
502
503         ZERO_STRUCT(q_u);
504         ZERO_STRUCT(r_u);
505
506         if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
507                 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
508                 return False;
509         }
510
511         r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
512
513         if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
514                 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
515                 return False;
516         }
517
518         return True;
519 }
520
521 /****************************************************************************
522 ****************************************************************************/
523
524 static bool api_spoolss_schedulejob(pipes_struct *p)
525 {
526         SPOOL_Q_SCHEDULEJOB q_u;
527         SPOOL_R_SCHEDULEJOB r_u;
528         prs_struct *data = &p->in_data.data;
529         prs_struct *rdata = &p->out_data.rdata;
530
531         ZERO_STRUCT(q_u);
532         ZERO_STRUCT(r_u);
533
534         if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
535                 DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
536                 return False;
537         }
538
539         r_u.status = _spoolss_schedulejob(p, &q_u, &r_u);
540
541         if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
542                 DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
543                 return False;
544         }
545
546         return True;
547 }
548
549 /****************************************************************************
550 ****************************************************************************/
551
552 static bool api_spoolss_setjob(pipes_struct *p)
553 {
554         SPOOL_Q_SETJOB q_u;
555         SPOOL_R_SETJOB r_u;
556         prs_struct *data = &p->in_data.data;
557         prs_struct *rdata = &p->out_data.rdata;
558
559         ZERO_STRUCT(q_u);
560         ZERO_STRUCT(r_u);
561
562         if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
563                 DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
564                 return False;
565         }
566
567         r_u.status = _spoolss_setjob(p, &q_u, &r_u);
568
569         if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
570                 DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
571                 return False;
572         }
573
574         return True;
575 }
576
577 /****************************************************************************
578 ****************************************************************************/
579
580 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
581 {
582         SPOOL_Q_ENUMPRINTERDRIVERS q_u;
583         SPOOL_R_ENUMPRINTERDRIVERS r_u;
584         prs_struct *data = &p->in_data.data;
585         prs_struct *rdata = &p->out_data.rdata;
586
587         ZERO_STRUCT(q_u);
588         ZERO_STRUCT(r_u);
589
590         if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
591                 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
592                 return False;
593         }
594
595         r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
596
597         if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
598                 DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
599                 return False;
600         }
601
602         return True;
603 }
604
605 /****************************************************************************
606 ****************************************************************************/
607
608 static bool api_spoolss_getform(pipes_struct *p)
609 {
610         return proxy_spoolss_call(p, NDR_SPOOLSS_GETFORM);
611 }
612
613 /****************************************************************************
614 ****************************************************************************/
615
616 static bool api_spoolss_enumforms(pipes_struct *p)
617 {
618         SPOOL_Q_ENUMFORMS q_u;
619         SPOOL_R_ENUMFORMS r_u;
620         prs_struct *data = &p->in_data.data;
621         prs_struct *rdata = &p->out_data.rdata;
622
623         ZERO_STRUCT(q_u);
624         ZERO_STRUCT(r_u);
625
626         if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
627                 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
628                 return False;
629         }
630
631         r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
632
633         if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
634                 DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
635                 return False;
636         }
637
638         return True;
639 }
640
641 /****************************************************************************
642 ****************************************************************************/
643
644 static bool api_spoolss_enumports(pipes_struct *p)
645 {
646         SPOOL_Q_ENUMPORTS q_u;
647         SPOOL_R_ENUMPORTS r_u;
648         prs_struct *data = &p->in_data.data;
649         prs_struct *rdata = &p->out_data.rdata;
650
651         ZERO_STRUCT(q_u);
652         ZERO_STRUCT(r_u);
653
654         if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
655                 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
656                 return False;
657         }
658
659         r_u.status = _spoolss_enumports(p, &q_u, &r_u);
660
661         if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
662                 DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
663                 return False;
664         }
665
666         return True;
667 }
668
669 /****************************************************************************
670 ****************************************************************************/
671
672 static bool api_spoolss_addprinterex(pipes_struct *p)
673 {
674         SPOOL_Q_ADDPRINTEREX q_u;
675         SPOOL_R_ADDPRINTEREX r_u;
676         prs_struct *data = &p->in_data.data;
677         prs_struct *rdata = &p->out_data.rdata;
678         
679         ZERO_STRUCT(q_u);
680         ZERO_STRUCT(r_u);
681         
682         if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
683                 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
684                 return False;
685         }
686         
687         r_u.status = _spoolss_addprinterex(p, &q_u, &r_u);
688                                 
689         if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
690                 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
691                 return False;
692         }
693         
694         return True;
695 }
696
697 /****************************************************************************
698 ****************************************************************************/
699
700 static bool api_spoolss_addprinterdriver(pipes_struct *p)
701 {
702         SPOOL_Q_ADDPRINTERDRIVER q_u;
703         SPOOL_R_ADDPRINTERDRIVER r_u;
704         prs_struct *data = &p->in_data.data;
705         prs_struct *rdata = &p->out_data.rdata;
706         
707         ZERO_STRUCT(q_u);
708         ZERO_STRUCT(r_u);
709         
710         if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
711                 if (q_u.level != 3 && q_u.level != 6) {
712                         /* Clever hack from Martin Zielinski <mz@seh.de>
713                          * to allow downgrade from level 8 (Vista).
714                          */
715                         DEBUG(3,("api_spoolss_addprinterdriver: unknown SPOOL_Q_ADDPRINTERDRIVER level %u.\n",
716                                 (unsigned int)q_u.level ));
717                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
718                         return True;
719                 }
720                 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
721                 return False;
722         }
723         
724         r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u);
725                                 
726         if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
727                 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
728                 return False;
729         }
730         
731         return True;
732 }
733
734 /****************************************************************************
735 ****************************************************************************/
736
737 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
738 {
739         SPOOL_Q_GETPRINTERDRIVERDIR q_u;
740         SPOOL_R_GETPRINTERDRIVERDIR r_u;
741         prs_struct *data = &p->in_data.data;
742         prs_struct *rdata = &p->out_data.rdata;
743
744         ZERO_STRUCT(q_u);
745         ZERO_STRUCT(r_u);
746
747         if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
748                 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
749                 return False;
750         }
751
752         r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
753
754         if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
755                 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
756                 return False;
757         }
758
759         return True;
760 }
761
762 /****************************************************************************
763 ****************************************************************************/
764
765 static bool api_spoolss_enumprinterdata(pipes_struct *p)
766 {
767         SPOOL_Q_ENUMPRINTERDATA q_u;
768         SPOOL_R_ENUMPRINTERDATA r_u;
769         prs_struct *data = &p->in_data.data;
770         prs_struct *rdata = &p->out_data.rdata;
771         
772         ZERO_STRUCT(q_u);
773         ZERO_STRUCT(r_u);
774         
775         if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
776                 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
777                 return False;
778         }
779         
780         r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
781                                 
782         if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
783                 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
784                 return False;
785         }
786
787         return True;
788 }
789
790 /****************************************************************************
791 ****************************************************************************/
792
793 static bool api_spoolss_setprinterdata(pipes_struct *p)
794 {
795         SPOOL_Q_SETPRINTERDATA q_u;
796         SPOOL_R_SETPRINTERDATA r_u;
797         prs_struct *data = &p->in_data.data;
798         prs_struct *rdata = &p->out_data.rdata;
799         
800         ZERO_STRUCT(q_u);
801         ZERO_STRUCT(r_u);
802         
803         if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
804                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
805                 return False;
806         }
807         
808         r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
809                                 
810         if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
811                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
812                 return False;
813         }
814
815         return True;
816 }
817
818 /****************************************************************************
819 ****************************************************************************/
820 static bool api_spoolss_reset_printer(pipes_struct *p)
821 {
822         SPOOL_Q_RESETPRINTER q_u;
823         SPOOL_R_RESETPRINTER r_u;
824         prs_struct *data = &p->in_data.data;
825         prs_struct *rdata = &p->out_data.rdata;
826
827         ZERO_STRUCT(q_u);
828         ZERO_STRUCT(r_u);
829
830         if(!spoolss_io_q_resetprinter("", &q_u, data, 0)) {
831                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
832                 return False;
833         }
834         
835         r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
836
837         if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) {
838                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n"));
839                 return False;
840         }
841
842         return True;
843 }
844
845 /****************************************************************************
846 ****************************************************************************/
847 static bool api_spoolss_addform(pipes_struct *p)
848 {
849         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDFORM);
850 }
851
852 /****************************************************************************
853 ****************************************************************************/
854
855 static bool api_spoolss_deleteform(pipes_struct *p)
856 {
857         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEFORM);
858 }
859
860 /****************************************************************************
861 ****************************************************************************/
862
863 static bool api_spoolss_setform(pipes_struct *p)
864 {
865         return proxy_spoolss_call(p, NDR_SPOOLSS_SETFORM);
866 }
867
868 /****************************************************************************
869 ****************************************************************************/
870
871 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
872 {
873         SPOOL_Q_ENUMPRINTPROCESSORS q_u;
874         SPOOL_R_ENUMPRINTPROCESSORS r_u;
875         prs_struct *data = &p->in_data.data;
876         prs_struct *rdata = &p->out_data.rdata;
877
878         ZERO_STRUCT(q_u);
879         ZERO_STRUCT(r_u);
880         
881         if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
882                 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
883                 return False;
884         }
885         
886         r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
887
888         if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
889                 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
890                 return False;
891         }
892         
893         return True;
894 }
895
896 /****************************************************************************
897 ****************************************************************************/
898
899 static bool api_spoolss_addprintprocessor(pipes_struct *p)
900 {
901         SPOOL_Q_ADDPRINTPROCESSOR q_u;
902         SPOOL_R_ADDPRINTPROCESSOR r_u;
903         prs_struct *data = &p->in_data.data;
904         prs_struct *rdata = &p->out_data.rdata;
905
906         ZERO_STRUCT(q_u);
907         ZERO_STRUCT(r_u);
908         
909         if(!spoolss_io_q_addprintprocessor("", &q_u, data, 0)) {
910                 DEBUG(0,("spoolss_io_q_addprintprocessor: unable to unmarshall SPOOL_Q_ADDPRINTPROCESSOR.\n"));
911                 return False;
912         }
913         
914         /* for now, just indicate success and ignore the add.  We'll
915            automatically set the winprint processor for printer
916            entries later.  Used to debug the LexMark Optra S 1855 PCL
917            driver --jerry */
918         r_u.status = WERR_OK;
919
920         if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) {
921                 DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n"));
922                 return False;
923         }
924         
925         return True;
926 }
927
928 /****************************************************************************
929 ****************************************************************************/
930
931 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
932 {
933         SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
934         SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
935         prs_struct *data = &p->in_data.data;
936         prs_struct *rdata = &p->out_data.rdata;
937
938         ZERO_STRUCT(q_u);
939         ZERO_STRUCT(r_u);
940         
941         if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
942                 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
943                 return False;
944         }
945         
946         r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
947
948         if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
949                 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
950                 return False;
951         }
952         
953         return True;
954 }
955
956 /****************************************************************************
957 ****************************************************************************/
958
959 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
960 {
961         SPOOL_Q_ENUMPRINTMONITORS q_u;
962         SPOOL_R_ENUMPRINTMONITORS r_u;
963         prs_struct *data = &p->in_data.data;
964         prs_struct *rdata = &p->out_data.rdata;
965
966         ZERO_STRUCT(q_u);
967         ZERO_STRUCT(r_u);
968         
969         if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
970                 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
971                 return False;
972         }
973                 
974         r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
975
976         if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
977                 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
978                 return False;
979         }
980         
981         return True;
982 }
983
984 /****************************************************************************
985 ****************************************************************************/
986
987 static bool api_spoolss_getjob(pipes_struct *p)
988 {
989         SPOOL_Q_GETJOB q_u;
990         SPOOL_R_GETJOB r_u;
991         prs_struct *data = &p->in_data.data;
992         prs_struct *rdata = &p->out_data.rdata;
993         
994         ZERO_STRUCT(q_u);
995         ZERO_STRUCT(r_u);
996         
997         if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
998                 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
999                 return False;
1000         }
1001
1002         r_u.status = _spoolss_getjob(p, &q_u, &r_u);
1003         
1004         if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1005                 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1006                 return False;
1007         }
1008                 
1009         return True;
1010 }
1011
1012 /********************************************************************
1013  * api_spoolss_getprinterdataex
1014  *
1015  * called from the spoolss dispatcher
1016  ********************************************************************/
1017
1018 static bool api_spoolss_getprinterdataex(pipes_struct *p)
1019 {
1020         SPOOL_Q_GETPRINTERDATAEX q_u;
1021         SPOOL_R_GETPRINTERDATAEX r_u;
1022         prs_struct *data = &p->in_data.data;
1023         prs_struct *rdata = &p->out_data.rdata;
1024
1025         ZERO_STRUCT(q_u);
1026         ZERO_STRUCT(r_u);
1027
1028         /* read the stream and fill the struct */
1029         if (!spoolss_io_q_getprinterdataex("", &q_u, data, 0)) {
1030                 DEBUG(0,("spoolss_io_q_getprinterdataex: unable to unmarshall SPOOL_Q_GETPRINTERDATAEX.\n"));
1031                 return False;
1032         }
1033         
1034         r_u.status = _spoolss_getprinterdataex( p, &q_u, &r_u);
1035
1036         if (!spoolss_io_r_getprinterdataex("", &r_u, rdata, 0)) {
1037                 DEBUG(0,("spoolss_io_r_getprinterdataex: unable to marshall SPOOL_R_GETPRINTERDATAEX.\n"));
1038                 return False;
1039         }
1040
1041         return True;
1042 }
1043
1044 /****************************************************************************
1045 ****************************************************************************/
1046
1047 static bool api_spoolss_setprinterdataex(pipes_struct *p)
1048 {
1049         SPOOL_Q_SETPRINTERDATAEX q_u;
1050         SPOOL_R_SETPRINTERDATAEX r_u;
1051         prs_struct *data = &p->in_data.data;
1052         prs_struct *rdata = &p->out_data.rdata;
1053         
1054         ZERO_STRUCT(q_u);
1055         ZERO_STRUCT(r_u);
1056         
1057         if(!spoolss_io_q_setprinterdataex("", &q_u, data, 0)) {
1058                 DEBUG(0,("spoolss_io_q_setprinterdataex: unable to unmarshall SPOOL_Q_SETPRINTERDATAEX.\n"));
1059                 return False;
1060         }
1061         
1062         r_u.status = _spoolss_setprinterdataex(p, &q_u, &r_u);
1063                                 
1064         if(!spoolss_io_r_setprinterdataex("", &r_u, rdata, 0)) {
1065                 DEBUG(0,("spoolss_io_r_setprinterdataex: unable to marshall SPOOL_R_SETPRINTERDATAEX.\n"));
1066                 return False;
1067         }
1068
1069         return True;
1070 }
1071
1072
1073 /****************************************************************************
1074 ****************************************************************************/
1075
1076 static bool api_spoolss_enumprinterkey(pipes_struct *p)
1077 {
1078         SPOOL_Q_ENUMPRINTERKEY q_u;
1079         SPOOL_R_ENUMPRINTERKEY r_u;
1080         prs_struct *data = &p->in_data.data;
1081         prs_struct *rdata = &p->out_data.rdata;
1082         
1083         ZERO_STRUCT(q_u);
1084         ZERO_STRUCT(r_u);
1085         
1086         if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
1087                 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
1088                 return False;
1089         }
1090         
1091         r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
1092                                 
1093         if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
1094                 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
1095                 return False;
1096         }
1097
1098         return True;
1099 }
1100
1101 /****************************************************************************
1102 ****************************************************************************/
1103
1104 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
1105 {
1106         SPOOL_Q_ENUMPRINTERDATAEX q_u;
1107         SPOOL_R_ENUMPRINTERDATAEX r_u;
1108         prs_struct *data = &p->in_data.data;
1109         prs_struct *rdata = &p->out_data.rdata;
1110         
1111         ZERO_STRUCT(q_u);
1112         ZERO_STRUCT(r_u);
1113         
1114         if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
1115                 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
1116                 return False;
1117         }
1118         
1119         r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
1120                                 
1121         if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
1122                 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
1123                 return False;
1124         }
1125
1126         return True;
1127 }
1128
1129 /****************************************************************************
1130 ****************************************************************************/
1131
1132 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
1133 {
1134         SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u;
1135         SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u;
1136         prs_struct *data = &p->in_data.data;
1137         prs_struct *rdata = &p->out_data.rdata;
1138         
1139         ZERO_STRUCT(q_u);
1140         ZERO_STRUCT(r_u);
1141         
1142         if(!spoolss_io_q_getprintprocessordirectory("", &q_u, data, 0)) {
1143                 DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n"));
1144                 return False;
1145         }
1146         
1147         r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
1148                                 
1149         if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) {
1150                 DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n"));
1151                 return False;
1152         }
1153         
1154         return True;
1155 }
1156
1157 /****************************************************************************
1158 ****************************************************************************/
1159
1160 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
1161 {
1162         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATAEX);
1163 }
1164
1165 /****************************************************************************
1166 ****************************************************************************/
1167
1168 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
1169 {
1170         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERKEY);
1171 }
1172
1173 /****************************************************************************
1174 ****************************************************************************/
1175
1176 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
1177 {
1178         SPOOL_Q_ADDPRINTERDRIVEREX q_u;
1179         SPOOL_R_ADDPRINTERDRIVEREX r_u;
1180         prs_struct *data = &p->in_data.data;
1181         prs_struct *rdata = &p->out_data.rdata;
1182         
1183         ZERO_STRUCT(q_u);
1184         ZERO_STRUCT(r_u);
1185         
1186         if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) {
1187                 if (q_u.level != 3 && q_u.level != 6) {
1188                         /* Clever hack from Martin Zielinski <mz@seh.de>
1189                          * to allow downgrade from level 8 (Vista).
1190                          */
1191                         DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n",
1192                                 (unsigned int)q_u.level ));
1193                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
1194                         return True;
1195                 }
1196                 DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
1197                 return False;
1198         }
1199         
1200         r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
1201                                 
1202         if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) {
1203                 DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n"));
1204                 return False;
1205         }
1206         
1207         return True;
1208 }
1209
1210 /****************************************************************************
1211 ****************************************************************************/
1212
1213 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
1214 {
1215         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVEREX);
1216 }
1217
1218 /****************************************************************************
1219 ****************************************************************************/
1220
1221 static bool api_spoolss_xcvdataport(pipes_struct *p)
1222 {
1223         SPOOL_Q_XCVDATAPORT q_u;
1224         SPOOL_R_XCVDATAPORT r_u;
1225         prs_struct *data = &p->in_data.data;
1226         prs_struct *rdata = &p->out_data.rdata;
1227         
1228         ZERO_STRUCT(q_u);
1229         ZERO_STRUCT(r_u);
1230         
1231         if(!spoolss_io_q_xcvdataport("", &q_u, data, 0)) {
1232                 DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_XCVDATAPORT.\n"));
1233                 return False;
1234         }
1235         
1236         r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u);
1237                                 
1238         if(!spoolss_io_r_xcvdataport("", &r_u, rdata, 0)) {
1239                 DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_XCVDATAPORT.\n"));
1240                 return False;
1241         }
1242         
1243         return True;
1244 }
1245
1246 /*******************************************************************
1247 \pipe\spoolss commands
1248 ********************************************************************/
1249
1250   struct api_struct api_spoolss_cmds[] = 
1251     {
1252  {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
1253  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
1254  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
1255  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
1256  {"SPOOLSS_DELETEPRINTER",             SPOOLSS_DELETEPRINTER,             api_spoolss_deleteprinter             },
1257  {"SPOOLSS_ABORTPRINTER",              SPOOLSS_ABORTPRINTER,              api_spoolss_abortprinter              },
1258  {"SPOOLSS_RFFPCNEX",                  SPOOLSS_RFFPCNEX,                  api_spoolss_rffpcnex                  },
1259  {"SPOOLSS_RFNPCNEX",                  SPOOLSS_RFNPCNEX,                  api_spoolss_rfnpcnex                  },
1260  {"SPOOLSS_ENUMPRINTERS",              SPOOLSS_ENUMPRINTERS,              api_spoolss_enumprinters              },
1261  {"SPOOLSS_GETPRINTER",                SPOOLSS_GETPRINTER,                api_spoolss_getprinter                },
1262  {"SPOOLSS_GETPRINTERDRIVER2",         SPOOLSS_GETPRINTERDRIVER2,         api_spoolss_getprinterdriver2         }, 
1263  {"SPOOLSS_STARTPAGEPRINTER",          SPOOLSS_STARTPAGEPRINTER,          api_spoolss_startpageprinter          },
1264  {"SPOOLSS_ENDPAGEPRINTER",            SPOOLSS_ENDPAGEPRINTER,            api_spoolss_endpageprinter            }, 
1265  {"SPOOLSS_STARTDOCPRINTER",           SPOOLSS_STARTDOCPRINTER,           api_spoolss_startdocprinter           },
1266  {"SPOOLSS_ENDDOCPRINTER",             SPOOLSS_ENDDOCPRINTER,             api_spoolss_enddocprinter             },
1267  {"SPOOLSS_WRITEPRINTER",              SPOOLSS_WRITEPRINTER,              api_spoolss_writeprinter              },
1268  {"SPOOLSS_SETPRINTER",                SPOOLSS_SETPRINTER,                api_spoolss_setprinter                },
1269  {"SPOOLSS_FCPN",                      SPOOLSS_FCPN,                      api_spoolss_fcpn                      },
1270  {"SPOOLSS_ADDJOB",                    SPOOLSS_ADDJOB,                    api_spoolss_addjob                    },
1271  {"SPOOLSS_ENUMJOBS",                  SPOOLSS_ENUMJOBS,                  api_spoolss_enumjobs                  },
1272  {"SPOOLSS_SCHEDULEJOB",               SPOOLSS_SCHEDULEJOB,               api_spoolss_schedulejob               },
1273  {"SPOOLSS_SETJOB",                    SPOOLSS_SETJOB,                    api_spoolss_setjob                    },
1274  {"SPOOLSS_ENUMFORMS",                 SPOOLSS_ENUMFORMS,                 api_spoolss_enumforms                 },
1275  {"SPOOLSS_ENUMPORTS",                 SPOOLSS_ENUMPORTS,                 api_spoolss_enumports                 },
1276  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
1277  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
1278  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
1279  {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
1280  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1281  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
1282  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
1283  {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
1284  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
1285  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
1286  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
1287  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
1288  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
1289  {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
1290  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
1291  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
1292  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
1293  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
1294  {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
1295  {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
1296  {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
1297  {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
1298  {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
1299  {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
1300  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
1301  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
1302  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
1303  {"SPOOLSS_XCVDATAPORT",               SPOOLSS_XCVDATAPORT,               api_spoolss_xcvdataport               },
1304 };
1305
1306 void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns )
1307 {
1308         *fns = api_spoolss_cmds;
1309         *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
1310 }
1311
1312 NTSTATUS rpc_spoolss2_init(void)
1313 {
1314         return rpc_srv_register(
1315                 SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss",
1316                 &ndr_table_spoolss,
1317                 api_spoolss_cmds,
1318                 sizeof(api_spoolss_cmds) / sizeof(struct api_struct));
1319 }