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