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(pipes_struct *p)
34 SPOOL_Q_OPEN_PRINTER_EX q_u;
35 SPOOL_R_OPEN_PRINTER_EX r_u;
36 UNISTR2 *printername = NULL;
37 prs_struct *data = &p->in_data.data;
38 prs_struct *rdata = &p->out_data.rdata;
43 if (!spoolss_io_q_open_printer_ex("", &q_u, data, 0)) {
44 DEBUG(0,("spoolss_io_q_open_printer_ex: unable to unmarshall SPOOL_Q_OPEN_PRINTER_EX.\n"));
48 if (q_u.printername_ptr != 0)
49 printername = &q_u.printername;
51 r_u.status = _spoolss_open_printer_ex( printername,
53 q_u.user_switch, q_u.user_ctr,
56 /* we _really_ need to switch to talloc() */
57 free_spoolss_q_open_printer_ex(&q_u);
59 if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){
60 DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n"));
67 /********************************************************************
68 * api_spoolss_getprinterdata
70 * called from the spoolss dispatcher
71 ********************************************************************/
72 static BOOL api_spoolss_getprinterdata(pipes_struct *p)
74 SPOOL_Q_GETPRINTERDATA q_u;
75 SPOOL_R_GETPRINTERDATA r_u;
76 prs_struct *data = &p->in_data.data;
77 prs_struct *rdata = &p->out_data.rdata;
82 /* read the stream and fill the struct */
83 if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) {
84 DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n"));
88 r_u.status = _spoolss_getprinterdata( &q_u.handle, &q_u.valuename,
89 q_u.size, &r_u.type, &r_u.size,
90 &r_u.data, &r_u.needed);
92 if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) {
93 DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n"));
102 /********************************************************************
103 * api_spoolss_closeprinter
105 * called from the spoolss dispatcher
106 ********************************************************************/
107 static BOOL api_spoolss_closeprinter(pipes_struct *p)
109 SPOOL_Q_CLOSEPRINTER q_u;
110 SPOOL_R_CLOSEPRINTER r_u;
111 prs_struct *data = &p->in_data.data;
112 prs_struct *rdata = &p->out_data.rdata;
117 if (!spoolss_io_q_closeprinter("", &q_u, data, 0)) {
118 DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n"));
122 r_u.status = _spoolss_closeprinter(&q_u.handle);
123 memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle));
125 if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) {
126 DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n"));
133 /********************************************************************
134 * api_spoolss_deleteprinter
136 * called from the spoolss dispatcher
137 ********************************************************************/
138 static BOOL api_spoolss_deleteprinter(pipes_struct *p)
140 SPOOL_Q_DELETEPRINTER q_u;
141 SPOOL_R_DELETEPRINTER r_u;
142 prs_struct *data = &p->in_data.data;
143 prs_struct *rdata = &p->out_data.rdata;
148 if (!spoolss_io_q_deleteprinter("", &q_u, data, 0)) {
149 DEBUG(0,("spoolss_io_q_deleteprinter: unable to unmarshall SPOOL_Q_DELETEPRINTER.\n"));
153 r_u.status = _spoolss_deleteprinter(&q_u.handle);
154 memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle));
156 if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) {
157 DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
165 /********************************************************************
166 * api_spoolss_rffpcnex
167 * ReplyFindFirstPrinterChangeNotifyEx
168 ********************************************************************/
169 static BOOL api_spoolss_rffpcnex(pipes_struct *p)
171 SPOOL_Q_RFFPCNEX q_u;
172 SPOOL_R_RFFPCNEX r_u;
173 prs_struct *data = &p->in_data.data;
174 prs_struct *rdata = &p->out_data.rdata;
179 if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
180 DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
184 r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags,
185 q_u.options, &q_u.localmachine,
186 q_u.printerlocal, q_u.option);
188 if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) {
189 DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
197 /********************************************************************
198 * api_spoolss_rfnpcnex
199 * ReplyFindNextPrinterChangeNotifyEx
200 * called from the spoolss dispatcher
202 ********************************************************************/
203 static BOOL api_spoolss_rfnpcnex(pipes_struct *p)
205 SPOOL_Q_RFNPCNEX q_u;
206 SPOOL_R_RFNPCNEX r_u;
207 prs_struct *data = &p->in_data.data;
208 prs_struct *rdata = &p->out_data.rdata;
213 if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
214 DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
218 r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change,
219 q_u.option, &r_u.info);
221 safe_free(q_u.option);
223 /* we always have a NOTIFY_INFO struct */
226 if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
227 DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
231 safe_free(r_u.info.data);
237 /********************************************************************
238 * api_spoolss_enumprinters
239 * called from the spoolss dispatcher
241 ********************************************************************/
242 static BOOL api_spoolss_enumprinters(pipes_struct *p)
244 SPOOL_Q_ENUMPRINTERS q_u;
245 SPOOL_R_ENUMPRINTERS r_u;
246 prs_struct *data = &p->in_data.data;
247 prs_struct *rdata = &p->out_data.rdata;
252 if(!new_spoolss_allocate_buffer(&q_u.buffer))
255 if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
256 DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
260 /* that's an [in out] buffer */
261 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
263 r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level,
264 r_u.buffer, q_u.offered,
265 &r_u.needed, &r_u.returned);
267 if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
268 DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
269 new_spoolss_free_buffer(q_u.buffer);
273 new_spoolss_free_buffer(q_u.buffer);
278 /********************************************************************
279 * api_spoolss_getprinter
280 * called from the spoolss dispatcher
282 ********************************************************************/
283 static BOOL api_spoolss_getprinter(pipes_struct *p)
285 SPOOL_Q_GETPRINTER q_u;
286 SPOOL_R_GETPRINTER r_u;
287 prs_struct *data = &p->in_data.data;
288 prs_struct *rdata = &p->out_data.rdata;
293 if(!new_spoolss_allocate_buffer(&q_u.buffer))
296 if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
297 DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
301 /* that's an [in out] buffer */
302 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
304 r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level,
305 r_u.buffer, q_u.offered,
308 if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
309 DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
310 new_spoolss_free_buffer(q_u.buffer);
314 new_spoolss_free_buffer(q_u.buffer);
319 /********************************************************************
320 * api_spoolss_getprinter
321 * called from the spoolss dispatcher
323 ********************************************************************/
324 static BOOL api_spoolss_getprinterdriver2(pipes_struct *p)
326 SPOOL_Q_GETPRINTERDRIVER2 q_u;
327 SPOOL_R_GETPRINTERDRIVER2 r_u;
328 prs_struct *data = &p->in_data.data;
329 prs_struct *rdata = &p->out_data.rdata;
334 if(!new_spoolss_allocate_buffer(&q_u.buffer))
337 if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
338 DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
342 /* that's an [in out] buffer */
343 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
345 r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level,
346 q_u.clientmajorversion, q_u.clientminorversion,
347 r_u.buffer, q_u.offered,
348 &r_u.needed, &r_u.servermajorversion, &r_u.serverminorversion);
350 if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
351 DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
352 new_spoolss_free_buffer(q_u.buffer);
356 new_spoolss_free_buffer(q_u.buffer);
360 /********************************************************************
361 * api_spoolss_getprinter
362 * called from the spoolss dispatcher
364 ********************************************************************/
365 static BOOL api_spoolss_startpageprinter(pipes_struct *p)
367 SPOOL_Q_STARTPAGEPRINTER q_u;
368 SPOOL_R_STARTPAGEPRINTER r_u;
369 prs_struct *data = &p->in_data.data;
370 prs_struct *rdata = &p->out_data.rdata;
375 if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) {
376 DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n"));
380 r_u.status = _spoolss_startpageprinter(&q_u.handle);
382 if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) {
383 DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n"));
391 /********************************************************************
392 * api_spoolss_getprinter
393 * called from the spoolss dispatcher
395 ********************************************************************/
396 static BOOL api_spoolss_endpageprinter(pipes_struct *p)
398 SPOOL_Q_ENDPAGEPRINTER q_u;
399 SPOOL_R_ENDPAGEPRINTER r_u;
400 prs_struct *data = &p->in_data.data;
401 prs_struct *rdata = &p->out_data.rdata;
406 if(!spoolss_io_q_endpageprinter("", &q_u, data, 0)) {
407 DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n"));
411 r_u.status = _spoolss_endpageprinter(&q_u.handle);
413 if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) {
414 DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n"));
421 /********************************************************************
422 ********************************************************************/
423 static BOOL api_spoolss_startdocprinter(pipes_struct *p)
425 SPOOL_Q_STARTDOCPRINTER q_u;
426 SPOOL_R_STARTDOCPRINTER r_u;
427 prs_struct *data = &p->in_data.data;
428 prs_struct *rdata = &p->out_data.rdata;
433 if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) {
434 DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
438 r_u.status = _spoolss_startdocprinter(&q_u.handle,
439 q_u.doc_info_container.level, p,
440 &q_u.doc_info_container.docinfo,
443 if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
444 DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
452 /********************************************************************
453 ********************************************************************/
454 static BOOL api_spoolss_enddocprinter(pipes_struct *p)
456 SPOOL_Q_ENDDOCPRINTER q_u;
457 SPOOL_R_ENDDOCPRINTER r_u;
458 prs_struct *data = &p->in_data.data;
459 prs_struct *rdata = &p->out_data.rdata;
464 if(!spoolss_io_q_enddocprinter("", &q_u, data, 0)) {
465 DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n"));
469 r_u.status = _spoolss_enddocprinter(&q_u.handle);
471 if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) {
472 DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n"));
480 /********************************************************************
481 ********************************************************************/
482 static BOOL api_spoolss_writeprinter(pipes_struct *p)
484 SPOOL_Q_WRITEPRINTER q_u;
485 SPOOL_R_WRITEPRINTER r_u;
486 prs_struct *data = &p->in_data.data;
487 prs_struct *rdata = &p->out_data.rdata;
492 if(!spoolss_io_q_writeprinter("", &q_u, data, 0)) {
493 DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n"));
497 r_u.status = _spoolss_writeprinter(&q_u.handle,
501 r_u.buffer_written = q_u.buffer_size2;
502 safe_free(q_u.buffer);
504 if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) {
505 DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n"));
512 /****************************************************************************
514 ****************************************************************************/
515 static BOOL api_spoolss_setprinter(pipes_struct *p)
517 SPOOL_Q_SETPRINTER q_u;
518 SPOOL_R_SETPRINTER r_u;
519 prs_struct *data = &p->in_data.data;
520 prs_struct *rdata = &p->out_data.rdata;
525 if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
526 DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
530 r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info,
531 q_u.devmode_ctr, q_u.secdesc_ctr,
534 if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
535 DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
536 free_spoolss_q_setprinter(&q_u);
540 /* Free anything allocated in the unparse. */
541 free_spoolss_q_setprinter(&q_u);
546 /****************************************************************************
547 ****************************************************************************/
548 static BOOL api_spoolss_fcpn(pipes_struct *p)
552 prs_struct *data = &p->in_data.data;
553 prs_struct *rdata = &p->out_data.rdata;
558 if(!spoolss_io_q_fcpn("", &q_u, data, 0)) {
559 DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n"));
563 r_u.status = _spoolss_fcpn(&q_u.handle);
565 if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) {
566 DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n"));
574 /****************************************************************************
575 ****************************************************************************/
576 static BOOL api_spoolss_addjob(pipes_struct *p)
580 prs_struct *data = &p->in_data.data;
581 prs_struct *rdata = &p->out_data.rdata;
586 if(!new_spoolss_allocate_buffer(&q_u.buffer))
589 if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
590 DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
594 /* that's only an [in] buffer ! */
596 r_u.status = _spoolss_addjob(&q_u.handle, q_u.level,
597 q_u.buffer, q_u.offered);
599 if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
600 DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
601 new_spoolss_free_buffer(q_u.buffer);
605 new_spoolss_free_buffer(q_u.buffer);
611 /****************************************************************************
612 ****************************************************************************/
613 static BOOL api_spoolss_enumjobs(pipes_struct *p)
615 SPOOL_Q_ENUMJOBS q_u;
616 SPOOL_R_ENUMJOBS r_u;
617 prs_struct *data = &p->in_data.data;
618 prs_struct *rdata = &p->out_data.rdata;
623 if(!new_spoolss_allocate_buffer(&q_u.buffer))
626 if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
627 DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
631 /* that's an [in out] buffer */
632 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
634 r_u.status = _spoolss_enumjobs(&q_u.handle, q_u.firstjob, q_u.numofjobs, q_u.level,
635 r_u.buffer, q_u.offered,
636 &r_u.needed, &r_u.returned);
638 if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
639 DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
640 new_spoolss_free_buffer(q_u.buffer);
644 new_spoolss_free_buffer(q_u.buffer);
650 /****************************************************************************
651 ****************************************************************************/
652 static BOOL api_spoolss_schedulejob(pipes_struct *p)
654 SPOOL_Q_SCHEDULEJOB q_u;
655 SPOOL_R_SCHEDULEJOB r_u;
656 prs_struct *data = &p->in_data.data;
657 prs_struct *rdata = &p->out_data.rdata;
662 if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
663 DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
667 r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid);
669 if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
670 DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
677 /****************************************************************************
678 ****************************************************************************/
679 static BOOL api_spoolss_setjob(pipes_struct *p)
683 prs_struct *data = &p->in_data.data;
684 prs_struct *rdata = &p->out_data.rdata;
689 if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
690 DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
694 r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid,
695 q_u.level, p, &q_u.ctr, q_u.command);
697 if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
698 DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
705 /****************************************************************************
706 ****************************************************************************/
708 static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p)
710 SPOOL_Q_ENUMPRINTERDRIVERS q_u;
711 SPOOL_R_ENUMPRINTERDRIVERS r_u;
712 prs_struct *data = &p->in_data.data;
713 prs_struct *rdata = &p->out_data.rdata;
718 if(!new_spoolss_allocate_buffer(&q_u.buffer))
721 if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
722 DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
726 /* that's an [in out] buffer */
727 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
729 r_u.status = _spoolss_enumprinterdrivers(&q_u.name, &q_u.environment, q_u.level,
730 r_u.buffer, q_u.offered,
731 &r_u.needed, &r_u.returned);
733 if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
734 DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
735 new_spoolss_free_buffer(q_u.buffer);
739 new_spoolss_free_buffer(q_u.buffer);
745 /****************************************************************************
746 ****************************************************************************/
747 static BOOL api_spoolss_enumforms(pipes_struct *p)
749 SPOOL_Q_ENUMFORMS q_u;
750 SPOOL_R_ENUMFORMS r_u;
751 prs_struct *data = &p->in_data.data;
752 prs_struct *rdata = &p->out_data.rdata;
757 if(!new_spoolss_allocate_buffer(&q_u.buffer))
760 if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
761 DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
765 /* that's an [in out] buffer */
766 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
768 r_u.status = _new_spoolss_enumforms(&q_u.handle, q_u.level,
769 r_u.buffer, q_u.offered,
770 &r_u.needed, &r_u.numofforms);
772 if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) {
773 DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
774 new_spoolss_free_buffer(q_u.buffer);
778 new_spoolss_free_buffer(q_u.buffer);
784 /****************************************************************************
785 ****************************************************************************/
786 static BOOL api_spoolss_enumports(pipes_struct *p)
788 SPOOL_Q_ENUMPORTS q_u;
789 SPOOL_R_ENUMPORTS r_u;
790 prs_struct *data = &p->in_data.data;
791 prs_struct *rdata = &p->out_data.rdata;
796 if(!new_spoolss_allocate_buffer(&q_u.buffer))
799 if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
800 DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
804 /* that's an [in out] buffer */
805 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
807 r_u.status = _spoolss_enumports(&q_u.name, q_u.level,
808 r_u.buffer, q_u.offered,
809 &r_u.needed, &r_u.returned);
811 if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) {
812 DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
813 new_spoolss_free_buffer(q_u.buffer);
817 new_spoolss_free_buffer(q_u.buffer);
823 /****************************************************************************
824 ****************************************************************************/
825 static BOOL api_spoolss_addprinterex(pipes_struct *p)
827 SPOOL_Q_ADDPRINTEREX q_u;
828 SPOOL_R_ADDPRINTEREX r_u;
829 prs_struct *data = &p->in_data.data;
830 prs_struct *rdata = &p->out_data.rdata;
835 if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
836 DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
840 r_u.status = _spoolss_addprinterex(&q_u.server_name,
841 q_u.level, &q_u.info,
842 q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3,
843 q_u.user_switch, &q_u.user_ctr,
846 if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
847 DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
851 if (q_u.info.info_ptr!=0) {
852 switch (q_u.info.level) {
854 safe_free(q_u.info.info_1);
857 safe_free(q_u.info.info_2);
865 /****************************************************************************
866 ****************************************************************************/
867 static BOOL api_spoolss_addprinterdriver(pipes_struct *p)
869 SPOOL_Q_ADDPRINTERDRIVER q_u;
870 SPOOL_R_ADDPRINTERDRIVER r_u;
871 prs_struct *data = &p->in_data.data;
872 prs_struct *rdata = &p->out_data.rdata;
877 if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
878 DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
879 free_spoolss_q_addprinterdriver(&q_u);
883 r_u.status = _spoolss_addprinterdriver(p, &q_u.server_name, q_u.level, &q_u.info);
885 if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
886 DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
887 free_spoolss_q_addprinterdriver(&q_u);
891 free_spoolss_q_addprinterdriver(&q_u);
896 /****************************************************************************
897 ****************************************************************************/
898 static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p)
900 SPOOL_Q_GETPRINTERDRIVERDIR q_u;
901 SPOOL_R_GETPRINTERDRIVERDIR r_u;
902 prs_struct *data = &p->in_data.data;
903 prs_struct *rdata = &p->out_data.rdata;
908 if(!new_spoolss_allocate_buffer(&q_u.buffer))
911 if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
912 DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
916 /* that's an [in out] buffer */
917 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
919 r_u.status = _spoolss_getprinterdriverdirectory(&q_u.name, &q_u.environment, q_u.level,
920 r_u.buffer, q_u.offered,
923 if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
924 DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
925 new_spoolss_free_buffer(q_u.buffer);
929 new_spoolss_free_buffer(q_u.buffer);
934 /****************************************************************************
935 ****************************************************************************/
936 static BOOL api_spoolss_enumprinterdata(pipes_struct *p)
938 SPOOL_Q_ENUMPRINTERDATA q_u;
939 SPOOL_R_ENUMPRINTERDATA r_u;
940 prs_struct *data = &p->in_data.data;
941 prs_struct *rdata = &p->out_data.rdata;
946 if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
947 DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
951 r_u.status = _spoolss_enumprinterdata(&q_u.handle, q_u.index, q_u.valuesize, q_u.datasize,
952 &r_u.valuesize, &r_u.value, &r_u.realvaluesize,
954 &r_u.datasize, &r_u.data, &r_u.realdatasize);
956 if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
957 DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
958 safe_free(r_u.value);
963 safe_free(r_u.value);
969 /****************************************************************************
970 ****************************************************************************/
971 static BOOL api_spoolss_setprinterdata(pipes_struct *p)
973 SPOOL_Q_SETPRINTERDATA q_u;
974 SPOOL_R_SETPRINTERDATA r_u;
975 prs_struct *data = &p->in_data.data;
976 prs_struct *rdata = &p->out_data.rdata;
981 if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
982 DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
986 r_u.status = _spoolss_setprinterdata(&q_u.handle,
987 &q_u.value, q_u.type, q_u.max_len,
988 q_u.data, q_u.real_len, q_u.numeric_data);
990 free_spoolss_q_setprinterdata(&q_u);
992 if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
993 DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
1000 /****************************************************************************
1001 ****************************************************************************/
1002 static BOOL api_spoolss_addform(pipes_struct *p)
1004 SPOOL_Q_ADDFORM q_u;
1005 SPOOL_R_ADDFORM r_u;
1006 prs_struct *data = &p->in_data.data;
1007 prs_struct *rdata = &p->out_data.rdata;
1012 if(!spoolss_io_q_addform("", &q_u, data, 0)) {
1013 DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n"));
1017 r_u.status = _spoolss_addform(&q_u.handle, q_u.level, &q_u.form);
1019 if(!spoolss_io_r_addform("", &r_u, rdata, 0)) {
1020 DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n"));
1027 /****************************************************************************
1028 ****************************************************************************/
1029 static BOOL api_spoolss_setform(pipes_struct *p)
1031 SPOOL_Q_SETFORM q_u;
1032 SPOOL_R_SETFORM r_u;
1033 prs_struct *data = &p->in_data.data;
1034 prs_struct *rdata = &p->out_data.rdata;
1039 if(!spoolss_io_q_setform("", &q_u, data, 0)) {
1040 DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n"));
1044 r_u.status = _spoolss_setform(&q_u.handle, &q_u.name, q_u.level, &q_u.form);
1046 if(!spoolss_io_r_setform("", &r_u, rdata, 0)) {
1047 DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n"));
1054 /****************************************************************************
1055 ****************************************************************************/
1056 static BOOL api_spoolss_enumprintprocessors(pipes_struct *p)
1058 SPOOL_Q_ENUMPRINTPROCESSORS q_u;
1059 SPOOL_R_ENUMPRINTPROCESSORS r_u;
1060 prs_struct *data = &p->in_data.data;
1061 prs_struct *rdata = &p->out_data.rdata;
1066 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1069 if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
1070 DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
1074 /* that's an [in out] buffer */
1075 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1077 r_u.status = _spoolss_enumprintprocessors(&q_u.name, &q_u.environment, q_u.level,
1078 r_u.buffer, q_u.offered,
1079 &r_u.needed, &r_u.returned);
1081 if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
1082 DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
1083 new_spoolss_free_buffer(q_u.buffer);
1087 new_spoolss_free_buffer(q_u.buffer);
1092 /****************************************************************************
1093 ****************************************************************************/
1094 static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p)
1096 SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
1097 SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
1098 prs_struct *data = &p->in_data.data;
1099 prs_struct *rdata = &p->out_data.rdata;
1104 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1107 if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
1108 DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
1112 /* that's an [in out] buffer */
1113 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1115 r_u.status = _spoolss_enumprintprocdatatypes(&q_u.name, &q_u.processor, q_u.level,
1116 r_u.buffer, q_u.offered,
1117 &r_u.needed, &r_u.returned);
1119 if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
1120 DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
1121 new_spoolss_free_buffer(q_u.buffer);
1125 new_spoolss_free_buffer(q_u.buffer);
1130 /****************************************************************************
1131 ****************************************************************************/
1132 static BOOL api_spoolss_enumprintmonitors(pipes_struct *p)
1134 SPOOL_Q_ENUMPRINTMONITORS q_u;
1135 SPOOL_R_ENUMPRINTMONITORS r_u;
1136 prs_struct *data = &p->in_data.data;
1137 prs_struct *rdata = &p->out_data.rdata;
1142 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1145 if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
1146 DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
1150 /* that's an [in out] buffer */
1151 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1153 r_u.status = _spoolss_enumprintmonitors(&q_u.name, q_u.level,
1154 r_u.buffer, q_u.offered,
1155 &r_u.needed, &r_u.returned);
1157 if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
1158 DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
1159 new_spoolss_free_buffer(q_u.buffer);
1163 new_spoolss_free_buffer(q_u.buffer);
1168 /****************************************************************************
1169 ****************************************************************************/
1170 static BOOL api_spoolss_getjob(pipes_struct *p)
1174 prs_struct *data = &p->in_data.data;
1175 prs_struct *rdata = &p->out_data.rdata;
1177 if(!new_spoolss_allocate_buffer(&q_u.buffer))
1180 if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
1181 DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
1185 /* that's an [in out] buffer */
1186 new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
1188 r_u.status = _spoolss_getjob(&q_u.handle, q_u.jobid, q_u.level,
1189 r_u.buffer, q_u.offered,
1192 if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
1193 DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
1194 new_spoolss_free_buffer(q_u.buffer);
1198 new_spoolss_free_buffer(q_u.buffer);
1202 /*******************************************************************
1203 \pipe\spoolss commands
1204 ********************************************************************/
1205 struct api_struct api_spoolss_cmds[] =
1207 {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex },
1208 {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
1209 {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
1210 {"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter },
1211 {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
1212 {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex },
1213 {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters },
1214 {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter },
1215 {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 },
1216 {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter },
1217 {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter },
1218 {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter },
1219 {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter },
1220 {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter },
1221 {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter },
1222 {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn },
1223 {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob },
1224 {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs },
1225 {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob },
1226 {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob },
1227 {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms },
1228 {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports },
1229 {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers },
1230 {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex },
1231 {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver },
1232 {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
1233 {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata },
1234 {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata },
1235 {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform },
1236 {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform },
1237 {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors },
1238 {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors },
1239 {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob },
1240 {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes },
1244 /*******************************************************************
1245 receives a spoolss pipe and responds.
1246 ********************************************************************/
1247 BOOL api_spoolss_rpc(pipes_struct *p)
1249 return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds);