68b7c3c4b9d6008cae2b029a96fda5e1a1ed1827
[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         SPOOL_Q_RFFPCNEX q_u;
165         SPOOL_R_RFFPCNEX r_u;
166         prs_struct *data = &p->in_data.data;
167         prs_struct *rdata = &p->out_data.rdata;
168
169         ZERO_STRUCT(q_u);
170         ZERO_STRUCT(r_u);
171
172         if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
173                 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
174                 return False;
175         }
176
177         r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u);
178
179         if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
180                 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
181                 return False;
182         }
183
184         return True;
185 }
186
187
188 /********************************************************************
189  * api_spoolss_rfnpcnex
190  * ReplyFindNextPrinterChangeNotifyEx
191  * called from the spoolss dispatcher
192
193  * Note - this is the *ONLY* function that breaks the RPC call
194  * symmetry in all the other calls. We need to do this to fix
195  * the massive memory allocation problem with thousands of jobs...
196  * JRA.
197  ********************************************************************/
198
199 static bool api_spoolss_rfnpcnex(pipes_struct *p)
200 {
201         SPOOL_Q_RFNPCNEX q_u;
202         SPOOL_R_RFNPCNEX r_u;
203         prs_struct *data = &p->in_data.data;
204         prs_struct *rdata = &p->out_data.rdata;
205
206         ZERO_STRUCT(q_u);
207         ZERO_STRUCT(r_u);
208
209         if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
210                 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
211                 return False;
212         }
213
214         r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u);
215
216         if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
217                 SAFE_FREE(r_u.info.data);
218                 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
219                 return False;
220         }
221
222         SAFE_FREE(r_u.info.data);
223
224         return True;
225 }
226
227
228 /********************************************************************
229  * api_spoolss_enumprinters
230  * called from the spoolss dispatcher
231  *
232  ********************************************************************/
233
234 static bool api_spoolss_enumprinters(pipes_struct *p)
235 {
236         SPOOL_Q_ENUMPRINTERS q_u;
237         SPOOL_R_ENUMPRINTERS r_u;
238         prs_struct *data = &p->in_data.data;
239         prs_struct *rdata = &p->out_data.rdata;
240
241         ZERO_STRUCT(q_u);
242         ZERO_STRUCT(r_u);
243
244         if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
245                 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
246                 return False;
247         }
248
249         r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
250
251         if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
252                 DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
253                 return False;
254         }
255
256         return True;
257 }
258
259 /********************************************************************
260  * api_spoolss_getprinter
261  * called from the spoolss dispatcher
262  *
263  ********************************************************************/
264
265 static bool api_spoolss_getprinter(pipes_struct *p)
266 {
267         SPOOL_Q_GETPRINTER q_u;
268         SPOOL_R_GETPRINTER r_u;
269         prs_struct *data = &p->in_data.data;
270         prs_struct *rdata = &p->out_data.rdata;
271
272         ZERO_STRUCT(q_u);
273         ZERO_STRUCT(r_u);
274
275         if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
276                 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
277                 return False;
278         }
279
280         r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
281
282         if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
283                 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
284                 return False;
285         }
286
287         return True;
288 }
289
290 /********************************************************************
291  * api_spoolss_getprinter
292  * called from the spoolss dispatcher
293  *
294  ********************************************************************/
295
296 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
297 {
298         SPOOL_Q_GETPRINTERDRIVER2 q_u;
299         SPOOL_R_GETPRINTERDRIVER2 r_u;
300         prs_struct *data = &p->in_data.data;
301         prs_struct *rdata = &p->out_data.rdata;
302
303         ZERO_STRUCT(q_u);
304         ZERO_STRUCT(r_u);
305
306         if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
307                 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
308                 return False;
309         }
310
311         r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
312         
313         if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
314                 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
315                 return False;
316         }
317         
318         return True;
319 }
320
321 /********************************************************************
322  * api_spoolss_getprinter
323  * called from the spoolss dispatcher
324  *
325  ********************************************************************/
326
327 static bool api_spoolss_startpageprinter(pipes_struct *p)
328 {
329         return proxy_spoolss_call(p, NDR_SPOOLSS_STARTPAGEPRINTER);
330 }
331
332 /********************************************************************
333  * api_spoolss_getprinter
334  * called from the spoolss dispatcher
335  *
336  ********************************************************************/
337
338 static bool api_spoolss_endpageprinter(pipes_struct *p)
339 {
340         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDPAGEPRINTER);
341 }
342
343 /********************************************************************
344 ********************************************************************/
345
346 static bool api_spoolss_startdocprinter(pipes_struct *p)
347 {
348         return proxy_spoolss_call(p, NDR_SPOOLSS_STARTDOCPRINTER);
349 }
350
351 /********************************************************************
352 ********************************************************************/
353
354 static bool api_spoolss_enddocprinter(pipes_struct *p)
355 {
356         return proxy_spoolss_call(p, NDR_SPOOLSS_ENDDOCPRINTER);
357 }
358
359 /********************************************************************
360 ********************************************************************/
361
362 static bool api_spoolss_writeprinter(pipes_struct *p)
363 {
364         return proxy_spoolss_call(p, NDR_SPOOLSS_WRITEPRINTER);
365 }
366
367 /****************************************************************************
368
369 ****************************************************************************/
370
371 static bool api_spoolss_setprinter(pipes_struct *p)
372 {
373         SPOOL_Q_SETPRINTER q_u;
374         SPOOL_R_SETPRINTER r_u;
375         prs_struct *data = &p->in_data.data;
376         prs_struct *rdata = &p->out_data.rdata;
377
378         ZERO_STRUCT(q_u);
379         ZERO_STRUCT(r_u);
380
381         if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
382                 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
383                 return False;
384         }
385         
386         r_u.status = _spoolss_setprinter(p, &q_u, &r_u);
387         
388         if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
389                 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
390                 return False;
391         }
392
393         return True;
394 }
395
396 /****************************************************************************
397 ****************************************************************************/
398
399 static bool api_spoolss_fcpn(pipes_struct *p)
400 {
401         return proxy_spoolss_call(p, NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY);
402 }
403
404 /****************************************************************************
405 ****************************************************************************/
406
407 static bool api_spoolss_addjob(pipes_struct *p)
408 {
409         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDJOB);
410 }
411
412 /****************************************************************************
413 ****************************************************************************/
414
415 static bool api_spoolss_enumjobs(pipes_struct *p)
416 {
417         SPOOL_Q_ENUMJOBS q_u;
418         SPOOL_R_ENUMJOBS r_u;
419         prs_struct *data = &p->in_data.data;
420         prs_struct *rdata = &p->out_data.rdata;
421
422         ZERO_STRUCT(q_u);
423         ZERO_STRUCT(r_u);
424
425         if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
426                 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
427                 return False;
428         }
429
430         r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
431
432         if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
433                 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
434                 return False;
435         }
436
437         return True;
438 }
439
440 /****************************************************************************
441 ****************************************************************************/
442
443 static bool api_spoolss_schedulejob(pipes_struct *p)
444 {
445         return proxy_spoolss_call(p, NDR_SPOOLSS_SCHEDULEJOB);
446 }
447
448 /****************************************************************************
449 ****************************************************************************/
450
451 static bool api_spoolss_setjob(pipes_struct *p)
452 {
453         return proxy_spoolss_call(p, NDR_SPOOLSS_SETJOB);
454 }
455
456 /****************************************************************************
457 ****************************************************************************/
458
459 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
460 {
461         SPOOL_Q_ENUMPRINTERDRIVERS q_u;
462         SPOOL_R_ENUMPRINTERDRIVERS r_u;
463         prs_struct *data = &p->in_data.data;
464         prs_struct *rdata = &p->out_data.rdata;
465
466         ZERO_STRUCT(q_u);
467         ZERO_STRUCT(r_u);
468
469         if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
470                 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
471                 return False;
472         }
473
474         r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
475
476         if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
477                 DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
478                 return False;
479         }
480
481         return True;
482 }
483
484 /****************************************************************************
485 ****************************************************************************/
486
487 static bool api_spoolss_getform(pipes_struct *p)
488 {
489         return proxy_spoolss_call(p, NDR_SPOOLSS_GETFORM);
490 }
491
492 /****************************************************************************
493 ****************************************************************************/
494
495 static bool api_spoolss_enumforms(pipes_struct *p)
496 {
497         SPOOL_Q_ENUMFORMS q_u;
498         SPOOL_R_ENUMFORMS r_u;
499         prs_struct *data = &p->in_data.data;
500         prs_struct *rdata = &p->out_data.rdata;
501
502         ZERO_STRUCT(q_u);
503         ZERO_STRUCT(r_u);
504
505         if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
506                 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
507                 return False;
508         }
509
510         r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
511
512         if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
513                 DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
514                 return False;
515         }
516
517         return True;
518 }
519
520 /****************************************************************************
521 ****************************************************************************/
522
523 static bool api_spoolss_enumports(pipes_struct *p)
524 {
525         SPOOL_Q_ENUMPORTS q_u;
526         SPOOL_R_ENUMPORTS r_u;
527         prs_struct *data = &p->in_data.data;
528         prs_struct *rdata = &p->out_data.rdata;
529
530         ZERO_STRUCT(q_u);
531         ZERO_STRUCT(r_u);
532
533         if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
534                 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
535                 return False;
536         }
537
538         r_u.status = _spoolss_enumports(p, &q_u, &r_u);
539
540         if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
541                 DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
542                 return False;
543         }
544
545         return True;
546 }
547
548 /****************************************************************************
549 ****************************************************************************/
550
551 static bool api_spoolss_addprinterex(pipes_struct *p)
552 {
553         SPOOL_Q_ADDPRINTEREX q_u;
554         SPOOL_R_ADDPRINTEREX r_u;
555         prs_struct *data = &p->in_data.data;
556         prs_struct *rdata = &p->out_data.rdata;
557         
558         ZERO_STRUCT(q_u);
559         ZERO_STRUCT(r_u);
560         
561         if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
562                 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
563                 return False;
564         }
565         
566         r_u.status = _spoolss_addprinterex(p, &q_u, &r_u);
567                                 
568         if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
569                 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
570                 return False;
571         }
572         
573         return True;
574 }
575
576 /****************************************************************************
577 ****************************************************************************/
578
579 static bool api_spoolss_addprinterdriver(pipes_struct *p)
580 {
581         SPOOL_Q_ADDPRINTERDRIVER q_u;
582         SPOOL_R_ADDPRINTERDRIVER r_u;
583         prs_struct *data = &p->in_data.data;
584         prs_struct *rdata = &p->out_data.rdata;
585         
586         ZERO_STRUCT(q_u);
587         ZERO_STRUCT(r_u);
588         
589         if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
590                 if (q_u.level != 3 && q_u.level != 6) {
591                         /* Clever hack from Martin Zielinski <mz@seh.de>
592                          * to allow downgrade from level 8 (Vista).
593                          */
594                         DEBUG(3,("api_spoolss_addprinterdriver: unknown SPOOL_Q_ADDPRINTERDRIVER level %u.\n",
595                                 (unsigned int)q_u.level ));
596                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
597                         return True;
598                 }
599                 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
600                 return False;
601         }
602         
603         r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u);
604                                 
605         if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
606                 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
607                 return False;
608         }
609         
610         return True;
611 }
612
613 /****************************************************************************
614 ****************************************************************************/
615
616 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
617 {
618         SPOOL_Q_GETPRINTERDRIVERDIR q_u;
619         SPOOL_R_GETPRINTERDRIVERDIR 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_getprinterdriverdir("", &q_u, data, 0)) {
627                 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
628                 return False;
629         }
630
631         r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
632
633         if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
634                 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
635                 return False;
636         }
637
638         return True;
639 }
640
641 /****************************************************************************
642 ****************************************************************************/
643
644 static bool api_spoolss_enumprinterdata(pipes_struct *p)
645 {
646         SPOOL_Q_ENUMPRINTERDATA q_u;
647         SPOOL_R_ENUMPRINTERDATA 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_enumprinterdata("", &q_u, data, 0)) {
655                 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
656                 return False;
657         }
658         
659         r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
660                                 
661         if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
662                 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
663                 return False;
664         }
665
666         return True;
667 }
668
669 /****************************************************************************
670 ****************************************************************************/
671
672 static bool api_spoolss_setprinterdata(pipes_struct *p)
673 {
674         SPOOL_Q_SETPRINTERDATA q_u;
675         SPOOL_R_SETPRINTERDATA 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_setprinterdata("", &q_u, data, 0)) {
683                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
684                 return False;
685         }
686         
687         r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
688                                 
689         if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
690                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
691                 return False;
692         }
693
694         return True;
695 }
696
697 /****************************************************************************
698 ****************************************************************************/
699 static bool api_spoolss_reset_printer(pipes_struct *p)
700 {
701         SPOOL_Q_RESETPRINTER q_u;
702         SPOOL_R_RESETPRINTER r_u;
703         prs_struct *data = &p->in_data.data;
704         prs_struct *rdata = &p->out_data.rdata;
705
706         ZERO_STRUCT(q_u);
707         ZERO_STRUCT(r_u);
708
709         if(!spoolss_io_q_resetprinter("", &q_u, data, 0)) {
710                 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
711                 return False;
712         }
713         
714         r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
715
716         if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) {
717                 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n"));
718                 return False;
719         }
720
721         return True;
722 }
723
724 /****************************************************************************
725 ****************************************************************************/
726 static bool api_spoolss_addform(pipes_struct *p)
727 {
728         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDFORM);
729 }
730
731 /****************************************************************************
732 ****************************************************************************/
733
734 static bool api_spoolss_deleteform(pipes_struct *p)
735 {
736         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEFORM);
737 }
738
739 /****************************************************************************
740 ****************************************************************************/
741
742 static bool api_spoolss_setform(pipes_struct *p)
743 {
744         return proxy_spoolss_call(p, NDR_SPOOLSS_SETFORM);
745 }
746
747 /****************************************************************************
748 ****************************************************************************/
749
750 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
751 {
752         SPOOL_Q_ENUMPRINTPROCESSORS q_u;
753         SPOOL_R_ENUMPRINTPROCESSORS r_u;
754         prs_struct *data = &p->in_data.data;
755         prs_struct *rdata = &p->out_data.rdata;
756
757         ZERO_STRUCT(q_u);
758         ZERO_STRUCT(r_u);
759         
760         if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
761                 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
762                 return False;
763         }
764         
765         r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
766
767         if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
768                 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
769                 return False;
770         }
771         
772         return True;
773 }
774
775 /****************************************************************************
776 ****************************************************************************/
777
778 static bool api_spoolss_addprintprocessor(pipes_struct *p)
779 {
780         return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTPROCESSOR);
781 }
782
783 /****************************************************************************
784 ****************************************************************************/
785
786 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
787 {
788         SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
789         SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
790         prs_struct *data = &p->in_data.data;
791         prs_struct *rdata = &p->out_data.rdata;
792
793         ZERO_STRUCT(q_u);
794         ZERO_STRUCT(r_u);
795         
796         if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
797                 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
798                 return False;
799         }
800         
801         r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
802
803         if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
804                 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
805                 return False;
806         }
807         
808         return True;
809 }
810
811 /****************************************************************************
812 ****************************************************************************/
813
814 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
815 {
816         SPOOL_Q_ENUMPRINTMONITORS q_u;
817         SPOOL_R_ENUMPRINTMONITORS r_u;
818         prs_struct *data = &p->in_data.data;
819         prs_struct *rdata = &p->out_data.rdata;
820
821         ZERO_STRUCT(q_u);
822         ZERO_STRUCT(r_u);
823         
824         if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
825                 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
826                 return False;
827         }
828                 
829         r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
830
831         if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
832                 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
833                 return False;
834         }
835         
836         return True;
837 }
838
839 /****************************************************************************
840 ****************************************************************************/
841
842 static bool api_spoolss_getjob(pipes_struct *p)
843 {
844         SPOOL_Q_GETJOB q_u;
845         SPOOL_R_GETJOB r_u;
846         prs_struct *data = &p->in_data.data;
847         prs_struct *rdata = &p->out_data.rdata;
848         
849         ZERO_STRUCT(q_u);
850         ZERO_STRUCT(r_u);
851         
852         if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
853                 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
854                 return False;
855         }
856
857         r_u.status = _spoolss_getjob(p, &q_u, &r_u);
858         
859         if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
860                 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
861                 return False;
862         }
863                 
864         return True;
865 }
866
867 /********************************************************************
868  * api_spoolss_getprinterdataex
869  *
870  * called from the spoolss dispatcher
871  ********************************************************************/
872
873 static bool api_spoolss_getprinterdataex(pipes_struct *p)
874 {
875         return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDATAEX);
876 }
877
878 /****************************************************************************
879 ****************************************************************************/
880
881 static bool api_spoolss_setprinterdataex(pipes_struct *p)
882 {
883         return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTERDATAEX);
884 }
885
886
887 /****************************************************************************
888 ****************************************************************************/
889
890 static bool api_spoolss_enumprinterkey(pipes_struct *p)
891 {
892         SPOOL_Q_ENUMPRINTERKEY q_u;
893         SPOOL_R_ENUMPRINTERKEY r_u;
894         prs_struct *data = &p->in_data.data;
895         prs_struct *rdata = &p->out_data.rdata;
896         
897         ZERO_STRUCT(q_u);
898         ZERO_STRUCT(r_u);
899         
900         if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
901                 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
902                 return False;
903         }
904         
905         r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
906                                 
907         if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
908                 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
909                 return False;
910         }
911
912         return True;
913 }
914
915 /****************************************************************************
916 ****************************************************************************/
917
918 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
919 {
920         SPOOL_Q_ENUMPRINTERDATAEX q_u;
921         SPOOL_R_ENUMPRINTERDATAEX r_u;
922         prs_struct *data = &p->in_data.data;
923         prs_struct *rdata = &p->out_data.rdata;
924         
925         ZERO_STRUCT(q_u);
926         ZERO_STRUCT(r_u);
927         
928         if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
929                 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
930                 return False;
931         }
932         
933         r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
934                                 
935         if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
936                 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
937                 return False;
938         }
939
940         return True;
941 }
942
943 /****************************************************************************
944 ****************************************************************************/
945
946 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
947 {
948         SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u;
949         SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u;
950         prs_struct *data = &p->in_data.data;
951         prs_struct *rdata = &p->out_data.rdata;
952         
953         ZERO_STRUCT(q_u);
954         ZERO_STRUCT(r_u);
955         
956         if(!spoolss_io_q_getprintprocessordirectory("", &q_u, data, 0)) {
957                 DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n"));
958                 return False;
959         }
960         
961         r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
962                                 
963         if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) {
964                 DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n"));
965                 return False;
966         }
967         
968         return True;
969 }
970
971 /****************************************************************************
972 ****************************************************************************/
973
974 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
975 {
976         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATAEX);
977 }
978
979 /****************************************************************************
980 ****************************************************************************/
981
982 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
983 {
984         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERKEY);
985 }
986
987 /****************************************************************************
988 ****************************************************************************/
989
990 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
991 {
992         SPOOL_Q_ADDPRINTERDRIVEREX q_u;
993         SPOOL_R_ADDPRINTERDRIVEREX r_u;
994         prs_struct *data = &p->in_data.data;
995         prs_struct *rdata = &p->out_data.rdata;
996         
997         ZERO_STRUCT(q_u);
998         ZERO_STRUCT(r_u);
999         
1000         if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) {
1001                 if (q_u.level != 3 && q_u.level != 6) {
1002                         /* Clever hack from Martin Zielinski <mz@seh.de>
1003                          * to allow downgrade from level 8 (Vista).
1004                          */
1005                         DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n",
1006                                 (unsigned int)q_u.level ));
1007                         setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
1008                         return True;
1009                 }
1010                 DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
1011                 return False;
1012         }
1013         
1014         r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
1015                                 
1016         if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) {
1017                 DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n"));
1018                 return False;
1019         }
1020         
1021         return True;
1022 }
1023
1024 /****************************************************************************
1025 ****************************************************************************/
1026
1027 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
1028 {
1029         return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVEREX);
1030 }
1031
1032 /****************************************************************************
1033 ****************************************************************************/
1034
1035 static bool api_spoolss_xcvdataport(pipes_struct *p)
1036 {
1037         SPOOL_Q_XCVDATAPORT q_u;
1038         SPOOL_R_XCVDATAPORT r_u;
1039         prs_struct *data = &p->in_data.data;
1040         prs_struct *rdata = &p->out_data.rdata;
1041         
1042         ZERO_STRUCT(q_u);
1043         ZERO_STRUCT(r_u);
1044         
1045         if(!spoolss_io_q_xcvdataport("", &q_u, data, 0)) {
1046                 DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_XCVDATAPORT.\n"));
1047                 return False;
1048         }
1049         
1050         r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u);
1051                                 
1052         if(!spoolss_io_r_xcvdataport("", &r_u, rdata, 0)) {
1053                 DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_XCVDATAPORT.\n"));
1054                 return False;
1055         }
1056         
1057         return True;
1058 }
1059
1060 /*******************************************************************
1061 \pipe\spoolss commands
1062 ********************************************************************/
1063
1064   struct api_struct api_spoolss_cmds[] = 
1065     {
1066  {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
1067  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
1068  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
1069  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
1070  {"SPOOLSS_DELETEPRINTER",             SPOOLSS_DELETEPRINTER,             api_spoolss_deleteprinter             },
1071  {"SPOOLSS_ABORTPRINTER",              SPOOLSS_ABORTPRINTER,              api_spoolss_abortprinter              },
1072  {"SPOOLSS_RFFPCNEX",                  SPOOLSS_RFFPCNEX,                  api_spoolss_rffpcnex                  },
1073  {"SPOOLSS_RFNPCNEX",                  SPOOLSS_RFNPCNEX,                  api_spoolss_rfnpcnex                  },
1074  {"SPOOLSS_ENUMPRINTERS",              SPOOLSS_ENUMPRINTERS,              api_spoolss_enumprinters              },
1075  {"SPOOLSS_GETPRINTER",                SPOOLSS_GETPRINTER,                api_spoolss_getprinter                },
1076  {"SPOOLSS_GETPRINTERDRIVER2",         SPOOLSS_GETPRINTERDRIVER2,         api_spoolss_getprinterdriver2         }, 
1077  {"SPOOLSS_STARTPAGEPRINTER",          SPOOLSS_STARTPAGEPRINTER,          api_spoolss_startpageprinter          },
1078  {"SPOOLSS_ENDPAGEPRINTER",            SPOOLSS_ENDPAGEPRINTER,            api_spoolss_endpageprinter            }, 
1079  {"SPOOLSS_STARTDOCPRINTER",           SPOOLSS_STARTDOCPRINTER,           api_spoolss_startdocprinter           },
1080  {"SPOOLSS_ENDDOCPRINTER",             SPOOLSS_ENDDOCPRINTER,             api_spoolss_enddocprinter             },
1081  {"SPOOLSS_WRITEPRINTER",              SPOOLSS_WRITEPRINTER,              api_spoolss_writeprinter              },
1082  {"SPOOLSS_SETPRINTER",                SPOOLSS_SETPRINTER,                api_spoolss_setprinter                },
1083  {"SPOOLSS_FCPN",                      SPOOLSS_FCPN,                      api_spoolss_fcpn                      },
1084  {"SPOOLSS_ADDJOB",                    SPOOLSS_ADDJOB,                    api_spoolss_addjob                    },
1085  {"SPOOLSS_ENUMJOBS",                  SPOOLSS_ENUMJOBS,                  api_spoolss_enumjobs                  },
1086  {"SPOOLSS_SCHEDULEJOB",               SPOOLSS_SCHEDULEJOB,               api_spoolss_schedulejob               },
1087  {"SPOOLSS_SETJOB",                    SPOOLSS_SETJOB,                    api_spoolss_setjob                    },
1088  {"SPOOLSS_ENUMFORMS",                 SPOOLSS_ENUMFORMS,                 api_spoolss_enumforms                 },
1089  {"SPOOLSS_ENUMPORTS",                 SPOOLSS_ENUMPORTS,                 api_spoolss_enumports                 },
1090  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
1091  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
1092  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
1093  {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
1094  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1095  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
1096  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
1097  {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
1098  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
1099  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
1100  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
1101  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
1102  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
1103  {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
1104  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
1105  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
1106  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
1107  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
1108  {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
1109  {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
1110  {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
1111  {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
1112  {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
1113  {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
1114  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
1115  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
1116  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
1117  {"SPOOLSS_XCVDATAPORT",               SPOOLSS_XCVDATAPORT,               api_spoolss_xcvdataport               },
1118 };
1119
1120 void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns )
1121 {
1122         *fns = api_spoolss_cmds;
1123         *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
1124 }
1125
1126 NTSTATUS rpc_spoolss2_init(void)
1127 {
1128         return rpc_srv_register(
1129                 SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss",
1130                 &ndr_table_spoolss,
1131                 api_spoolss_cmds,
1132                 sizeof(api_spoolss_cmds) / sizeof(struct api_struct));
1133 }