s4: make libintl a build dependency of heimdal_krb5 so all dependent binaries are...
[tprouty/samba.git] / source3 / rpc_server / srv_spoolss.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-2000,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6  *  Copyright (C) Jean François Micouleau      1998-2000,
7  *  Copyright (C) Jeremy Allison                    2001,
8  *  Copyright (C) Gerald Carter                2001-2002,
9  *  Copyright (C) Jim McDonough <jmcd@us.ibm.com>   2003.
10  *  
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 3 of the License, or
14  *  (at your option) any later version.
15  *  
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *  
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
23  */
24
25 #include "includes.h"
26
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_RPC_SRV
29
30 /*******************************************************************
31  ********************************************************************/
32
33 static bool proxy_spoolss_call(pipes_struct *p, uint8_t opnum)
34 {
35         struct api_struct *fns;
36         int n_fns;
37
38         spoolss_get_pipe_fns(&fns, &n_fns);
39
40         if (opnum >= n_fns) {
41                 return false;
42         }
43
44         if (fns[opnum].opnum != opnum) {
45                 smb_panic("SPOOLSS function table not sorted");
46         }
47
48         return fns[opnum].fn(p);
49 }
50
51 /********************************************************************
52  * api_spoolss_open_printer_ex (rarely seen - older call)
53  ********************************************************************/
54
55 static bool api_spoolss_open_printer(pipes_struct *p)
56 {
57         return proxy_spoolss_call(p, NDR_SPOOLSS_OPENPRINTER);
58 }
59
60 /********************************************************************
61  * api_spoolss_open_printer_ex
62  ********************************************************************/
63
64 static bool api_spoolss_open_printer_ex(pipes_struct *p)
65 {
66         return proxy_spoolss_call(p, NDR_SPOOLSS_OPENPRINTEREX);
67 }
68
69 /********************************************************************
70  * api_spoolss_getprinterdata
71  *
72  * called from the spoolss dispatcher
73  ********************************************************************/
74
75 static bool api_spoolss_getprinterdata(pipes_struct *p)
76 {
77         SPOOL_Q_GETPRINTERDATA q_u;
78         SPOOL_R_GETPRINTERDATA r_u;
79         prs_struct *data = &p->in_data.data;
80         prs_struct *rdata = &p->out_data.rdata;
81
82         ZERO_STRUCT(q_u);
83         ZERO_STRUCT(r_u);
84
85         /* read the stream and fill the struct */
86         if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) {
87                 DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n"));
88                 return False;
89         }
90         
91         r_u.status = _spoolss_getprinterdata( p, &q_u, &r_u);
92
93         if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) {
94                 DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n"));
95                 return False;
96         }
97
98         return True;
99 }
100
101 /********************************************************************
102  * api_spoolss_deleteprinterdata
103  *
104  * called from the spoolss dispatcher
105  ********************************************************************/
106
107 static bool api_spoolss_deleteprinterdata(pipes_struct *p)
108 {
109         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATA);
110 }
111
112 /********************************************************************
113  * api_spoolss_closeprinter
114  *
115  * called from the spoolss dispatcher
116  ********************************************************************/
117
118 static bool api_spoolss_closeprinter(pipes_struct *p)
119 {
120         return proxy_spoolss_call(p, NDR_SPOOLSS_CLOSEPRINTER);
121 }
122
123 /********************************************************************
124  * api_spoolss_abortprinter
125  *
126  * called from the spoolss dispatcher
127  ********************************************************************/
128
129 static bool api_spoolss_abortprinter(pipes_struct *p)
130 {
131         return proxy_spoolss_call(p, NDR_SPOOLSS_ABORTPRINTER);
132 }
133
134 /********************************************************************
135  * api_spoolss_deleteprinter
136  *
137  * called from the spoolss dispatcher
138  ********************************************************************/
139
140 static bool api_spoolss_deleteprinter(pipes_struct *p)
141 {
142         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTER);
143 }
144
145 /********************************************************************
146  * api_spoolss_deleteprinterdriver
147  *
148  * called from the spoolss dispatcher
149  ********************************************************************/
150
151 static bool api_spoolss_deleteprinterdriver(pipes_struct *p)
152 {
153         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVER);
154 }
155
156
157 /********************************************************************
158  * api_spoolss_rffpcnex
159  * ReplyFindFirstPrinterChangeNotifyEx
160  ********************************************************************/
161
162 static bool api_spoolss_rffpcnex(pipes_struct *p)
163 {
164         return proxy_spoolss_call(p, NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX);
165 }
166
167
168 /********************************************************************
169  * api_spoolss_rfnpcnex
170  * ReplyFindNextPrinterChangeNotifyEx
171  * called from the spoolss dispatcher
172
173  * Note - this is the *ONLY* function that breaks the RPC call
174  * symmetry in all the other calls. We need to do this to fix
175  * the massive memory allocation problem with thousands of jobs...
176  * JRA.
177  ********************************************************************/
178
179 static bool api_spoolss_rfnpcnex(pipes_struct *p)
180 {
181         return proxy_spoolss_call(p, NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFY);
182 }
183
184
185 /********************************************************************
186  * api_spoolss_enumprinters
187  * called from the spoolss dispatcher
188  *
189  ********************************************************************/
190
191 static bool api_spoolss_enumprinters(pipes_struct *p)
192 {
193         SPOOL_Q_ENUMPRINTERS q_u;
194         SPOOL_R_ENUMPRINTERS r_u;
195         prs_struct *data = &p->in_data.data;
196         prs_struct *rdata = &p->out_data.rdata;
197
198         ZERO_STRUCT(q_u);
199         ZERO_STRUCT(r_u);
200
201         if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
202                 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
203                 return False;
204         }
205
206         r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
207
208         if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
209                 DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
210                 return False;
211         }
212
213         return True;
214 }
215
216 /********************************************************************
217  * api_spoolss_getprinter
218  * called from the spoolss dispatcher
219  *
220  ********************************************************************/
221
222 static bool api_spoolss_getprinter(pipes_struct *p)
223 {
224         SPOOL_Q_GETPRINTER q_u;
225         SPOOL_R_GETPRINTER r_u;
226         prs_struct *data = &p->in_data.data;
227         prs_struct *rdata = &p->out_data.rdata;
228
229         ZERO_STRUCT(q_u);
230         ZERO_STRUCT(r_u);
231
232         if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
233                 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
234                 return False;
235         }
236
237         r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
238
239         if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
240                 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
241                 return False;
242         }
243
244         return True;
245 }
246
247 /********************************************************************
248  * api_spoolss_getprinter
249  * called from the spoolss dispatcher
250  *
251  ********************************************************************/
252
253 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
254 {
255         SPOOL_Q_GETPRINTERDRIVER2 q_u;
256         SPOOL_R_GETPRINTERDRIVER2 r_u;
257         prs_struct *data = &p->in_data.data;
258         prs_struct *rdata = &p->out_data.rdata;
259
260         ZERO_STRUCT(q_u);
261         ZERO_STRUCT(r_u);
262
263         if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
264                 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
265                 return False;
266         }
267
268         r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
269         
270         if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
271                 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
272                 return False;
273         }
274         
275         return True;
276 }
277
278 /********************************************************************
279  * api_spoolss_getprinter
280  * called from the spoolss dispatcher
281  *
282  ********************************************************************/
283
284 static bool api_spoolss_startpageprinter(pipes_struct *p)
285 {
286         return proxy_spoolss_call(p, NDR_SPOOLSS_STARTPAGEPRINTER);
287 }
288
289 /********************************************************************
290  * api_spoolss_getprinter
291  * called from the spoolss dispatcher
292  *
293  ********************************************************************/
294
295 static bool api_spoolss_endpageprinter(pipes_struct *p)
296 {
297         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDPAGEPRINTER);
298 }
299
300 /********************************************************************
301 ********************************************************************/
302
303 static bool api_spoolss_startdocprinter(pipes_struct *p)
304 {
305         return proxy_spoolss_call(p, NDR_SPOOLSS_STARTDOCPRINTER);
306 }
307
308 /********************************************************************
309 ********************************************************************/
310
311 static bool api_spoolss_enddocprinter(pipes_struct *p)
312 {
313         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDDOCPRINTER);
314 }
315
316 /********************************************************************
317 ********************************************************************/
318
319 static bool api_spoolss_writeprinter(pipes_struct *p)
320 {
321         return proxy_spoolss_call(p, NDR_SPOOLSS_WRITEPRINTER);
322 }
323
324 /****************************************************************************
325
326 ****************************************************************************/
327
328 static bool api_spoolss_setprinter(pipes_struct *p)
329 {
330         return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTER);
331 }
332
333 /****************************************************************************
334 ****************************************************************************/
335
336 static bool api_spoolss_fcpn(pipes_struct *p)
337 {
338         return proxy_spoolss_call(p, NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY);
339 }
340
341 /****************************************************************************
342 ****************************************************************************/
343
344 static bool api_spoolss_addjob(pipes_struct *p)
345 {
346         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDJOB);
347 }
348
349 /****************************************************************************
350 ****************************************************************************/
351
352 static bool api_spoolss_enumjobs(pipes_struct *p)
353 {
354         SPOOL_Q_ENUMJOBS q_u;
355         SPOOL_R_ENUMJOBS r_u;
356         prs_struct *data = &p->in_data.data;
357         prs_struct *rdata = &p->out_data.rdata;
358
359         ZERO_STRUCT(q_u);
360         ZERO_STRUCT(r_u);
361
362         if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
363                 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
364                 return False;
365         }
366
367         r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
368
369         if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
370                 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
371                 return False;
372         }
373
374         return True;
375 }
376
377 /****************************************************************************
378 ****************************************************************************/
379
380 static bool api_spoolss_schedulejob(pipes_struct *p)
381 {
382         return proxy_spoolss_call(p, NDR_SPOOLSS_SCHEDULEJOB);
383 }
384
385 /****************************************************************************
386 ****************************************************************************/
387
388 static bool api_spoolss_setjob(pipes_struct *p)
389 {
390         return proxy_spoolss_call(p, NDR_SPOOLSS_SETJOB);
391 }
392
393 /****************************************************************************
394 ****************************************************************************/
395
396 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
397 {
398         SPOOL_Q_ENUMPRINTERDRIVERS q_u;
399         SPOOL_R_ENUMPRINTERDRIVERS r_u;
400         prs_struct *data = &p->in_data.data;
401         prs_struct *rdata = &p->out_data.rdata;
402
403         ZERO_STRUCT(q_u);
404         ZERO_STRUCT(r_u);
405
406         if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
407                 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
408                 return False;
409         }
410
411         r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
412
413         if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
414                 DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
415                 return False;
416         }
417
418         return True;
419 }
420
421 /****************************************************************************
422 ****************************************************************************/
423
424 static bool api_spoolss_getform(pipes_struct *p)
425 {
426         return proxy_spoolss_call(p, NDR_SPOOLSS_GETFORM);
427 }
428
429 /****************************************************************************
430 ****************************************************************************/
431
432 static bool api_spoolss_enumforms(pipes_struct *p)
433 {
434         SPOOL_Q_ENUMFORMS q_u;
435         SPOOL_R_ENUMFORMS r_u;
436         prs_struct *data = &p->in_data.data;
437         prs_struct *rdata = &p->out_data.rdata;
438
439         ZERO_STRUCT(q_u);
440         ZERO_STRUCT(r_u);
441
442         if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
443                 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
444                 return False;
445         }
446
447         r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
448
449         if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
450                 DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
451                 return False;
452         }
453
454         return True;
455 }
456
457 /****************************************************************************
458 ****************************************************************************/
459
460 static bool api_spoolss_enumports(pipes_struct *p)
461 {
462         SPOOL_Q_ENUMPORTS q_u;
463         SPOOL_R_ENUMPORTS r_u;
464         prs_struct *data = &p->in_data.data;
465         prs_struct *rdata = &p->out_data.rdata;
466
467         ZERO_STRUCT(q_u);
468         ZERO_STRUCT(r_u);
469
470         if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
471                 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
472                 return False;
473         }
474
475         r_u.status = _spoolss_enumports(p, &q_u, &r_u);
476
477         if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
478                 DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
479                 return False;
480         }
481
482         return True;
483 }
484
485 /****************************************************************************
486 ****************************************************************************/
487
488 static bool api_spoolss_addprinterex(pipes_struct *p)
489 {
490         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTEREX);
491 }
492
493 /****************************************************************************
494 ****************************************************************************/
495
496 static bool api_spoolss_addprinterdriver(pipes_struct *p)
497 {
498         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTERDRIVER);
499 }
500
501 /****************************************************************************
502 ****************************************************************************/
503
504 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
505 {
506         return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY);
507 }
508
509 /****************************************************************************
510 ****************************************************************************/
511
512 static bool api_spoolss_enumprinterdata(pipes_struct *p)
513 {
514         SPOOL_Q_ENUMPRINTERDATA q_u;
515         SPOOL_R_ENUMPRINTERDATA r_u;
516         prs_struct *data = &p->in_data.data;
517         prs_struct *rdata = &p->out_data.rdata;
518         
519         ZERO_STRUCT(q_u);
520         ZERO_STRUCT(r_u);
521         
522         if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
523                 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
524                 return False;
525         }
526         
527         r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
528                                 
529         if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
530                 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
531                 return False;
532         }
533
534         return True;
535 }
536
537 /****************************************************************************
538 ****************************************************************************/
539
540 static bool api_spoolss_setprinterdata(pipes_struct *p)
541 {
542         SPOOL_Q_SETPRINTERDATA q_u;
543         SPOOL_R_SETPRINTERDATA r_u;
544         prs_struct *data = &p->in_data.data;
545         prs_struct *rdata = &p->out_data.rdata;
546         
547         ZERO_STRUCT(q_u);
548         ZERO_STRUCT(r_u);
549         
550         if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
551                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
552                 return False;
553         }
554         
555         r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
556                                 
557         if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
558                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
559                 return False;
560         }
561
562         return True;
563 }
564
565 /****************************************************************************
566 ****************************************************************************/
567 static bool api_spoolss_reset_printer(pipes_struct *p)
568 {
569         return proxy_spoolss_call(p, NDR_SPOOLSS_RESETPRINTER);
570 }
571
572 /****************************************************************************
573 ****************************************************************************/
574 static bool api_spoolss_addform(pipes_struct *p)
575 {
576         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDFORM);
577 }
578
579 /****************************************************************************
580 ****************************************************************************/
581
582 static bool api_spoolss_deleteform(pipes_struct *p)
583 {
584         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEFORM);
585 }
586
587 /****************************************************************************
588 ****************************************************************************/
589
590 static bool api_spoolss_setform(pipes_struct *p)
591 {
592         return proxy_spoolss_call(p, NDR_SPOOLSS_SETFORM);
593 }
594
595 /****************************************************************************
596 ****************************************************************************/
597
598 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
599 {
600         SPOOL_Q_ENUMPRINTPROCESSORS q_u;
601         SPOOL_R_ENUMPRINTPROCESSORS r_u;
602         prs_struct *data = &p->in_data.data;
603         prs_struct *rdata = &p->out_data.rdata;
604
605         ZERO_STRUCT(q_u);
606         ZERO_STRUCT(r_u);
607         
608         if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
609                 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
610                 return False;
611         }
612         
613         r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
614
615         if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
616                 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
617                 return False;
618         }
619         
620         return True;
621 }
622
623 /****************************************************************************
624 ****************************************************************************/
625
626 static bool api_spoolss_addprintprocessor(pipes_struct *p)
627 {
628         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTPROCESSOR);
629 }
630
631 /****************************************************************************
632 ****************************************************************************/
633
634 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
635 {
636         SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
637         SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
638         prs_struct *data = &p->in_data.data;
639         prs_struct *rdata = &p->out_data.rdata;
640
641         ZERO_STRUCT(q_u);
642         ZERO_STRUCT(r_u);
643         
644         if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
645                 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
646                 return False;
647         }
648         
649         r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
650
651         if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
652                 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
653                 return False;
654         }
655         
656         return True;
657 }
658
659 /****************************************************************************
660 ****************************************************************************/
661
662 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
663 {
664         SPOOL_Q_ENUMPRINTMONITORS q_u;
665         SPOOL_R_ENUMPRINTMONITORS r_u;
666         prs_struct *data = &p->in_data.data;
667         prs_struct *rdata = &p->out_data.rdata;
668
669         ZERO_STRUCT(q_u);
670         ZERO_STRUCT(r_u);
671         
672         if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
673                 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
674                 return False;
675         }
676                 
677         r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
678
679         if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
680                 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
681                 return False;
682         }
683         
684         return True;
685 }
686
687 /****************************************************************************
688 ****************************************************************************/
689
690 static bool api_spoolss_getjob(pipes_struct *p)
691 {
692         SPOOL_Q_GETJOB q_u;
693         SPOOL_R_GETJOB r_u;
694         prs_struct *data = &p->in_data.data;
695         prs_struct *rdata = &p->out_data.rdata;
696         
697         ZERO_STRUCT(q_u);
698         ZERO_STRUCT(r_u);
699         
700         if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
701                 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
702                 return False;
703         }
704
705         r_u.status = _spoolss_getjob(p, &q_u, &r_u);
706         
707         if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
708                 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
709                 return False;
710         }
711                 
712         return True;
713 }
714
715 /********************************************************************
716  * api_spoolss_getprinterdataex
717  *
718  * called from the spoolss dispatcher
719  ********************************************************************/
720
721 static bool api_spoolss_getprinterdataex(pipes_struct *p)
722 {
723         return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDATAEX);
724 }
725
726 /****************************************************************************
727 ****************************************************************************/
728
729 static bool api_spoolss_setprinterdataex(pipes_struct *p)
730 {
731         return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTERDATAEX);
732 }
733
734
735 /****************************************************************************
736 ****************************************************************************/
737
738 static bool api_spoolss_enumprinterkey(pipes_struct *p)
739 {
740         SPOOL_Q_ENUMPRINTERKEY q_u;
741         SPOOL_R_ENUMPRINTERKEY r_u;
742         prs_struct *data = &p->in_data.data;
743         prs_struct *rdata = &p->out_data.rdata;
744         
745         ZERO_STRUCT(q_u);
746         ZERO_STRUCT(r_u);
747         
748         if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
749                 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
750                 return False;
751         }
752         
753         r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
754                                 
755         if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
756                 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
757                 return False;
758         }
759
760         return True;
761 }
762
763 /****************************************************************************
764 ****************************************************************************/
765
766 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
767 {
768         SPOOL_Q_ENUMPRINTERDATAEX q_u;
769         SPOOL_R_ENUMPRINTERDATAEX r_u;
770         prs_struct *data = &p->in_data.data;
771         prs_struct *rdata = &p->out_data.rdata;
772         
773         ZERO_STRUCT(q_u);
774         ZERO_STRUCT(r_u);
775         
776         if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
777                 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
778                 return False;
779         }
780         
781         r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
782                                 
783         if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
784                 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
785                 return False;
786         }
787
788         return True;
789 }
790
791 /****************************************************************************
792 ****************************************************************************/
793
794 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
795 {
796         return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY);
797 }
798
799 /****************************************************************************
800 ****************************************************************************/
801
802 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
803 {
804         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATAEX);
805 }
806
807 /****************************************************************************
808 ****************************************************************************/
809
810 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
811 {
812         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERKEY);
813 }
814
815 /****************************************************************************
816 ****************************************************************************/
817
818 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
819 {
820         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTERDRIVEREX);
821 }
822
823 /****************************************************************************
824 ****************************************************************************/
825
826 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
827 {
828         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVEREX);
829 }
830
831 /****************************************************************************
832 ****************************************************************************/
833
834 static bool api_spoolss_xcvdataport(pipes_struct *p)
835 {
836         return proxy_spoolss_call(p, NDR_SPOOLSS_XCVDATA);
837 }
838
839 /*******************************************************************
840 \pipe\spoolss commands
841 ********************************************************************/
842
843   struct api_struct api_spoolss_cmds[] = 
844     {
845  {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
846  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
847  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
848  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
849  {"SPOOLSS_DELETEPRINTER",             SPOOLSS_DELETEPRINTER,             api_spoolss_deleteprinter             },
850  {"SPOOLSS_ABORTPRINTER",              SPOOLSS_ABORTPRINTER,              api_spoolss_abortprinter              },
851  {"SPOOLSS_RFFPCNEX",                  SPOOLSS_RFFPCNEX,                  api_spoolss_rffpcnex                  },
852  {"SPOOLSS_RFNPCNEX",                  SPOOLSS_RFNPCNEX,                  api_spoolss_rfnpcnex                  },
853  {"SPOOLSS_ENUMPRINTERS",              SPOOLSS_ENUMPRINTERS,              api_spoolss_enumprinters              },
854  {"SPOOLSS_GETPRINTER",                SPOOLSS_GETPRINTER,                api_spoolss_getprinter                },
855  {"SPOOLSS_GETPRINTERDRIVER2",         SPOOLSS_GETPRINTERDRIVER2,         api_spoolss_getprinterdriver2         }, 
856  {"SPOOLSS_STARTPAGEPRINTER",          SPOOLSS_STARTPAGEPRINTER,          api_spoolss_startpageprinter          },
857  {"SPOOLSS_ENDPAGEPRINTER",            SPOOLSS_ENDPAGEPRINTER,            api_spoolss_endpageprinter            }, 
858  {"SPOOLSS_STARTDOCPRINTER",           SPOOLSS_STARTDOCPRINTER,           api_spoolss_startdocprinter           },
859  {"SPOOLSS_ENDDOCPRINTER",             SPOOLSS_ENDDOCPRINTER,             api_spoolss_enddocprinter             },
860  {"SPOOLSS_WRITEPRINTER",              SPOOLSS_WRITEPRINTER,              api_spoolss_writeprinter              },
861  {"SPOOLSS_SETPRINTER",                SPOOLSS_SETPRINTER,                api_spoolss_setprinter                },
862  {"SPOOLSS_FCPN",                      SPOOLSS_FCPN,                      api_spoolss_fcpn                      },
863  {"SPOOLSS_ADDJOB",                    SPOOLSS_ADDJOB,                    api_spoolss_addjob                    },
864  {"SPOOLSS_ENUMJOBS",                  SPOOLSS_ENUMJOBS,                  api_spoolss_enumjobs                  },
865  {"SPOOLSS_SCHEDULEJOB",               SPOOLSS_SCHEDULEJOB,               api_spoolss_schedulejob               },
866  {"SPOOLSS_SETJOB",                    SPOOLSS_SETJOB,                    api_spoolss_setjob                    },
867  {"SPOOLSS_ENUMFORMS",                 SPOOLSS_ENUMFORMS,                 api_spoolss_enumforms                 },
868  {"SPOOLSS_ENUMPORTS",                 SPOOLSS_ENUMPORTS,                 api_spoolss_enumports                 },
869  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
870  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
871  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
872  {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
873  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
874  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
875  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
876  {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
877  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
878  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
879  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
880  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
881  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
882  {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
883  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
884  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
885  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
886  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
887  {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
888  {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
889  {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
890  {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
891  {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
892  {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
893  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
894  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
895  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
896  {"SPOOLSS_XCVDATAPORT",               SPOOLSS_XCVDATAPORT,               api_spoolss_xcvdataport               },
897 };
898
899 void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns )
900 {
901         *fns = api_spoolss_cmds;
902         *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
903 }
904
905 NTSTATUS rpc_spoolss2_init(void)
906 {
907         return rpc_srv_register(
908                 SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss",
909                 &ndr_table_spoolss,
910                 api_spoolss_cmds,
911                 sizeof(api_spoolss_cmds) / sizeof(struct api_struct));
912 }