2 Unix SMB/CIFS implementation.
5 Copyright (C) Gerald Carter 2001-2005,
6 Copyright (C) Tim Potter 2000-2002,
7 Copyright (C) Andrew Tridgell 1994-2000,
8 Copyright (C) Jean-Francois Micouleau 1999-2000.
9 Copyright (C) Jeremy Allison 2005.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "rpc_client.h"
29 /*********************************************************************
30 Decode various spoolss rpc's and info levels
31 ********************************************************************/
33 /**********************************************************************
34 **********************************************************************/
36 static BOOL
decode_printer_info_0(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
37 uint32 returned
, PRINTER_INFO_0
**info
)
42 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_0
, returned
);
46 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_0
));
48 prs_set_offset(&buffer
->prs
,0);
50 for (i
=0; i
<returned
; i
++) {
51 if (!smb_io_printer_info_0("", buffer
, &inf
[i
], 0)) {
60 /**********************************************************************
61 **********************************************************************/
63 static BOOL
decode_printer_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
64 uint32 returned
, PRINTER_INFO_1
**info
)
69 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_1
, returned
);
73 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_1
));
75 prs_set_offset(&buffer
->prs
,0);
77 for (i
=0; i
<returned
; i
++) {
78 if (!smb_io_printer_info_1("", buffer
, &inf
[i
], 0)) {
87 /**********************************************************************
88 **********************************************************************/
90 static BOOL
decode_printer_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
91 uint32 returned
, PRINTER_INFO_2
**info
)
96 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_2
, returned
);
100 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_2
));
102 prs_set_offset(&buffer
->prs
,0);
104 for (i
=0; i
<returned
; i
++) {
105 /* a little initialization as we go */
106 inf
[i
].secdesc
= NULL
;
107 if (!smb_io_printer_info_2("", buffer
, &inf
[i
], 0)) {
116 /**********************************************************************
117 **********************************************************************/
119 static BOOL
decode_printer_info_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
120 uint32 returned
, PRINTER_INFO_3
**info
)
125 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_3
, returned
);
129 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_3
));
131 prs_set_offset(&buffer
->prs
,0);
133 for (i
=0; i
<returned
; i
++) {
134 inf
[i
].secdesc
= NULL
;
135 if (!smb_io_printer_info_3("", buffer
, &inf
[i
], 0)) {
144 /**********************************************************************
145 **********************************************************************/
147 static BOOL
decode_printer_info_7(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
148 uint32 returned
, PRINTER_INFO_7
**info
)
153 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_7
, returned
);
157 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_7
));
159 prs_set_offset(&buffer
->prs
,0);
161 for (i
=0; i
<returned
; i
++) {
162 if (!smb_io_printer_info_7("", buffer
, &inf
[i
], 0)) {
172 /**********************************************************************
173 **********************************************************************/
175 static BOOL
decode_port_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
176 uint32 returned
, PORT_INFO_1
**info
)
181 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_1
, returned
);
185 memset(inf
, 0, returned
*sizeof(PORT_INFO_1
));
187 prs_set_offset(&buffer
->prs
, 0);
189 for (i
=0; i
<returned
; i
++) {
190 if (!smb_io_port_info_1("", buffer
, &(inf
[i
]), 0)) {
199 /**********************************************************************
200 **********************************************************************/
202 static BOOL
decode_port_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
203 uint32 returned
, PORT_INFO_2
**info
)
208 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_2
, returned
);
212 memset(inf
, 0, returned
*sizeof(PORT_INFO_2
));
214 prs_set_offset(&buffer
->prs
, 0);
216 for (i
=0; i
<returned
; i
++) {
217 if (!smb_io_port_info_2("", buffer
, &(inf
[i
]), 0)) {
226 /**********************************************************************
227 **********************************************************************/
229 static BOOL
decode_printer_driver_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
230 uint32 returned
, DRIVER_INFO_1
**info
)
235 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_1
, returned
);
239 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_1
));
241 prs_set_offset(&buffer
->prs
,0);
243 for (i
=0; i
<returned
; i
++) {
244 if (!smb_io_printer_driver_info_1("", buffer
, &(inf
[i
]), 0)) {
253 /**********************************************************************
254 **********************************************************************/
256 static BOOL
decode_printer_driver_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
257 uint32 returned
, DRIVER_INFO_2
**info
)
262 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_2
, returned
);
266 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_2
));
268 prs_set_offset(&buffer
->prs
,0);
270 for (i
=0; i
<returned
; i
++) {
271 if (!smb_io_printer_driver_info_2("", buffer
, &(inf
[i
]), 0)) {
280 /**********************************************************************
281 **********************************************************************/
283 static BOOL
decode_printer_driver_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
284 uint32 returned
, DRIVER_INFO_3
**info
)
289 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_3
, returned
);
293 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_3
));
295 prs_set_offset(&buffer
->prs
,0);
297 for (i
=0; i
<returned
; i
++) {
298 if (!smb_io_printer_driver_info_3("", buffer
, &(inf
[i
]), 0)) {
307 /**********************************************************************
308 **********************************************************************/
310 static BOOL
decode_printerdriverdir_1 (TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
311 uint32 returned
, DRIVER_DIRECTORY_1
**info
314 DRIVER_DIRECTORY_1
*inf
;
316 inf
=TALLOC_P(mem_ctx
, DRIVER_DIRECTORY_1
);
320 memset(inf
, 0, sizeof(DRIVER_DIRECTORY_1
));
322 prs_set_offset(&buffer
->prs
, 0);
324 if (!smb_io_driverdir_1("", buffer
, inf
, 0)) {
332 /**********************************************************************
333 **********************************************************************/
335 static BOOL
decode_jobs_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
336 uint32 num_jobs
, JOB_INFO_1
**jobs
)
340 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_1
, num_jobs
);
344 prs_set_offset(&buffer
->prs
,0);
346 for (i
= 0; i
< num_jobs
; i
++) {
347 if (!smb_io_job_info_1("", buffer
, &((*jobs
)[i
]), 0)) {
355 /**********************************************************************
356 **********************************************************************/
358 static BOOL
decode_jobs_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
359 uint32 num_jobs
, JOB_INFO_2
**jobs
)
363 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_2
, num_jobs
);
367 prs_set_offset(&buffer
->prs
,0);
369 for (i
= 0; i
< num_jobs
; i
++) {
370 if (!smb_io_job_info_2("", buffer
, &((*jobs
)[i
]), 0)) {
378 /**********************************************************************
379 **********************************************************************/
381 static BOOL
decode_forms_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
382 uint32 num_forms
, FORM_1
**forms
)
386 *forms
= TALLOC_ARRAY(mem_ctx
, FORM_1
, num_forms
);
387 if (*forms
== NULL
) {
390 prs_set_offset(&buffer
->prs
,0);
392 for (i
= 0; i
< num_forms
; i
++) {
393 if (!smb_io_form_1("", buffer
, &((*forms
)[i
]), 0)) {
401 /**********************************************************************
402 **********************************************************************/
404 WERROR
rpccli_spoolss_open_printer_ex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
405 const char *printername
, const char *datatype
, uint32 access_required
,
406 const char *station
, const char *username
, POLICY_HND
*pol
)
408 prs_struct qbuf
, rbuf
;
409 SPOOL_Q_OPEN_PRINTER_EX in
;
410 SPOOL_R_OPEN_PRINTER_EX out
;
415 make_spoolss_q_open_printer_ex( &in
, printername
, datatype
,
416 access_required
, station
, username
);
418 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_OPENPRINTEREX
,
421 spoolss_io_q_open_printer_ex
,
422 spoolss_io_r_open_printer_ex
,
423 WERR_GENERAL_FAILURE
);
425 memcpy( pol
, &out
.handle
, sizeof(POLICY_HND
) );
430 /**********************************************************************
431 **********************************************************************/
433 WERROR
rpccli_spoolss_close_printer(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
436 prs_struct qbuf
, rbuf
;
437 SPOOL_Q_CLOSEPRINTER in
;
438 SPOOL_R_CLOSEPRINTER out
;
443 make_spoolss_q_closeprinter( &in
, pol
);
445 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_CLOSEPRINTER
,
448 spoolss_io_q_closeprinter
,
449 spoolss_io_r_closeprinter
,
450 WERR_GENERAL_FAILURE
);
455 /**********************************************************************
456 **********************************************************************/
458 WERROR
rpccli_spoolss_enum_printers(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
459 char *name
, uint32 flags
, uint32 level
,
460 uint32
*num_printers
, PRINTER_INFO_CTR
*ctr
)
462 prs_struct qbuf
, rbuf
;
463 SPOOL_Q_ENUMPRINTERS in
;
464 SPOOL_R_ENUMPRINTERS out
;
472 rpcbuf_init(&buffer
, offered
, mem_ctx
);
473 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
475 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERS
,
478 spoolss_io_q_enumprinters
,
479 spoolss_io_r_enumprinters
,
480 WERR_GENERAL_FAILURE
);
482 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
483 offered
= out
.needed
;
488 rpcbuf_init(&buffer
, offered
, mem_ctx
);
489 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
491 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERS
,
494 spoolss_io_q_enumprinters
,
495 spoolss_io_r_enumprinters
,
496 WERR_GENERAL_FAILURE
);
499 if ( !W_ERROR_IS_OK(out
.status
) )
504 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_0
)) {
505 return WERR_GENERAL_FAILURE
;
509 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_1
)) {
510 return WERR_GENERAL_FAILURE
;
514 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_2
)) {
515 return WERR_GENERAL_FAILURE
;
519 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_3
)) {
520 return WERR_GENERAL_FAILURE
;
524 return WERR_UNKNOWN_LEVEL
;
527 *num_printers
= out
.returned
;
532 /**********************************************************************
533 **********************************************************************/
535 WERROR
rpccli_spoolss_enum_ports(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
536 uint32 level
, uint32
*num_ports
, PORT_INFO_CTR
*ctr
)
538 prs_struct qbuf
, rbuf
;
539 SPOOL_Q_ENUMPORTS in
;
540 SPOOL_R_ENUMPORTS out
;
548 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
552 rpcbuf_init(&buffer
, offered
, mem_ctx
);
553 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
555 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPORTS
,
558 spoolss_io_q_enumports
,
559 spoolss_io_r_enumports
,
560 WERR_GENERAL_FAILURE
);
562 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
563 offered
= out
.needed
;
568 rpcbuf_init(&buffer
, offered
, mem_ctx
);
569 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
571 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPORTS
,
574 spoolss_io_q_enumports
,
575 spoolss_io_r_enumports
,
576 WERR_GENERAL_FAILURE
);
579 if ( !W_ERROR_IS_OK(out
.status
) )
584 if (!decode_port_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_1
)) {
585 return WERR_GENERAL_FAILURE
;
589 if (!decode_port_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_2
)) {
590 return WERR_GENERAL_FAILURE
;
594 return WERR_UNKNOWN_LEVEL
;
597 *num_ports
= out
.returned
;
602 /**********************************************************************
603 **********************************************************************/
605 WERROR
rpccli_spoolss_getprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
606 POLICY_HND
*pol
, uint32 level
,
607 PRINTER_INFO_CTR
*ctr
)
609 prs_struct qbuf
, rbuf
;
610 SPOOL_Q_GETPRINTER in
;
611 SPOOL_R_GETPRINTER out
;
618 /* Initialise input parameters */
621 rpcbuf_init(&buffer
, offered
, mem_ctx
);
622 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
624 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTER
,
627 spoolss_io_q_getprinter
,
628 spoolss_io_r_getprinter
,
629 WERR_GENERAL_FAILURE
);
631 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
632 offered
= out
.needed
;
637 rpcbuf_init(&buffer
, offered
, mem_ctx
);
638 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
640 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTER
,
643 spoolss_io_q_getprinter
,
644 spoolss_io_r_getprinter
,
645 WERR_GENERAL_FAILURE
);
648 if ( !W_ERROR_IS_OK(out
.status
) )
653 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, 1, &ctr
->printers_0
)) {
654 return WERR_GENERAL_FAILURE
;
658 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, 1, &ctr
->printers_1
)) {
659 return WERR_GENERAL_FAILURE
;
663 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, 1, &ctr
->printers_2
)) {
664 return WERR_GENERAL_FAILURE
;
668 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, 1, &ctr
->printers_3
)) {
669 return WERR_GENERAL_FAILURE
;
673 if (!decode_printer_info_7(mem_ctx
, out
.buffer
, 1, &ctr
->printers_7
)) {
674 return WERR_GENERAL_FAILURE
;
678 return WERR_UNKNOWN_LEVEL
;
684 /**********************************************************************
685 **********************************************************************/
687 WERROR
rpccli_spoolss_setprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
688 POLICY_HND
*pol
, uint32 level
,
689 PRINTER_INFO_CTR
*ctr
, uint32 command
)
691 prs_struct qbuf
, rbuf
;
692 SPOOL_Q_SETPRINTER in
;
693 SPOOL_R_SETPRINTER out
;
698 make_spoolss_q_setprinter( mem_ctx
, &in
, pol
, level
, ctr
, command
);
700 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTER
,
703 spoolss_io_q_setprinter
,
704 spoolss_io_r_setprinter
,
705 WERR_GENERAL_FAILURE
);
710 /**********************************************************************
711 **********************************************************************/
713 WERROR
rpccli_spoolss_getprinterdriver(struct rpc_pipe_client
*cli
,
715 POLICY_HND
*pol
, uint32 level
,
716 const char *env
, int version
, PRINTER_DRIVER_CTR
*ctr
)
718 prs_struct qbuf
, rbuf
;
719 SPOOL_Q_GETPRINTERDRIVER2 in
;
720 SPOOL_R_GETPRINTERDRIVER2 out
;
728 fstrcpy(server
, cli
->cli
->desthost
);
732 rpcbuf_init(&buffer
, offered
, mem_ctx
);
733 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
734 version
, 2, &buffer
, offered
);
736 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVER2
,
739 spoolss_io_q_getprinterdriver2
,
740 spoolss_io_r_getprinterdriver2
,
741 WERR_GENERAL_FAILURE
);
743 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
744 offered
= out
.needed
;
749 rpcbuf_init(&buffer
, offered
, mem_ctx
);
750 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
751 version
, 2, &buffer
, offered
);
753 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVER2
,
756 spoolss_io_q_getprinterdriver2
,
757 spoolss_io_r_getprinterdriver2
,
758 WERR_GENERAL_FAILURE
);
761 if ( !W_ERROR_IS_OK(out
.status
) )
766 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
767 return WERR_GENERAL_FAILURE
;
771 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, 1, &ctr
->info2
)) {
772 return WERR_GENERAL_FAILURE
;
776 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, 1, &ctr
->info3
)) {
777 return WERR_GENERAL_FAILURE
;
781 return WERR_UNKNOWN_LEVEL
;
787 /**********************************************************************
788 **********************************************************************/
790 WERROR
rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client
*cli
,
792 uint32 level
, const char *env
,
794 PRINTER_DRIVER_CTR
*ctr
)
796 prs_struct qbuf
, rbuf
;
797 SPOOL_Q_ENUMPRINTERDRIVERS in
;
798 SPOOL_R_ENUMPRINTERDRIVERS out
;
806 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
810 rpcbuf_init(&buffer
, offered
, mem_ctx
);
811 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
814 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDRIVERS
,
817 spoolss_io_q_enumprinterdrivers
,
818 spoolss_io_r_enumprinterdrivers
,
819 WERR_GENERAL_FAILURE
);
821 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
822 offered
= out
.needed
;
827 rpcbuf_init(&buffer
, offered
, mem_ctx
);
828 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
831 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDRIVERS
,
834 spoolss_io_q_enumprinterdrivers
,
835 spoolss_io_r_enumprinterdrivers
,
836 WERR_GENERAL_FAILURE
);
839 *num_drivers
= out
.returned
;
841 if ( !W_ERROR_IS_OK(out
.status
) )
844 if ( out
.returned
) {
848 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info1
)) {
849 return WERR_GENERAL_FAILURE
;
853 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info2
)) {
854 return WERR_GENERAL_FAILURE
;
858 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info3
)) {
859 return WERR_GENERAL_FAILURE
;
863 return WERR_UNKNOWN_LEVEL
;
871 /**********************************************************************
872 **********************************************************************/
874 WERROR
rpccli_spoolss_getprinterdriverdir (struct rpc_pipe_client
*cli
,
876 uint32 level
, char *env
,
877 DRIVER_DIRECTORY_CTR
*ctr
)
879 prs_struct qbuf
, rbuf
;
880 SPOOL_Q_GETPRINTERDRIVERDIR in
;
881 SPOOL_R_GETPRINTERDRIVERDIR out
;
889 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
893 rpcbuf_init(&buffer
, offered
, mem_ctx
);
894 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
897 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
900 spoolss_io_q_getprinterdriverdir
,
901 spoolss_io_r_getprinterdriverdir
,
902 WERR_GENERAL_FAILURE
);
904 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
905 offered
= out
.needed
;
910 rpcbuf_init(&buffer
, offered
, mem_ctx
);
911 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
914 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
917 spoolss_io_q_getprinterdriverdir
,
918 spoolss_io_r_getprinterdriverdir
,
919 WERR_GENERAL_FAILURE
);
922 if (!W_ERROR_IS_OK(out
.status
))
925 if (!decode_printerdriverdir_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
926 return WERR_GENERAL_FAILURE
;
932 /**********************************************************************
933 **********************************************************************/
935 WERROR
rpccli_spoolss_addprinterdriver (struct rpc_pipe_client
*cli
,
936 TALLOC_CTX
*mem_ctx
, uint32 level
,
937 PRINTER_DRIVER_CTR
*ctr
)
939 prs_struct qbuf
, rbuf
;
940 SPOOL_Q_ADDPRINTERDRIVER in
;
941 SPOOL_R_ADDPRINTERDRIVER out
;
947 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
950 make_spoolss_q_addprinterdriver( mem_ctx
, &in
, server
, level
, ctr
);
952 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDPRINTERDRIVER
,
955 spoolss_io_q_addprinterdriver
,
956 spoolss_io_r_addprinterdriver
,
957 WERR_GENERAL_FAILURE
);
962 /**********************************************************************
963 **********************************************************************/
965 WERROR
rpccli_spoolss_addprinterex (struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
966 uint32 level
, PRINTER_INFO_CTR
*ctr
)
968 prs_struct qbuf
, rbuf
;
969 SPOOL_Q_ADDPRINTEREX in
;
970 SPOOL_R_ADDPRINTEREX out
;
971 fstring server
, client
, user
;
976 slprintf(client
, sizeof(fstring
)-1, "\\\\%s", global_myname());
977 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
982 fstrcpy (user
, cli
->user_name
);
984 make_spoolss_q_addprinterex( mem_ctx
, &in
, server
, client
,
987 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDPRINTEREX
,
990 spoolss_io_q_addprinterex
,
991 spoolss_io_r_addprinterex
,
992 WERR_GENERAL_FAILURE
);
997 /**********************************************************************
998 **********************************************************************/
1000 WERROR
rpccli_spoolss_deleteprinterdriverex(struct rpc_pipe_client
*cli
,
1001 TALLOC_CTX
*mem_ctx
, const char *arch
,
1002 const char *driver
, int version
)
1004 prs_struct qbuf
, rbuf
;
1005 SPOOL_Q_DELETEPRINTERDRIVEREX in
;
1006 SPOOL_R_DELETEPRINTERDRIVEREX out
;
1012 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
1015 make_spoolss_q_deleteprinterdriverex( mem_ctx
, &in
, server
, arch
, driver
, version
);
1017 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDRIVEREX
,
1020 spoolss_io_q_deleteprinterdriverex
,
1021 spoolss_io_r_deleteprinterdriverex
,
1022 WERR_GENERAL_FAILURE
);
1027 /**********************************************************************
1028 **********************************************************************/
1030 WERROR
rpccli_spoolss_deleteprinterdriver (struct rpc_pipe_client
*cli
,
1031 TALLOC_CTX
*mem_ctx
, const char *arch
,
1034 prs_struct qbuf
, rbuf
;
1035 SPOOL_Q_DELETEPRINTERDRIVER in
;
1036 SPOOL_R_DELETEPRINTERDRIVER out
;
1042 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
1045 make_spoolss_q_deleteprinterdriver( mem_ctx
, &in
, server
, arch
, driver
);
1047 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDRIVER
,
1050 spoolss_io_q_deleteprinterdriver
,
1051 spoolss_io_r_deleteprinterdriver
,
1052 WERR_GENERAL_FAILURE
);
1057 /**********************************************************************
1058 **********************************************************************/
1060 WERROR
rpccli_spoolss_getprintprocessordirectory(struct rpc_pipe_client
*cli
,
1061 TALLOC_CTX
*mem_ctx
,
1062 char *name
, char *environment
,
1065 prs_struct qbuf
, rbuf
;
1066 SPOOL_Q_GETPRINTPROCESSORDIRECTORY in
;
1067 SPOOL_R_GETPRINTPROCESSORDIRECTORY out
;
1076 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1077 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1078 environment
, level
, &buffer
, offered
);
1080 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1083 spoolss_io_q_getprintprocessordirectory
,
1084 spoolss_io_r_getprintprocessordirectory
,
1085 WERR_GENERAL_FAILURE
);
1087 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1088 offered
= out
.needed
;
1093 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1094 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1095 environment
, level
, &buffer
, offered
);
1097 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1100 spoolss_io_q_getprintprocessordirectory
,
1101 spoolss_io_r_getprintprocessordirectory
,
1102 WERR_GENERAL_FAILURE
);
1105 if ( !W_ERROR_IS_OK(out
.status
) )
1108 fstrcpy(procdir
, "Not implemented!");
1113 /**********************************************************************
1114 **********************************************************************/
1116 WERROR
rpccli_spoolss_addform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1117 POLICY_HND
*handle
, uint32 level
, FORM
*form
)
1119 prs_struct qbuf
, rbuf
;
1121 SPOOL_R_ADDFORM out
;
1126 make_spoolss_q_addform( &in
, handle
, level
, form
);
1128 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDFORM
,
1131 spoolss_io_q_addform
,
1132 spoolss_io_r_addform
,
1133 WERR_GENERAL_FAILURE
);
1138 /**********************************************************************
1139 **********************************************************************/
1141 WERROR
rpccli_spoolss_setform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1142 POLICY_HND
*handle
, uint32 level
,
1143 const char *form_name
, FORM
*form
)
1145 prs_struct qbuf
, rbuf
;
1147 SPOOL_R_SETFORM out
;
1152 make_spoolss_q_setform( &in
, handle
, level
, form_name
, form
);
1154 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETFORM
,
1157 spoolss_io_q_setform
,
1158 spoolss_io_r_setform
,
1159 WERR_GENERAL_FAILURE
);
1164 /**********************************************************************
1165 **********************************************************************/
1167 WERROR
rpccli_spoolss_getform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1168 POLICY_HND
*handle
, const char *formname
,
1169 uint32 level
, FORM_1
*form
)
1171 prs_struct qbuf
, rbuf
;
1173 SPOOL_R_GETFORM out
;
1181 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1182 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1184 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETFORM
,
1187 spoolss_io_q_getform
,
1188 spoolss_io_r_getform
,
1189 WERR_GENERAL_FAILURE
);
1191 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1192 offered
= out
.needed
;
1197 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1198 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1200 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETFORM
,
1203 spoolss_io_q_getform
,
1204 spoolss_io_r_getform
,
1205 WERR_GENERAL_FAILURE
);
1208 if (!W_ERROR_IS_OK(out
.status
))
1211 if (!smb_io_form_1("", out
.buffer
, form
, 0)) {
1212 return WERR_GENERAL_FAILURE
;
1218 /**********************************************************************
1219 **********************************************************************/
1221 WERROR
rpccli_spoolss_deleteform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1222 POLICY_HND
*handle
, const char *form_name
)
1224 prs_struct qbuf
, rbuf
;
1225 SPOOL_Q_DELETEFORM in
;
1226 SPOOL_R_DELETEFORM out
;
1231 make_spoolss_q_deleteform( &in
, handle
, form_name
);
1233 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEFORM
,
1236 spoolss_io_q_deleteform
,
1237 spoolss_io_r_deleteform
,
1238 WERR_GENERAL_FAILURE
);
1243 /**********************************************************************
1244 **********************************************************************/
1246 WERROR
rpccli_spoolss_enumforms(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1247 POLICY_HND
*handle
, int level
, uint32
*num_forms
,
1250 prs_struct qbuf
, rbuf
;
1251 SPOOL_Q_ENUMFORMS in
;
1252 SPOOL_R_ENUMFORMS out
;
1260 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1261 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1263 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMFORMS
,
1266 spoolss_io_q_enumforms
,
1267 spoolss_io_r_enumforms
,
1268 WERR_GENERAL_FAILURE
);
1270 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1271 offered
= out
.needed
;
1276 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1277 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1279 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMFORMS
,
1282 spoolss_io_q_enumforms
,
1283 spoolss_io_r_enumforms
,
1284 WERR_GENERAL_FAILURE
);
1287 if (!W_ERROR_IS_OK(out
.status
))
1290 *num_forms
= out
.numofforms
;
1292 if (!decode_forms_1(mem_ctx
, out
.buffer
, *num_forms
, forms
)) {
1293 return WERR_GENERAL_FAILURE
;
1299 /**********************************************************************
1300 **********************************************************************/
1302 WERROR
rpccli_spoolss_enumjobs(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1303 POLICY_HND
*hnd
, uint32 level
, uint32 firstjob
,
1304 uint32 num_jobs
, uint32
*returned
, JOB_INFO_CTR
*ctr
)
1306 prs_struct qbuf
, rbuf
;
1307 SPOOL_Q_ENUMJOBS in
;
1308 SPOOL_R_ENUMJOBS out
;
1316 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1317 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1320 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMJOBS
,
1323 spoolss_io_q_enumjobs
,
1324 spoolss_io_r_enumjobs
,
1325 WERR_GENERAL_FAILURE
);
1327 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1328 offered
= out
.needed
;
1333 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1334 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1337 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMJOBS
,
1340 spoolss_io_q_enumjobs
,
1341 spoolss_io_r_enumjobs
,
1342 WERR_GENERAL_FAILURE
);
1345 if (!W_ERROR_IS_OK(out
.status
))
1350 if (!decode_jobs_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_1
)) {
1351 return WERR_GENERAL_FAILURE
;
1355 if (!decode_jobs_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_2
)) {
1356 return WERR_GENERAL_FAILURE
;
1360 DEBUG(3, ("unsupported info level %d", level
));
1361 return WERR_UNKNOWN_LEVEL
;
1364 *returned
= out
.returned
;
1369 /**********************************************************************
1370 **********************************************************************/
1372 WERROR
rpccli_spoolss_setjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1373 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1376 prs_struct qbuf
, rbuf
;
1383 make_spoolss_q_setjob( &in
, hnd
, jobid
, level
, command
);
1385 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETJOB
,
1388 spoolss_io_q_setjob
,
1389 spoolss_io_r_setjob
,
1390 WERR_GENERAL_FAILURE
);
1395 /**********************************************************************
1396 **********************************************************************/
1398 WERROR
rpccli_spoolss_getjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1399 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1402 prs_struct qbuf
, rbuf
;
1412 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1413 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1415 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETJOB
,
1418 spoolss_io_q_getjob
,
1419 spoolss_io_r_getjob
,
1420 WERR_GENERAL_FAILURE
);
1422 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1423 offered
= out
.needed
;
1428 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1429 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1431 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETJOB
,
1434 spoolss_io_q_getjob
,
1435 spoolss_io_r_getjob
,
1436 WERR_GENERAL_FAILURE
);
1439 if (!W_ERROR_IS_OK(out
.status
))
1444 if (!decode_jobs_1(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_1
)) {
1445 return WERR_GENERAL_FAILURE
;
1449 if (!decode_jobs_2(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_2
)) {
1450 return WERR_GENERAL_FAILURE
;
1454 return WERR_UNKNOWN_LEVEL
;
1460 /**********************************************************************
1461 **********************************************************************/
1463 WERROR
rpccli_spoolss_startpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1466 prs_struct qbuf
, rbuf
;
1467 SPOOL_Q_STARTPAGEPRINTER in
;
1468 SPOOL_R_STARTPAGEPRINTER out
;
1473 make_spoolss_q_startpageprinter( &in
, hnd
);
1475 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_STARTPAGEPRINTER
,
1478 spoolss_io_q_startpageprinter
,
1479 spoolss_io_r_startpageprinter
,
1480 WERR_GENERAL_FAILURE
);
1485 /**********************************************************************
1486 **********************************************************************/
1488 WERROR
rpccli_spoolss_endpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1491 prs_struct qbuf
, rbuf
;
1492 SPOOL_Q_ENDPAGEPRINTER in
;
1493 SPOOL_R_ENDPAGEPRINTER out
;
1498 make_spoolss_q_endpageprinter( &in
, hnd
);
1500 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENDPAGEPRINTER
,
1503 spoolss_io_q_endpageprinter
,
1504 spoolss_io_r_endpageprinter
,
1505 WERR_GENERAL_FAILURE
);
1510 /**********************************************************************
1511 **********************************************************************/
1513 WERROR
rpccli_spoolss_startdocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1514 POLICY_HND
*hnd
, char *docname
,
1515 char *outputfile
, char *datatype
,
1518 prs_struct qbuf
, rbuf
;
1519 SPOOL_Q_STARTDOCPRINTER in
;
1520 SPOOL_R_STARTDOCPRINTER out
;
1526 make_spoolss_q_startdocprinter( &in
, hnd
, level
, docname
,
1527 outputfile
, datatype
);
1529 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_STARTDOCPRINTER
,
1532 spoolss_io_q_startdocprinter
,
1533 spoolss_io_r_startdocprinter
,
1534 WERR_GENERAL_FAILURE
);
1541 /**********************************************************************
1542 **********************************************************************/
1544 WERROR
rpccli_spoolss_enddocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1547 prs_struct qbuf
, rbuf
;
1548 SPOOL_Q_ENDDOCPRINTER in
;
1549 SPOOL_R_ENDDOCPRINTER out
;
1554 make_spoolss_q_enddocprinter( &in
, hnd
);
1556 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENDDOCPRINTER
,
1559 spoolss_io_q_enddocprinter
,
1560 spoolss_io_r_enddocprinter
,
1561 WERR_GENERAL_FAILURE
);
1566 /**********************************************************************
1567 **********************************************************************/
1569 WERROR
rpccli_spoolss_getprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1570 POLICY_HND
*hnd
, const char *valuename
,
1571 REGISTRY_VALUE
*value
)
1573 prs_struct qbuf
, rbuf
;
1574 SPOOL_Q_GETPRINTERDATA in
;
1575 SPOOL_R_GETPRINTERDATA out
;
1582 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1584 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATA
,
1587 spoolss_io_q_getprinterdata
,
1588 spoolss_io_r_getprinterdata
,
1589 WERR_GENERAL_FAILURE
);
1591 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1592 offered
= out
.needed
;
1597 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1599 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATA
,
1602 spoolss_io_q_getprinterdata
,
1603 spoolss_io_r_getprinterdata
,
1604 WERR_GENERAL_FAILURE
);
1607 if (!W_ERROR_IS_OK(out
.status
))
1610 /* Return output parameters */
1612 value
->data_p
= TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1613 value
->type
= out
.type
;
1614 value
->size
= out
.size
;
1619 /**********************************************************************
1620 **********************************************************************/
1622 WERROR
rpccli_spoolss_getprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1623 POLICY_HND
*hnd
, const char *keyname
,
1624 const char *valuename
,
1625 REGISTRY_VALUE
*value
)
1627 prs_struct qbuf
, rbuf
;
1628 SPOOL_Q_GETPRINTERDATAEX in
;
1629 SPOOL_R_GETPRINTERDATAEX out
;
1635 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1637 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATAEX
,
1640 spoolss_io_q_getprinterdataex
,
1641 spoolss_io_r_getprinterdataex
,
1642 WERR_GENERAL_FAILURE
);
1644 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1645 offered
= out
.needed
;
1650 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1652 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATAEX
,
1655 spoolss_io_q_getprinterdataex
,
1656 spoolss_io_r_getprinterdataex
,
1657 WERR_GENERAL_FAILURE
);
1660 if (!W_ERROR_IS_OK(out
.status
))
1663 /* Return output parameters */
1665 value
->data_p
= TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1666 value
->type
= out
.type
;
1667 value
->size
= out
.needed
;
1672 /**********************************************************************
1673 **********************************************************************/
1675 WERROR
rpccli_spoolss_setprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1676 POLICY_HND
*hnd
, REGISTRY_VALUE
*value
)
1678 prs_struct qbuf
, rbuf
;
1679 SPOOL_Q_SETPRINTERDATA in
;
1680 SPOOL_R_SETPRINTERDATA out
;
1685 make_spoolss_q_setprinterdata( &in
, hnd
, value
->valuename
,
1686 value
->type
, (char *)value
->data_p
, value
->size
);
1688 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTERDATA
,
1691 spoolss_io_q_setprinterdata
,
1692 spoolss_io_r_setprinterdata
,
1693 WERR_GENERAL_FAILURE
);
1698 /**********************************************************************
1699 **********************************************************************/
1701 WERROR
rpccli_spoolss_setprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1702 POLICY_HND
*hnd
, char *keyname
,
1703 REGISTRY_VALUE
*value
)
1705 prs_struct qbuf
, rbuf
;
1706 SPOOL_Q_SETPRINTERDATAEX in
;
1707 SPOOL_R_SETPRINTERDATAEX out
;
1712 make_spoolss_q_setprinterdataex( &in
, hnd
, keyname
, value
->valuename
,
1713 value
->type
, (char *)value
->data_p
, value
->size
);
1715 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTERDATAEX
,
1718 spoolss_io_q_setprinterdataex
,
1719 spoolss_io_r_setprinterdataex
,
1720 WERR_GENERAL_FAILURE
);
1725 /**********************************************************************
1726 **********************************************************************/
1728 WERROR
rpccli_spoolss_enumprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1729 POLICY_HND
*hnd
, uint32 ndx
,
1730 uint32 value_offered
, uint32 data_offered
,
1731 uint32
*value_needed
, uint32
*data_needed
,
1732 REGISTRY_VALUE
*value
)
1734 prs_struct qbuf
, rbuf
;
1735 SPOOL_Q_ENUMPRINTERDATA in
;
1736 SPOOL_R_ENUMPRINTERDATA out
;
1741 make_spoolss_q_enumprinterdata( &in
, hnd
, ndx
, value_offered
, data_offered
);
1743 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATA
,
1746 spoolss_io_q_enumprinterdata
,
1747 spoolss_io_r_enumprinterdata
,
1748 WERR_GENERAL_FAILURE
);
1751 *value_needed
= out
.realvaluesize
;
1753 *data_needed
= out
.realdatasize
;
1755 if (!W_ERROR_IS_OK(out
.status
))
1759 rpcstr_pull(value
->valuename
, out
.value
, sizeof(value
->valuename
), -1,
1761 value
->data_p
= TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.realdatasize
);
1762 value
->type
= out
.type
;
1763 value
->size
= out
.realdatasize
;
1769 /**********************************************************************
1770 **********************************************************************/
1772 WERROR
rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1773 POLICY_HND
*hnd
, const char *keyname
,
1776 prs_struct qbuf
, rbuf
;
1777 SPOOL_Q_ENUMPRINTERDATAEX in
;
1778 SPOOL_R_ENUMPRINTERDATAEX out
;
1786 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1788 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATAEX
,
1791 spoolss_io_q_enumprinterdataex
,
1792 spoolss_io_r_enumprinterdataex
,
1793 WERR_GENERAL_FAILURE
);
1795 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1796 offered
= out
.needed
;
1801 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1803 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATAEX
,
1806 spoolss_io_q_enumprinterdataex
,
1807 spoolss_io_r_enumprinterdataex
,
1808 WERR_GENERAL_FAILURE
);
1811 if (!W_ERROR_IS_OK(out
.status
))
1814 for (i
= 0; i
< out
.returned
; i
++) {
1815 PRINTER_ENUM_VALUES
*v
= &out
.ctr
.values
[i
];
1818 rpcstr_pull(name
, v
->valuename
.buffer
, sizeof(name
), -1,
1820 regval_ctr_addvalue(ctr
, name
, v
->type
, (const char *)v
->data
, v
->data_len
);
1826 /**********************************************************************
1827 **********************************************************************/
1829 WERROR
rpccli_spoolss_writeprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1830 POLICY_HND
*hnd
, uint32 data_size
, char *data
,
1831 uint32
*num_written
)
1833 prs_struct qbuf
, rbuf
;
1834 SPOOL_Q_WRITEPRINTER in
;
1835 SPOOL_R_WRITEPRINTER out
;
1840 make_spoolss_q_writeprinter( &in
, hnd
, data_size
, data
);
1842 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_WRITEPRINTER
,
1845 spoolss_io_q_writeprinter
,
1846 spoolss_io_r_writeprinter
,
1847 WERR_GENERAL_FAILURE
);
1850 *num_written
= out
.buffer_written
;
1855 /**********************************************************************
1856 **********************************************************************/
1858 WERROR
rpccli_spoolss_deleteprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1859 POLICY_HND
*hnd
, char *valuename
)
1861 prs_struct qbuf
, rbuf
;
1862 SPOOL_Q_DELETEPRINTERDATA in
;
1863 SPOOL_R_DELETEPRINTERDATA out
;
1868 make_spoolss_q_deleteprinterdata( &in
, hnd
, valuename
);
1870 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDATA
,
1873 spoolss_io_q_deleteprinterdata
,
1874 spoolss_io_r_deleteprinterdata
,
1875 WERR_GENERAL_FAILURE
);
1880 /**********************************************************************
1881 **********************************************************************/
1883 WERROR
rpccli_spoolss_deleteprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1884 POLICY_HND
*hnd
, char *keyname
,
1887 prs_struct qbuf
, rbuf
;
1888 SPOOL_Q_DELETEPRINTERDATAEX in
;
1889 SPOOL_R_DELETEPRINTERDATAEX out
;
1894 make_spoolss_q_deleteprinterdataex( &in
, hnd
, keyname
, valuename
);
1896 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDATAEX
,
1899 spoolss_io_q_deleteprinterdataex
,
1900 spoolss_io_r_deleteprinterdataex
,
1901 WERR_GENERAL_FAILURE
);
1906 /**********************************************************************
1907 **********************************************************************/
1909 WERROR
rpccli_spoolss_enumprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1910 POLICY_HND
*hnd
, const char *keyname
,
1911 uint16
**keylist
, uint32
*len
)
1913 prs_struct qbuf
, rbuf
;
1914 SPOOL_Q_ENUMPRINTERKEY in
;
1915 SPOOL_R_ENUMPRINTERKEY out
;
1921 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
1923 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERKEY
,
1926 spoolss_io_q_enumprinterkey
,
1927 spoolss_io_r_enumprinterkey
,
1928 WERR_GENERAL_FAILURE
);
1930 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1931 offered
= out
.needed
;
1936 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
1938 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERKEY
,
1941 spoolss_io_q_enumprinterkey
,
1942 spoolss_io_r_enumprinterkey
,
1943 WERR_GENERAL_FAILURE
);
1946 if ( !W_ERROR_IS_OK(out
.status
) )
1950 *keylist
= SMB_MALLOC_ARRAY(uint16
, out
.keys
.buf_len
);
1954 memcpy(*keylist
, out
.keys
.buffer
, out
.keys
.buf_len
* 2);
1956 *len
= out
.keys
.buf_len
* 2;
1962 /**********************************************************************
1963 **********************************************************************/
1965 WERROR
rpccli_spoolss_deleteprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1966 POLICY_HND
*hnd
, char *keyname
)
1968 prs_struct qbuf
, rbuf
;
1969 SPOOL_Q_DELETEPRINTERKEY in
;
1970 SPOOL_R_DELETEPRINTERKEY out
;
1975 make_spoolss_q_deleteprinterkey( &in
, hnd
, keyname
);
1977 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERKEY
,
1980 spoolss_io_q_deleteprinterkey
,
1981 spoolss_io_r_deleteprinterkey
,
1982 WERR_GENERAL_FAILURE
);