Refactoring: Change calling conventions for cli_rpc_pipe_open_noauth
[kamenim/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  * api_spoolss_open_printer_ex (rarely seen - older call)
32  ********************************************************************/
33
34 static bool api_spoolss_open_printer(pipes_struct *p)
35 {
36         SPOOL_Q_OPEN_PRINTER q_u;
37         SPOOL_R_OPEN_PRINTER r_u;
38         prs_struct *data = &p->in_data.data;
39         prs_struct *rdata = &p->out_data.rdata;
40
41         ZERO_STRUCT(q_u);
42         ZERO_STRUCT(r_u);
43
44         if (!spoolss_io_q_open_printer("", &q_u, data, 0)) {
45                 DEBUG(0,("spoolss_io_q_open_printer: unable to unmarshall SPOOL_Q_OPEN_PRINTER.\n"));
46                 return False;
47         }
48
49         r_u.status = _spoolss_open_printer( p, &q_u, &r_u);
50         
51         if (!spoolss_io_r_open_printer("",&r_u,rdata,0)){
52                 DEBUG(0,("spoolss_io_r_open_printer: unable to marshall SPOOL_R_OPEN_PRINTER.\n"));
53                 return False;
54         }
55
56         return True;
57 }
58
59
60 /********************************************************************
61  * api_spoolss_open_printer_ex
62  ********************************************************************/
63
64 static bool api_spoolss_open_printer_ex(pipes_struct *p)
65 {
66         SPOOL_Q_OPEN_PRINTER_EX q_u;
67         SPOOL_R_OPEN_PRINTER_EX r_u;
68         prs_struct *data = &p->in_data.data;
69         prs_struct *rdata = &p->out_data.rdata;
70
71         ZERO_STRUCT(q_u);
72         ZERO_STRUCT(r_u);
73
74         if (!spoolss_io_q_open_printer_ex("", &q_u, data, 0)) {
75                 DEBUG(0,("spoolss_io_q_open_printer_ex: unable to unmarshall SPOOL_Q_OPEN_PRINTER_EX.\n"));
76                 return False;
77         }
78
79         r_u.status = _spoolss_open_printer_ex( p, &q_u, &r_u);
80
81         if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){
82                 DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n"));
83                 return False;
84         }
85
86         return True;
87 }
88
89 /********************************************************************
90  * api_spoolss_getprinterdata
91  *
92  * called from the spoolss dispatcher
93  ********************************************************************/
94
95 static bool api_spoolss_getprinterdata(pipes_struct *p)
96 {
97         SPOOL_Q_GETPRINTERDATA q_u;
98         SPOOL_R_GETPRINTERDATA r_u;
99         prs_struct *data = &p->in_data.data;
100         prs_struct *rdata = &p->out_data.rdata;
101
102         ZERO_STRUCT(q_u);
103         ZERO_STRUCT(r_u);
104
105         /* read the stream and fill the struct */
106         if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) {
107                 DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n"));
108                 return False;
109         }
110         
111         r_u.status = _spoolss_getprinterdata( p, &q_u, &r_u);
112
113         if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) {
114                 DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n"));
115                 return False;
116         }
117
118         return True;
119 }
120
121 /********************************************************************
122  * api_spoolss_deleteprinterdata
123  *
124  * called from the spoolss dispatcher
125  ********************************************************************/
126
127 static bool api_spoolss_deleteprinterdata(pipes_struct *p)
128 {
129         SPOOL_Q_DELETEPRINTERDATA q_u;
130         SPOOL_R_DELETEPRINTERDATA r_u;
131         prs_struct *data = &p->in_data.data;
132         prs_struct *rdata = &p->out_data.rdata;
133
134         ZERO_STRUCT(q_u);
135         ZERO_STRUCT(r_u);
136
137         /* read the stream and fill the struct */
138         if (!spoolss_io_q_deleteprinterdata("", &q_u, data, 0)) {
139                 DEBUG(0,("spoolss_io_q_deleteprinterdata: unable to unmarshall SPOOL_Q_DELETEPRINTERDATA.\n"));
140                 return False;
141         }
142         
143         r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u );
144
145         if (!spoolss_io_r_deleteprinterdata("", &r_u, rdata, 0)) {
146                 DEBUG(0,("spoolss_io_r_deleteprinterdata: unable to marshall SPOOL_R_DELETEPRINTERDATA.\n"));
147                 return False;
148         }
149
150         return True;
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         SPOOL_Q_CLOSEPRINTER q_u;
162         SPOOL_R_CLOSEPRINTER r_u;
163         prs_struct *data = &p->in_data.data;
164         prs_struct *rdata = &p->out_data.rdata;
165
166         ZERO_STRUCT(q_u);
167         ZERO_STRUCT(r_u);
168
169         if (!spoolss_io_q_closeprinter("", &q_u, data, 0)) {
170                 DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n"));
171                 return False;
172         }
173
174         r_u.status = _spoolss_closeprinter(p, &q_u, &r_u);
175
176         if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) {
177                 DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n"));
178                 return False;
179         }
180
181         return True;
182 }
183
184 /********************************************************************
185  * api_spoolss_abortprinter
186  *
187  * called from the spoolss dispatcher
188  ********************************************************************/
189
190 static bool api_spoolss_abortprinter(pipes_struct *p)
191 {
192         SPOOL_Q_ABORTPRINTER q_u;
193         SPOOL_R_ABORTPRINTER r_u;
194         prs_struct *data = &p->in_data.data;
195         prs_struct *rdata = &p->out_data.rdata;
196
197         ZERO_STRUCT(q_u);
198         ZERO_STRUCT(r_u);
199
200         if (!spoolss_io_q_abortprinter("", &q_u, data, 0)) {
201                 DEBUG(0,("spoolss_io_q_abortprinter: unable to unmarshall SPOOL_Q_ABORTPRINTER.\n"));
202                 return False;
203         }
204
205         r_u.status = _spoolss_abortprinter(p, &q_u, &r_u);
206
207         if (!spoolss_io_r_abortprinter("",&r_u,rdata,0)) {
208                 DEBUG(0,("spoolss_io_r_abortprinter: unable to marshall SPOOL_R_ABORTPRINTER.\n"));
209                 return False;
210         }
211
212         return True;
213 }
214
215 /********************************************************************
216  * api_spoolss_deleteprinter
217  *
218  * called from the spoolss dispatcher
219  ********************************************************************/
220
221 static bool api_spoolss_deleteprinter(pipes_struct *p)
222 {
223         SPOOL_Q_DELETEPRINTER q_u;
224         SPOOL_R_DELETEPRINTER r_u;
225         prs_struct *data = &p->in_data.data;
226         prs_struct *rdata = &p->out_data.rdata;
227
228         ZERO_STRUCT(q_u);
229         ZERO_STRUCT(r_u);
230
231         if (!spoolss_io_q_deleteprinter("", &q_u, data, 0)) {
232                 DEBUG(0,("spoolss_io_q_deleteprinter: unable to unmarshall SPOOL_Q_DELETEPRINTER.\n"));
233                 return False;
234         }
235
236         r_u.status = _spoolss_deleteprinter(p, &q_u, &r_u);
237
238         if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) {
239                 DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
240                 return False;
241         }
242
243         return True;
244 }
245
246
247 /********************************************************************
248  * api_spoolss_deleteprinterdriver
249  *
250  * called from the spoolss dispatcher
251  ********************************************************************/
252
253 static bool api_spoolss_deleteprinterdriver(pipes_struct *p)
254 {
255         SPOOL_Q_DELETEPRINTERDRIVER q_u;
256         SPOOL_R_DELETEPRINTERDRIVER r_u;
257         prs_struct *data = &p->in_data.data;
258         prs_struct *rdata = &p->out_data.rdata;
259
260         ZERO_STRUCT(q_u);
261         ZERO_STRUCT(r_u);
262
263         if (!spoolss_io_q_deleteprinterdriver("", &q_u, data, 0)) {
264                 DEBUG(0,("spoolss_io_q_deleteprinterdriver: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVER.\n"));
265                 return False;
266         }
267
268         r_u.status = _spoolss_deleteprinterdriver(p, &q_u, &r_u);
269
270         if (!spoolss_io_r_deleteprinterdriver("",&r_u,rdata,0)) {
271                 DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
272                 return False;
273         }
274
275         return True;
276 }
277
278
279 /********************************************************************
280  * api_spoolss_rffpcnex
281  * ReplyFindFirstPrinterChangeNotifyEx
282  ********************************************************************/
283
284 static bool api_spoolss_rffpcnex(pipes_struct *p)
285 {
286         SPOOL_Q_RFFPCNEX q_u;
287         SPOOL_R_RFFPCNEX r_u;
288         prs_struct *data = &p->in_data.data;
289         prs_struct *rdata = &p->out_data.rdata;
290
291         ZERO_STRUCT(q_u);
292         ZERO_STRUCT(r_u);
293
294         if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
295                 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
296                 return False;
297         }
298
299         r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u);
300
301         if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
302                 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
303                 return False;
304         }
305
306         return True;
307 }
308
309
310 /********************************************************************
311  * api_spoolss_rfnpcnex
312  * ReplyFindNextPrinterChangeNotifyEx
313  * called from the spoolss dispatcher
314
315  * Note - this is the *ONLY* function that breaks the RPC call
316  * symmetry in all the other calls. We need to do this to fix
317  * the massive memory allocation problem with thousands of jobs...
318  * JRA.
319  ********************************************************************/
320
321 static bool api_spoolss_rfnpcnex(pipes_struct *p)
322 {
323         SPOOL_Q_RFNPCNEX q_u;
324         SPOOL_R_RFNPCNEX r_u;
325         prs_struct *data = &p->in_data.data;
326         prs_struct *rdata = &p->out_data.rdata;
327
328         ZERO_STRUCT(q_u);
329         ZERO_STRUCT(r_u);
330
331         if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
332                 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
333                 return False;
334         }
335
336         r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u);
337
338         if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
339                 SAFE_FREE(r_u.info.data);
340                 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
341                 return False;
342         }
343
344         SAFE_FREE(r_u.info.data);
345
346         return True;
347 }
348
349
350 /********************************************************************
351  * api_spoolss_enumprinters
352  * called from the spoolss dispatcher
353  *
354  ********************************************************************/
355
356 static bool api_spoolss_enumprinters(pipes_struct *p)
357 {
358         SPOOL_Q_ENUMPRINTERS q_u;
359         SPOOL_R_ENUMPRINTERS r_u;
360         prs_struct *data = &p->in_data.data;
361         prs_struct *rdata = &p->out_data.rdata;
362
363         ZERO_STRUCT(q_u);
364         ZERO_STRUCT(r_u);
365
366         if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
367                 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
368                 return False;
369         }
370
371         r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
372
373         if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
374                 DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
375                 return False;
376         }
377
378         return True;
379 }
380
381 /********************************************************************
382  * api_spoolss_getprinter
383  * called from the spoolss dispatcher
384  *
385  ********************************************************************/
386
387 static bool api_spoolss_getprinter(pipes_struct *p)
388 {
389         SPOOL_Q_GETPRINTER q_u;
390         SPOOL_R_GETPRINTER 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_getprinter("", &q_u, data, 0)) {
398                 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
399                 return False;
400         }
401
402         r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
403
404         if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
405                 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
406                 return False;
407         }
408
409         return True;
410 }
411
412 /********************************************************************
413  * api_spoolss_getprinter
414  * called from the spoolss dispatcher
415  *
416  ********************************************************************/
417
418 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
419 {
420         SPOOL_Q_GETPRINTERDRIVER2 q_u;
421         SPOOL_R_GETPRINTERDRIVER2 r_u;
422         prs_struct *data = &p->in_data.data;
423         prs_struct *rdata = &p->out_data.rdata;
424
425         ZERO_STRUCT(q_u);
426         ZERO_STRUCT(r_u);
427
428         if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
429                 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
430                 return False;
431         }
432
433         r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
434         
435         if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
436                 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
437                 return False;
438         }
439         
440         return True;
441 }
442
443 /********************************************************************
444  * api_spoolss_getprinter
445  * called from the spoolss dispatcher
446  *
447  ********************************************************************/
448
449 static bool api_spoolss_startpageprinter(pipes_struct *p)
450 {
451         SPOOL_Q_STARTPAGEPRINTER q_u;
452         SPOOL_R_STARTPAGEPRINTER r_u;
453         prs_struct *data = &p->in_data.data;
454         prs_struct *rdata = &p->out_data.rdata;
455
456         ZERO_STRUCT(q_u);
457         ZERO_STRUCT(r_u);
458
459         if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) {
460                 DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n"));
461                 return False;
462         }
463
464         r_u.status = _spoolss_startpageprinter(p, &q_u, &r_u);
465
466         if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) {
467                 DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n"));
468                 return False;
469         }
470
471         return True;
472 }
473
474 /********************************************************************
475  * api_spoolss_getprinter
476  * called from the spoolss dispatcher
477  *
478  ********************************************************************/
479
480 static bool api_spoolss_endpageprinter(pipes_struct *p)
481 {
482         SPOOL_Q_ENDPAGEPRINTER q_u;
483         SPOOL_R_ENDPAGEPRINTER 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_endpageprinter("", &q_u, data, 0)) {
491                 DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n"));
492                 return False;
493         }
494
495         r_u.status = _spoolss_endpageprinter(p, &q_u, &r_u);
496
497         if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) {
498                 DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n"));
499                 return False;
500         }
501
502         return True;
503 }
504
505 /********************************************************************
506 ********************************************************************/
507
508 static bool api_spoolss_startdocprinter(pipes_struct *p)
509 {
510         SPOOL_Q_STARTDOCPRINTER q_u;
511         SPOOL_R_STARTDOCPRINTER 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_startdocprinter("", &q_u, data, 0)) {
519                 DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
520                 return False;
521         }
522
523         r_u.status = _spoolss_startdocprinter(p, &q_u, &r_u);
524
525         if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
526                 DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
527                 return False;
528         }
529
530         return True;
531 }
532
533 /********************************************************************
534 ********************************************************************/
535
536 static bool api_spoolss_enddocprinter(pipes_struct *p)
537 {
538         SPOOL_Q_ENDDOCPRINTER q_u;
539         SPOOL_R_ENDDOCPRINTER 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_enddocprinter("", &q_u, data, 0)) {
547                 DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n"));
548                 return False;
549         }
550
551         r_u.status = _spoolss_enddocprinter(p, &q_u, &r_u);
552
553         if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) {
554                 DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n"));
555                 return False;
556         }
557
558         return True;            
559 }
560
561 /********************************************************************
562 ********************************************************************/
563
564 static bool api_spoolss_writeprinter(pipes_struct *p)
565 {
566         SPOOL_Q_WRITEPRINTER q_u;
567         SPOOL_R_WRITEPRINTER 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_writeprinter("", &q_u, data, 0)) {
575                 DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n"));
576                 return False;
577         }
578
579         r_u.status = _spoolss_writeprinter(p, &q_u, &r_u);
580
581         if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) {
582                 DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n"));
583                 return False;
584         }
585
586         return True;
587 }
588
589 /****************************************************************************
590
591 ****************************************************************************/
592
593 static bool api_spoolss_setprinter(pipes_struct *p)
594 {
595         SPOOL_Q_SETPRINTER q_u;
596         SPOOL_R_SETPRINTER r_u;
597         prs_struct *data = &p->in_data.data;
598         prs_struct *rdata = &p->out_data.rdata;
599
600         ZERO_STRUCT(q_u);
601         ZERO_STRUCT(r_u);
602
603         if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
604                 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
605                 return False;
606         }
607         
608         r_u.status = _spoolss_setprinter(p, &q_u, &r_u);
609         
610         if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
611                 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
612                 return False;
613         }
614
615         return True;
616 }
617
618 /****************************************************************************
619 ****************************************************************************/
620
621 static bool api_spoolss_fcpn(pipes_struct *p)
622 {
623         SPOOL_Q_FCPN q_u;
624         SPOOL_R_FCPN r_u;
625         prs_struct *data = &p->in_data.data;
626         prs_struct *rdata = &p->out_data.rdata;
627
628         ZERO_STRUCT(q_u);
629         ZERO_STRUCT(r_u);
630
631         if(!spoolss_io_q_fcpn("", &q_u, data, 0)) {
632                 DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n"));
633                 return False;
634         }
635
636         r_u.status = _spoolss_fcpn(p, &q_u, &r_u);
637
638         if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) {
639                 DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n"));
640                 return False;
641         }
642
643         return True;
644 }
645
646 /****************************************************************************
647 ****************************************************************************/
648
649 static bool api_spoolss_addjob(pipes_struct *p)
650 {
651         SPOOL_Q_ADDJOB q_u;
652         SPOOL_R_ADDJOB r_u;
653         prs_struct *data = &p->in_data.data;
654         prs_struct *rdata = &p->out_data.rdata;
655
656         ZERO_STRUCT(q_u);
657         ZERO_STRUCT(r_u);
658
659         if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
660                 DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
661                 return False;
662         }
663
664         r_u.status = _spoolss_addjob(p, &q_u, &r_u);
665                 
666         if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
667                 DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
668                 return False;
669         }
670
671         return True;            
672 }
673
674 /****************************************************************************
675 ****************************************************************************/
676
677 static bool api_spoolss_enumjobs(pipes_struct *p)
678 {
679         SPOOL_Q_ENUMJOBS q_u;
680         SPOOL_R_ENUMJOBS r_u;
681         prs_struct *data = &p->in_data.data;
682         prs_struct *rdata = &p->out_data.rdata;
683
684         ZERO_STRUCT(q_u);
685         ZERO_STRUCT(r_u);
686
687         if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
688                 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
689                 return False;
690         }
691
692         r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
693
694         if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
695                 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
696                 return False;
697         }
698
699         return True;
700 }
701
702 /****************************************************************************
703 ****************************************************************************/
704
705 static bool api_spoolss_schedulejob(pipes_struct *p)
706 {
707         SPOOL_Q_SCHEDULEJOB q_u;
708         SPOOL_R_SCHEDULEJOB r_u;
709         prs_struct *data = &p->in_data.data;
710         prs_struct *rdata = &p->out_data.rdata;
711
712         ZERO_STRUCT(q_u);
713         ZERO_STRUCT(r_u);
714
715         if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
716                 DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
717                 return False;
718         }
719
720         r_u.status = _spoolss_schedulejob(p, &q_u, &r_u);
721
722         if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
723                 DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
724                 return False;
725         }
726
727         return True;
728 }
729
730 /****************************************************************************
731 ****************************************************************************/
732
733 static bool api_spoolss_setjob(pipes_struct *p)
734 {
735         SPOOL_Q_SETJOB q_u;
736         SPOOL_R_SETJOB r_u;
737         prs_struct *data = &p->in_data.data;
738         prs_struct *rdata = &p->out_data.rdata;
739
740         ZERO_STRUCT(q_u);
741         ZERO_STRUCT(r_u);
742
743         if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
744                 DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
745                 return False;
746         }
747
748         r_u.status = _spoolss_setjob(p, &q_u, &r_u);
749
750         if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
751                 DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
752                 return False;
753         }
754
755         return True;
756 }
757
758 /****************************************************************************
759 ****************************************************************************/
760
761 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
762 {
763         SPOOL_Q_ENUMPRINTERDRIVERS q_u;
764         SPOOL_R_ENUMPRINTERDRIVERS r_u;
765         prs_struct *data = &p->in_data.data;
766         prs_struct *rdata = &p->out_data.rdata;
767
768         ZERO_STRUCT(q_u);
769         ZERO_STRUCT(r_u);
770
771         if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
772                 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
773                 return False;
774         }
775
776         r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
777
778         if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
779                 DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
780                 return False;
781         }
782
783         return True;
784 }
785
786 /****************************************************************************
787 ****************************************************************************/
788
789 static bool api_spoolss_getform(pipes_struct *p)
790 {
791         SPOOL_Q_GETFORM q_u;
792         SPOOL_R_GETFORM r_u;
793         prs_struct *data = &p->in_data.data;
794         prs_struct *rdata = &p->out_data.rdata;
795
796         ZERO_STRUCT(q_u);
797         ZERO_STRUCT(r_u);
798
799         if (!spoolss_io_q_getform("", &q_u, data, 0)) {
800                 DEBUG(0,("spoolss_io_q_getform: unable to unmarshall SPOOL_Q_GETFORM.\n"));
801                 return False;
802         }
803
804         r_u.status = _spoolss_getform(p, &q_u, &r_u);
805
806         if (!spoolss_io_r_getform("",&r_u,rdata,0)) {
807                 DEBUG(0,("spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n"));
808                 return False;
809         }
810
811         return True;
812 }
813
814 /****************************************************************************
815 ****************************************************************************/
816
817 static bool api_spoolss_enumforms(pipes_struct *p)
818 {
819         SPOOL_Q_ENUMFORMS q_u;
820         SPOOL_R_ENUMFORMS r_u;
821         prs_struct *data = &p->in_data.data;
822         prs_struct *rdata = &p->out_data.rdata;
823
824         ZERO_STRUCT(q_u);
825         ZERO_STRUCT(r_u);
826
827         if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
828                 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
829                 return False;
830         }
831
832         r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
833
834         if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
835                 DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
836                 return False;
837         }
838
839         return True;
840 }
841
842 /****************************************************************************
843 ****************************************************************************/
844
845 static bool api_spoolss_enumports(pipes_struct *p)
846 {
847         SPOOL_Q_ENUMPORTS q_u;
848         SPOOL_R_ENUMPORTS r_u;
849         prs_struct *data = &p->in_data.data;
850         prs_struct *rdata = &p->out_data.rdata;
851
852         ZERO_STRUCT(q_u);
853         ZERO_STRUCT(r_u);
854
855         if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
856                 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
857                 return False;
858         }
859
860         r_u.status = _spoolss_enumports(p, &q_u, &r_u);
861
862         if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
863                 DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
864                 return False;
865         }
866
867         return True;
868 }
869
870 /****************************************************************************
871 ****************************************************************************/
872
873 static bool api_spoolss_addprinterex(pipes_struct *p)
874 {
875         SPOOL_Q_ADDPRINTEREX q_u;
876         SPOOL_R_ADDPRINTEREX r_u;
877         prs_struct *data = &p->in_data.data;
878         prs_struct *rdata = &p->out_data.rdata;
879         
880         ZERO_STRUCT(q_u);
881         ZERO_STRUCT(r_u);
882         
883         if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
884                 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
885                 return False;
886         }
887         
888         r_u.status = _spoolss_addprinterex(p, &q_u, &r_u);
889                                 
890         if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
891                 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
892                 return False;
893         }
894         
895         return True;
896 }
897
898 /****************************************************************************
899 ****************************************************************************/
900
901 static bool api_spoolss_addprinterdriver(pipes_struct *p)
902 {
903         SPOOL_Q_ADDPRINTERDRIVER q_u;
904         SPOOL_R_ADDPRINTERDRIVER r_u;
905         prs_struct *data = &p->in_data.data;
906         prs_struct *rdata = &p->out_data.rdata;
907         
908         ZERO_STRUCT(q_u);
909         ZERO_STRUCT(r_u);
910         
911         if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
912                 if (q_u.level != 3 && q_u.level != 6) {
913                         /* Clever hack from Martin Zielinski <mz@seh.de>
914                          * to allow downgrade from level 8 (Vista).
915                          */
916                         DEBUG(3,("api_spoolss_addprinterdriver: unknown SPOOL_Q_ADDPRINTERDRIVER level %u.\n",
917                                 (unsigned int)q_u.level ));
918                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
919                         return True;
920                 }
921                 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
922                 return False;
923         }
924         
925         r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u);
926                                 
927         if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
928                 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
929                 return False;
930         }
931         
932         return True;
933 }
934
935 /****************************************************************************
936 ****************************************************************************/
937
938 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
939 {
940         SPOOL_Q_GETPRINTERDRIVERDIR q_u;
941         SPOOL_R_GETPRINTERDRIVERDIR r_u;
942         prs_struct *data = &p->in_data.data;
943         prs_struct *rdata = &p->out_data.rdata;
944
945         ZERO_STRUCT(q_u);
946         ZERO_STRUCT(r_u);
947
948         if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
949                 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
950                 return False;
951         }
952
953         r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
954
955         if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
956                 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
957                 return False;
958         }
959
960         return True;
961 }
962
963 /****************************************************************************
964 ****************************************************************************/
965
966 static bool api_spoolss_enumprinterdata(pipes_struct *p)
967 {
968         SPOOL_Q_ENUMPRINTERDATA q_u;
969         SPOOL_R_ENUMPRINTERDATA r_u;
970         prs_struct *data = &p->in_data.data;
971         prs_struct *rdata = &p->out_data.rdata;
972         
973         ZERO_STRUCT(q_u);
974         ZERO_STRUCT(r_u);
975         
976         if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
977                 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
978                 return False;
979         }
980         
981         r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
982                                 
983         if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
984                 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
985                 return False;
986         }
987
988         return True;
989 }
990
991 /****************************************************************************
992 ****************************************************************************/
993
994 static bool api_spoolss_setprinterdata(pipes_struct *p)
995 {
996         SPOOL_Q_SETPRINTERDATA q_u;
997         SPOOL_R_SETPRINTERDATA r_u;
998         prs_struct *data = &p->in_data.data;
999         prs_struct *rdata = &p->out_data.rdata;
1000         
1001         ZERO_STRUCT(q_u);
1002         ZERO_STRUCT(r_u);
1003         
1004         if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
1005                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
1006                 return False;
1007         }
1008         
1009         r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
1010                                 
1011         if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
1012                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
1013                 return False;
1014         }
1015
1016         return True;
1017 }
1018
1019 /****************************************************************************
1020 ****************************************************************************/
1021 static bool api_spoolss_reset_printer(pipes_struct *p)
1022 {
1023         SPOOL_Q_RESETPRINTER q_u;
1024         SPOOL_R_RESETPRINTER r_u;
1025         prs_struct *data = &p->in_data.data;
1026         prs_struct *rdata = &p->out_data.rdata;
1027
1028         ZERO_STRUCT(q_u);
1029         ZERO_STRUCT(r_u);
1030
1031         if(!spoolss_io_q_resetprinter("", &q_u, data, 0)) {
1032                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
1033                 return False;
1034         }
1035         
1036         r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
1037
1038         if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) {
1039                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n"));
1040                 return False;
1041         }
1042
1043         return True;
1044 }
1045
1046 /****************************************************************************
1047 ****************************************************************************/
1048 static bool api_spoolss_addform(pipes_struct *p)
1049 {
1050         SPOOL_Q_ADDFORM q_u;
1051         SPOOL_R_ADDFORM r_u;
1052         prs_struct *data = &p->in_data.data;
1053         prs_struct *rdata = &p->out_data.rdata;
1054
1055         ZERO_STRUCT(q_u);
1056         ZERO_STRUCT(r_u);
1057         
1058         if(!spoolss_io_q_addform("", &q_u, data, 0)) {
1059                 DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n"));
1060                 return False;
1061         }
1062         
1063         r_u.status = _spoolss_addform(p, &q_u, &r_u);
1064         
1065         if(!spoolss_io_r_addform("", &r_u, rdata, 0)) {
1066                 DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n"));
1067                 return False;
1068         }
1069
1070         return True;
1071 }
1072
1073 /****************************************************************************
1074 ****************************************************************************/
1075
1076 static bool api_spoolss_deleteform(pipes_struct *p)
1077 {
1078         SPOOL_Q_DELETEFORM q_u;
1079         SPOOL_R_DELETEFORM 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_deleteform("", &q_u, data, 0)) {
1087                 DEBUG(0,("spoolss_io_q_deleteform: unable to unmarshall SPOOL_Q_DELETEFORM.\n"));
1088                 return False;
1089         }
1090         
1091         r_u.status = _spoolss_deleteform(p, &q_u, &r_u);
1092         
1093         if(!spoolss_io_r_deleteform("", &r_u, rdata, 0)) {
1094                 DEBUG(0,("spoolss_io_r_deleteform: unable to marshall SPOOL_R_DELETEFORM.\n"));
1095                 return False;
1096         }
1097
1098         return True;
1099 }
1100
1101 /****************************************************************************
1102 ****************************************************************************/
1103
1104 static bool api_spoolss_setform(pipes_struct *p)
1105 {
1106         SPOOL_Q_SETFORM q_u;
1107         SPOOL_R_SETFORM 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_setform("", &q_u, data, 0)) {
1115                 DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n"));
1116                 return False;
1117         }
1118         
1119         r_u.status = _spoolss_setform(p, &q_u, &r_u);
1120                                       
1121         if(!spoolss_io_r_setform("", &r_u, rdata, 0)) {
1122                 DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n"));
1123                 return False;
1124         }
1125
1126         return True;
1127 }
1128
1129 /****************************************************************************
1130 ****************************************************************************/
1131
1132 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
1133 {
1134         SPOOL_Q_ENUMPRINTPROCESSORS q_u;
1135         SPOOL_R_ENUMPRINTPROCESSORS 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_enumprintprocessors("", &q_u, data, 0)) {
1143                 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
1144                 return False;
1145         }
1146         
1147         r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
1148
1149         if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
1150                 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
1151                 return False;
1152         }
1153         
1154         return True;
1155 }
1156
1157 /****************************************************************************
1158 ****************************************************************************/
1159
1160 static bool api_spoolss_addprintprocessor(pipes_struct *p)
1161 {
1162         SPOOL_Q_ADDPRINTPROCESSOR q_u;
1163         SPOOL_R_ADDPRINTPROCESSOR r_u;
1164         prs_struct *data = &p->in_data.data;
1165         prs_struct *rdata = &p->out_data.rdata;
1166
1167         ZERO_STRUCT(q_u);
1168         ZERO_STRUCT(r_u);
1169         
1170         if(!spoolss_io_q_addprintprocessor("", &q_u, data, 0)) {
1171                 DEBUG(0,("spoolss_io_q_addprintprocessor: unable to unmarshall SPOOL_Q_ADDPRINTPROCESSOR.\n"));
1172                 return False;
1173         }
1174         
1175         /* for now, just indicate success and ignore the add.  We'll
1176            automatically set the winprint processor for printer
1177            entries later.  Used to debug the LexMark Optra S 1855 PCL
1178            driver --jerry */
1179         r_u.status = WERR_OK;
1180
1181         if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) {
1182                 DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n"));
1183                 return False;
1184         }
1185         
1186         return True;
1187 }
1188
1189 /****************************************************************************
1190 ****************************************************************************/
1191
1192 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
1193 {
1194         SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
1195         SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
1196         prs_struct *data = &p->in_data.data;
1197         prs_struct *rdata = &p->out_data.rdata;
1198
1199         ZERO_STRUCT(q_u);
1200         ZERO_STRUCT(r_u);
1201         
1202         if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
1203                 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
1204                 return False;
1205         }
1206         
1207         r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
1208
1209         if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
1210                 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
1211                 return False;
1212         }
1213         
1214         return True;
1215 }
1216
1217 /****************************************************************************
1218 ****************************************************************************/
1219
1220 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
1221 {
1222         SPOOL_Q_ENUMPRINTMONITORS q_u;
1223         SPOOL_R_ENUMPRINTMONITORS r_u;
1224         prs_struct *data = &p->in_data.data;
1225         prs_struct *rdata = &p->out_data.rdata;
1226
1227         ZERO_STRUCT(q_u);
1228         ZERO_STRUCT(r_u);
1229         
1230         if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
1231                 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
1232                 return False;
1233         }
1234                 
1235         r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
1236
1237         if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
1238                 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
1239                 return False;
1240         }
1241         
1242         return True;
1243 }
1244
1245 /****************************************************************************
1246 ****************************************************************************/
1247
1248 static bool api_spoolss_getjob(pipes_struct *p)
1249 {
1250         SPOOL_Q_GETJOB q_u;
1251         SPOOL_R_GETJOB r_u;
1252         prs_struct *data = &p->in_data.data;
1253         prs_struct *rdata = &p->out_data.rdata;
1254         
1255         ZERO_STRUCT(q_u);
1256         ZERO_STRUCT(r_u);
1257         
1258         if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
1259                 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
1260                 return False;
1261         }
1262
1263         r_u.status = _spoolss_getjob(p, &q_u, &r_u);
1264         
1265         if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1266                 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1267                 return False;
1268         }
1269                 
1270         return True;
1271 }
1272
1273 /********************************************************************
1274  * api_spoolss_getprinterdataex
1275  *
1276  * called from the spoolss dispatcher
1277  ********************************************************************/
1278
1279 static bool api_spoolss_getprinterdataex(pipes_struct *p)
1280 {
1281         SPOOL_Q_GETPRINTERDATAEX q_u;
1282         SPOOL_R_GETPRINTERDATAEX r_u;
1283         prs_struct *data = &p->in_data.data;
1284         prs_struct *rdata = &p->out_data.rdata;
1285
1286         ZERO_STRUCT(q_u);
1287         ZERO_STRUCT(r_u);
1288
1289         /* read the stream and fill the struct */
1290         if (!spoolss_io_q_getprinterdataex("", &q_u, data, 0)) {
1291                 DEBUG(0,("spoolss_io_q_getprinterdataex: unable to unmarshall SPOOL_Q_GETPRINTERDATAEX.\n"));
1292                 return False;
1293         }
1294         
1295         r_u.status = _spoolss_getprinterdataex( p, &q_u, &r_u);
1296
1297         if (!spoolss_io_r_getprinterdataex("", &r_u, rdata, 0)) {
1298                 DEBUG(0,("spoolss_io_r_getprinterdataex: unable to marshall SPOOL_R_GETPRINTERDATAEX.\n"));
1299                 return False;
1300         }
1301
1302         return True;
1303 }
1304
1305 /****************************************************************************
1306 ****************************************************************************/
1307
1308 static bool api_spoolss_setprinterdataex(pipes_struct *p)
1309 {
1310         SPOOL_Q_SETPRINTERDATAEX q_u;
1311         SPOOL_R_SETPRINTERDATAEX r_u;
1312         prs_struct *data = &p->in_data.data;
1313         prs_struct *rdata = &p->out_data.rdata;
1314         
1315         ZERO_STRUCT(q_u);
1316         ZERO_STRUCT(r_u);
1317         
1318         if(!spoolss_io_q_setprinterdataex("", &q_u, data, 0)) {
1319                 DEBUG(0,("spoolss_io_q_setprinterdataex: unable to unmarshall SPOOL_Q_SETPRINTERDATAEX.\n"));
1320                 return False;
1321         }
1322         
1323         r_u.status = _spoolss_setprinterdataex(p, &q_u, &r_u);
1324                                 
1325         if(!spoolss_io_r_setprinterdataex("", &r_u, rdata, 0)) {
1326                 DEBUG(0,("spoolss_io_r_setprinterdataex: unable to marshall SPOOL_R_SETPRINTERDATAEX.\n"));
1327                 return False;
1328         }
1329
1330         return True;
1331 }
1332
1333
1334 /****************************************************************************
1335 ****************************************************************************/
1336
1337 static bool api_spoolss_enumprinterkey(pipes_struct *p)
1338 {
1339         SPOOL_Q_ENUMPRINTERKEY q_u;
1340         SPOOL_R_ENUMPRINTERKEY r_u;
1341         prs_struct *data = &p->in_data.data;
1342         prs_struct *rdata = &p->out_data.rdata;
1343         
1344         ZERO_STRUCT(q_u);
1345         ZERO_STRUCT(r_u);
1346         
1347         if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
1348                 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
1349                 return False;
1350         }
1351         
1352         r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
1353                                 
1354         if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
1355                 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
1356                 return False;
1357         }
1358
1359         return True;
1360 }
1361
1362 /****************************************************************************
1363 ****************************************************************************/
1364
1365 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
1366 {
1367         SPOOL_Q_ENUMPRINTERDATAEX q_u;
1368         SPOOL_R_ENUMPRINTERDATAEX r_u;
1369         prs_struct *data = &p->in_data.data;
1370         prs_struct *rdata = &p->out_data.rdata;
1371         
1372         ZERO_STRUCT(q_u);
1373         ZERO_STRUCT(r_u);
1374         
1375         if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
1376                 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
1377                 return False;
1378         }
1379         
1380         r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
1381                                 
1382         if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
1383                 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
1384                 return False;
1385         }
1386
1387         return True;
1388 }
1389
1390 /****************************************************************************
1391 ****************************************************************************/
1392
1393 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
1394 {
1395         SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u;
1396         SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u;
1397         prs_struct *data = &p->in_data.data;
1398         prs_struct *rdata = &p->out_data.rdata;
1399         
1400         ZERO_STRUCT(q_u);
1401         ZERO_STRUCT(r_u);
1402         
1403         if(!spoolss_io_q_getprintprocessordirectory("", &q_u, data, 0)) {
1404                 DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n"));
1405                 return False;
1406         }
1407         
1408         r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
1409                                 
1410         if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) {
1411                 DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n"));
1412                 return False;
1413         }
1414         
1415         return True;
1416 }
1417
1418 /****************************************************************************
1419 ****************************************************************************/
1420
1421 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
1422 {
1423         SPOOL_Q_DELETEPRINTERDATAEX q_u;
1424         SPOOL_R_DELETEPRINTERDATAEX r_u;
1425         prs_struct *data = &p->in_data.data;
1426         prs_struct *rdata = &p->out_data.rdata;
1427         
1428         ZERO_STRUCT(q_u);
1429         ZERO_STRUCT(r_u);
1430         
1431         if(!spoolss_io_q_deleteprinterdataex("", &q_u, data, 0)) {
1432                 DEBUG(0,("spoolss_io_q_deleteprinterdataex: unable to unmarshall SPOOL_Q_DELETEPRINTERDATAEX.\n"));
1433                 return False;
1434         }
1435         
1436         r_u.status = _spoolss_deleteprinterdataex(p, &q_u, &r_u);
1437                                 
1438         if(!spoolss_io_r_deleteprinterdataex("", &r_u, rdata, 0)) {
1439                 DEBUG(0,("spoolss_io_r_deleteprinterdataex: unable to marshall SPOOL_R_DELETEPRINTERDATAEX.\n"));
1440                 return False;
1441         }
1442         
1443         return True;
1444 }
1445
1446 /****************************************************************************
1447 ****************************************************************************/
1448
1449 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
1450 {
1451         SPOOL_Q_DELETEPRINTERKEY q_u;
1452         SPOOL_R_DELETEPRINTERKEY r_u;
1453         prs_struct *data = &p->in_data.data;
1454         prs_struct *rdata = &p->out_data.rdata;
1455         
1456         ZERO_STRUCT(q_u);
1457         ZERO_STRUCT(r_u);
1458         
1459         if(!spoolss_io_q_deleteprinterkey("", &q_u, data, 0)) {
1460                 DEBUG(0,("spoolss_io_q_deleteprinterkey: unable to unmarshall SPOOL_Q_DELETEPRINTERKEY.\n"));
1461                 return False;
1462         }
1463         
1464         r_u.status = _spoolss_deleteprinterkey(p, &q_u, &r_u);
1465                                 
1466         if(!spoolss_io_r_deleteprinterkey("", &r_u, rdata, 0)) {
1467                 DEBUG(0,("spoolss_io_r_deleteprinterkey: unable to marshall SPOOL_R_DELETEPRINTERKEY.\n"));
1468                 return False;
1469         }
1470         
1471         return True;
1472 }
1473
1474 /****************************************************************************
1475 ****************************************************************************/
1476
1477 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
1478 {
1479         SPOOL_Q_ADDPRINTERDRIVEREX q_u;
1480         SPOOL_R_ADDPRINTERDRIVEREX r_u;
1481         prs_struct *data = &p->in_data.data;
1482         prs_struct *rdata = &p->out_data.rdata;
1483         
1484         ZERO_STRUCT(q_u);
1485         ZERO_STRUCT(r_u);
1486         
1487         if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) {
1488                 if (q_u.level != 3 && q_u.level != 6) {
1489                         /* Clever hack from Martin Zielinski <mz@seh.de>
1490                          * to allow downgrade from level 8 (Vista).
1491                          */
1492                         DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n",
1493                                 (unsigned int)q_u.level ));
1494                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
1495                         return True;
1496                 }
1497                 DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
1498                 return False;
1499         }
1500         
1501         r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
1502                                 
1503         if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) {
1504                 DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n"));
1505                 return False;
1506         }
1507         
1508         return True;
1509 }
1510
1511 /****************************************************************************
1512 ****************************************************************************/
1513
1514 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
1515 {
1516         SPOOL_Q_DELETEPRINTERDRIVEREX q_u;
1517         SPOOL_R_DELETEPRINTERDRIVEREX r_u;
1518         prs_struct *data = &p->in_data.data;
1519         prs_struct *rdata = &p->out_data.rdata;
1520         
1521         ZERO_STRUCT(q_u);
1522         ZERO_STRUCT(r_u);
1523         
1524         if(!spoolss_io_q_deleteprinterdriverex("", &q_u, data, 0)) {
1525                 DEBUG(0,("spoolss_io_q_deleteprinterdriverex: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVEREX.\n"));
1526                 return False;
1527         }
1528         
1529         r_u.status = _spoolss_deleteprinterdriverex(p, &q_u, &r_u);
1530                                 
1531         if(!spoolss_io_r_deleteprinterdriverex("", &r_u, rdata, 0)) {
1532                 DEBUG(0,("spoolss_io_r_deleteprinterdriverex: unable to marshall SPOOL_R_DELETEPRINTERDRIVEREX.\n"));
1533                 return False;
1534         }
1535         
1536         return True;
1537 }
1538
1539 /****************************************************************************
1540 ****************************************************************************/
1541
1542 static bool api_spoolss_xcvdataport(pipes_struct *p)
1543 {
1544         SPOOL_Q_XCVDATAPORT q_u;
1545         SPOOL_R_XCVDATAPORT r_u;
1546         prs_struct *data = &p->in_data.data;
1547         prs_struct *rdata = &p->out_data.rdata;
1548         
1549         ZERO_STRUCT(q_u);
1550         ZERO_STRUCT(r_u);
1551         
1552         if(!spoolss_io_q_xcvdataport("", &q_u, data, 0)) {
1553                 DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_XCVDATAPORT.\n"));
1554                 return False;
1555         }
1556         
1557         r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u);
1558                                 
1559         if(!spoolss_io_r_xcvdataport("", &r_u, rdata, 0)) {
1560                 DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_XCVDATAPORT.\n"));
1561                 return False;
1562         }
1563         
1564         return True;
1565 }
1566
1567 /*******************************************************************
1568 \pipe\spoolss commands
1569 ********************************************************************/
1570
1571   struct api_struct api_spoolss_cmds[] = 
1572     {
1573  {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
1574  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
1575  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
1576  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
1577  {"SPOOLSS_DELETEPRINTER",             SPOOLSS_DELETEPRINTER,             api_spoolss_deleteprinter             },
1578  {"SPOOLSS_ABORTPRINTER",              SPOOLSS_ABORTPRINTER,              api_spoolss_abortprinter              },
1579  {"SPOOLSS_RFFPCNEX",                  SPOOLSS_RFFPCNEX,                  api_spoolss_rffpcnex                  },
1580  {"SPOOLSS_RFNPCNEX",                  SPOOLSS_RFNPCNEX,                  api_spoolss_rfnpcnex                  },
1581  {"SPOOLSS_ENUMPRINTERS",              SPOOLSS_ENUMPRINTERS,              api_spoolss_enumprinters              },
1582  {"SPOOLSS_GETPRINTER",                SPOOLSS_GETPRINTER,                api_spoolss_getprinter                },
1583  {"SPOOLSS_GETPRINTERDRIVER2",         SPOOLSS_GETPRINTERDRIVER2,         api_spoolss_getprinterdriver2         }, 
1584  {"SPOOLSS_STARTPAGEPRINTER",          SPOOLSS_STARTPAGEPRINTER,          api_spoolss_startpageprinter          },
1585  {"SPOOLSS_ENDPAGEPRINTER",            SPOOLSS_ENDPAGEPRINTER,            api_spoolss_endpageprinter            }, 
1586  {"SPOOLSS_STARTDOCPRINTER",           SPOOLSS_STARTDOCPRINTER,           api_spoolss_startdocprinter           },
1587  {"SPOOLSS_ENDDOCPRINTER",             SPOOLSS_ENDDOCPRINTER,             api_spoolss_enddocprinter             },
1588  {"SPOOLSS_WRITEPRINTER",              SPOOLSS_WRITEPRINTER,              api_spoolss_writeprinter              },
1589  {"SPOOLSS_SETPRINTER",                SPOOLSS_SETPRINTER,                api_spoolss_setprinter                },
1590  {"SPOOLSS_FCPN",                      SPOOLSS_FCPN,                      api_spoolss_fcpn                      },
1591  {"SPOOLSS_ADDJOB",                    SPOOLSS_ADDJOB,                    api_spoolss_addjob                    },
1592  {"SPOOLSS_ENUMJOBS",                  SPOOLSS_ENUMJOBS,                  api_spoolss_enumjobs                  },
1593  {"SPOOLSS_SCHEDULEJOB",               SPOOLSS_SCHEDULEJOB,               api_spoolss_schedulejob               },
1594  {"SPOOLSS_SETJOB",                    SPOOLSS_SETJOB,                    api_spoolss_setjob                    },
1595  {"SPOOLSS_ENUMFORMS",                 SPOOLSS_ENUMFORMS,                 api_spoolss_enumforms                 },
1596  {"SPOOLSS_ENUMPORTS",                 SPOOLSS_ENUMPORTS,                 api_spoolss_enumports                 },
1597  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
1598  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
1599  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
1600  {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
1601  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1602  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
1603  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
1604  {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
1605  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
1606  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
1607  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
1608  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
1609  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
1610  {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
1611  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
1612  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
1613  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
1614  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
1615  {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
1616  {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
1617  {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
1618  {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
1619  {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
1620  {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
1621  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
1622  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
1623  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
1624  {"SPOOLSS_XCVDATAPORT",               SPOOLSS_XCVDATAPORT,               api_spoolss_xcvdataport               },
1625 };
1626
1627 void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns )
1628 {
1629         *fns = api_spoolss_cmds;
1630         *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
1631 }
1632
1633 NTSTATUS rpc_spoolss_init(void)
1634 {
1635   return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
1636                                     "spoolss", "spoolss", &syntax_spoolss,
1637                                     api_spoolss_cmds,
1638                                     sizeof(api_spoolss_cmds) / sizeof(struct api_struct));
1639 }