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