3 * Unix SMB/Netbios implementation.
5 * RPC Pipe client / server routines
6 * Copyright (C) Andrew Tridgell 1992-2000,
7 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
8 * Copyright (C) Jean François Micouleau 1998-2000.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * 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(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 /* we _really_ need to switch to talloc() */
55 safe_free(q_u.printer_default.devmode_cont.devmode);
57 if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){
58 DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n"));
65 /********************************************************************
66 * api_spoolss_getprinterdata
68 * called from the spoolss dispatcher
69 ********************************************************************/
70 static BOOL api_spoolss_getprinterdata(prs_struct *data, prs_struct *rdata)
72 SPOOL_Q_GETPRINTERDATA q_u;
73 SPOOL_R_GETPRINTERDATA r_u;
78 /* read the stream and fill the struct */
79 if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) {
80 DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n"));
84 r_u.status = _spoolss_getprinterdata( &q_u.handle, &q_u.valuename,
85 q_u.size, &r_u.type, &r_u.size,
86 &r_u.data, &r_u.needed);
88 if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) {
89 DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n"));
98 /********************************************************************
99 * api_spoolss_closeprinter
101 * called from the spoolss dispatcher
102 ********************************************************************/
103 static BOOL api_spoolss_closeprinter(prs_struct *data, prs_struct *rdata)
105 SPOOL_Q_CLOSEPRINTER q_u;
106 SPOOL_R_CLOSEPRINTER r_u;
111 if (!spoolss_io_q_closeprinter("", &q_u, data, 0)) {
112 DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n"));
116 r_u.status = _spoolss_closeprinter(&q_u.handle);
117 memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle));
119 if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) {
120 DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n"));
127 /********************************************************************
128 * api_spoolss_deleteprinter
130 * called from the spoolss dispatcher
131 ********************************************************************/
132 static BOOL api_spoolss_deleteprinter(prs_struct *data, prs_struct *rdata)
134 SPOOL_Q_DELETEPRINTER q_u;
135 SPOOL_R_DELETEPRINTER r_u;
140 if (!spoolss_io_q_deleteprinter("", &q_u, data, 0)) {
141 DEBUG(0,("spoolss_io_q_deleteprinter: unable to unmarshall SPOOL_Q_DELETEPRINTER.\n"));
145 r_u.status = _spoolss_deleteprinter(&q_u.handle);
146 memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle));
148 if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) {
149 DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
157 /********************************************************************
158 * api_spoolss_rffpcnex
159 * ReplyFindFirstPrinterChangeNotifyEx
160 ********************************************************************/
161 static BOOL api_spoolss_rffpcnex(prs_struct *data, prs_struct *rdata)
163 SPOOL_Q_RFFPCNEX q_u;
164 SPOOL_R_RFFPCNEX r_u;
169 if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
170 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
174 r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags,
175 q_u.options, &q_u.localmachine,
176 q_u.printerlocal, q_u.option);
178 if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
179 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
187 /********************************************************************
188 * api_spoolss_rfnpcnex
189 * ReplyFindNextPrinterChangeNotifyEx
190 * called from the spoolss dispatcher
192 ********************************************************************/
193 static BOOL api_spoolss_rfnpcnex(prs_struct *data, prs_struct *rdata)
195 SPOOL_Q_RFNPCNEX q_u;
196 SPOOL_R_RFNPCNEX r_u;
201 if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
202 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
206 r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change,
207 q_u.option, &r_u.info);
209 safe_free(q_u.option);
211 /* we always have a NOTIFY_INFO struct */
214 if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
215 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
219 safe_free(r_u.info.data);
225 /********************************************************************
226 * api_spoolss_enumprinters
227 * called from the spoolss dispatcher
229 ********************************************************************/
230 static BOOL api_spoolss_enumprinters(prs_struct *data, prs_struct *rdata)
232 SPOOL_Q_ENUMPRINTERS q_u;
233 SPOOL_R_ENUMPRINTERS r_u;
238 if(!new_spoolss_allocate_buffer(&q_u.buffer))
241 if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
242 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
246 /* that's an [in out] buffer */
247 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
249 r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level,
250 r_u.buffer, q_u.offered,
251 &r_u.needed, &r_u.returned);
253 if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
254 DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
255 new_spoolss_free_buffer(q_u.buffer);
259 new_spoolss_free_buffer(q_u.buffer);
264 /********************************************************************
265 * api_spoolss_getprinter
266 * called from the spoolss dispatcher
268 ********************************************************************/
269 static BOOL api_spoolss_getprinter(prs_struct *data, prs_struct *rdata)
271 SPOOL_Q_GETPRINTER q_u;
272 SPOOL_R_GETPRINTER r_u;
277 if(!new_spoolss_allocate_buffer(&q_u.buffer))
280 if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
281 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
285 /* that's an [in out] buffer */
286 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
288 r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level,
289 r_u.buffer, q_u.offered,
292 if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
293 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
294 new_spoolss_free_buffer(q_u.buffer);
298 new_spoolss_free_buffer(q_u.buffer);
303 /********************************************************************
304 * api_spoolss_getprinter
305 * called from the spoolss dispatcher
307 ********************************************************************/
308 static BOOL api_spoolss_getprinterdriver2(prs_struct *data, prs_struct *rdata)
310 SPOOL_Q_GETPRINTERDRIVER2 q_u;
311 SPOOL_R_GETPRINTERDRIVER2 r_u;
316 if(!new_spoolss_allocate_buffer(&q_u.buffer))
319 if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
320 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
324 /* that's an [in out] buffer */
325 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
327 r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level,
328 q_u.clientmajorversion, q_u.clientminorversion,
329 r_u.buffer, q_u.offered,
330 &r_u.needed, &r_u.servermajorversion, &r_u.serverminorversion);
332 if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
333 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
334 new_spoolss_free_buffer(q_u.buffer);
338 new_spoolss_free_buffer(q_u.buffer);
342 /********************************************************************
343 * api_spoolss_getprinter
344 * called from the spoolss dispatcher
346 ********************************************************************/
347 static BOOL api_spoolss_startpageprinter(prs_struct *data, prs_struct *rdata)
349 SPOOL_Q_STARTPAGEPRINTER q_u;
350 SPOOL_R_STARTPAGEPRINTER r_u;
355 if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) {
356 DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n"));
360 r_u.status = _spoolss_startpageprinter(&q_u.handle);
362 if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) {
363 DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n"));
371 /********************************************************************
372 * api_spoolss_getprinter
373 * called from the spoolss dispatcher
375 ********************************************************************/
376 static BOOL api_spoolss_endpageprinter(prs_struct *data, prs_struct *rdata)
378 SPOOL_Q_ENDPAGEPRINTER q_u;
379 SPOOL_R_ENDPAGEPRINTER r_u;
384 if(!spoolss_io_q_endpageprinter("", &q_u, data, 0)) {
385 DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n"));
389 r_u.status = _spoolss_endpageprinter(&q_u.handle);
391 if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) {
392 DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n"));
399 /********************************************************************
400 ********************************************************************/
401 static BOOL api_spoolss_startdocprinter(prs_struct *data, prs_struct *rdata)
403 SPOOL_Q_STARTDOCPRINTER q_u;
404 SPOOL_R_STARTDOCPRINTER r_u;
409 if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) {
410 DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
414 r_u.status = _spoolss_startdocprinter(&q_u.handle,
415 q_u.doc_info_container.level,
416 &q_u.doc_info_container.docinfo,
419 if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
420 DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
428 /********************************************************************
429 ********************************************************************/
430 static BOOL api_spoolss_enddocprinter(prs_struct *data, prs_struct *rdata)
432 SPOOL_Q_ENDDOCPRINTER q_u;
433 SPOOL_R_ENDDOCPRINTER r_u;
438 if(!spoolss_io_q_enddocprinter("", &q_u, data, 0)) {
439 DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n"));
443 r_u.status = _spoolss_enddocprinter(&q_u.handle);
445 if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) {
446 DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n"));
454 /********************************************************************
455 ********************************************************************/
456 static BOOL api_spoolss_writeprinter(prs_struct *data, prs_struct *rdata)
458 SPOOL_Q_WRITEPRINTER q_u;
459 SPOOL_R_WRITEPRINTER r_u;
464 if(!spoolss_io_q_writeprinter("", &q_u, data, 0)) {
465 DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n"));
469 r_u.status = _spoolss_writeprinter(&q_u.handle,
473 r_u.buffer_written = q_u.buffer_size2;
474 safe_free(q_u.buffer);
476 if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) {
477 DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n"));
484 /****************************************************************************
486 ****************************************************************************/
487 static BOOL api_spoolss_setprinter(prs_struct *data, prs_struct *rdata)
489 SPOOL_Q_SETPRINTER q_u;
490 SPOOL_R_SETPRINTER r_u;
495 if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
496 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
500 r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info,
501 q_u.devmode_ctr, q_u.secdesc_ctr,
504 if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
505 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
506 free_spoolss_q_setprinter(&q_u);
510 /* Free anything allocated in the unparse. */
511 free_spoolss_q_setprinter(&q_u);
516 /****************************************************************************
517 ****************************************************************************/
518 static BOOL api_spoolss_fcpn(prs_struct *data, prs_struct *rdata)
526 if(!spoolss_io_q_fcpn("", &q_u, data, 0)) {
527 DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n"));
531 r_u.status = _spoolss_fcpn(&q_u.handle);
533 if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) {
534 DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n"));
542 /****************************************************************************
543 ****************************************************************************/
544 static BOOL api_spoolss_addjob(prs_struct *data, prs_struct *rdata)
552 if(!new_spoolss_allocate_buffer(&q_u.buffer))
555 if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
556 DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
560 /* that's only an [in] buffer ! */
562 r_u.status = _spoolss_addjob(&q_u.handle, q_u.level,
563 q_u.buffer, q_u.offered);
565 if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
566 DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
567 new_spoolss_free_buffer(q_u.buffer);
571 new_spoolss_free_buffer(q_u.buffer);
577 /****************************************************************************
578 ****************************************************************************/
579 static BOOL api_spoolss_enumjobs(prs_struct *data, prs_struct *rdata)
581 SPOOL_Q_ENUMJOBS q_u;
582 SPOOL_R_ENUMJOBS r_u;
587 if(!new_spoolss_allocate_buffer(&q_u.buffer))
590 if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
591 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
595 /* that's an [in out] buffer */
596 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
598 r_u.status = _spoolss_enumjobs(&q_u.handle, q_u.firstjob, q_u.numofjobs, q_u.level,
599 r_u.buffer, q_u.offered,
600 &r_u.needed, &r_u.returned);
602 if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
603 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
604 new_spoolss_free_buffer(q_u.buffer);
608 new_spoolss_free_buffer(q_u.buffer);
614 /****************************************************************************
615 ****************************************************************************/
616 static BOOL api_spoolss_schedulejob(prs_struct *data, prs_struct *rdata)
618 SPOOL_Q_SCHEDULEJOB q_u;
619 SPOOL_R_SCHEDULEJOB r_u;
624 if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
625 DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
629 r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid);
631 if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
632 DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
639 /****************************************************************************
640 ****************************************************************************/
641 static BOOL api_spoolss_setjob(prs_struct *data, prs_struct *rdata)
649 if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
650 DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
654 r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid,
655 q_u.level, &q_u.ctr, q_u.command);
657 if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
658 DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
665 /****************************************************************************
666 ****************************************************************************/
668 static BOOL api_spoolss_enumprinterdrivers(prs_struct *data, prs_struct *rdata)
670 SPOOL_Q_ENUMPRINTERDRIVERS q_u;
671 SPOOL_R_ENUMPRINTERDRIVERS r_u;
676 if(!new_spoolss_allocate_buffer(&q_u.buffer))
679 if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
680 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
684 /* that's an [in out] buffer */
685 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
687 r_u.status = _spoolss_enumprinterdrivers(&q_u.name, &q_u.environment, q_u.level,
688 r_u.buffer, q_u.offered,
689 &r_u.needed, &r_u.returned);
691 if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
692 DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
693 new_spoolss_free_buffer(q_u.buffer);
697 new_spoolss_free_buffer(q_u.buffer);
703 /****************************************************************************
704 ****************************************************************************/
705 static BOOL api_spoolss_enumforms(prs_struct *data, prs_struct *rdata)
707 SPOOL_Q_ENUMFORMS q_u;
708 SPOOL_R_ENUMFORMS r_u;
713 if(!new_spoolss_allocate_buffer(&q_u.buffer))
716 if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
717 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
721 /* that's an [in out] buffer */
722 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
724 r_u.status = _new_spoolss_enumforms(&q_u.handle, q_u.level,
725 r_u.buffer, q_u.offered,
726 &r_u.needed, &r_u.numofforms);
728 if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) {
729 DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
730 new_spoolss_free_buffer(q_u.buffer);
734 new_spoolss_free_buffer(q_u.buffer);
740 /****************************************************************************
741 ****************************************************************************/
742 static BOOL api_spoolss_enumports(prs_struct *data, prs_struct *rdata)
744 SPOOL_Q_ENUMPORTS q_u;
745 SPOOL_R_ENUMPORTS r_u;
750 if(!new_spoolss_allocate_buffer(&q_u.buffer))
753 if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
754 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
758 /* that's an [in out] buffer */
759 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
761 r_u.status = _spoolss_enumports(&q_u.name, q_u.level,
762 r_u.buffer, q_u.offered,
763 &r_u.needed, &r_u.returned);
765 if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) {
766 DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
767 new_spoolss_free_buffer(q_u.buffer);
771 new_spoolss_free_buffer(q_u.buffer);
777 /****************************************************************************
778 ****************************************************************************/
779 static BOOL api_spoolss_addprinterex(prs_struct *data, prs_struct *rdata)
781 SPOOL_Q_ADDPRINTEREX q_u;
782 SPOOL_R_ADDPRINTEREX r_u;
787 if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
788 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
792 r_u.status = _spoolss_addprinterex(&q_u.server_name,
793 q_u.level, &q_u.info,
794 q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3,
795 q_u.user_switch, &q_u.user_ctr,
798 if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
799 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
803 if (q_u.info.info_ptr!=0) {
804 switch (q_u.info.level) {
806 safe_free(q_u.info.info_1);
809 safe_free(q_u.info.info_2);
817 /****************************************************************************
818 ****************************************************************************/
819 static BOOL api_spoolss_addprinterdriver(prs_struct *data, prs_struct *rdata)
821 SPOOL_Q_ADDPRINTERDRIVER q_u;
822 SPOOL_R_ADDPRINTERDRIVER r_u;
827 if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
828 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
832 r_u.status = _spoolss_addprinterdriver(&q_u.server_name, q_u.level, &q_u.info);
834 if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
835 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
836 free_spoolss_q_addprinterdriver(&q_u);
840 free_spoolss_q_addprinterdriver(&q_u);
845 /****************************************************************************
846 ****************************************************************************/
847 static BOOL api_spoolss_getprinterdriverdirectory(prs_struct *data, prs_struct *rdata)
849 SPOOL_Q_GETPRINTERDRIVERDIR q_u;
850 SPOOL_R_GETPRINTERDRIVERDIR r_u;
855 if(!new_spoolss_allocate_buffer(&q_u.buffer))
858 if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
859 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
863 /* that's an [in out] buffer */
864 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
866 r_u.status = _spoolss_getprinterdriverdirectory(&q_u.name, &q_u.environment, q_u.level,
867 r_u.buffer, q_u.offered,
870 if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
871 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
872 new_spoolss_free_buffer(q_u.buffer);
876 new_spoolss_free_buffer(q_u.buffer);
881 /****************************************************************************
882 ****************************************************************************/
883 static BOOL api_spoolss_enumprinterdata(prs_struct *data, prs_struct *rdata)
885 SPOOL_Q_ENUMPRINTERDATA q_u;
886 SPOOL_R_ENUMPRINTERDATA r_u;
891 if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
892 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
896 r_u.status = _spoolss_enumprinterdata(&q_u.handle, q_u.index, q_u.valuesize, q_u.datasize,
897 &r_u.valuesize, &r_u.value, &r_u.realvaluesize,
899 &r_u.datasize, &r_u.data, &r_u.realdatasize);
901 if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
902 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
903 safe_free(r_u.value);
908 safe_free(r_u.value);
914 /****************************************************************************
915 ****************************************************************************/
916 static BOOL api_spoolss_setprinterdata(prs_struct *data, prs_struct *rdata)
918 SPOOL_Q_SETPRINTERDATA q_u;
919 SPOOL_R_SETPRINTERDATA r_u;
924 if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
925 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
929 r_u.status = _spoolss_setprinterdata(&q_u.handle,
930 &q_u.value, q_u.type, q_u.max_len,
931 q_u.data, q_u.real_len, q_u.numeric_data);
933 if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
934 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
941 /****************************************************************************
942 ****************************************************************************/
943 static BOOL api_spoolss_addform(prs_struct *data, prs_struct *rdata)
951 if(!spoolss_io_q_addform("", &q_u, data, 0)) {
952 DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n"));
956 r_u.status = _spoolss_addform(&q_u.handle, q_u.level, &q_u.form);
958 if(!spoolss_io_r_addform("", &r_u, rdata, 0)) {
959 DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n"));
966 /****************************************************************************
967 ****************************************************************************/
968 static BOOL api_spoolss_setform(prs_struct *data, prs_struct *rdata)
976 if(!spoolss_io_q_setform("", &q_u, data, 0)) {
977 DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n"));
981 r_u.status = _spoolss_setform(&q_u.handle, &q_u.name, q_u.level, &q_u.form);
983 if(!spoolss_io_r_setform("", &r_u, rdata, 0)) {
984 DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n"));
991 /****************************************************************************
992 ****************************************************************************/
993 static BOOL api_spoolss_enumprintprocessors(prs_struct *data, prs_struct *rdata)
995 SPOOL_Q_ENUMPRINTPROCESSORS q_u;
996 SPOOL_R_ENUMPRINTPROCESSORS r_u;
1001 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1004 if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
1005 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
1009 /* that's an [in out] buffer */
1010 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1012 r_u.status = _spoolss_enumprintprocessors(&q_u.name, &q_u.environment, q_u.level,
1013 r_u.buffer, q_u.offered,
1014 &r_u.needed, &r_u.returned);
1016 if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
1017 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
1018 new_spoolss_free_buffer(q_u.buffer);
1022 new_spoolss_free_buffer(q_u.buffer);
1027 /****************************************************************************
1028 ****************************************************************************/
1029 static BOOL api_spoolss_enumprintprocdatatypes(prs_struct *data, prs_struct *rdata)
1031 SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
1032 SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
1037 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1040 if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
1041 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
1045 /* that's an [in out] buffer */
1046 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1048 r_u.status = _spoolss_enumprintprocdatatypes(&q_u.name, &q_u.processor, q_u.level,
1049 r_u.buffer, q_u.offered,
1050 &r_u.needed, &r_u.returned);
1052 if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
1053 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
1054 new_spoolss_free_buffer(q_u.buffer);
1058 new_spoolss_free_buffer(q_u.buffer);
1063 /****************************************************************************
1064 ****************************************************************************/
1065 static BOOL api_spoolss_enumprintmonitors(prs_struct *data, prs_struct *rdata)
1067 SPOOL_Q_ENUMPRINTMONITORS q_u;
1068 SPOOL_R_ENUMPRINTMONITORS r_u;
1073 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1076 if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
1077 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
1081 /* that's an [in out] buffer */
1082 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1084 r_u.status = _spoolss_enumprintmonitors(&q_u.name, q_u.level,
1085 r_u.buffer, q_u.offered,
1086 &r_u.needed, &r_u.returned);
1088 if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
1089 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
1090 new_spoolss_free_buffer(q_u.buffer);
1094 new_spoolss_free_buffer(q_u.buffer);
1099 /****************************************************************************
1100 ****************************************************************************/
1101 static BOOL api_spoolss_getjob(prs_struct *data, prs_struct *rdata)
1106 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1109 if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
1110 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
1114 /* that's an [in out] buffer */
1115 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1117 r_u.status = _spoolss_getjob(&q_u.handle, q_u.jobid, q_u.level,
1118 r_u.buffer, q_u.offered,
1121 if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1122 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1123 new_spoolss_free_buffer(q_u.buffer);
1127 new_spoolss_free_buffer(q_u.buffer);
1131 /*******************************************************************
1132 \pipe\spoolss commands
1133 ********************************************************************/
1134 struct api_struct api_spoolss_cmds[] =
1136 {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex },
1137 {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
1138 {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
1139 {"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter },
1140 {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
1141 {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex },
1142 {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters },
1143 {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter },
1144 {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 },
1145 {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter },
1146 {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter },
1147 {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter },
1148 {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter },
1149 {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter },
1150 {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter },
1151 {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn },
1152 {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob },
1153 {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs },
1154 {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob },
1155 {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob },
1156 {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms },
1157 {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports },
1158 {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers },
1159 {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex },
1160 {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver },
1161 {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1162 {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata },
1163 {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata },
1164 {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform },
1165 {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform },
1166 {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors },
1167 {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors },
1168 {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob },
1169 {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes },
1173 /*******************************************************************
1174 receives a spoolss pipe and responds.
1175 ********************************************************************/
1176 BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data)
1178 return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data);