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