updated the 3.0 branch from the head branch - ready for alpha18
[kai/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  *  
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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                 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
913                 return False;
914         }
915         
916         r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u);
917                                 
918         if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
919                 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
920                 return False;
921         }
922         
923         return True;
924 }
925
926 /****************************************************************************
927 ****************************************************************************/
928
929 static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p)
930 {
931         SPOOL_Q_GETPRINTERDRIVERDIR q_u;
932         SPOOL_R_GETPRINTERDRIVERDIR r_u;
933         prs_struct *data = &p->in_data.data;
934         prs_struct *rdata = &p->out_data.rdata;
935
936         ZERO_STRUCT(q_u);
937         ZERO_STRUCT(r_u);
938
939         if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
940                 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
941                 return False;
942         }
943
944         r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
945
946         if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
947                 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
948                 return False;
949         }
950
951         return True;
952 }
953
954 /****************************************************************************
955 ****************************************************************************/
956
957 static BOOL api_spoolss_enumprinterdata(pipes_struct *p)
958 {
959         SPOOL_Q_ENUMPRINTERDATA q_u;
960         SPOOL_R_ENUMPRINTERDATA r_u;
961         prs_struct *data = &p->in_data.data;
962         prs_struct *rdata = &p->out_data.rdata;
963         
964         ZERO_STRUCT(q_u);
965         ZERO_STRUCT(r_u);
966         
967         if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
968                 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
969                 return False;
970         }
971         
972         r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
973                                 
974         if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
975                 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
976                 return False;
977         }
978
979         return True;
980 }
981
982 /****************************************************************************
983 ****************************************************************************/
984
985 static BOOL api_spoolss_setprinterdata(pipes_struct *p)
986 {
987         SPOOL_Q_SETPRINTERDATA q_u;
988         SPOOL_R_SETPRINTERDATA r_u;
989         prs_struct *data = &p->in_data.data;
990         prs_struct *rdata = &p->out_data.rdata;
991         
992         ZERO_STRUCT(q_u);
993         ZERO_STRUCT(r_u);
994         
995         if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
996                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
997                 return False;
998         }
999         
1000         r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
1001                                 
1002         if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
1003                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
1004                 return False;
1005         }
1006
1007         return True;
1008 }
1009
1010 /****************************************************************************
1011 ****************************************************************************/
1012 static BOOL api_spoolss_reset_printer(pipes_struct *p)
1013 {
1014         SPOOL_Q_RESETPRINTER q_u;
1015         SPOOL_R_RESETPRINTER r_u;
1016         prs_struct *data = &p->in_data.data;
1017         prs_struct *rdata = &p->out_data.rdata;
1018
1019         ZERO_STRUCT(q_u);
1020         ZERO_STRUCT(r_u);
1021
1022         if(!spoolss_io_q_resetprinter("", &q_u, data, 0)) {
1023                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
1024                 return False;
1025         }
1026         
1027         r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
1028
1029         if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) {
1030                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n"));
1031                 return False;
1032         }
1033
1034         return True;
1035 }
1036
1037 /****************************************************************************
1038 ****************************************************************************/
1039 static BOOL api_spoolss_addform(pipes_struct *p)
1040 {
1041         SPOOL_Q_ADDFORM q_u;
1042         SPOOL_R_ADDFORM r_u;
1043         prs_struct *data = &p->in_data.data;
1044         prs_struct *rdata = &p->out_data.rdata;
1045
1046         ZERO_STRUCT(q_u);
1047         ZERO_STRUCT(r_u);
1048         
1049         if(!spoolss_io_q_addform("", &q_u, data, 0)) {
1050                 DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n"));
1051                 return False;
1052         }
1053         
1054         r_u.status = _spoolss_addform(p, &q_u, &r_u);
1055         
1056         if(!spoolss_io_r_addform("", &r_u, rdata, 0)) {
1057                 DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n"));
1058                 return False;
1059         }
1060
1061         return True;
1062 }
1063
1064 /****************************************************************************
1065 ****************************************************************************/
1066
1067 static BOOL api_spoolss_deleteform(pipes_struct *p)
1068 {
1069         SPOOL_Q_DELETEFORM q_u;
1070         SPOOL_R_DELETEFORM r_u;
1071         prs_struct *data = &p->in_data.data;
1072         prs_struct *rdata = &p->out_data.rdata;
1073
1074         ZERO_STRUCT(q_u);
1075         ZERO_STRUCT(r_u);
1076         
1077         if(!spoolss_io_q_deleteform("", &q_u, data, 0)) {
1078                 DEBUG(0,("spoolss_io_q_deleteform: unable to unmarshall SPOOL_Q_DELETEFORM.\n"));
1079                 return False;
1080         }
1081         
1082         r_u.status = _spoolss_deleteform(p, &q_u, &r_u);
1083         
1084         if(!spoolss_io_r_deleteform("", &r_u, rdata, 0)) {
1085                 DEBUG(0,("spoolss_io_r_deleteform: unable to marshall SPOOL_R_DELETEFORM.\n"));
1086                 return False;
1087         }
1088
1089         return True;
1090 }
1091
1092 /****************************************************************************
1093 ****************************************************************************/
1094
1095 static BOOL api_spoolss_setform(pipes_struct *p)
1096 {
1097         SPOOL_Q_SETFORM q_u;
1098         SPOOL_R_SETFORM r_u;
1099         prs_struct *data = &p->in_data.data;
1100         prs_struct *rdata = &p->out_data.rdata;
1101
1102         ZERO_STRUCT(q_u);
1103         ZERO_STRUCT(r_u);
1104         
1105         if(!spoolss_io_q_setform("", &q_u, data, 0)) {
1106                 DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n"));
1107                 return False;
1108         }
1109         
1110         r_u.status = _spoolss_setform(p, &q_u, &r_u);
1111                                       
1112         if(!spoolss_io_r_setform("", &r_u, rdata, 0)) {
1113                 DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n"));
1114                 return False;
1115         }
1116
1117         return True;
1118 }
1119
1120 /****************************************************************************
1121 ****************************************************************************/
1122
1123 static BOOL api_spoolss_enumprintprocessors(pipes_struct *p)
1124 {
1125         SPOOL_Q_ENUMPRINTPROCESSORS q_u;
1126         SPOOL_R_ENUMPRINTPROCESSORS r_u;
1127         prs_struct *data = &p->in_data.data;
1128         prs_struct *rdata = &p->out_data.rdata;
1129
1130         ZERO_STRUCT(q_u);
1131         ZERO_STRUCT(r_u);
1132         
1133         if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
1134                 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
1135                 return False;
1136         }
1137         
1138         r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
1139
1140         if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
1141                 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
1142                 return False;
1143         }
1144         
1145         return True;
1146 }
1147
1148 /****************************************************************************
1149 ****************************************************************************/
1150
1151 static BOOL api_spoolss_addprintprocessor(pipes_struct *p)
1152 {
1153         SPOOL_Q_ADDPRINTPROCESSOR q_u;
1154         SPOOL_R_ADDPRINTPROCESSOR r_u;
1155         prs_struct *data = &p->in_data.data;
1156         prs_struct *rdata = &p->out_data.rdata;
1157
1158         ZERO_STRUCT(q_u);
1159         ZERO_STRUCT(r_u);
1160         
1161         if(!spoolss_io_q_addprintprocessor("", &q_u, data, 0)) {
1162                 DEBUG(0,("spoolss_io_q_addprintprocessor: unable to unmarshall SPOOL_Q_ADDPRINTPROCESSOR.\n"));
1163                 return False;
1164         }
1165         
1166         /* for now, just indicate success and ignore the add.  We'll
1167            automatically set the winprint processor for printer
1168            entries later.  Used to debug the LexMark Optra S 1855 PCL
1169            driver --jerry */
1170         r_u.status = WERR_OK;
1171
1172         if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) {
1173                 DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n"));
1174                 return False;
1175         }
1176         
1177         return True;
1178 }
1179
1180 /****************************************************************************
1181 ****************************************************************************/
1182
1183 static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p)
1184 {
1185         SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
1186         SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
1187         prs_struct *data = &p->in_data.data;
1188         prs_struct *rdata = &p->out_data.rdata;
1189
1190         ZERO_STRUCT(q_u);
1191         ZERO_STRUCT(r_u);
1192         
1193         if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
1194                 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
1195                 return False;
1196         }
1197         
1198         r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
1199
1200         if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
1201                 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
1202                 return False;
1203         }
1204         
1205         return True;
1206 }
1207
1208 /****************************************************************************
1209 ****************************************************************************/
1210
1211 static BOOL api_spoolss_enumprintmonitors(pipes_struct *p)
1212 {
1213         SPOOL_Q_ENUMPRINTMONITORS q_u;
1214         SPOOL_R_ENUMPRINTMONITORS r_u;
1215         prs_struct *data = &p->in_data.data;
1216         prs_struct *rdata = &p->out_data.rdata;
1217
1218         ZERO_STRUCT(q_u);
1219         ZERO_STRUCT(r_u);
1220         
1221         if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
1222                 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
1223                 return False;
1224         }
1225                 
1226         r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
1227
1228         if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
1229                 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
1230                 return False;
1231         }
1232         
1233         return True;
1234 }
1235
1236 /****************************************************************************
1237 ****************************************************************************/
1238
1239 static BOOL api_spoolss_getjob(pipes_struct *p)
1240 {
1241         SPOOL_Q_GETJOB q_u;
1242         SPOOL_R_GETJOB r_u;
1243         prs_struct *data = &p->in_data.data;
1244         prs_struct *rdata = &p->out_data.rdata;
1245         
1246         if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
1247                 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
1248                 return False;
1249         }
1250
1251         r_u.status = _spoolss_getjob(p, &q_u, &r_u);
1252         
1253         if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1254                 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1255                 return False;
1256         }
1257                 
1258         return True;
1259 }
1260
1261 /********************************************************************
1262  * api_spoolss_getprinterdataex
1263  *
1264  * called from the spoolss dispatcher
1265  ********************************************************************/
1266
1267 static BOOL api_spoolss_getprinterdataex(pipes_struct *p)
1268 {
1269         SPOOL_Q_GETPRINTERDATAEX q_u;
1270         SPOOL_R_GETPRINTERDATAEX r_u;
1271         prs_struct *data = &p->in_data.data;
1272         prs_struct *rdata = &p->out_data.rdata;
1273
1274         ZERO_STRUCT(q_u);
1275         ZERO_STRUCT(r_u);
1276
1277         /* read the stream and fill the struct */
1278         if (!spoolss_io_q_getprinterdataex("", &q_u, data, 0)) {
1279                 DEBUG(0,("spoolss_io_q_getprinterdataex: unable to unmarshall SPOOL_Q_GETPRINTERDATAEX.\n"));
1280                 return False;
1281         }
1282         
1283         r_u.status = _spoolss_getprinterdataex( p, &q_u, &r_u);
1284
1285         if (!spoolss_io_r_getprinterdataex("", &r_u, rdata, 0)) {
1286                 DEBUG(0,("spoolss_io_r_getprinterdataex: unable to marshall SPOOL_R_GETPRINTERDATAEX.\n"));
1287                 return False;
1288         }
1289
1290         return True;
1291 }
1292
1293 /****************************************************************************
1294 ****************************************************************************/
1295
1296 static BOOL api_spoolss_setprinterdataex(pipes_struct *p)
1297 {
1298         SPOOL_Q_SETPRINTERDATAEX q_u;
1299         SPOOL_R_SETPRINTERDATAEX r_u;
1300         prs_struct *data = &p->in_data.data;
1301         prs_struct *rdata = &p->out_data.rdata;
1302         
1303         ZERO_STRUCT(q_u);
1304         ZERO_STRUCT(r_u);
1305         
1306         if(!spoolss_io_q_setprinterdataex("", &q_u, data, 0)) {
1307                 DEBUG(0,("spoolss_io_q_setprinterdataex: unable to unmarshall SPOOL_Q_SETPRINTERDATAEX.\n"));
1308                 return False;
1309         }
1310         
1311         r_u.status = _spoolss_setprinterdataex(p, &q_u, &r_u);
1312                                 
1313         if(!spoolss_io_r_setprinterdataex("", &r_u, rdata, 0)) {
1314                 DEBUG(0,("spoolss_io_r_setprinterdataex: unable to marshall SPOOL_R_SETPRINTERDATAEX.\n"));
1315                 return False;
1316         }
1317
1318         return True;
1319 }
1320
1321
1322 /****************************************************************************
1323 ****************************************************************************/
1324
1325 static BOOL api_spoolss_enumprinterkey(pipes_struct *p)
1326 {
1327         SPOOL_Q_ENUMPRINTERKEY q_u;
1328         SPOOL_R_ENUMPRINTERKEY r_u;
1329         prs_struct *data = &p->in_data.data;
1330         prs_struct *rdata = &p->out_data.rdata;
1331         
1332         ZERO_STRUCT(q_u);
1333         ZERO_STRUCT(r_u);
1334         
1335         if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
1336                 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
1337                 return False;
1338         }
1339         
1340         r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
1341                                 
1342         if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
1343                 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
1344                 return False;
1345         }
1346
1347         return True;
1348 }
1349
1350 /****************************************************************************
1351 ****************************************************************************/
1352
1353 static BOOL api_spoolss_enumprinterdataex(pipes_struct *p)
1354 {
1355         SPOOL_Q_ENUMPRINTERDATAEX q_u;
1356         SPOOL_R_ENUMPRINTERDATAEX r_u;
1357         prs_struct *data = &p->in_data.data;
1358         prs_struct *rdata = &p->out_data.rdata;
1359         
1360         ZERO_STRUCT(q_u);
1361         ZERO_STRUCT(r_u);
1362         
1363         if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
1364                 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
1365                 return False;
1366         }
1367         
1368         r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
1369                                 
1370         if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
1371                 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
1372                 return False;
1373         }
1374
1375         return True;
1376 }
1377
1378 /****************************************************************************
1379 ****************************************************************************/
1380
1381 static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p)
1382 {
1383         SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u;
1384         SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u;
1385         prs_struct *data = &p->in_data.data;
1386         prs_struct *rdata = &p->out_data.rdata;
1387         
1388         ZERO_STRUCT(q_u);
1389         ZERO_STRUCT(r_u);
1390         
1391         if(!spoolss_io_q_getprintprocessordirectory("", &q_u, data, 0)) {
1392                 DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n"));
1393                 return False;
1394         }
1395         
1396         r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
1397                                 
1398         if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) {
1399                 DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n"));
1400                 return False;
1401         }
1402         
1403         return True;
1404 }
1405
1406 /****************************************************************************
1407 ****************************************************************************/
1408
1409 static BOOL api_spoolss_deleteprinterdataex(pipes_struct *p)
1410 {
1411         SPOOL_Q_DELETEPRINTERDATAEX q_u;
1412         SPOOL_R_DELETEPRINTERDATAEX r_u;
1413         prs_struct *data = &p->in_data.data;
1414         prs_struct *rdata = &p->out_data.rdata;
1415         
1416         ZERO_STRUCT(q_u);
1417         ZERO_STRUCT(r_u);
1418         
1419         if(!spoolss_io_q_deleteprinterdataex("", &q_u, data, 0)) {
1420                 DEBUG(0,("spoolss_io_q_deleteprinterdataex: unable to unmarshall SPOOL_Q_DELETEPRINTERDATAEX.\n"));
1421                 return False;
1422         }
1423         
1424         r_u.status = _spoolss_deleteprinterdataex(p, &q_u, &r_u);
1425                                 
1426         if(!spoolss_io_r_deleteprinterdataex("", &r_u, rdata, 0)) {
1427                 DEBUG(0,("spoolss_io_r_deleteprinterdataex: unable to marshall SPOOL_R_DELETEPRINTERDATAEX.\n"));
1428                 return False;
1429         }
1430         
1431         return True;
1432 }
1433
1434 /****************************************************************************
1435 ****************************************************************************/
1436
1437 static BOOL api_spoolss_deleteprinterkey(pipes_struct *p)
1438 {
1439         SPOOL_Q_DELETEPRINTERKEY q_u;
1440         SPOOL_R_DELETEPRINTERKEY r_u;
1441         prs_struct *data = &p->in_data.data;
1442         prs_struct *rdata = &p->out_data.rdata;
1443         
1444         ZERO_STRUCT(q_u);
1445         ZERO_STRUCT(r_u);
1446         
1447         if(!spoolss_io_q_deleteprinterkey("", &q_u, data, 0)) {
1448                 DEBUG(0,("spoolss_io_q_deleteprinterkey: unable to unmarshall SPOOL_Q_DELETEPRINTERKEY.\n"));
1449                 return False;
1450         }
1451         
1452         r_u.status = _spoolss_deleteprinterkey(p, &q_u, &r_u);
1453                                 
1454         if(!spoolss_io_r_deleteprinterkey("", &r_u, rdata, 0)) {
1455                 DEBUG(0,("spoolss_io_r_deleteprinterkey: unable to marshall SPOOL_R_DELETEPRINTERKEY.\n"));
1456                 return False;
1457         }
1458         
1459         return True;
1460 }
1461
1462 /****************************************************************************
1463 ****************************************************************************/
1464
1465 static BOOL api_spoolss_addprinterdriverex(pipes_struct *p)
1466 {
1467         SPOOL_Q_ADDPRINTERDRIVEREX q_u;
1468         SPOOL_R_ADDPRINTERDRIVEREX r_u;
1469         prs_struct *data = &p->in_data.data;
1470         prs_struct *rdata = &p->out_data.rdata;
1471         
1472         ZERO_STRUCT(q_u);
1473         ZERO_STRUCT(r_u);
1474         
1475         if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) {
1476                 DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
1477                 return False;
1478         }
1479         
1480         r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
1481                                 
1482         if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) {
1483                 DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n"));
1484                 return False;
1485         }
1486         
1487         return True;
1488 }
1489
1490 /****************************************************************************
1491 ****************************************************************************/
1492
1493 static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p)
1494 {
1495         SPOOL_Q_DELETEPRINTERDRIVEREX q_u;
1496         SPOOL_R_DELETEPRINTERDRIVEREX r_u;
1497         prs_struct *data = &p->in_data.data;
1498         prs_struct *rdata = &p->out_data.rdata;
1499         
1500         ZERO_STRUCT(q_u);
1501         ZERO_STRUCT(r_u);
1502         
1503         if(!spoolss_io_q_deleteprinterdriverex("", &q_u, data, 0)) {
1504                 DEBUG(0,("spoolss_io_q_deleteprinterdriverex: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVEREX.\n"));
1505                 return False;
1506         }
1507         
1508         r_u.status = _spoolss_deleteprinterdriverex(p, &q_u, &r_u);
1509                                 
1510         if(!spoolss_io_r_deleteprinterdriverex("", &r_u, rdata, 0)) {
1511                 DEBUG(0,("spoolss_io_r_deleteprinterdriverex: unable to marshall SPOOL_R_DELETEPRINTERDRIVEREX.\n"));
1512                 return False;
1513         }
1514         
1515         return True;
1516 }
1517
1518
1519 /*******************************************************************
1520 \pipe\spoolss commands
1521 ********************************************************************/
1522
1523 struct api_struct api_spoolss_cmds[] = 
1524 {
1525  {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
1526  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
1527  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
1528  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
1529  {"SPOOLSS_DELETEPRINTER",             SPOOLSS_DELETEPRINTER,             api_spoolss_deleteprinter             },
1530  {"SPOOLSS_ABORTPRINTER",              SPOOLSS_ABORTPRINTER,              api_spoolss_abortprinter              },
1531  {"SPOOLSS_RFFPCNEX",                  SPOOLSS_RFFPCNEX,                  api_spoolss_rffpcnex                  },
1532  {"SPOOLSS_RFNPCNEX",                  SPOOLSS_RFNPCNEX,                  api_spoolss_rfnpcnex                  },
1533  {"SPOOLSS_ENUMPRINTERS",              SPOOLSS_ENUMPRINTERS,              api_spoolss_enumprinters              },
1534  {"SPOOLSS_GETPRINTER",                SPOOLSS_GETPRINTER,                api_spoolss_getprinter                },
1535  {"SPOOLSS_GETPRINTERDRIVER2",         SPOOLSS_GETPRINTERDRIVER2,         api_spoolss_getprinterdriver2         }, 
1536  {"SPOOLSS_STARTPAGEPRINTER",          SPOOLSS_STARTPAGEPRINTER,          api_spoolss_startpageprinter          },
1537  {"SPOOLSS_ENDPAGEPRINTER",            SPOOLSS_ENDPAGEPRINTER,            api_spoolss_endpageprinter            }, 
1538  {"SPOOLSS_STARTDOCPRINTER",           SPOOLSS_STARTDOCPRINTER,           api_spoolss_startdocprinter           },
1539  {"SPOOLSS_ENDDOCPRINTER",             SPOOLSS_ENDDOCPRINTER,             api_spoolss_enddocprinter             },
1540  {"SPOOLSS_WRITEPRINTER",              SPOOLSS_WRITEPRINTER,              api_spoolss_writeprinter              },
1541  {"SPOOLSS_SETPRINTER",                SPOOLSS_SETPRINTER,                api_spoolss_setprinter                },
1542  {"SPOOLSS_FCPN",                      SPOOLSS_FCPN,                      api_spoolss_fcpn                      },
1543  {"SPOOLSS_ADDJOB",                    SPOOLSS_ADDJOB,                    api_spoolss_addjob                    },
1544  {"SPOOLSS_ENUMJOBS",                  SPOOLSS_ENUMJOBS,                  api_spoolss_enumjobs                  },
1545  {"SPOOLSS_SCHEDULEJOB",               SPOOLSS_SCHEDULEJOB,               api_spoolss_schedulejob               },
1546  {"SPOOLSS_SETJOB",                    SPOOLSS_SETJOB,                    api_spoolss_setjob                    },
1547  {"SPOOLSS_ENUMFORMS",                 SPOOLSS_ENUMFORMS,                 api_spoolss_enumforms                 },
1548  {"SPOOLSS_ENUMPORTS",                 SPOOLSS_ENUMPORTS,                 api_spoolss_enumports                 },
1549  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
1550  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
1551  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
1552  {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
1553  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1554  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
1555  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
1556  {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
1557  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
1558  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
1559  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
1560  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
1561  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
1562  {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
1563  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
1564  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
1565  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
1566  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
1567  {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
1568  {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
1569  {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
1570  {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
1571  {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
1572  {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
1573  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
1574  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
1575  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
1576  { NULL,                               0,                                 NULL                                  }
1577 };
1578
1579 /*******************************************************************
1580 receives a spoolss pipe and responds.
1581 ********************************************************************/
1582 BOOL api_spoolss_rpc(pipes_struct *p)
1583 {
1584         return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds);
1585 }