2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Jean François Micouleau 1998-2000.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 extern int DEBUGLEVEL;
29 /********************************************************************
30 * api_spoolss_open_printer_ex
31 ********************************************************************/
32 static BOOL api_spoolss_open_printer_ex(uint16 vuid, prs_struct *data, prs_struct *rdata)
34 SPOOL_Q_OPEN_PRINTER_EX q_u;
35 SPOOL_R_OPEN_PRINTER_EX r_u;
36 UNISTR2 *printername = NULL;
41 if (!spoolss_io_q_open_printer_ex("", &q_u, data, 0)) {
42 DEBUG(0,("spoolss_io_q_open_printer_ex: unable to unmarshall SPOOL_Q_OPEN_PRINTER_EX.\n"));
46 if (q_u.printername_ptr != 0)
47 printername = &q_u.printername;
49 r_u.status = _spoolss_open_printer_ex( printername,
51 q_u.user_switch, q_u.user_ctr,
54 if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){
55 DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n"));
62 /********************************************************************
63 * api_spoolss_getprinterdata
65 * called from the spoolss dispatcher
66 ********************************************************************/
67 static BOOL api_spoolss_getprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata)
69 SPOOL_Q_GETPRINTERDATA q_u;
70 SPOOL_R_GETPRINTERDATA r_u;
75 /* read the stream and fill the struct */
76 if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) {
77 DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n"));
81 r_u.status = _spoolss_getprinterdata( &q_u.handle, &q_u.valuename,
82 q_u.size, &r_u.type, &r_u.size,
83 &r_u.data, &r_u.needed);
85 if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) {
86 DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n"));
95 /********************************************************************
96 * api_spoolss_closeprinter
98 * called from the spoolss dispatcher
99 ********************************************************************/
100 static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
102 SPOOL_Q_CLOSEPRINTER q_u;
103 SPOOL_R_CLOSEPRINTER r_u;
108 if (!spoolss_io_q_closeprinter("", &q_u, data, 0)) {
109 DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n"));
113 r_u.status = _spoolss_closeprinter(&q_u.handle);
114 memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle));
116 if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) {
117 DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n"));
124 /********************************************************************
125 * api_spoolss_rffpcnex
126 * ReplyFindFirstPrinterChangeNotifyEx
127 ********************************************************************/
128 static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdata)
130 SPOOL_Q_RFFPCNEX q_u;
131 SPOOL_R_RFFPCNEX r_u;
136 if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
137 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
141 r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags,
142 q_u.options, &q_u.localmachine,
143 q_u.printerlocal, q_u.option);
145 if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
146 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
154 /********************************************************************
155 * api_spoolss_rfnpcnex
156 * ReplyFindNextPrinterChangeNotifyEx
157 * called from the spoolss dispatcher
159 ********************************************************************/
160 static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdata)
162 SPOOL_Q_RFNPCNEX q_u;
163 SPOOL_R_RFNPCNEX r_u;
168 if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
169 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
173 r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change,
174 q_u.option, &r_u.info);
176 /* we always have a NOTIFY_INFO struct */
179 if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
180 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
184 safe_free(r_u.info.data);
190 /********************************************************************
191 * api_spoolss_enumprinters
192 * called from the spoolss dispatcher
194 ********************************************************************/
195 static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct *rdata)
197 SPOOL_Q_ENUMPRINTERS q_u;
198 SPOOL_R_ENUMPRINTERS r_u;
203 new_spoolss_allocate_buffer(&q_u.buffer);
205 if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
206 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
210 /* that's an [in out] buffer */
211 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
213 r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level,
214 r_u.buffer, q_u.offered,
215 &r_u.needed, &r_u.returned);
217 if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
218 DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
219 new_spoolss_free_buffer(q_u.buffer);
223 new_spoolss_free_buffer(q_u.buffer);
228 /********************************************************************
229 * api_spoolss_getprinter
230 * called from the spoolss dispatcher
232 ********************************************************************/
233 static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
235 SPOOL_Q_GETPRINTER q_u;
236 SPOOL_R_GETPRINTER r_u;
241 new_spoolss_allocate_buffer(&q_u.buffer);
243 if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
244 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
248 /* that's an [in out] buffer */
249 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
251 r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level,
252 r_u.buffer, q_u.offered,
255 if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
256 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
257 new_spoolss_free_buffer(q_u.buffer);
261 new_spoolss_free_buffer(q_u.buffer);
266 /********************************************************************
267 * api_spoolss_getprinter
268 * called from the spoolss dispatcher
270 ********************************************************************/
271 static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_struct *rdata)
273 SPOOL_Q_GETPRINTERDRIVER2 q_u;
274 SPOOL_R_GETPRINTERDRIVER2 r_u;
279 new_spoolss_allocate_buffer(&q_u.buffer);
281 if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
282 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
286 /* that's an [in out] buffer */
287 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
289 r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, q_u.unknown,
290 r_u.buffer, q_u.offered,
291 &r_u.needed, &r_u.unknown0, &r_u.unknown1);
293 if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
294 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
295 new_spoolss_free_buffer(q_u.buffer);
299 new_spoolss_free_buffer(q_u.buffer);
303 /********************************************************************
304 * api_spoolss_getprinter
305 * called from the spoolss dispatcher
307 ********************************************************************/
308 static BOOL api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
310 SPOOL_Q_STARTPAGEPRINTER q_u;
311 SPOOL_R_STARTPAGEPRINTER r_u;
316 if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) {
317 DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n"));
321 r_u.status = _spoolss_startpageprinter(&q_u.handle);
323 if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) {
324 DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n"));
332 /********************************************************************
333 * api_spoolss_getprinter
334 * called from the spoolss dispatcher
336 ********************************************************************/
337 static BOOL api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
339 SPOOL_Q_ENDPAGEPRINTER q_u;
340 SPOOL_R_ENDPAGEPRINTER r_u;
345 if(!spoolss_io_q_endpageprinter("", &q_u, data, 0)) {
346 DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n"));
350 r_u.status = _spoolss_endpageprinter(&q_u.handle);
352 if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) {
353 DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n"));
360 /********************************************************************
361 ********************************************************************/
362 static BOOL api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
364 SPOOL_Q_STARTDOCPRINTER q_u;
365 SPOOL_R_STARTDOCPRINTER r_u;
370 if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) {
371 DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
375 r_u.status = _spoolss_startdocprinter(&q_u.handle,
376 q_u.doc_info_container.level,
377 &q_u.doc_info_container.docinfo,
380 if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
381 DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
389 /********************************************************************
390 ********************************************************************/
391 static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
393 SPOOL_Q_ENDDOCPRINTER q_u;
394 SPOOL_R_ENDDOCPRINTER r_u;
399 if(!spoolss_io_q_enddocprinter("", &q_u, data, 0)) {
400 DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n"));
404 r_u.status = _spoolss_enddocprinter(&q_u.handle);
406 if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) {
407 DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n"));
415 /********************************************************************
416 ********************************************************************/
417 static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
419 SPOOL_Q_WRITEPRINTER q_u;
420 SPOOL_R_WRITEPRINTER r_u;
425 if(!spoolss_io_q_writeprinter("", &q_u, data, 0)) {
426 DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n"));
430 r_u.status = _spoolss_writeprinter(&q_u.handle,
434 r_u.buffer_written = q_u.buffer_size2;
435 safe_free(q_u.buffer);
437 if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) {
438 DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n"));
445 /****************************************************************************
447 ****************************************************************************/
448 static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rdata)
450 SPOOL_Q_SETPRINTER q_u;
451 SPOOL_R_SETPRINTER r_u;
456 if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
457 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
461 r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info,
462 q_u.devmode_ctr, q_u.command);
464 /* now, we can free the memory */
465 if (q_u.info.level==2 && q_u.info.info_ptr!=0)
466 safe_free(q_u.info.info_2);
468 if (q_u.devmode_ctr.devmode_ptr!=0)
469 safe_free(q_u.devmode_ctr.devmode);
471 if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
472 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
479 /****************************************************************************
480 ****************************************************************************/
481 static BOOL api_spoolss_fcpn(uint16 vuid, prs_struct *data, prs_struct *rdata)
489 if(!spoolss_io_q_fcpn("", &q_u, data, 0)) {
490 DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n"));
494 r_u.status = _spoolss_fcpn(&q_u.handle);
496 if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) {
497 DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n"));
505 /****************************************************************************
506 ****************************************************************************/
507 static BOOL api_spoolss_addjob(uint16 vuid, prs_struct *data, prs_struct *rdata)
515 new_spoolss_allocate_buffer(&q_u.buffer);
517 if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
518 DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
522 /* that's only an [in] buffer ! */
524 r_u.status = _spoolss_addjob(&q_u.handle, q_u.level,
525 q_u.buffer, q_u.offered);
527 if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
528 DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
529 new_spoolss_free_buffer(q_u.buffer);
533 new_spoolss_free_buffer(q_u.buffer);
539 /****************************************************************************
540 ****************************************************************************/
541 static BOOL api_spoolss_enumjobs(uint16 vuid, prs_struct *data, prs_struct *rdata)
543 SPOOL_Q_ENUMJOBS q_u;
544 SPOOL_R_ENUMJOBS r_u;
549 new_spoolss_allocate_buffer(&q_u.buffer);
551 if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
552 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
556 /* that's an [in out] buffer */
557 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
559 r_u.status = _spoolss_enumjobs(&q_u.handle, q_u.firstjob, q_u.numofjobs, q_u.level,
560 r_u.buffer, q_u.offered,
561 &r_u.needed, &r_u.returned);
563 if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
564 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
565 new_spoolss_free_buffer(q_u.buffer);
569 new_spoolss_free_buffer(q_u.buffer);
575 /****************************************************************************
576 ****************************************************************************/
577 static BOOL api_spoolss_schedulejob(uint16 vuid, prs_struct *data, prs_struct *rdata)
579 SPOOL_Q_SCHEDULEJOB q_u;
580 SPOOL_R_SCHEDULEJOB r_u;
585 if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
586 DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
590 r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid);
592 if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
593 DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
600 /****************************************************************************
601 ****************************************************************************/
602 static BOOL api_spoolss_setjob(uint16 vuid, prs_struct *data, prs_struct *rdata)
610 if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
611 DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
615 r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid,
616 q_u.level, &q_u.ctr, q_u.command);
618 if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
619 DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
626 /****************************************************************************
627 ****************************************************************************/
629 static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_struct *rdata)
631 SPOOL_Q_ENUMPRINTERDRIVERS q_u;
632 SPOOL_R_ENUMPRINTERDRIVERS r_u;
637 new_spoolss_allocate_buffer(&q_u.buffer);
639 if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
640 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
644 /* that's an [in out] buffer */
645 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
647 r_u.status = _spoolss_enumprinterdrivers(&q_u.name, &q_u.environment, q_u.level,
648 r_u.buffer, q_u.offered,
649 &r_u.needed, &r_u.returned);
651 if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
652 DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
653 new_spoolss_free_buffer(q_u.buffer);
657 new_spoolss_free_buffer(q_u.buffer);
663 /****************************************************************************
664 ****************************************************************************/
665 static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rdata)
667 SPOOL_Q_ENUMFORMS q_u;
668 SPOOL_R_ENUMFORMS r_u;
673 new_spoolss_allocate_buffer(&q_u.buffer);
675 if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
676 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
680 /* that's an [in out] buffer */
681 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
683 r_u.status = _new_spoolss_enumforms(&q_u.handle, q_u.level,
684 r_u.buffer, q_u.offered,
685 &r_u.needed, &r_u.numofforms);
687 if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) {
688 DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
689 new_spoolss_free_buffer(q_u.buffer);
693 new_spoolss_free_buffer(q_u.buffer);
699 /****************************************************************************
700 ****************************************************************************/
701 static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rdata)
703 SPOOL_Q_ENUMPORTS q_u;
704 SPOOL_R_ENUMPORTS r_u;
709 new_spoolss_allocate_buffer(&q_u.buffer);
711 if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
712 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
716 /* that's an [in out] buffer */
717 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
719 r_u.status = _spoolss_enumports(&q_u.name, q_u.level,
720 r_u.buffer, q_u.offered,
721 &r_u.needed, &r_u.returned);
723 if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) {
724 DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
725 new_spoolss_free_buffer(q_u.buffer);
729 new_spoolss_free_buffer(q_u.buffer);
735 /****************************************************************************
736 ****************************************************************************/
737 static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct *rdata)
739 SPOOL_Q_ADDPRINTEREX q_u;
740 SPOOL_R_ADDPRINTEREX r_u;
745 if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
746 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
750 r_u.status = _spoolss_addprinterex(&q_u.server_name,
751 q_u.level, &q_u.info,
752 q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3,
753 q_u.user_switch, &q_u.user_ctr,
756 if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
757 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
764 /****************************************************************************
765 ****************************************************************************/
766 static BOOL api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, prs_struct *rdata)
768 SPOOL_Q_ADDPRINTERDRIVER q_u;
769 SPOOL_R_ADDPRINTERDRIVER r_u;
774 if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
775 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
779 r_u.status = _spoolss_addprinterdriver(&q_u.server_name, q_u.level, &q_u.info);
781 if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
782 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
789 /****************************************************************************
790 ****************************************************************************/
791 static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, prs_struct *rdata)
793 SPOOL_Q_GETPRINTERDRIVERDIR q_u;
794 SPOOL_R_GETPRINTERDRIVERDIR r_u;
799 new_spoolss_allocate_buffer(&q_u.buffer);
801 if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
802 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
806 /* that's an [in out] buffer */
807 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
809 r_u.status = _spoolss_getprinterdriverdirectory(&q_u.name, &q_u.environment, q_u.level,
810 r_u.buffer, q_u.offered,
813 if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
814 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
815 new_spoolss_free_buffer(q_u.buffer);
819 new_spoolss_free_buffer(q_u.buffer);
824 /****************************************************************************
825 ****************************************************************************/
826 static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata)
828 SPOOL_Q_ENUMPRINTERDATA q_u;
829 SPOOL_R_ENUMPRINTERDATA r_u;
834 if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
835 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
839 r_u.status = _spoolss_enumprinterdata(&q_u.handle, q_u.index, q_u.valuesize, q_u.datasize,
840 &r_u.valuesize, &r_u.value, &r_u.realvaluesize,
842 &r_u.datasize, &r_u.data, &r_u.realdatasize);
844 if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
845 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
846 safe_free(r_u.value);
851 safe_free(r_u.value);
857 /****************************************************************************
858 ****************************************************************************/
859 static BOOL api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata)
861 SPOOL_Q_SETPRINTERDATA q_u;
862 SPOOL_R_SETPRINTERDATA r_u;
867 if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
868 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
872 r_u.status = _spoolss_setprinterdata(&q_u.handle,
873 &q_u.value, q_u.type, q_u.max_len,
874 q_u.data, q_u.real_len, q_u.numeric_data);
876 if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
877 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
884 /****************************************************************************
885 ****************************************************************************/
886 static BOOL api_spoolss_addform(uint16 vuid, prs_struct *data, prs_struct *rdata)
894 if(!spoolss_io_q_addform("", &q_u, data, 0)) {
895 DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n"));
899 r_u.status = _spoolss_addform(&q_u.handle, q_u.level, &q_u.form);
901 if(!spoolss_io_r_addform("", &r_u, rdata, 0)) {
902 DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n"));
909 /****************************************************************************
910 ****************************************************************************/
911 static BOOL api_spoolss_setform(uint16 vuid, prs_struct *data, prs_struct *rdata)
919 if(!spoolss_io_q_setform("", &q_u, data, 0)) {
920 DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n"));
924 r_u.status = _spoolss_setform(&q_u.handle, &q_u.name, q_u.level, &q_u.form);
926 if(!spoolss_io_r_setform("", &r_u, rdata, 0)) {
927 DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n"));
934 /****************************************************************************
935 ****************************************************************************/
936 static BOOL api_spoolss_enumprintprocessors(uint16 vuid, prs_struct *data, prs_struct *rdata)
938 SPOOL_Q_ENUMPRINTPROCESSORS q_u;
939 SPOOL_R_ENUMPRINTPROCESSORS r_u;
944 new_spoolss_allocate_buffer(&q_u.buffer);
946 if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
947 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
951 /* that's an [in out] buffer */
952 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
954 r_u.status = _spoolss_enumprintprocessors(&q_u.name, &q_u.environment, q_u.level,
955 r_u.buffer, q_u.offered,
956 &r_u.needed, &r_u.returned);
958 if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
959 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
960 new_spoolss_free_buffer(q_u.buffer);
964 new_spoolss_free_buffer(q_u.buffer);
969 /****************************************************************************
970 ****************************************************************************/
971 static BOOL api_spoolss_enumprintmonitors(uint16 vuid, prs_struct *data, prs_struct *rdata)
973 SPOOL_Q_ENUMPRINTMONITORS q_u;
974 SPOOL_R_ENUMPRINTMONITORS r_u;
979 new_spoolss_allocate_buffer(&q_u.buffer);
981 if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
982 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
986 /* that's an [in out] buffer */
987 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
989 r_u.status = _spoolss_enumprintmonitors(&q_u.name, q_u.level,
990 r_u.buffer, q_u.offered,
991 &r_u.needed, &r_u.returned);
993 if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
994 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
995 new_spoolss_free_buffer(q_u.buffer);
999 new_spoolss_free_buffer(q_u.buffer);
1004 /****************************************************************************
1005 ****************************************************************************/
1006 static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata)
1011 new_spoolss_allocate_buffer(&q_u.buffer);
1013 if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
1014 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
1018 /* that's an [in out] buffer */
1019 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1021 r_u.status = _spoolss_getjob(&q_u.handle, q_u.jobid, q_u.level,
1022 r_u.buffer, q_u.offered,
1025 if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1026 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1027 new_spoolss_free_buffer(q_u.buffer);
1031 new_spoolss_free_buffer(q_u.buffer);
1035 /*******************************************************************
1036 \pipe\spoolss commands
1037 ********************************************************************/
1038 struct api_struct api_spoolss_cmds[] =
1040 {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex },
1041 {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
1042 {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
1043 {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
1044 {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex },
1045 {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters },
1046 {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter },
1047 {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 },
1048 {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter },
1049 {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter },
1050 {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter },
1051 {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter },
1052 {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter },
1053 {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter },
1054 {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn },
1055 {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob },
1056 {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs },
1057 {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob },
1058 {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob },
1059 {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms },
1060 {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports },
1061 {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers },
1062 {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex },
1063 {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver },
1064 {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1065 {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata },
1066 {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata },
1067 {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform },
1068 {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform },
1069 {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors },
1070 {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors },
1071 {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob },
1075 /*******************************************************************
1076 receives a spoolss pipe and responds.
1077 ********************************************************************/
1078 BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data)
1080 return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data);