s3-spoolss: use pidl for _spoolss_EnumPrinterDataEx.
[Samba/fernandojvsilva.git] / source3 / rpc_server / srv_spoolss.c
blob301d4a7dd1598bfe275bc87561a7b74e1d1cbda5
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.
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.
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.
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/>.
25 #include "includes.h"
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_RPC_SRV
30 /*******************************************************************
31 ********************************************************************/
33 static bool proxy_spoolss_call(pipes_struct *p, uint8_t opnum)
35 struct api_struct *fns;
36 int n_fns;
38 spoolss_get_pipe_fns(&fns, &n_fns);
40 if (opnum >= n_fns) {
41 return false;
44 if (fns[opnum].opnum != opnum) {
45 smb_panic("SPOOLSS function table not sorted");
48 return fns[opnum].fn(p);
51 /********************************************************************
52 * api_spoolss_open_printer_ex (rarely seen - older call)
53 ********************************************************************/
55 static bool api_spoolss_open_printer(pipes_struct *p)
57 return proxy_spoolss_call(p, NDR_SPOOLSS_OPENPRINTER);
60 /********************************************************************
61 * api_spoolss_open_printer_ex
62 ********************************************************************/
64 static bool api_spoolss_open_printer_ex(pipes_struct *p)
66 return proxy_spoolss_call(p, NDR_SPOOLSS_OPENPRINTEREX);
69 /********************************************************************
70 * api_spoolss_getprinterdata
72 * called from the spoolss dispatcher
73 ********************************************************************/
75 static bool api_spoolss_getprinterdata(pipes_struct *p)
77 return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDATA);
80 /********************************************************************
81 * api_spoolss_deleteprinterdata
83 * called from the spoolss dispatcher
84 ********************************************************************/
86 static bool api_spoolss_deleteprinterdata(pipes_struct *p)
88 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATA);
91 /********************************************************************
92 * api_spoolss_closeprinter
94 * called from the spoolss dispatcher
95 ********************************************************************/
97 static bool api_spoolss_closeprinter(pipes_struct *p)
99 return proxy_spoolss_call(p, NDR_SPOOLSS_CLOSEPRINTER);
102 /********************************************************************
103 * api_spoolss_abortprinter
105 * called from the spoolss dispatcher
106 ********************************************************************/
108 static bool api_spoolss_abortprinter(pipes_struct *p)
110 return proxy_spoolss_call(p, NDR_SPOOLSS_ABORTPRINTER);
113 /********************************************************************
114 * api_spoolss_deleteprinter
116 * called from the spoolss dispatcher
117 ********************************************************************/
119 static bool api_spoolss_deleteprinter(pipes_struct *p)
121 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTER);
124 /********************************************************************
125 * api_spoolss_deleteprinterdriver
127 * called from the spoolss dispatcher
128 ********************************************************************/
130 static bool api_spoolss_deleteprinterdriver(pipes_struct *p)
132 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVER);
136 /********************************************************************
137 * api_spoolss_rffpcnex
138 * ReplyFindFirstPrinterChangeNotifyEx
139 ********************************************************************/
141 static bool api_spoolss_rffpcnex(pipes_struct *p)
143 return proxy_spoolss_call(p, NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX);
147 /********************************************************************
148 * api_spoolss_rfnpcnex
149 * ReplyFindNextPrinterChangeNotifyEx
150 * called from the spoolss dispatcher
152 * Note - this is the *ONLY* function that breaks the RPC call
153 * symmetry in all the other calls. We need to do this to fix
154 * the massive memory allocation problem with thousands of jobs...
155 * JRA.
156 ********************************************************************/
158 static bool api_spoolss_rfnpcnex(pipes_struct *p)
160 return proxy_spoolss_call(p, NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFY);
164 /********************************************************************
165 * api_spoolss_enumprinters
166 * called from the spoolss dispatcher
168 ********************************************************************/
170 static bool api_spoolss_enumprinters(pipes_struct *p)
172 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERS);
175 /********************************************************************
176 * api_spoolss_getprinter
177 * called from the spoolss dispatcher
179 ********************************************************************/
181 static bool api_spoolss_getprinter(pipes_struct *p)
183 return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTER);
186 /********************************************************************
187 * api_spoolss_getprinter
188 * called from the spoolss dispatcher
190 ********************************************************************/
192 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
194 return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDRIVER2);
197 /********************************************************************
198 * api_spoolss_getprinter
199 * called from the spoolss dispatcher
201 ********************************************************************/
203 static bool api_spoolss_startpageprinter(pipes_struct *p)
205 return proxy_spoolss_call(p, NDR_SPOOLSS_STARTPAGEPRINTER);
208 /********************************************************************
209 * api_spoolss_getprinter
210 * called from the spoolss dispatcher
212 ********************************************************************/
214 static bool api_spoolss_endpageprinter(pipes_struct *p)
216 return proxy_spoolss_call(p, NDR_SPOOLSS_ENDPAGEPRINTER);
219 /********************************************************************
220 ********************************************************************/
222 static bool api_spoolss_startdocprinter(pipes_struct *p)
224 return proxy_spoolss_call(p, NDR_SPOOLSS_STARTDOCPRINTER);
227 /********************************************************************
228 ********************************************************************/
230 static bool api_spoolss_enddocprinter(pipes_struct *p)
232 return proxy_spoolss_call(p, NDR_SPOOLSS_ENDDOCPRINTER);
235 /********************************************************************
236 ********************************************************************/
238 static bool api_spoolss_writeprinter(pipes_struct *p)
240 return proxy_spoolss_call(p, NDR_SPOOLSS_WRITEPRINTER);
243 /****************************************************************************
245 ****************************************************************************/
247 static bool api_spoolss_setprinter(pipes_struct *p)
249 return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTER);
252 /****************************************************************************
253 ****************************************************************************/
255 static bool api_spoolss_fcpn(pipes_struct *p)
257 return proxy_spoolss_call(p, NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY);
260 /****************************************************************************
261 ****************************************************************************/
263 static bool api_spoolss_addjob(pipes_struct *p)
265 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDJOB);
268 /****************************************************************************
269 ****************************************************************************/
271 static bool api_spoolss_enumjobs(pipes_struct *p)
273 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMJOBS);
276 /****************************************************************************
277 ****************************************************************************/
279 static bool api_spoolss_schedulejob(pipes_struct *p)
281 return proxy_spoolss_call(p, NDR_SPOOLSS_SCHEDULEJOB);
284 /****************************************************************************
285 ****************************************************************************/
287 static bool api_spoolss_setjob(pipes_struct *p)
289 return proxy_spoolss_call(p, NDR_SPOOLSS_SETJOB);
292 /****************************************************************************
293 ****************************************************************************/
295 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
297 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERDRIVERS);
300 /****************************************************************************
301 ****************************************************************************/
303 static bool api_spoolss_getform(pipes_struct *p)
305 return proxy_spoolss_call(p, NDR_SPOOLSS_GETFORM);
308 /****************************************************************************
309 ****************************************************************************/
311 static bool api_spoolss_enumforms(pipes_struct *p)
313 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMFORMS);
316 /****************************************************************************
317 ****************************************************************************/
319 static bool api_spoolss_enumports(pipes_struct *p)
321 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPORTS);
324 /****************************************************************************
325 ****************************************************************************/
327 static bool api_spoolss_addprinterex(pipes_struct *p)
329 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTEREX);
332 /****************************************************************************
333 ****************************************************************************/
335 static bool api_spoolss_addprinterdriver(pipes_struct *p)
337 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTERDRIVER);
340 /****************************************************************************
341 ****************************************************************************/
343 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
345 return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY);
348 /****************************************************************************
349 ****************************************************************************/
351 static bool api_spoolss_enumprinterdata(pipes_struct *p)
353 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERDATA);
356 /****************************************************************************
357 ****************************************************************************/
359 static bool api_spoolss_setprinterdata(pipes_struct *p)
361 return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTERDATA);
364 /****************************************************************************
365 ****************************************************************************/
366 static bool api_spoolss_reset_printer(pipes_struct *p)
368 return proxy_spoolss_call(p, NDR_SPOOLSS_RESETPRINTER);
371 /****************************************************************************
372 ****************************************************************************/
373 static bool api_spoolss_addform(pipes_struct *p)
375 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDFORM);
378 /****************************************************************************
379 ****************************************************************************/
381 static bool api_spoolss_deleteform(pipes_struct *p)
383 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEFORM);
386 /****************************************************************************
387 ****************************************************************************/
389 static bool api_spoolss_setform(pipes_struct *p)
391 return proxy_spoolss_call(p, NDR_SPOOLSS_SETFORM);
394 /****************************************************************************
395 ****************************************************************************/
397 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
399 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCESSORS);
402 /****************************************************************************
403 ****************************************************************************/
405 static bool api_spoolss_addprintprocessor(pipes_struct *p)
407 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTPROCESSOR);
410 /****************************************************************************
411 ****************************************************************************/
413 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
415 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCDATATYPES);
418 /****************************************************************************
419 ****************************************************************************/
421 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
423 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMMONITORS);
426 /****************************************************************************
427 ****************************************************************************/
429 static bool api_spoolss_getjob(pipes_struct *p)
431 return proxy_spoolss_call(p, NDR_SPOOLSS_GETJOB);
434 /********************************************************************
435 * api_spoolss_getprinterdataex
437 * called from the spoolss dispatcher
438 ********************************************************************/
440 static bool api_spoolss_getprinterdataex(pipes_struct *p)
442 return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDATAEX);
445 /****************************************************************************
446 ****************************************************************************/
448 static bool api_spoolss_setprinterdataex(pipes_struct *p)
450 return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTERDATAEX);
454 /****************************************************************************
455 ****************************************************************************/
457 static bool api_spoolss_enumprinterkey(pipes_struct *p)
459 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERKEY);
462 /****************************************************************************
463 ****************************************************************************/
465 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
467 return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERDATAEX);
470 /****************************************************************************
471 ****************************************************************************/
473 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
475 return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY);
478 /****************************************************************************
479 ****************************************************************************/
481 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
483 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATAEX);
486 /****************************************************************************
487 ****************************************************************************/
489 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
491 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERKEY);
494 /****************************************************************************
495 ****************************************************************************/
497 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
499 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTERDRIVEREX);
502 /****************************************************************************
503 ****************************************************************************/
505 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
507 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVEREX);
510 /****************************************************************************
511 ****************************************************************************/
513 static bool api_spoolss_xcvdataport(pipes_struct *p)
515 return proxy_spoolss_call(p, NDR_SPOOLSS_XCVDATA);
518 /*******************************************************************
519 \pipe\spoolss commands
520 ********************************************************************/
522 struct api_struct api_spoolss_cmds[] =
524 {"SPOOLSS_OPENPRINTER", SPOOLSS_OPENPRINTER, api_spoolss_open_printer },
525 {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex },
526 {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
527 {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
528 {"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter },
529 {"SPOOLSS_ABORTPRINTER", SPOOLSS_ABORTPRINTER, api_spoolss_abortprinter },
530 {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
531 {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex },
532 {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters },
533 {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter },
534 {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 },
535 {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter },
536 {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter },
537 {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter },
538 {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter },
539 {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter },
540 {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter },
541 {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn },
542 {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob },
543 {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs },
544 {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob },
545 {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob },
546 {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms },
547 {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports },
548 {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers },
549 {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex },
550 {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver },
551 {"SPOOLSS_DELETEPRINTERDRIVER", SPOOLSS_DELETEPRINTERDRIVER, api_spoolss_deleteprinterdriver },
552 {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
553 {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata },
554 {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata },
555 {"SPOOLSS_RESETPRINTER", SPOOLSS_RESETPRINTER, api_spoolss_reset_printer },
556 {"SPOOLSS_DELETEPRINTERDATA", SPOOLSS_DELETEPRINTERDATA, api_spoolss_deleteprinterdata },
557 {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform },
558 {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform },
559 {"SPOOLSS_GETFORM", SPOOLSS_GETFORM, api_spoolss_getform },
560 {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform },
561 {"SPOOLSS_ADDPRINTPROCESSOR", SPOOLSS_ADDPRINTPROCESSOR, api_spoolss_addprintprocessor },
562 {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors },
563 {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors },
564 {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob },
565 {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes },
566 {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex },
567 {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex },
568 {"SPOOLSS_DELETEPRINTERDATAEX", SPOOLSS_DELETEPRINTERDATAEX, api_spoolss_deleteprinterdataex },
569 {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex },
570 {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey },
571 {"SPOOLSS_DELETEPRINTERKEY", SPOOLSS_DELETEPRINTERKEY, api_spoolss_deleteprinterkey },
572 {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
573 {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex },
574 {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex },
575 {"SPOOLSS_XCVDATAPORT", SPOOLSS_XCVDATAPORT, api_spoolss_xcvdataport },
578 void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns )
580 *fns = api_spoolss_cmds;
581 *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
584 NTSTATUS rpc_spoolss2_init(void)
586 return rpc_srv_register(
587 SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss",
588 &ndr_table_spoolss,
589 api_spoolss_cmds,
590 sizeof(api_spoolss_cmds) / sizeof(struct api_struct));