lib/tevent: expose ev_timeval_zero() for internal usage
[Samba/gbeck.git] / source3 / rpc_server / srv_spoolss.c
blob68b7c3c4b9d6008cae2b029a96fda5e1a1ed1827
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 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;
82 ZERO_STRUCT(q_u);
83 ZERO_STRUCT(r_u);
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;
91 r_u.status = _spoolss_getprinterdata( p, &q_u, &r_u);
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;
98 return True;
101 /********************************************************************
102 * api_spoolss_deleteprinterdata
104 * called from the spoolss dispatcher
105 ********************************************************************/
107 static bool api_spoolss_deleteprinterdata(pipes_struct *p)
109 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATA);
112 /********************************************************************
113 * api_spoolss_closeprinter
115 * called from the spoolss dispatcher
116 ********************************************************************/
118 static bool api_spoolss_closeprinter(pipes_struct *p)
120 return proxy_spoolss_call(p, NDR_SPOOLSS_CLOSEPRINTER);
123 /********************************************************************
124 * api_spoolss_abortprinter
126 * called from the spoolss dispatcher
127 ********************************************************************/
129 static bool api_spoolss_abortprinter(pipes_struct *p)
131 return proxy_spoolss_call(p, NDR_SPOOLSS_ABORTPRINTER);
134 /********************************************************************
135 * api_spoolss_deleteprinter
137 * called from the spoolss dispatcher
138 ********************************************************************/
140 static bool api_spoolss_deleteprinter(pipes_struct *p)
142 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTER);
145 /********************************************************************
146 * api_spoolss_deleteprinterdriver
148 * called from the spoolss dispatcher
149 ********************************************************************/
151 static bool api_spoolss_deleteprinterdriver(pipes_struct *p)
153 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVER);
157 /********************************************************************
158 * api_spoolss_rffpcnex
159 * ReplyFindFirstPrinterChangeNotifyEx
160 ********************************************************************/
162 static bool api_spoolss_rffpcnex(pipes_struct *p)
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;
169 ZERO_STRUCT(q_u);
170 ZERO_STRUCT(r_u);
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;
177 r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u);
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;
184 return True;
188 /********************************************************************
189 * api_spoolss_rfnpcnex
190 * ReplyFindNextPrinterChangeNotifyEx
191 * called from the spoolss dispatcher
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 ********************************************************************/
199 static bool api_spoolss_rfnpcnex(pipes_struct *p)
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;
206 ZERO_STRUCT(q_u);
207 ZERO_STRUCT(r_u);
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;
214 r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u);
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;
222 SAFE_FREE(r_u.info.data);
224 return True;
228 /********************************************************************
229 * api_spoolss_enumprinters
230 * called from the spoolss dispatcher
232 ********************************************************************/
234 static bool api_spoolss_enumprinters(pipes_struct *p)
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;
241 ZERO_STRUCT(q_u);
242 ZERO_STRUCT(r_u);
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;
249 r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
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;
256 return True;
259 /********************************************************************
260 * api_spoolss_getprinter
261 * called from the spoolss dispatcher
263 ********************************************************************/
265 static bool api_spoolss_getprinter(pipes_struct *p)
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;
272 ZERO_STRUCT(q_u);
273 ZERO_STRUCT(r_u);
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;
280 r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
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;
287 return True;
290 /********************************************************************
291 * api_spoolss_getprinter
292 * called from the spoolss dispatcher
294 ********************************************************************/
296 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
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;
303 ZERO_STRUCT(q_u);
304 ZERO_STRUCT(r_u);
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;
311 r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
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;
318 return True;
321 /********************************************************************
322 * api_spoolss_getprinter
323 * called from the spoolss dispatcher
325 ********************************************************************/
327 static bool api_spoolss_startpageprinter(pipes_struct *p)
329 return proxy_spoolss_call(p, NDR_SPOOLSS_STARTPAGEPRINTER);
332 /********************************************************************
333 * api_spoolss_getprinter
334 * called from the spoolss dispatcher
336 ********************************************************************/
338 static bool api_spoolss_endpageprinter(pipes_struct *p)
340 return proxy_spoolss_call(p, NDR_SPOOLSS_ENDPAGEPRINTER);
343 /********************************************************************
344 ********************************************************************/
346 static bool api_spoolss_startdocprinter(pipes_struct *p)
348 return proxy_spoolss_call(p, NDR_SPOOLSS_STARTDOCPRINTER);
351 /********************************************************************
352 ********************************************************************/
354 static bool api_spoolss_enddocprinter(pipes_struct *p)
356 return proxy_spoolss_call(p, NDR_SPOOLSS_ENDDOCPRINTER);
359 /********************************************************************
360 ********************************************************************/
362 static bool api_spoolss_writeprinter(pipes_struct *p)
364 return proxy_spoolss_call(p, NDR_SPOOLSS_WRITEPRINTER);
367 /****************************************************************************
369 ****************************************************************************/
371 static bool api_spoolss_setprinter(pipes_struct *p)
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;
378 ZERO_STRUCT(q_u);
379 ZERO_STRUCT(r_u);
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;
386 r_u.status = _spoolss_setprinter(p, &q_u, &r_u);
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;
393 return True;
396 /****************************************************************************
397 ****************************************************************************/
399 static bool api_spoolss_fcpn(pipes_struct *p)
401 return proxy_spoolss_call(p, NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY);
404 /****************************************************************************
405 ****************************************************************************/
407 static bool api_spoolss_addjob(pipes_struct *p)
409 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDJOB);
412 /****************************************************************************
413 ****************************************************************************/
415 static bool api_spoolss_enumjobs(pipes_struct *p)
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;
422 ZERO_STRUCT(q_u);
423 ZERO_STRUCT(r_u);
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;
430 r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
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;
437 return True;
440 /****************************************************************************
441 ****************************************************************************/
443 static bool api_spoolss_schedulejob(pipes_struct *p)
445 return proxy_spoolss_call(p, NDR_SPOOLSS_SCHEDULEJOB);
448 /****************************************************************************
449 ****************************************************************************/
451 static bool api_spoolss_setjob(pipes_struct *p)
453 return proxy_spoolss_call(p, NDR_SPOOLSS_SETJOB);
456 /****************************************************************************
457 ****************************************************************************/
459 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
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;
466 ZERO_STRUCT(q_u);
467 ZERO_STRUCT(r_u);
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;
474 r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
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;
481 return True;
484 /****************************************************************************
485 ****************************************************************************/
487 static bool api_spoolss_getform(pipes_struct *p)
489 return proxy_spoolss_call(p, NDR_SPOOLSS_GETFORM);
492 /****************************************************************************
493 ****************************************************************************/
495 static bool api_spoolss_enumforms(pipes_struct *p)
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;
502 ZERO_STRUCT(q_u);
503 ZERO_STRUCT(r_u);
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;
510 r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
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;
517 return True;
520 /****************************************************************************
521 ****************************************************************************/
523 static bool api_spoolss_enumports(pipes_struct *p)
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;
530 ZERO_STRUCT(q_u);
531 ZERO_STRUCT(r_u);
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;
538 r_u.status = _spoolss_enumports(p, &q_u, &r_u);
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;
545 return True;
548 /****************************************************************************
549 ****************************************************************************/
551 static bool api_spoolss_addprinterex(pipes_struct *p)
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;
558 ZERO_STRUCT(q_u);
559 ZERO_STRUCT(r_u);
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;
566 r_u.status = _spoolss_addprinterex(p, &q_u, &r_u);
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;
573 return True;
576 /****************************************************************************
577 ****************************************************************************/
579 static bool api_spoolss_addprinterdriver(pipes_struct *p)
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;
586 ZERO_STRUCT(q_u);
587 ZERO_STRUCT(r_u);
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).
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;
599 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
600 return False;
603 r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u);
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;
610 return True;
613 /****************************************************************************
614 ****************************************************************************/
616 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
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;
623 ZERO_STRUCT(q_u);
624 ZERO_STRUCT(r_u);
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;
631 r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
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;
638 return True;
641 /****************************************************************************
642 ****************************************************************************/
644 static bool api_spoolss_enumprinterdata(pipes_struct *p)
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;
651 ZERO_STRUCT(q_u);
652 ZERO_STRUCT(r_u);
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;
659 r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
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;
666 return True;
669 /****************************************************************************
670 ****************************************************************************/
672 static bool api_spoolss_setprinterdata(pipes_struct *p)
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;
679 ZERO_STRUCT(q_u);
680 ZERO_STRUCT(r_u);
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;
687 r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
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;
694 return True;
697 /****************************************************************************
698 ****************************************************************************/
699 static bool api_spoolss_reset_printer(pipes_struct *p)
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;
706 ZERO_STRUCT(q_u);
707 ZERO_STRUCT(r_u);
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;
714 r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
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;
721 return True;
724 /****************************************************************************
725 ****************************************************************************/
726 static bool api_spoolss_addform(pipes_struct *p)
728 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDFORM);
731 /****************************************************************************
732 ****************************************************************************/
734 static bool api_spoolss_deleteform(pipes_struct *p)
736 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEFORM);
739 /****************************************************************************
740 ****************************************************************************/
742 static bool api_spoolss_setform(pipes_struct *p)
744 return proxy_spoolss_call(p, NDR_SPOOLSS_SETFORM);
747 /****************************************************************************
748 ****************************************************************************/
750 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
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;
757 ZERO_STRUCT(q_u);
758 ZERO_STRUCT(r_u);
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;
765 r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
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;
772 return True;
775 /****************************************************************************
776 ****************************************************************************/
778 static bool api_spoolss_addprintprocessor(pipes_struct *p)
780 return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTPROCESSOR);
783 /****************************************************************************
784 ****************************************************************************/
786 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
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;
793 ZERO_STRUCT(q_u);
794 ZERO_STRUCT(r_u);
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;
801 r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
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;
808 return True;
811 /****************************************************************************
812 ****************************************************************************/
814 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
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;
821 ZERO_STRUCT(q_u);
822 ZERO_STRUCT(r_u);
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;
829 r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
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;
836 return True;
839 /****************************************************************************
840 ****************************************************************************/
842 static bool api_spoolss_getjob(pipes_struct *p)
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;
849 ZERO_STRUCT(q_u);
850 ZERO_STRUCT(r_u);
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;
857 r_u.status = _spoolss_getjob(p, &q_u, &r_u);
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;
864 return True;
867 /********************************************************************
868 * api_spoolss_getprinterdataex
870 * called from the spoolss dispatcher
871 ********************************************************************/
873 static bool api_spoolss_getprinterdataex(pipes_struct *p)
875 return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDATAEX);
878 /****************************************************************************
879 ****************************************************************************/
881 static bool api_spoolss_setprinterdataex(pipes_struct *p)
883 return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTERDATAEX);
887 /****************************************************************************
888 ****************************************************************************/
890 static bool api_spoolss_enumprinterkey(pipes_struct *p)
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;
897 ZERO_STRUCT(q_u);
898 ZERO_STRUCT(r_u);
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;
905 r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
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;
912 return True;
915 /****************************************************************************
916 ****************************************************************************/
918 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
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;
925 ZERO_STRUCT(q_u);
926 ZERO_STRUCT(r_u);
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;
933 r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
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;
940 return True;
943 /****************************************************************************
944 ****************************************************************************/
946 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
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;
953 ZERO_STRUCT(q_u);
954 ZERO_STRUCT(r_u);
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;
961 r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
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;
968 return True;
971 /****************************************************************************
972 ****************************************************************************/
974 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
976 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDATAEX);
979 /****************************************************************************
980 ****************************************************************************/
982 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
984 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERKEY);
987 /****************************************************************************
988 ****************************************************************************/
990 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
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;
997 ZERO_STRUCT(q_u);
998 ZERO_STRUCT(r_u);
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).
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;
1010 DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
1011 return False;
1014 r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
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;
1021 return True;
1024 /****************************************************************************
1025 ****************************************************************************/
1027 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
1029 return proxy_spoolss_call(p, NDR_SPOOLSS_DELETEPRINTERDRIVEREX);
1032 /****************************************************************************
1033 ****************************************************************************/
1035 static bool api_spoolss_xcvdataport(pipes_struct *p)
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;
1042 ZERO_STRUCT(q_u);
1043 ZERO_STRUCT(r_u);
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;
1050 r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u);
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;
1057 return True;
1060 /*******************************************************************
1061 \pipe\spoolss commands
1062 ********************************************************************/
1064 struct api_struct api_spoolss_cmds[] =
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 },
1120 void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns )
1122 *fns = api_spoolss_cmds;
1123 *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
1126 NTSTATUS rpc_spoolss2_init(void)
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));