Fix bug 5860: safe_strcpy gives a nasty error message for overlong strings
[Samba.git] / source / rpc_server / srv_spoolss.c
blob7802fe447e7c20347a84d502111a4d3233a3af55
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 * api_spoolss_open_printer_ex (rarely seen - older call)
32 ********************************************************************/
34 static bool api_spoolss_open_printer(pipes_struct *p)
36 SPOOL_Q_OPEN_PRINTER q_u;
37 SPOOL_R_OPEN_PRINTER r_u;
38 prs_struct *data = &p->in_data.data;
39 prs_struct *rdata = &p->out_data.rdata;
41 ZERO_STRUCT(q_u);
42 ZERO_STRUCT(r_u);
44 if (!spoolss_io_q_open_printer("", &q_u, data, 0)) {
45 DEBUG(0,("spoolss_io_q_open_printer: unable to unmarshall SPOOL_Q_OPEN_PRINTER.\n"));
46 return False;
49 r_u.status = _spoolss_open_printer( p, &q_u, &r_u);
51 if (!spoolss_io_r_open_printer("",&r_u,rdata,0)){
52 DEBUG(0,("spoolss_io_r_open_printer: unable to marshall SPOOL_R_OPEN_PRINTER.\n"));
53 return False;
56 return True;
60 /********************************************************************
61 * api_spoolss_open_printer_ex
62 ********************************************************************/
64 static bool api_spoolss_open_printer_ex(pipes_struct *p)
66 SPOOL_Q_OPEN_PRINTER_EX q_u;
67 SPOOL_R_OPEN_PRINTER_EX r_u;
68 prs_struct *data = &p->in_data.data;
69 prs_struct *rdata = &p->out_data.rdata;
71 ZERO_STRUCT(q_u);
72 ZERO_STRUCT(r_u);
74 if (!spoolss_io_q_open_printer_ex("", &q_u, data, 0)) {
75 DEBUG(0,("spoolss_io_q_open_printer_ex: unable to unmarshall SPOOL_Q_OPEN_PRINTER_EX.\n"));
76 return False;
79 r_u.status = _spoolss_open_printer_ex( p, &q_u, &r_u);
81 if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){
82 DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n"));
83 return False;
86 return True;
89 /********************************************************************
90 * api_spoolss_getprinterdata
92 * called from the spoolss dispatcher
93 ********************************************************************/
95 static bool api_spoolss_getprinterdata(pipes_struct *p)
97 SPOOL_Q_GETPRINTERDATA q_u;
98 SPOOL_R_GETPRINTERDATA r_u;
99 prs_struct *data = &p->in_data.data;
100 prs_struct *rdata = &p->out_data.rdata;
102 ZERO_STRUCT(q_u);
103 ZERO_STRUCT(r_u);
105 /* read the stream and fill the struct */
106 if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) {
107 DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n"));
108 return False;
111 r_u.status = _spoolss_getprinterdata( p, &q_u, &r_u);
113 if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) {
114 DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n"));
115 return False;
118 return True;
121 /********************************************************************
122 * api_spoolss_deleteprinterdata
124 * called from the spoolss dispatcher
125 ********************************************************************/
127 static bool api_spoolss_deleteprinterdata(pipes_struct *p)
129 SPOOL_Q_DELETEPRINTERDATA q_u;
130 SPOOL_R_DELETEPRINTERDATA r_u;
131 prs_struct *data = &p->in_data.data;
132 prs_struct *rdata = &p->out_data.rdata;
134 ZERO_STRUCT(q_u);
135 ZERO_STRUCT(r_u);
137 /* read the stream and fill the struct */
138 if (!spoolss_io_q_deleteprinterdata("", &q_u, data, 0)) {
139 DEBUG(0,("spoolss_io_q_deleteprinterdata: unable to unmarshall SPOOL_Q_DELETEPRINTERDATA.\n"));
140 return False;
143 r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u );
145 if (!spoolss_io_r_deleteprinterdata("", &r_u, rdata, 0)) {
146 DEBUG(0,("spoolss_io_r_deleteprinterdata: unable to marshall SPOOL_R_DELETEPRINTERDATA.\n"));
147 return False;
150 return True;
153 /********************************************************************
154 * api_spoolss_closeprinter
156 * called from the spoolss dispatcher
157 ********************************************************************/
159 static bool api_spoolss_closeprinter(pipes_struct *p)
161 SPOOL_Q_CLOSEPRINTER q_u;
162 SPOOL_R_CLOSEPRINTER r_u;
163 prs_struct *data = &p->in_data.data;
164 prs_struct *rdata = &p->out_data.rdata;
166 ZERO_STRUCT(q_u);
167 ZERO_STRUCT(r_u);
169 if (!spoolss_io_q_closeprinter("", &q_u, data, 0)) {
170 DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n"));
171 return False;
174 r_u.status = _spoolss_closeprinter(p, &q_u, &r_u);
176 if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) {
177 DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n"));
178 return False;
181 return True;
184 /********************************************************************
185 * api_spoolss_abortprinter
187 * called from the spoolss dispatcher
188 ********************************************************************/
190 static bool api_spoolss_abortprinter(pipes_struct *p)
192 SPOOL_Q_ABORTPRINTER q_u;
193 SPOOL_R_ABORTPRINTER r_u;
194 prs_struct *data = &p->in_data.data;
195 prs_struct *rdata = &p->out_data.rdata;
197 ZERO_STRUCT(q_u);
198 ZERO_STRUCT(r_u);
200 if (!spoolss_io_q_abortprinter("", &q_u, data, 0)) {
201 DEBUG(0,("spoolss_io_q_abortprinter: unable to unmarshall SPOOL_Q_ABORTPRINTER.\n"));
202 return False;
205 r_u.status = _spoolss_abortprinter(p, &q_u, &r_u);
207 if (!spoolss_io_r_abortprinter("",&r_u,rdata,0)) {
208 DEBUG(0,("spoolss_io_r_abortprinter: unable to marshall SPOOL_R_ABORTPRINTER.\n"));
209 return False;
212 return True;
215 /********************************************************************
216 * api_spoolss_deleteprinter
218 * called from the spoolss dispatcher
219 ********************************************************************/
221 static bool api_spoolss_deleteprinter(pipes_struct *p)
223 SPOOL_Q_DELETEPRINTER q_u;
224 SPOOL_R_DELETEPRINTER r_u;
225 prs_struct *data = &p->in_data.data;
226 prs_struct *rdata = &p->out_data.rdata;
228 ZERO_STRUCT(q_u);
229 ZERO_STRUCT(r_u);
231 if (!spoolss_io_q_deleteprinter("", &q_u, data, 0)) {
232 DEBUG(0,("spoolss_io_q_deleteprinter: unable to unmarshall SPOOL_Q_DELETEPRINTER.\n"));
233 return False;
236 r_u.status = _spoolss_deleteprinter(p, &q_u, &r_u);
238 if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) {
239 DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
240 return False;
243 return True;
247 /********************************************************************
248 * api_spoolss_deleteprinterdriver
250 * called from the spoolss dispatcher
251 ********************************************************************/
253 static bool api_spoolss_deleteprinterdriver(pipes_struct *p)
255 SPOOL_Q_DELETEPRINTERDRIVER q_u;
256 SPOOL_R_DELETEPRINTERDRIVER r_u;
257 prs_struct *data = &p->in_data.data;
258 prs_struct *rdata = &p->out_data.rdata;
260 ZERO_STRUCT(q_u);
261 ZERO_STRUCT(r_u);
263 if (!spoolss_io_q_deleteprinterdriver("", &q_u, data, 0)) {
264 DEBUG(0,("spoolss_io_q_deleteprinterdriver: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVER.\n"));
265 return False;
268 r_u.status = _spoolss_deleteprinterdriver(p, &q_u, &r_u);
270 if (!spoolss_io_r_deleteprinterdriver("",&r_u,rdata,0)) {
271 DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
272 return False;
275 return True;
279 /********************************************************************
280 * api_spoolss_rffpcnex
281 * ReplyFindFirstPrinterChangeNotifyEx
282 ********************************************************************/
284 static bool api_spoolss_rffpcnex(pipes_struct *p)
286 SPOOL_Q_RFFPCNEX q_u;
287 SPOOL_R_RFFPCNEX r_u;
288 prs_struct *data = &p->in_data.data;
289 prs_struct *rdata = &p->out_data.rdata;
291 ZERO_STRUCT(q_u);
292 ZERO_STRUCT(r_u);
294 if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
295 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
296 return False;
299 r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u);
301 if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
302 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
303 return False;
306 return True;
310 /********************************************************************
311 * api_spoolss_rfnpcnex
312 * ReplyFindNextPrinterChangeNotifyEx
313 * called from the spoolss dispatcher
315 * Note - this is the *ONLY* function that breaks the RPC call
316 * symmetry in all the other calls. We need to do this to fix
317 * the massive memory allocation problem with thousands of jobs...
318 * JRA.
319 ********************************************************************/
321 static bool api_spoolss_rfnpcnex(pipes_struct *p)
323 SPOOL_Q_RFNPCNEX q_u;
324 SPOOL_R_RFNPCNEX r_u;
325 prs_struct *data = &p->in_data.data;
326 prs_struct *rdata = &p->out_data.rdata;
328 ZERO_STRUCT(q_u);
329 ZERO_STRUCT(r_u);
331 if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
332 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
333 return False;
336 r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u);
338 if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
339 SAFE_FREE(r_u.info.data);
340 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
341 return False;
344 SAFE_FREE(r_u.info.data);
346 return True;
350 /********************************************************************
351 * api_spoolss_enumprinters
352 * called from the spoolss dispatcher
354 ********************************************************************/
356 static bool api_spoolss_enumprinters(pipes_struct *p)
358 SPOOL_Q_ENUMPRINTERS q_u;
359 SPOOL_R_ENUMPRINTERS r_u;
360 prs_struct *data = &p->in_data.data;
361 prs_struct *rdata = &p->out_data.rdata;
363 ZERO_STRUCT(q_u);
364 ZERO_STRUCT(r_u);
366 if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
367 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
368 return False;
371 r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
373 if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
374 DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
375 return False;
378 return True;
381 /********************************************************************
382 * api_spoolss_getprinter
383 * called from the spoolss dispatcher
385 ********************************************************************/
387 static bool api_spoolss_getprinter(pipes_struct *p)
389 SPOOL_Q_GETPRINTER q_u;
390 SPOOL_R_GETPRINTER r_u;
391 prs_struct *data = &p->in_data.data;
392 prs_struct *rdata = &p->out_data.rdata;
394 ZERO_STRUCT(q_u);
395 ZERO_STRUCT(r_u);
397 if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
398 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
399 return False;
402 r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
404 if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
405 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
406 return False;
409 return True;
412 /********************************************************************
413 * api_spoolss_getprinter
414 * called from the spoolss dispatcher
416 ********************************************************************/
418 static bool api_spoolss_getprinterdriver2(pipes_struct *p)
420 SPOOL_Q_GETPRINTERDRIVER2 q_u;
421 SPOOL_R_GETPRINTERDRIVER2 r_u;
422 prs_struct *data = &p->in_data.data;
423 prs_struct *rdata = &p->out_data.rdata;
425 ZERO_STRUCT(q_u);
426 ZERO_STRUCT(r_u);
428 if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
429 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
430 return False;
433 r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
435 if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
436 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
437 return False;
440 return True;
443 /********************************************************************
444 * api_spoolss_getprinter
445 * called from the spoolss dispatcher
447 ********************************************************************/
449 static bool api_spoolss_startpageprinter(pipes_struct *p)
451 SPOOL_Q_STARTPAGEPRINTER q_u;
452 SPOOL_R_STARTPAGEPRINTER r_u;
453 prs_struct *data = &p->in_data.data;
454 prs_struct *rdata = &p->out_data.rdata;
456 ZERO_STRUCT(q_u);
457 ZERO_STRUCT(r_u);
459 if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) {
460 DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n"));
461 return False;
464 r_u.status = _spoolss_startpageprinter(p, &q_u, &r_u);
466 if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) {
467 DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n"));
468 return False;
471 return True;
474 /********************************************************************
475 * api_spoolss_getprinter
476 * called from the spoolss dispatcher
478 ********************************************************************/
480 static bool api_spoolss_endpageprinter(pipes_struct *p)
482 SPOOL_Q_ENDPAGEPRINTER q_u;
483 SPOOL_R_ENDPAGEPRINTER r_u;
484 prs_struct *data = &p->in_data.data;
485 prs_struct *rdata = &p->out_data.rdata;
487 ZERO_STRUCT(q_u);
488 ZERO_STRUCT(r_u);
490 if(!spoolss_io_q_endpageprinter("", &q_u, data, 0)) {
491 DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n"));
492 return False;
495 r_u.status = _spoolss_endpageprinter(p, &q_u, &r_u);
497 if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) {
498 DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n"));
499 return False;
502 return True;
505 /********************************************************************
506 ********************************************************************/
508 static bool api_spoolss_startdocprinter(pipes_struct *p)
510 SPOOL_Q_STARTDOCPRINTER q_u;
511 SPOOL_R_STARTDOCPRINTER r_u;
512 prs_struct *data = &p->in_data.data;
513 prs_struct *rdata = &p->out_data.rdata;
515 ZERO_STRUCT(q_u);
516 ZERO_STRUCT(r_u);
518 if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) {
519 DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
520 return False;
523 r_u.status = _spoolss_startdocprinter(p, &q_u, &r_u);
525 if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
526 DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
527 return False;
530 return True;
533 /********************************************************************
534 ********************************************************************/
536 static bool api_spoolss_enddocprinter(pipes_struct *p)
538 SPOOL_Q_ENDDOCPRINTER q_u;
539 SPOOL_R_ENDDOCPRINTER r_u;
540 prs_struct *data = &p->in_data.data;
541 prs_struct *rdata = &p->out_data.rdata;
543 ZERO_STRUCT(q_u);
544 ZERO_STRUCT(r_u);
546 if(!spoolss_io_q_enddocprinter("", &q_u, data, 0)) {
547 DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n"));
548 return False;
551 r_u.status = _spoolss_enddocprinter(p, &q_u, &r_u);
553 if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) {
554 DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n"));
555 return False;
558 return True;
561 /********************************************************************
562 ********************************************************************/
564 static bool api_spoolss_writeprinter(pipes_struct *p)
566 SPOOL_Q_WRITEPRINTER q_u;
567 SPOOL_R_WRITEPRINTER r_u;
568 prs_struct *data = &p->in_data.data;
569 prs_struct *rdata = &p->out_data.rdata;
571 ZERO_STRUCT(q_u);
572 ZERO_STRUCT(r_u);
574 if(!spoolss_io_q_writeprinter("", &q_u, data, 0)) {
575 DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n"));
576 return False;
579 r_u.status = _spoolss_writeprinter(p, &q_u, &r_u);
581 if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) {
582 DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n"));
583 return False;
586 return True;
589 /****************************************************************************
591 ****************************************************************************/
593 static bool api_spoolss_setprinter(pipes_struct *p)
595 SPOOL_Q_SETPRINTER q_u;
596 SPOOL_R_SETPRINTER r_u;
597 prs_struct *data = &p->in_data.data;
598 prs_struct *rdata = &p->out_data.rdata;
600 ZERO_STRUCT(q_u);
601 ZERO_STRUCT(r_u);
603 if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
604 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
605 return False;
608 r_u.status = _spoolss_setprinter(p, &q_u, &r_u);
610 if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
611 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
612 return False;
615 return True;
618 /****************************************************************************
619 ****************************************************************************/
621 static bool api_spoolss_fcpn(pipes_struct *p)
623 SPOOL_Q_FCPN q_u;
624 SPOOL_R_FCPN r_u;
625 prs_struct *data = &p->in_data.data;
626 prs_struct *rdata = &p->out_data.rdata;
628 ZERO_STRUCT(q_u);
629 ZERO_STRUCT(r_u);
631 if(!spoolss_io_q_fcpn("", &q_u, data, 0)) {
632 DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n"));
633 return False;
636 r_u.status = _spoolss_fcpn(p, &q_u, &r_u);
638 if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) {
639 DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n"));
640 return False;
643 return True;
646 /****************************************************************************
647 ****************************************************************************/
649 static bool api_spoolss_addjob(pipes_struct *p)
651 SPOOL_Q_ADDJOB q_u;
652 SPOOL_R_ADDJOB r_u;
653 prs_struct *data = &p->in_data.data;
654 prs_struct *rdata = &p->out_data.rdata;
656 ZERO_STRUCT(q_u);
657 ZERO_STRUCT(r_u);
659 if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
660 DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
661 return False;
664 r_u.status = _spoolss_addjob(p, &q_u, &r_u);
666 if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
667 DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
668 return False;
671 return True;
674 /****************************************************************************
675 ****************************************************************************/
677 static bool api_spoolss_enumjobs(pipes_struct *p)
679 SPOOL_Q_ENUMJOBS q_u;
680 SPOOL_R_ENUMJOBS r_u;
681 prs_struct *data = &p->in_data.data;
682 prs_struct *rdata = &p->out_data.rdata;
684 ZERO_STRUCT(q_u);
685 ZERO_STRUCT(r_u);
687 if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
688 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
689 return False;
692 r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
694 if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
695 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
696 return False;
699 return True;
702 /****************************************************************************
703 ****************************************************************************/
705 static bool api_spoolss_schedulejob(pipes_struct *p)
707 SPOOL_Q_SCHEDULEJOB q_u;
708 SPOOL_R_SCHEDULEJOB r_u;
709 prs_struct *data = &p->in_data.data;
710 prs_struct *rdata = &p->out_data.rdata;
712 ZERO_STRUCT(q_u);
713 ZERO_STRUCT(r_u);
715 if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
716 DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
717 return False;
720 r_u.status = _spoolss_schedulejob(p, &q_u, &r_u);
722 if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
723 DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
724 return False;
727 return True;
730 /****************************************************************************
731 ****************************************************************************/
733 static bool api_spoolss_setjob(pipes_struct *p)
735 SPOOL_Q_SETJOB q_u;
736 SPOOL_R_SETJOB r_u;
737 prs_struct *data = &p->in_data.data;
738 prs_struct *rdata = &p->out_data.rdata;
740 ZERO_STRUCT(q_u);
741 ZERO_STRUCT(r_u);
743 if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
744 DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
745 return False;
748 r_u.status = _spoolss_setjob(p, &q_u, &r_u);
750 if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
751 DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
752 return False;
755 return True;
758 /****************************************************************************
759 ****************************************************************************/
761 static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
763 SPOOL_Q_ENUMPRINTERDRIVERS q_u;
764 SPOOL_R_ENUMPRINTERDRIVERS r_u;
765 prs_struct *data = &p->in_data.data;
766 prs_struct *rdata = &p->out_data.rdata;
768 ZERO_STRUCT(q_u);
769 ZERO_STRUCT(r_u);
771 if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
772 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
773 return False;
776 r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
778 if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
779 DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
780 return False;
783 return True;
786 /****************************************************************************
787 ****************************************************************************/
789 static bool api_spoolss_getform(pipes_struct *p)
791 SPOOL_Q_GETFORM q_u;
792 SPOOL_R_GETFORM r_u;
793 prs_struct *data = &p->in_data.data;
794 prs_struct *rdata = &p->out_data.rdata;
796 ZERO_STRUCT(q_u);
797 ZERO_STRUCT(r_u);
799 if (!spoolss_io_q_getform("", &q_u, data, 0)) {
800 DEBUG(0,("spoolss_io_q_getform: unable to unmarshall SPOOL_Q_GETFORM.\n"));
801 return False;
804 r_u.status = _spoolss_getform(p, &q_u, &r_u);
806 if (!spoolss_io_r_getform("",&r_u,rdata,0)) {
807 DEBUG(0,("spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n"));
808 return False;
811 return True;
814 /****************************************************************************
815 ****************************************************************************/
817 static bool api_spoolss_enumforms(pipes_struct *p)
819 SPOOL_Q_ENUMFORMS q_u;
820 SPOOL_R_ENUMFORMS r_u;
821 prs_struct *data = &p->in_data.data;
822 prs_struct *rdata = &p->out_data.rdata;
824 ZERO_STRUCT(q_u);
825 ZERO_STRUCT(r_u);
827 if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
828 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
829 return False;
832 r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
834 if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
835 DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
836 return False;
839 return True;
842 /****************************************************************************
843 ****************************************************************************/
845 static bool api_spoolss_enumports(pipes_struct *p)
847 SPOOL_Q_ENUMPORTS q_u;
848 SPOOL_R_ENUMPORTS r_u;
849 prs_struct *data = &p->in_data.data;
850 prs_struct *rdata = &p->out_data.rdata;
852 ZERO_STRUCT(q_u);
853 ZERO_STRUCT(r_u);
855 if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
856 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
857 return False;
860 r_u.status = _spoolss_enumports(p, &q_u, &r_u);
862 if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
863 DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
864 return False;
867 return True;
870 /****************************************************************************
871 ****************************************************************************/
873 static bool api_spoolss_addprinterex(pipes_struct *p)
875 SPOOL_Q_ADDPRINTEREX q_u;
876 SPOOL_R_ADDPRINTEREX r_u;
877 prs_struct *data = &p->in_data.data;
878 prs_struct *rdata = &p->out_data.rdata;
880 ZERO_STRUCT(q_u);
881 ZERO_STRUCT(r_u);
883 if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
884 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
885 return False;
888 r_u.status = _spoolss_addprinterex(p, &q_u, &r_u);
890 if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
891 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
892 return False;
895 return True;
898 /****************************************************************************
899 ****************************************************************************/
901 static bool api_spoolss_addprinterdriver(pipes_struct *p)
903 SPOOL_Q_ADDPRINTERDRIVER q_u;
904 SPOOL_R_ADDPRINTERDRIVER r_u;
905 prs_struct *data = &p->in_data.data;
906 prs_struct *rdata = &p->out_data.rdata;
908 ZERO_STRUCT(q_u);
909 ZERO_STRUCT(r_u);
911 if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
912 if (q_u.level != 3 && q_u.level != 6) {
913 /* Clever hack from Martin Zielinski <mz@seh.de>
914 * to allow downgrade from level 8 (Vista).
916 DEBUG(3,("api_spoolss_addprinterdriver: unknown SPOOL_Q_ADDPRINTERDRIVER level %u.\n",
917 (unsigned int)q_u.level ));
918 setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
919 return True;
921 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
922 return False;
925 r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u);
927 if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
928 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
929 return False;
932 return True;
935 /****************************************************************************
936 ****************************************************************************/
938 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
940 SPOOL_Q_GETPRINTERDRIVERDIR q_u;
941 SPOOL_R_GETPRINTERDRIVERDIR r_u;
942 prs_struct *data = &p->in_data.data;
943 prs_struct *rdata = &p->out_data.rdata;
945 ZERO_STRUCT(q_u);
946 ZERO_STRUCT(r_u);
948 if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
949 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
950 return False;
953 r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
955 if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
956 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
957 return False;
960 return True;
963 /****************************************************************************
964 ****************************************************************************/
966 static bool api_spoolss_enumprinterdata(pipes_struct *p)
968 SPOOL_Q_ENUMPRINTERDATA q_u;
969 SPOOL_R_ENUMPRINTERDATA r_u;
970 prs_struct *data = &p->in_data.data;
971 prs_struct *rdata = &p->out_data.rdata;
973 ZERO_STRUCT(q_u);
974 ZERO_STRUCT(r_u);
976 if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
977 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
978 return False;
981 r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u);
983 if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
984 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
985 return False;
988 return True;
991 /****************************************************************************
992 ****************************************************************************/
994 static bool api_spoolss_setprinterdata(pipes_struct *p)
996 SPOOL_Q_SETPRINTERDATA q_u;
997 SPOOL_R_SETPRINTERDATA r_u;
998 prs_struct *data = &p->in_data.data;
999 prs_struct *rdata = &p->out_data.rdata;
1001 ZERO_STRUCT(q_u);
1002 ZERO_STRUCT(r_u);
1004 if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
1005 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
1006 return False;
1009 r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
1011 if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
1012 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
1013 return False;
1016 return True;
1019 /****************************************************************************
1020 ****************************************************************************/
1021 static bool api_spoolss_reset_printer(pipes_struct *p)
1023 SPOOL_Q_RESETPRINTER q_u;
1024 SPOOL_R_RESETPRINTER r_u;
1025 prs_struct *data = &p->in_data.data;
1026 prs_struct *rdata = &p->out_data.rdata;
1028 ZERO_STRUCT(q_u);
1029 ZERO_STRUCT(r_u);
1031 if(!spoolss_io_q_resetprinter("", &q_u, data, 0)) {
1032 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
1033 return False;
1036 r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
1038 if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) {
1039 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n"));
1040 return False;
1043 return True;
1046 /****************************************************************************
1047 ****************************************************************************/
1048 static bool api_spoolss_addform(pipes_struct *p)
1050 SPOOL_Q_ADDFORM q_u;
1051 SPOOL_R_ADDFORM r_u;
1052 prs_struct *data = &p->in_data.data;
1053 prs_struct *rdata = &p->out_data.rdata;
1055 ZERO_STRUCT(q_u);
1056 ZERO_STRUCT(r_u);
1058 if(!spoolss_io_q_addform("", &q_u, data, 0)) {
1059 DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n"));
1060 return False;
1063 r_u.status = _spoolss_addform(p, &q_u, &r_u);
1065 if(!spoolss_io_r_addform("", &r_u, rdata, 0)) {
1066 DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n"));
1067 return False;
1070 return True;
1073 /****************************************************************************
1074 ****************************************************************************/
1076 static bool api_spoolss_deleteform(pipes_struct *p)
1078 SPOOL_Q_DELETEFORM q_u;
1079 SPOOL_R_DELETEFORM r_u;
1080 prs_struct *data = &p->in_data.data;
1081 prs_struct *rdata = &p->out_data.rdata;
1083 ZERO_STRUCT(q_u);
1084 ZERO_STRUCT(r_u);
1086 if(!spoolss_io_q_deleteform("", &q_u, data, 0)) {
1087 DEBUG(0,("spoolss_io_q_deleteform: unable to unmarshall SPOOL_Q_DELETEFORM.\n"));
1088 return False;
1091 r_u.status = _spoolss_deleteform(p, &q_u, &r_u);
1093 if(!spoolss_io_r_deleteform("", &r_u, rdata, 0)) {
1094 DEBUG(0,("spoolss_io_r_deleteform: unable to marshall SPOOL_R_DELETEFORM.\n"));
1095 return False;
1098 return True;
1101 /****************************************************************************
1102 ****************************************************************************/
1104 static bool api_spoolss_setform(pipes_struct *p)
1106 SPOOL_Q_SETFORM q_u;
1107 SPOOL_R_SETFORM r_u;
1108 prs_struct *data = &p->in_data.data;
1109 prs_struct *rdata = &p->out_data.rdata;
1111 ZERO_STRUCT(q_u);
1112 ZERO_STRUCT(r_u);
1114 if(!spoolss_io_q_setform("", &q_u, data, 0)) {
1115 DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n"));
1116 return False;
1119 r_u.status = _spoolss_setform(p, &q_u, &r_u);
1121 if(!spoolss_io_r_setform("", &r_u, rdata, 0)) {
1122 DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n"));
1123 return False;
1126 return True;
1129 /****************************************************************************
1130 ****************************************************************************/
1132 static bool api_spoolss_enumprintprocessors(pipes_struct *p)
1134 SPOOL_Q_ENUMPRINTPROCESSORS q_u;
1135 SPOOL_R_ENUMPRINTPROCESSORS r_u;
1136 prs_struct *data = &p->in_data.data;
1137 prs_struct *rdata = &p->out_data.rdata;
1139 ZERO_STRUCT(q_u);
1140 ZERO_STRUCT(r_u);
1142 if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
1143 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
1144 return False;
1147 r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
1149 if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
1150 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
1151 return False;
1154 return True;
1157 /****************************************************************************
1158 ****************************************************************************/
1160 static bool api_spoolss_addprintprocessor(pipes_struct *p)
1162 SPOOL_Q_ADDPRINTPROCESSOR q_u;
1163 SPOOL_R_ADDPRINTPROCESSOR r_u;
1164 prs_struct *data = &p->in_data.data;
1165 prs_struct *rdata = &p->out_data.rdata;
1167 ZERO_STRUCT(q_u);
1168 ZERO_STRUCT(r_u);
1170 if(!spoolss_io_q_addprintprocessor("", &q_u, data, 0)) {
1171 DEBUG(0,("spoolss_io_q_addprintprocessor: unable to unmarshall SPOOL_Q_ADDPRINTPROCESSOR.\n"));
1172 return False;
1175 /* for now, just indicate success and ignore the add. We'll
1176 automatically set the winprint processor for printer
1177 entries later. Used to debug the LexMark Optra S 1855 PCL
1178 driver --jerry */
1179 r_u.status = WERR_OK;
1181 if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) {
1182 DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n"));
1183 return False;
1186 return True;
1189 /****************************************************************************
1190 ****************************************************************************/
1192 static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
1194 SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
1195 SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
1196 prs_struct *data = &p->in_data.data;
1197 prs_struct *rdata = &p->out_data.rdata;
1199 ZERO_STRUCT(q_u);
1200 ZERO_STRUCT(r_u);
1202 if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
1203 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
1204 return False;
1207 r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
1209 if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
1210 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
1211 return False;
1214 return True;
1217 /****************************************************************************
1218 ****************************************************************************/
1220 static bool api_spoolss_enumprintmonitors(pipes_struct *p)
1222 SPOOL_Q_ENUMPRINTMONITORS q_u;
1223 SPOOL_R_ENUMPRINTMONITORS r_u;
1224 prs_struct *data = &p->in_data.data;
1225 prs_struct *rdata = &p->out_data.rdata;
1227 ZERO_STRUCT(q_u);
1228 ZERO_STRUCT(r_u);
1230 if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
1231 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
1232 return False;
1235 r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
1237 if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
1238 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
1239 return False;
1242 return True;
1245 /****************************************************************************
1246 ****************************************************************************/
1248 static bool api_spoolss_getjob(pipes_struct *p)
1250 SPOOL_Q_GETJOB q_u;
1251 SPOOL_R_GETJOB r_u;
1252 prs_struct *data = &p->in_data.data;
1253 prs_struct *rdata = &p->out_data.rdata;
1255 ZERO_STRUCT(q_u);
1256 ZERO_STRUCT(r_u);
1258 if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
1259 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
1260 return False;
1263 r_u.status = _spoolss_getjob(p, &q_u, &r_u);
1265 if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1266 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1267 return False;
1270 return True;
1273 /********************************************************************
1274 * api_spoolss_getprinterdataex
1276 * called from the spoolss dispatcher
1277 ********************************************************************/
1279 static bool api_spoolss_getprinterdataex(pipes_struct *p)
1281 SPOOL_Q_GETPRINTERDATAEX q_u;
1282 SPOOL_R_GETPRINTERDATAEX r_u;
1283 prs_struct *data = &p->in_data.data;
1284 prs_struct *rdata = &p->out_data.rdata;
1286 ZERO_STRUCT(q_u);
1287 ZERO_STRUCT(r_u);
1289 /* read the stream and fill the struct */
1290 if (!spoolss_io_q_getprinterdataex("", &q_u, data, 0)) {
1291 DEBUG(0,("spoolss_io_q_getprinterdataex: unable to unmarshall SPOOL_Q_GETPRINTERDATAEX.\n"));
1292 return False;
1295 r_u.status = _spoolss_getprinterdataex( p, &q_u, &r_u);
1297 if (!spoolss_io_r_getprinterdataex("", &r_u, rdata, 0)) {
1298 DEBUG(0,("spoolss_io_r_getprinterdataex: unable to marshall SPOOL_R_GETPRINTERDATAEX.\n"));
1299 return False;
1302 return True;
1305 /****************************************************************************
1306 ****************************************************************************/
1308 static bool api_spoolss_setprinterdataex(pipes_struct *p)
1310 SPOOL_Q_SETPRINTERDATAEX q_u;
1311 SPOOL_R_SETPRINTERDATAEX r_u;
1312 prs_struct *data = &p->in_data.data;
1313 prs_struct *rdata = &p->out_data.rdata;
1315 ZERO_STRUCT(q_u);
1316 ZERO_STRUCT(r_u);
1318 if(!spoolss_io_q_setprinterdataex("", &q_u, data, 0)) {
1319 DEBUG(0,("spoolss_io_q_setprinterdataex: unable to unmarshall SPOOL_Q_SETPRINTERDATAEX.\n"));
1320 return False;
1323 r_u.status = _spoolss_setprinterdataex(p, &q_u, &r_u);
1325 if(!spoolss_io_r_setprinterdataex("", &r_u, rdata, 0)) {
1326 DEBUG(0,("spoolss_io_r_setprinterdataex: unable to marshall SPOOL_R_SETPRINTERDATAEX.\n"));
1327 return False;
1330 return True;
1334 /****************************************************************************
1335 ****************************************************************************/
1337 static bool api_spoolss_enumprinterkey(pipes_struct *p)
1339 SPOOL_Q_ENUMPRINTERKEY q_u;
1340 SPOOL_R_ENUMPRINTERKEY r_u;
1341 prs_struct *data = &p->in_data.data;
1342 prs_struct *rdata = &p->out_data.rdata;
1344 ZERO_STRUCT(q_u);
1345 ZERO_STRUCT(r_u);
1347 if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) {
1348 DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
1349 return False;
1352 r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
1354 if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
1355 DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
1356 return False;
1359 return True;
1362 /****************************************************************************
1363 ****************************************************************************/
1365 static bool api_spoolss_enumprinterdataex(pipes_struct *p)
1367 SPOOL_Q_ENUMPRINTERDATAEX q_u;
1368 SPOOL_R_ENUMPRINTERDATAEX r_u;
1369 prs_struct *data = &p->in_data.data;
1370 prs_struct *rdata = &p->out_data.rdata;
1372 ZERO_STRUCT(q_u);
1373 ZERO_STRUCT(r_u);
1375 if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) {
1376 DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
1377 return False;
1380 r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
1382 if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
1383 DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
1384 return False;
1387 return True;
1390 /****************************************************************************
1391 ****************************************************************************/
1393 static bool api_spoolss_getprintprocessordirectory(pipes_struct *p)
1395 SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u;
1396 SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u;
1397 prs_struct *data = &p->in_data.data;
1398 prs_struct *rdata = &p->out_data.rdata;
1400 ZERO_STRUCT(q_u);
1401 ZERO_STRUCT(r_u);
1403 if(!spoolss_io_q_getprintprocessordirectory("", &q_u, data, 0)) {
1404 DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n"));
1405 return False;
1408 r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
1410 if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) {
1411 DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n"));
1412 return False;
1415 return True;
1418 /****************************************************************************
1419 ****************************************************************************/
1421 static bool api_spoolss_deleteprinterdataex(pipes_struct *p)
1423 SPOOL_Q_DELETEPRINTERDATAEX q_u;
1424 SPOOL_R_DELETEPRINTERDATAEX r_u;
1425 prs_struct *data = &p->in_data.data;
1426 prs_struct *rdata = &p->out_data.rdata;
1428 ZERO_STRUCT(q_u);
1429 ZERO_STRUCT(r_u);
1431 if(!spoolss_io_q_deleteprinterdataex("", &q_u, data, 0)) {
1432 DEBUG(0,("spoolss_io_q_deleteprinterdataex: unable to unmarshall SPOOL_Q_DELETEPRINTERDATAEX.\n"));
1433 return False;
1436 r_u.status = _spoolss_deleteprinterdataex(p, &q_u, &r_u);
1438 if(!spoolss_io_r_deleteprinterdataex("", &r_u, rdata, 0)) {
1439 DEBUG(0,("spoolss_io_r_deleteprinterdataex: unable to marshall SPOOL_R_DELETEPRINTERDATAEX.\n"));
1440 return False;
1443 return True;
1446 /****************************************************************************
1447 ****************************************************************************/
1449 static bool api_spoolss_deleteprinterkey(pipes_struct *p)
1451 SPOOL_Q_DELETEPRINTERKEY q_u;
1452 SPOOL_R_DELETEPRINTERKEY r_u;
1453 prs_struct *data = &p->in_data.data;
1454 prs_struct *rdata = &p->out_data.rdata;
1456 ZERO_STRUCT(q_u);
1457 ZERO_STRUCT(r_u);
1459 if(!spoolss_io_q_deleteprinterkey("", &q_u, data, 0)) {
1460 DEBUG(0,("spoolss_io_q_deleteprinterkey: unable to unmarshall SPOOL_Q_DELETEPRINTERKEY.\n"));
1461 return False;
1464 r_u.status = _spoolss_deleteprinterkey(p, &q_u, &r_u);
1466 if(!spoolss_io_r_deleteprinterkey("", &r_u, rdata, 0)) {
1467 DEBUG(0,("spoolss_io_r_deleteprinterkey: unable to marshall SPOOL_R_DELETEPRINTERKEY.\n"));
1468 return False;
1471 return True;
1474 /****************************************************************************
1475 ****************************************************************************/
1477 static bool api_spoolss_addprinterdriverex(pipes_struct *p)
1479 SPOOL_Q_ADDPRINTERDRIVEREX q_u;
1480 SPOOL_R_ADDPRINTERDRIVEREX r_u;
1481 prs_struct *data = &p->in_data.data;
1482 prs_struct *rdata = &p->out_data.rdata;
1484 ZERO_STRUCT(q_u);
1485 ZERO_STRUCT(r_u);
1487 if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) {
1488 if (q_u.level != 3 && q_u.level != 6) {
1489 /* Clever hack from Martin Zielinski <mz@seh.de>
1490 * to allow downgrade from level 8 (Vista).
1492 DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n",
1493 (unsigned int)q_u.level ));
1494 setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
1495 return True;
1497 DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
1498 return False;
1501 r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
1503 if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) {
1504 DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n"));
1505 return False;
1508 return True;
1511 /****************************************************************************
1512 ****************************************************************************/
1514 static bool api_spoolss_deleteprinterdriverex(pipes_struct *p)
1516 SPOOL_Q_DELETEPRINTERDRIVEREX q_u;
1517 SPOOL_R_DELETEPRINTERDRIVEREX r_u;
1518 prs_struct *data = &p->in_data.data;
1519 prs_struct *rdata = &p->out_data.rdata;
1521 ZERO_STRUCT(q_u);
1522 ZERO_STRUCT(r_u);
1524 if(!spoolss_io_q_deleteprinterdriverex("", &q_u, data, 0)) {
1525 DEBUG(0,("spoolss_io_q_deleteprinterdriverex: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVEREX.\n"));
1526 return False;
1529 r_u.status = _spoolss_deleteprinterdriverex(p, &q_u, &r_u);
1531 if(!spoolss_io_r_deleteprinterdriverex("", &r_u, rdata, 0)) {
1532 DEBUG(0,("spoolss_io_r_deleteprinterdriverex: unable to marshall SPOOL_R_DELETEPRINTERDRIVEREX.\n"));
1533 return False;
1536 return True;
1539 /****************************************************************************
1540 ****************************************************************************/
1542 static bool api_spoolss_xcvdataport(pipes_struct *p)
1544 SPOOL_Q_XCVDATAPORT q_u;
1545 SPOOL_R_XCVDATAPORT r_u;
1546 prs_struct *data = &p->in_data.data;
1547 prs_struct *rdata = &p->out_data.rdata;
1549 ZERO_STRUCT(q_u);
1550 ZERO_STRUCT(r_u);
1552 if(!spoolss_io_q_xcvdataport("", &q_u, data, 0)) {
1553 DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_XCVDATAPORT.\n"));
1554 return False;
1557 r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u);
1559 if(!spoolss_io_r_xcvdataport("", &r_u, rdata, 0)) {
1560 DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_XCVDATAPORT.\n"));
1561 return False;
1564 return True;
1567 /*******************************************************************
1568 \pipe\spoolss commands
1569 ********************************************************************/
1571 struct api_struct api_spoolss_cmds[] =
1573 {"SPOOLSS_OPENPRINTER", SPOOLSS_OPENPRINTER, api_spoolss_open_printer },
1574 {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex },
1575 {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
1576 {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
1577 {"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter },
1578 {"SPOOLSS_ABORTPRINTER", SPOOLSS_ABORTPRINTER, api_spoolss_abortprinter },
1579 {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
1580 {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex },
1581 {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters },
1582 {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter },
1583 {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 },
1584 {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter },
1585 {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter },
1586 {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter },
1587 {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter },
1588 {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter },
1589 {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter },
1590 {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn },
1591 {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob },
1592 {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs },
1593 {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob },
1594 {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob },
1595 {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms },
1596 {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports },
1597 {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers },
1598 {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex },
1599 {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver },
1600 {"SPOOLSS_DELETEPRINTERDRIVER", SPOOLSS_DELETEPRINTERDRIVER, api_spoolss_deleteprinterdriver },
1601 {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1602 {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata },
1603 {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata },
1604 {"SPOOLSS_RESETPRINTER", SPOOLSS_RESETPRINTER, api_spoolss_reset_printer },
1605 {"SPOOLSS_DELETEPRINTERDATA", SPOOLSS_DELETEPRINTERDATA, api_spoolss_deleteprinterdata },
1606 {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform },
1607 {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform },
1608 {"SPOOLSS_GETFORM", SPOOLSS_GETFORM, api_spoolss_getform },
1609 {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform },
1610 {"SPOOLSS_ADDPRINTPROCESSOR", SPOOLSS_ADDPRINTPROCESSOR, api_spoolss_addprintprocessor },
1611 {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors },
1612 {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors },
1613 {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob },
1614 {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes },
1615 {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex },
1616 {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex },
1617 {"SPOOLSS_DELETEPRINTERDATAEX", SPOOLSS_DELETEPRINTERDATAEX, api_spoolss_deleteprinterdataex },
1618 {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex },
1619 {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey },
1620 {"SPOOLSS_DELETEPRINTERKEY", SPOOLSS_DELETEPRINTERKEY, api_spoolss_deleteprinterkey },
1621 {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
1622 {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex },
1623 {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex },
1624 {"SPOOLSS_XCVDATAPORT", SPOOLSS_XCVDATAPORT, api_spoolss_xcvdataport },
1627 void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns )
1629 *fns = api_spoolss_cmds;
1630 *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
1633 NTSTATUS rpc_spoolss_init(void)
1635 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss", api_spoolss_cmds,
1636 sizeof(api_spoolss_cmds) / sizeof(struct api_struct));