Merge branch 'master' of ssh://git.samba.org/data/git/samba into wspp-schema
[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         return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMFORMS);
435 }
436
437 /****************************************************************************
438 ****************************************************************************/
439
440 static bool api_spoolss_enumports(pipes_struct *p)
441 {
442         return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPORTS);
443 }
444
445 /****************************************************************************
446 ****************************************************************************/
447
448 static bool api_spoolss_addprinterex(pipes_struct *p)
449 {
450         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTEREX);
451 }
452
453 /****************************************************************************
454 ****************************************************************************/
455
456 static bool api_spoolss_addprinterdriver(pipes_struct *p)
457 {
458         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTERDRIVER);
459 }
460
461 /****************************************************************************
462 ****************************************************************************/
463
464 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
465 {
466         return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY);
467 }
468
469 /****************************************************************************
470 ****************************************************************************/
471
472 static bool api_spoolss_enumprinterdata(pipes_struct *p)
473 {
474         SPOOL_Q_ENUMPRINTERDATA q_u;
475         SPOOL_R_ENUMPRINTERDATA r_u;
476         prs_struct *data = &p->in_data.data;
477         prs_struct *rdata = &p->out_data.rdata;
478         
479         ZERO_STRUCT(q_u);
480         ZERO_STRUCT(r_u);
481         
482         if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
483                 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
484                 return False;
485         }
486         
487         r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
488                                 
489         if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
490                 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
491                 return False;
492         }
493
494         return True;
495 }
496
497 /****************************************************************************
498 ****************************************************************************/
499
500 static bool api_spoolss_setprinterdata(pipes_struct *p)
501 {
502         SPOOL_Q_SETPRINTERDATA q_u;
503         SPOOL_R_SETPRINTERDATA r_u;
504         prs_struct *data = &p->in_data.data;
505         prs_struct *rdata = &p->out_data.rdata;
506         
507         ZERO_STRUCT(q_u);
508         ZERO_STRUCT(r_u);
509         
510         if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
511                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
512                 return False;
513         }
514         
515         r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
516                                 
517         if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
518                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
519                 return False;
520         }
521
522         return True;
523 }
524
525 /****************************************************************************
526 ****************************************************************************/
527 static bool api_spoolss_reset_printer(pipes_struct *p)
528 {
529         return proxy_spoolss_call(p, NDR_SPOOLSS_RESETPRINTER);
530 }
531
532 /****************************************************************************
533 ****************************************************************************/
534 static bool api_spoolss_addform(pipes_struct *p)
535 {
536         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDFORM);
537 }
538
539 /****************************************************************************
540 ****************************************************************************/
541
542 static bool api_spoolss_deleteform(pipes_struct *p)
543 {
544         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEFORM);
545 }
546
547 /****************************************************************************
548 ****************************************************************************/
549
550 static bool api_spoolss_setform(pipes_struct *p)
551 {
552         return proxy_spoolss_call(p, NDR_SPOOLSS_SETFORM);
553 }
554
555 /****************************************************************************
556 ****************************************************************************/
557
558 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
559 {
560         return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCESSORS);
561 }
562
563 /****************************************************************************
564 ****************************************************************************/
565
566 static bool api_spoolss_addprintprocessor(pipes_struct *p)
567 {
568         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTPROCESSOR);
569 }
570
571 /****************************************************************************
572 ****************************************************************************/
573
574 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
575 {
576         return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCDATATYPES);
577 }
578
579 /****************************************************************************
580 ****************************************************************************/
581
582 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
583 {
584         return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMMONITORS);
585 }
586
587 /****************************************************************************
588 ****************************************************************************/
589
590 static bool api_spoolss_getjob(pipes_struct *p)
591 {
592         SPOOL_Q_GETJOB q_u;
593         SPOOL_R_GETJOB r_u;
594         prs_struct *data = &p->in_data.data;
595         prs_struct *rdata = &p->out_data.rdata;
596         
597         ZERO_STRUCT(q_u);
598         ZERO_STRUCT(r_u);
599         
600         if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
601                 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
602                 return False;
603         }
604
605         r_u.status = _spoolss_getjob(p, &q_u, &r_u);
606         
607         if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
608                 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
609                 return False;
610         }
611                 
612         return True;
613 }
614
615 /********************************************************************
616  * api_spoolss_getprinterdataex
617  *
618  * called from the spoolss dispatcher
619  ********************************************************************/
620
621 static bool api_spoolss_getprinterdataex(pipes_struct *p)
622 {
623         return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDATAEX);
624 }
625
626 /****************************************************************************
627 ****************************************************************************/
628
629 static bool api_spoolss_setprinterdataex(pipes_struct *p)
630 {
631         return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTERDATAEX);
632 }
633
634
635 /****************************************************************************
636 ****************************************************************************/
637
638 static bool api_spoolss_enumprinterkey(pipes_struct *p)
639 {
640         SPOOL_Q_ENUMPRINTERKEY q_u;
641         SPOOL_R_ENUMPRINTERKEY r_u;
642         prs_struct *data = &p->in_data.data;
643         prs_struct *rdata = &p->out_data.rdata;
644         
645         ZERO_STRUCT(q_u);
646         ZERO_STRUCT(r_u);
647         
648         if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
649                 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
650                 return False;
651         }
652         
653         r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
654                                 
655         if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
656                 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
657                 return False;
658         }
659
660         return True;
661 }
662
663 /****************************************************************************
664 ****************************************************************************/
665
666 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
667 {
668         SPOOL_Q_ENUMPRINTERDATAEX q_u;
669         SPOOL_R_ENUMPRINTERDATAEX r_u;
670         prs_struct *data = &p->in_data.data;
671         prs_struct *rdata = &p->out_data.rdata;
672         
673         ZERO_STRUCT(q_u);
674         ZERO_STRUCT(r_u);
675         
676         if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
677                 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
678                 return False;
679         }
680         
681         r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
682                                 
683         if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
684                 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
685                 return False;
686         }
687
688         return True;
689 }
690
691 /****************************************************************************
692 ****************************************************************************/
693
694 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
695 {
696         return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY);
697 }
698
699 /****************************************************************************
700 ****************************************************************************/
701
702 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
703 {
704         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATAEX);
705 }
706
707 /****************************************************************************
708 ****************************************************************************/
709
710 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
711 {
712         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERKEY);
713 }
714
715 /****************************************************************************
716 ****************************************************************************/
717
718 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
719 {
720         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTERDRIVEREX);
721 }
722
723 /****************************************************************************
724 ****************************************************************************/
725
726 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
727 {
728         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVEREX);
729 }
730
731 /****************************************************************************
732 ****************************************************************************/
733
734 static bool api_spoolss_xcvdataport(pipes_struct *p)
735 {
736         return proxy_spoolss_call(p, NDR_SPOOLSS_XCVDATA);
737 }
738
739 /*******************************************************************
740 \pipe\spoolss commands
741 ********************************************************************/
742
743   struct api_struct api_spoolss_cmds[] = 
744     {
745  {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
746  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
747  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
748  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
749  {"SPOOLSS_DELETEPRINTER",             SPOOLSS_DELETEPRINTER,             api_spoolss_deleteprinter             },
750  {"SPOOLSS_ABORTPRINTER",              SPOOLSS_ABORTPRINTER,              api_spoolss_abortprinter              },
751  {"SPOOLSS_RFFPCNEX",                  SPOOLSS_RFFPCNEX,                  api_spoolss_rffpcnex                  },
752  {"SPOOLSS_RFNPCNEX",                  SPOOLSS_RFNPCNEX,                  api_spoolss_rfnpcnex                  },
753  {"SPOOLSS_ENUMPRINTERS",              SPOOLSS_ENUMPRINTERS,              api_spoolss_enumprinters              },
754  {"SPOOLSS_GETPRINTER",                SPOOLSS_GETPRINTER,                api_spoolss_getprinter                },
755  {"SPOOLSS_GETPRINTERDRIVER2",         SPOOLSS_GETPRINTERDRIVER2,         api_spoolss_getprinterdriver2         }, 
756  {"SPOOLSS_STARTPAGEPRINTER",          SPOOLSS_STARTPAGEPRINTER,          api_spoolss_startpageprinter          },
757  {"SPOOLSS_ENDPAGEPRINTER",            SPOOLSS_ENDPAGEPRINTER,            api_spoolss_endpageprinter            }, 
758  {"SPOOLSS_STARTDOCPRINTER",           SPOOLSS_STARTDOCPRINTER,           api_spoolss_startdocprinter           },
759  {"SPOOLSS_ENDDOCPRINTER",             SPOOLSS_ENDDOCPRINTER,             api_spoolss_enddocprinter             },
760  {"SPOOLSS_WRITEPRINTER",              SPOOLSS_WRITEPRINTER,              api_spoolss_writeprinter              },
761  {"SPOOLSS_SETPRINTER",                SPOOLSS_SETPRINTER,                api_spoolss_setprinter                },
762  {"SPOOLSS_FCPN",                      SPOOLSS_FCPN,                      api_spoolss_fcpn                      },
763  {"SPOOLSS_ADDJOB",                    SPOOLSS_ADDJOB,                    api_spoolss_addjob                    },
764  {"SPOOLSS_ENUMJOBS",                  SPOOLSS_ENUMJOBS,                  api_spoolss_enumjobs                  },
765  {"SPOOLSS_SCHEDULEJOB",               SPOOLSS_SCHEDULEJOB,               api_spoolss_schedulejob               },
766  {"SPOOLSS_SETJOB",                    SPOOLSS_SETJOB,                    api_spoolss_setjob                    },
767  {"SPOOLSS_ENUMFORMS",                 SPOOLSS_ENUMFORMS,                 api_spoolss_enumforms                 },
768  {"SPOOLSS_ENUMPORTS",                 SPOOLSS_ENUMPORTS,                 api_spoolss_enumports                 },
769  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
770  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
771  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
772  {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
773  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
774  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
775  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
776  {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
777  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
778  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
779  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
780  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
781  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
782  {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
783  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
784  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
785  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
786  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
787  {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
788  {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
789  {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
790  {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
791  {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
792  {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
793  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
794  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
795  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
796  {"SPOOLSS_XCVDATAPORT",               SPOOLSS_XCVDATAPORT,               api_spoolss_xcvdataport               },
797 };
798
799 void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns )
800 {
801         *fns = api_spoolss_cmds;
802         *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
803 }
804
805 NTSTATUS rpc_spoolss2_init(void)
806 {
807         return rpc_srv_register(
808                 SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss",
809                 &ndr_table_spoolss,
810                 api_spoolss_cmds,
811                 sizeof(api_spoolss_cmds) / sizeof(struct api_struct));
812 }