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
)
43 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_0
, returned
);
47 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_0
));
52 prs_set_offset(&buffer
->prs
,0);
54 for (i
=0; i
<returned
; i
++) {
55 if (!smb_io_printer_info_0("", buffer
, &inf
[i
], 0)) {
64 /**********************************************************************
65 **********************************************************************/
67 static BOOL
decode_printer_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
68 uint32 returned
, PRINTER_INFO_1
**info
)
74 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_1
, returned
);
78 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_1
));
83 prs_set_offset(&buffer
->prs
,0);
85 for (i
=0; i
<returned
; i
++) {
86 if (!smb_io_printer_info_1("", buffer
, &inf
[i
], 0)) {
95 /**********************************************************************
96 **********************************************************************/
98 static BOOL
decode_printer_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
99 uint32 returned
, PRINTER_INFO_2
**info
)
105 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_2
, returned
);
109 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_2
));
114 prs_set_offset(&buffer
->prs
,0);
116 for (i
=0; i
<returned
; i
++) {
117 /* a little initialization as we go */
118 inf
[i
].secdesc
= NULL
;
119 if (!smb_io_printer_info_2("", buffer
, &inf
[i
], 0)) {
128 /**********************************************************************
129 **********************************************************************/
131 static BOOL
decode_printer_info_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
132 uint32 returned
, PRINTER_INFO_3
**info
)
138 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_3
, returned
);
142 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_3
));
147 prs_set_offset(&buffer
->prs
,0);
149 for (i
=0; i
<returned
; i
++) {
150 inf
[i
].secdesc
= NULL
;
151 if (!smb_io_printer_info_3("", buffer
, &inf
[i
], 0)) {
160 /**********************************************************************
161 **********************************************************************/
163 static BOOL
decode_printer_info_7(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
164 uint32 returned
, PRINTER_INFO_7
**info
)
170 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_7
, returned
);
174 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_7
));
179 prs_set_offset(&buffer
->prs
,0);
181 for (i
=0; i
<returned
; i
++) {
182 if (!smb_io_printer_info_7("", buffer
, &inf
[i
], 0)) {
192 /**********************************************************************
193 **********************************************************************/
195 static BOOL
decode_port_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
196 uint32 returned
, PORT_INFO_1
**info
)
202 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_1
, returned
);
206 memset(inf
, 0, returned
*sizeof(PORT_INFO_1
));
211 prs_set_offset(&buffer
->prs
, 0);
213 for (i
=0; i
<returned
; i
++) {
214 if (!smb_io_port_info_1("", buffer
, &(inf
[i
]), 0)) {
223 /**********************************************************************
224 **********************************************************************/
226 static BOOL
decode_port_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
227 uint32 returned
, PORT_INFO_2
**info
)
233 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_2
, returned
);
237 memset(inf
, 0, returned
*sizeof(PORT_INFO_2
));
242 prs_set_offset(&buffer
->prs
, 0);
244 for (i
=0; i
<returned
; i
++) {
245 if (!smb_io_port_info_2("", buffer
, &(inf
[i
]), 0)) {
254 /**********************************************************************
255 **********************************************************************/
257 static BOOL
decode_printer_driver_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
258 uint32 returned
, DRIVER_INFO_1
**info
)
264 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_1
, returned
);
268 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_1
));
273 prs_set_offset(&buffer
->prs
,0);
275 for (i
=0; i
<returned
; i
++) {
276 if (!smb_io_printer_driver_info_1("", buffer
, &(inf
[i
]), 0)) {
285 /**********************************************************************
286 **********************************************************************/
288 static BOOL
decode_printer_driver_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
289 uint32 returned
, DRIVER_INFO_2
**info
)
295 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_2
, returned
);
299 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_2
));
304 prs_set_offset(&buffer
->prs
,0);
306 for (i
=0; i
<returned
; i
++) {
307 if (!smb_io_printer_driver_info_2("", buffer
, &(inf
[i
]), 0)) {
316 /**********************************************************************
317 **********************************************************************/
319 static BOOL
decode_printer_driver_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
320 uint32 returned
, DRIVER_INFO_3
**info
)
326 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_3
, returned
);
330 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_3
));
335 prs_set_offset(&buffer
->prs
,0);
337 for (i
=0; i
<returned
; i
++) {
338 if (!smb_io_printer_driver_info_3("", buffer
, &(inf
[i
]), 0)) {
347 /**********************************************************************
348 **********************************************************************/
350 static BOOL
decode_printerdriverdir_1 (TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
351 uint32 returned
, DRIVER_DIRECTORY_1
**info
354 DRIVER_DIRECTORY_1
*inf
;
356 inf
=TALLOC_P(mem_ctx
, DRIVER_DIRECTORY_1
);
360 memset(inf
, 0, sizeof(DRIVER_DIRECTORY_1
));
362 prs_set_offset(&buffer
->prs
, 0);
364 if (!smb_io_driverdir_1("", buffer
, inf
, 0)) {
372 /**********************************************************************
373 **********************************************************************/
375 static BOOL
decode_jobs_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
376 uint32 num_jobs
, JOB_INFO_1
**jobs
)
381 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_1
, num_jobs
);
388 prs_set_offset(&buffer
->prs
,0);
390 for (i
= 0; i
< num_jobs
; i
++) {
391 if (!smb_io_job_info_1("", buffer
, &((*jobs
)[i
]), 0)) {
399 /**********************************************************************
400 **********************************************************************/
402 static BOOL
decode_jobs_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
403 uint32 num_jobs
, JOB_INFO_2
**jobs
)
408 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_2
, num_jobs
);
415 prs_set_offset(&buffer
->prs
,0);
417 for (i
= 0; i
< num_jobs
; i
++) {
418 if (!smb_io_job_info_2("", buffer
, &((*jobs
)[i
]), 0)) {
426 /**********************************************************************
427 **********************************************************************/
429 static BOOL
decode_forms_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
430 uint32 num_forms
, FORM_1
**forms
)
435 *forms
= TALLOC_ARRAY(mem_ctx
, FORM_1
, num_forms
);
436 if (*forms
== NULL
) {
443 prs_set_offset(&buffer
->prs
,0);
445 for (i
= 0; i
< num_forms
; i
++) {
446 if (!smb_io_form_1("", buffer
, &((*forms
)[i
]), 0)) {
454 /**********************************************************************
455 **********************************************************************/
457 WERROR
rpccli_spoolss_open_printer_ex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
458 const char *printername
, const char *datatype
, uint32 access_required
,
459 const char *station
, const char *username
, POLICY_HND
*pol
)
461 prs_struct qbuf
, rbuf
;
462 SPOOL_Q_OPEN_PRINTER_EX in
;
463 SPOOL_R_OPEN_PRINTER_EX out
;
468 make_spoolss_q_open_printer_ex( &in
, printername
, datatype
,
469 access_required
, station
, username
);
471 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_OPENPRINTEREX
,
474 spoolss_io_q_open_printer_ex
,
475 spoolss_io_r_open_printer_ex
,
476 WERR_GENERAL_FAILURE
);
478 memcpy( pol
, &out
.handle
, sizeof(POLICY_HND
) );
483 /**********************************************************************
484 **********************************************************************/
486 WERROR
rpccli_spoolss_close_printer(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
489 prs_struct qbuf
, rbuf
;
490 SPOOL_Q_CLOSEPRINTER in
;
491 SPOOL_R_CLOSEPRINTER out
;
496 make_spoolss_q_closeprinter( &in
, pol
);
498 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_CLOSEPRINTER
,
501 spoolss_io_q_closeprinter
,
502 spoolss_io_r_closeprinter
,
503 WERR_GENERAL_FAILURE
);
508 /**********************************************************************
509 **********************************************************************/
511 WERROR
rpccli_spoolss_enum_printers(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
512 char *name
, uint32 flags
, uint32 level
,
513 uint32
*num_printers
, PRINTER_INFO_CTR
*ctr
)
515 prs_struct qbuf
, rbuf
;
516 SPOOL_Q_ENUMPRINTERS in
;
517 SPOOL_R_ENUMPRINTERS out
;
525 rpcbuf_init(&buffer
, offered
, mem_ctx
);
526 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
528 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERS
,
531 spoolss_io_q_enumprinters
,
532 spoolss_io_r_enumprinters
,
533 WERR_GENERAL_FAILURE
);
535 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
536 offered
= out
.needed
;
541 rpcbuf_init(&buffer
, offered
, mem_ctx
);
542 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
544 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERS
,
547 spoolss_io_q_enumprinters
,
548 spoolss_io_r_enumprinters
,
549 WERR_GENERAL_FAILURE
);
552 if ( !W_ERROR_IS_OK(out
.status
) )
557 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_0
)) {
558 return WERR_GENERAL_FAILURE
;
562 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_1
)) {
563 return WERR_GENERAL_FAILURE
;
567 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_2
)) {
568 return WERR_GENERAL_FAILURE
;
572 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_3
)) {
573 return WERR_GENERAL_FAILURE
;
577 return WERR_UNKNOWN_LEVEL
;
580 *num_printers
= out
.returned
;
585 /**********************************************************************
586 **********************************************************************/
588 WERROR
rpccli_spoolss_enum_ports(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
589 uint32 level
, uint32
*num_ports
, PORT_INFO_CTR
*ctr
)
591 prs_struct qbuf
, rbuf
;
592 SPOOL_Q_ENUMPORTS in
;
593 SPOOL_R_ENUMPORTS out
;
601 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
605 rpcbuf_init(&buffer
, offered
, mem_ctx
);
606 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
608 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPORTS
,
611 spoolss_io_q_enumports
,
612 spoolss_io_r_enumports
,
613 WERR_GENERAL_FAILURE
);
615 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
616 offered
= out
.needed
;
621 rpcbuf_init(&buffer
, offered
, mem_ctx
);
622 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
624 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPORTS
,
627 spoolss_io_q_enumports
,
628 spoolss_io_r_enumports
,
629 WERR_GENERAL_FAILURE
);
632 if ( !W_ERROR_IS_OK(out
.status
) )
637 if (!decode_port_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_1
)) {
638 return WERR_GENERAL_FAILURE
;
642 if (!decode_port_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_2
)) {
643 return WERR_GENERAL_FAILURE
;
647 return WERR_UNKNOWN_LEVEL
;
650 *num_ports
= out
.returned
;
655 /**********************************************************************
656 **********************************************************************/
658 WERROR
rpccli_spoolss_getprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
659 POLICY_HND
*pol
, uint32 level
,
660 PRINTER_INFO_CTR
*ctr
)
662 prs_struct qbuf
, rbuf
;
663 SPOOL_Q_GETPRINTER in
;
664 SPOOL_R_GETPRINTER out
;
671 /* Initialise input parameters */
674 rpcbuf_init(&buffer
, offered
, mem_ctx
);
675 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
677 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTER
,
680 spoolss_io_q_getprinter
,
681 spoolss_io_r_getprinter
,
682 WERR_GENERAL_FAILURE
);
684 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
685 offered
= out
.needed
;
690 rpcbuf_init(&buffer
, offered
, mem_ctx
);
691 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
693 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTER
,
696 spoolss_io_q_getprinter
,
697 spoolss_io_r_getprinter
,
698 WERR_GENERAL_FAILURE
);
701 if ( !W_ERROR_IS_OK(out
.status
) )
706 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, 1, &ctr
->printers_0
)) {
707 return WERR_GENERAL_FAILURE
;
711 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, 1, &ctr
->printers_1
)) {
712 return WERR_GENERAL_FAILURE
;
716 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, 1, &ctr
->printers_2
)) {
717 return WERR_GENERAL_FAILURE
;
721 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, 1, &ctr
->printers_3
)) {
722 return WERR_GENERAL_FAILURE
;
726 if (!decode_printer_info_7(mem_ctx
, out
.buffer
, 1, &ctr
->printers_7
)) {
727 return WERR_GENERAL_FAILURE
;
731 return WERR_UNKNOWN_LEVEL
;
737 /**********************************************************************
738 **********************************************************************/
740 WERROR
rpccli_spoolss_setprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
741 POLICY_HND
*pol
, uint32 level
,
742 PRINTER_INFO_CTR
*ctr
, uint32 command
)
744 prs_struct qbuf
, rbuf
;
745 SPOOL_Q_SETPRINTER in
;
746 SPOOL_R_SETPRINTER out
;
751 make_spoolss_q_setprinter( mem_ctx
, &in
, pol
, level
, ctr
, command
);
753 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTER
,
756 spoolss_io_q_setprinter
,
757 spoolss_io_r_setprinter
,
758 WERR_GENERAL_FAILURE
);
763 /**********************************************************************
764 **********************************************************************/
766 WERROR
rpccli_spoolss_getprinterdriver(struct rpc_pipe_client
*cli
,
768 POLICY_HND
*pol
, uint32 level
,
769 const char *env
, int version
, PRINTER_DRIVER_CTR
*ctr
)
771 prs_struct qbuf
, rbuf
;
772 SPOOL_Q_GETPRINTERDRIVER2 in
;
773 SPOOL_R_GETPRINTERDRIVER2 out
;
781 fstrcpy(server
, cli
->cli
->desthost
);
785 rpcbuf_init(&buffer
, offered
, mem_ctx
);
786 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
787 version
, 2, &buffer
, offered
);
789 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVER2
,
792 spoolss_io_q_getprinterdriver2
,
793 spoolss_io_r_getprinterdriver2
,
794 WERR_GENERAL_FAILURE
);
796 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
797 offered
= out
.needed
;
802 rpcbuf_init(&buffer
, offered
, mem_ctx
);
803 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
804 version
, 2, &buffer
, offered
);
806 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVER2
,
809 spoolss_io_q_getprinterdriver2
,
810 spoolss_io_r_getprinterdriver2
,
811 WERR_GENERAL_FAILURE
);
814 if ( !W_ERROR_IS_OK(out
.status
) )
819 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
820 return WERR_GENERAL_FAILURE
;
824 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, 1, &ctr
->info2
)) {
825 return WERR_GENERAL_FAILURE
;
829 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, 1, &ctr
->info3
)) {
830 return WERR_GENERAL_FAILURE
;
834 return WERR_UNKNOWN_LEVEL
;
840 /**********************************************************************
841 **********************************************************************/
843 WERROR
rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client
*cli
,
845 uint32 level
, const char *env
,
847 PRINTER_DRIVER_CTR
*ctr
)
849 prs_struct qbuf
, rbuf
;
850 SPOOL_Q_ENUMPRINTERDRIVERS in
;
851 SPOOL_R_ENUMPRINTERDRIVERS out
;
859 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
863 rpcbuf_init(&buffer
, offered
, mem_ctx
);
864 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
867 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDRIVERS
,
870 spoolss_io_q_enumprinterdrivers
,
871 spoolss_io_r_enumprinterdrivers
,
872 WERR_GENERAL_FAILURE
);
874 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
875 offered
= out
.needed
;
880 rpcbuf_init(&buffer
, offered
, mem_ctx
);
881 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
884 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDRIVERS
,
887 spoolss_io_q_enumprinterdrivers
,
888 spoolss_io_r_enumprinterdrivers
,
889 WERR_GENERAL_FAILURE
);
892 *num_drivers
= out
.returned
;
894 if ( !W_ERROR_IS_OK(out
.status
) )
897 if ( out
.returned
) {
901 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info1
)) {
902 return WERR_GENERAL_FAILURE
;
906 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info2
)) {
907 return WERR_GENERAL_FAILURE
;
911 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info3
)) {
912 return WERR_GENERAL_FAILURE
;
916 return WERR_UNKNOWN_LEVEL
;
924 /**********************************************************************
925 **********************************************************************/
927 WERROR
rpccli_spoolss_getprinterdriverdir (struct rpc_pipe_client
*cli
,
929 uint32 level
, char *env
,
930 DRIVER_DIRECTORY_CTR
*ctr
)
932 prs_struct qbuf
, rbuf
;
933 SPOOL_Q_GETPRINTERDRIVERDIR in
;
934 SPOOL_R_GETPRINTERDRIVERDIR out
;
942 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
946 rpcbuf_init(&buffer
, offered
, mem_ctx
);
947 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
950 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
953 spoolss_io_q_getprinterdriverdir
,
954 spoolss_io_r_getprinterdriverdir
,
955 WERR_GENERAL_FAILURE
);
957 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
958 offered
= out
.needed
;
963 rpcbuf_init(&buffer
, offered
, mem_ctx
);
964 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
967 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
970 spoolss_io_q_getprinterdriverdir
,
971 spoolss_io_r_getprinterdriverdir
,
972 WERR_GENERAL_FAILURE
);
975 if (!W_ERROR_IS_OK(out
.status
))
978 if (!decode_printerdriverdir_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
979 return WERR_GENERAL_FAILURE
;
985 /**********************************************************************
986 **********************************************************************/
988 WERROR
rpccli_spoolss_addprinterdriver (struct rpc_pipe_client
*cli
,
989 TALLOC_CTX
*mem_ctx
, uint32 level
,
990 PRINTER_DRIVER_CTR
*ctr
)
992 prs_struct qbuf
, rbuf
;
993 SPOOL_Q_ADDPRINTERDRIVER in
;
994 SPOOL_R_ADDPRINTERDRIVER out
;
1000 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
1003 make_spoolss_q_addprinterdriver( mem_ctx
, &in
, server
, level
, ctr
);
1005 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDPRINTERDRIVER
,
1008 spoolss_io_q_addprinterdriver
,
1009 spoolss_io_r_addprinterdriver
,
1010 WERR_GENERAL_FAILURE
);
1015 /**********************************************************************
1016 **********************************************************************/
1018 WERROR
rpccli_spoolss_addprinterex (struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1019 uint32 level
, PRINTER_INFO_CTR
*ctr
)
1021 prs_struct qbuf
, rbuf
;
1022 SPOOL_Q_ADDPRINTEREX in
;
1023 SPOOL_R_ADDPRINTEREX out
;
1024 fstring server
, client
, user
;
1029 slprintf(client
, sizeof(fstring
)-1, "\\\\%s", global_myname());
1030 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
1035 fstrcpy (user
, cli
->user_name
);
1037 make_spoolss_q_addprinterex( mem_ctx
, &in
, server
, client
,
1040 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDPRINTEREX
,
1043 spoolss_io_q_addprinterex
,
1044 spoolss_io_r_addprinterex
,
1045 WERR_GENERAL_FAILURE
);
1050 /**********************************************************************
1051 **********************************************************************/
1053 WERROR
rpccli_spoolss_deleteprinterdriverex(struct rpc_pipe_client
*cli
,
1054 TALLOC_CTX
*mem_ctx
, const char *arch
,
1055 const char *driver
, int version
)
1057 prs_struct qbuf
, rbuf
;
1058 SPOOL_Q_DELETEPRINTERDRIVEREX in
;
1059 SPOOL_R_DELETEPRINTERDRIVEREX out
;
1065 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
1068 make_spoolss_q_deleteprinterdriverex( mem_ctx
, &in
, server
, arch
, driver
, version
);
1070 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDRIVEREX
,
1073 spoolss_io_q_deleteprinterdriverex
,
1074 spoolss_io_r_deleteprinterdriverex
,
1075 WERR_GENERAL_FAILURE
);
1080 /**********************************************************************
1081 **********************************************************************/
1083 WERROR
rpccli_spoolss_deleteprinterdriver (struct rpc_pipe_client
*cli
,
1084 TALLOC_CTX
*mem_ctx
, const char *arch
,
1087 prs_struct qbuf
, rbuf
;
1088 SPOOL_Q_DELETEPRINTERDRIVER in
;
1089 SPOOL_R_DELETEPRINTERDRIVER out
;
1095 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->cli
->desthost
);
1098 make_spoolss_q_deleteprinterdriver( mem_ctx
, &in
, server
, arch
, driver
);
1100 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDRIVER
,
1103 spoolss_io_q_deleteprinterdriver
,
1104 spoolss_io_r_deleteprinterdriver
,
1105 WERR_GENERAL_FAILURE
);
1110 /**********************************************************************
1111 **********************************************************************/
1113 WERROR
rpccli_spoolss_getprintprocessordirectory(struct rpc_pipe_client
*cli
,
1114 TALLOC_CTX
*mem_ctx
,
1115 char *name
, char *environment
,
1118 prs_struct qbuf
, rbuf
;
1119 SPOOL_Q_GETPRINTPROCESSORDIRECTORY in
;
1120 SPOOL_R_GETPRINTPROCESSORDIRECTORY out
;
1129 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1130 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1131 environment
, level
, &buffer
, offered
);
1133 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1136 spoolss_io_q_getprintprocessordirectory
,
1137 spoolss_io_r_getprintprocessordirectory
,
1138 WERR_GENERAL_FAILURE
);
1140 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1141 offered
= out
.needed
;
1146 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1147 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1148 environment
, level
, &buffer
, offered
);
1150 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1153 spoolss_io_q_getprintprocessordirectory
,
1154 spoolss_io_r_getprintprocessordirectory
,
1155 WERR_GENERAL_FAILURE
);
1158 if ( !W_ERROR_IS_OK(out
.status
) )
1161 fstrcpy(procdir
, "Not implemented!");
1166 /**********************************************************************
1167 **********************************************************************/
1169 WERROR
rpccli_spoolss_addform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1170 POLICY_HND
*handle
, uint32 level
, FORM
*form
)
1172 prs_struct qbuf
, rbuf
;
1174 SPOOL_R_ADDFORM out
;
1179 make_spoolss_q_addform( &in
, handle
, level
, form
);
1181 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDFORM
,
1184 spoolss_io_q_addform
,
1185 spoolss_io_r_addform
,
1186 WERR_GENERAL_FAILURE
);
1191 /**********************************************************************
1192 **********************************************************************/
1194 WERROR
rpccli_spoolss_setform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1195 POLICY_HND
*handle
, uint32 level
,
1196 const char *form_name
, FORM
*form
)
1198 prs_struct qbuf
, rbuf
;
1200 SPOOL_R_SETFORM out
;
1205 make_spoolss_q_setform( &in
, handle
, level
, form_name
, form
);
1207 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETFORM
,
1210 spoolss_io_q_setform
,
1211 spoolss_io_r_setform
,
1212 WERR_GENERAL_FAILURE
);
1217 /**********************************************************************
1218 **********************************************************************/
1220 WERROR
rpccli_spoolss_getform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1221 POLICY_HND
*handle
, const char *formname
,
1222 uint32 level
, FORM_1
*form
)
1224 prs_struct qbuf
, rbuf
;
1226 SPOOL_R_GETFORM out
;
1234 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1235 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1237 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETFORM
,
1240 spoolss_io_q_getform
,
1241 spoolss_io_r_getform
,
1242 WERR_GENERAL_FAILURE
);
1244 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1245 offered
= out
.needed
;
1250 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1251 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1253 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETFORM
,
1256 spoolss_io_q_getform
,
1257 spoolss_io_r_getform
,
1258 WERR_GENERAL_FAILURE
);
1261 if (!W_ERROR_IS_OK(out
.status
))
1264 if (!smb_io_form_1("", out
.buffer
, form
, 0)) {
1265 return WERR_GENERAL_FAILURE
;
1271 /**********************************************************************
1272 **********************************************************************/
1274 WERROR
rpccli_spoolss_deleteform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1275 POLICY_HND
*handle
, const char *form_name
)
1277 prs_struct qbuf
, rbuf
;
1278 SPOOL_Q_DELETEFORM in
;
1279 SPOOL_R_DELETEFORM out
;
1284 make_spoolss_q_deleteform( &in
, handle
, form_name
);
1286 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEFORM
,
1289 spoolss_io_q_deleteform
,
1290 spoolss_io_r_deleteform
,
1291 WERR_GENERAL_FAILURE
);
1296 /**********************************************************************
1297 **********************************************************************/
1299 WERROR
rpccli_spoolss_enumforms(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1300 POLICY_HND
*handle
, int level
, uint32
*num_forms
,
1303 prs_struct qbuf
, rbuf
;
1304 SPOOL_Q_ENUMFORMS in
;
1305 SPOOL_R_ENUMFORMS out
;
1313 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1314 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1316 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMFORMS
,
1319 spoolss_io_q_enumforms
,
1320 spoolss_io_r_enumforms
,
1321 WERR_GENERAL_FAILURE
);
1323 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1324 offered
= out
.needed
;
1329 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1330 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1332 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMFORMS
,
1335 spoolss_io_q_enumforms
,
1336 spoolss_io_r_enumforms
,
1337 WERR_GENERAL_FAILURE
);
1340 if (!W_ERROR_IS_OK(out
.status
))
1343 *num_forms
= out
.numofforms
;
1345 if (!decode_forms_1(mem_ctx
, out
.buffer
, *num_forms
, forms
)) {
1346 return WERR_GENERAL_FAILURE
;
1352 /**********************************************************************
1353 **********************************************************************/
1355 WERROR
rpccli_spoolss_enumjobs(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1356 POLICY_HND
*hnd
, uint32 level
, uint32 firstjob
,
1357 uint32 num_jobs
, uint32
*returned
, JOB_INFO_CTR
*ctr
)
1359 prs_struct qbuf
, rbuf
;
1360 SPOOL_Q_ENUMJOBS in
;
1361 SPOOL_R_ENUMJOBS out
;
1369 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1370 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1373 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMJOBS
,
1376 spoolss_io_q_enumjobs
,
1377 spoolss_io_r_enumjobs
,
1378 WERR_GENERAL_FAILURE
);
1380 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1381 offered
= out
.needed
;
1386 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1387 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1390 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMJOBS
,
1393 spoolss_io_q_enumjobs
,
1394 spoolss_io_r_enumjobs
,
1395 WERR_GENERAL_FAILURE
);
1398 if (!W_ERROR_IS_OK(out
.status
))
1403 if (!decode_jobs_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_1
)) {
1404 return WERR_GENERAL_FAILURE
;
1408 if (!decode_jobs_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_2
)) {
1409 return WERR_GENERAL_FAILURE
;
1413 DEBUG(3, ("unsupported info level %d", level
));
1414 return WERR_UNKNOWN_LEVEL
;
1417 *returned
= out
.returned
;
1422 /**********************************************************************
1423 **********************************************************************/
1425 WERROR
rpccli_spoolss_setjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1426 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1429 prs_struct qbuf
, rbuf
;
1436 make_spoolss_q_setjob( &in
, hnd
, jobid
, level
, command
);
1438 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETJOB
,
1441 spoolss_io_q_setjob
,
1442 spoolss_io_r_setjob
,
1443 WERR_GENERAL_FAILURE
);
1448 /**********************************************************************
1449 **********************************************************************/
1451 WERROR
rpccli_spoolss_getjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1452 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1455 prs_struct qbuf
, rbuf
;
1465 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1466 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1468 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETJOB
,
1471 spoolss_io_q_getjob
,
1472 spoolss_io_r_getjob
,
1473 WERR_GENERAL_FAILURE
);
1475 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1476 offered
= out
.needed
;
1481 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1482 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1484 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETJOB
,
1487 spoolss_io_q_getjob
,
1488 spoolss_io_r_getjob
,
1489 WERR_GENERAL_FAILURE
);
1492 if (!W_ERROR_IS_OK(out
.status
))
1497 if (!decode_jobs_1(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_1
)) {
1498 return WERR_GENERAL_FAILURE
;
1502 if (!decode_jobs_2(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_2
)) {
1503 return WERR_GENERAL_FAILURE
;
1507 return WERR_UNKNOWN_LEVEL
;
1513 /**********************************************************************
1514 **********************************************************************/
1516 WERROR
rpccli_spoolss_startpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1519 prs_struct qbuf
, rbuf
;
1520 SPOOL_Q_STARTPAGEPRINTER in
;
1521 SPOOL_R_STARTPAGEPRINTER out
;
1526 make_spoolss_q_startpageprinter( &in
, hnd
);
1528 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_STARTPAGEPRINTER
,
1531 spoolss_io_q_startpageprinter
,
1532 spoolss_io_r_startpageprinter
,
1533 WERR_GENERAL_FAILURE
);
1538 /**********************************************************************
1539 **********************************************************************/
1541 WERROR
rpccli_spoolss_endpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1544 prs_struct qbuf
, rbuf
;
1545 SPOOL_Q_ENDPAGEPRINTER in
;
1546 SPOOL_R_ENDPAGEPRINTER out
;
1551 make_spoolss_q_endpageprinter( &in
, hnd
);
1553 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENDPAGEPRINTER
,
1556 spoolss_io_q_endpageprinter
,
1557 spoolss_io_r_endpageprinter
,
1558 WERR_GENERAL_FAILURE
);
1563 /**********************************************************************
1564 **********************************************************************/
1566 WERROR
rpccli_spoolss_startdocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1567 POLICY_HND
*hnd
, char *docname
,
1568 char *outputfile
, char *datatype
,
1571 prs_struct qbuf
, rbuf
;
1572 SPOOL_Q_STARTDOCPRINTER in
;
1573 SPOOL_R_STARTDOCPRINTER out
;
1579 make_spoolss_q_startdocprinter( &in
, hnd
, level
, docname
,
1580 outputfile
, datatype
);
1582 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_STARTDOCPRINTER
,
1585 spoolss_io_q_startdocprinter
,
1586 spoolss_io_r_startdocprinter
,
1587 WERR_GENERAL_FAILURE
);
1594 /**********************************************************************
1595 **********************************************************************/
1597 WERROR
rpccli_spoolss_enddocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1600 prs_struct qbuf
, rbuf
;
1601 SPOOL_Q_ENDDOCPRINTER in
;
1602 SPOOL_R_ENDDOCPRINTER out
;
1607 make_spoolss_q_enddocprinter( &in
, hnd
);
1609 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENDDOCPRINTER
,
1612 spoolss_io_q_enddocprinter
,
1613 spoolss_io_r_enddocprinter
,
1614 WERR_GENERAL_FAILURE
);
1619 /**********************************************************************
1620 **********************************************************************/
1622 WERROR
rpccli_spoolss_getprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1623 POLICY_HND
*hnd
, const char *valuename
,
1624 REGISTRY_VALUE
*value
)
1626 prs_struct qbuf
, rbuf
;
1627 SPOOL_Q_GETPRINTERDATA in
;
1628 SPOOL_R_GETPRINTERDATA out
;
1635 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1637 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATA
,
1640 spoolss_io_q_getprinterdata
,
1641 spoolss_io_r_getprinterdata
,
1642 WERR_GENERAL_FAILURE
);
1644 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1645 offered
= out
.needed
;
1650 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1652 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATA
,
1655 spoolss_io_q_getprinterdata
,
1656 spoolss_io_r_getprinterdata
,
1657 WERR_GENERAL_FAILURE
);
1660 if (!W_ERROR_IS_OK(out
.status
))
1663 /* Return output parameters */
1666 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1668 value
->data_p
= NULL
;
1670 value
->type
= out
.type
;
1671 value
->size
= out
.size
;
1676 /**********************************************************************
1677 **********************************************************************/
1679 WERROR
rpccli_spoolss_getprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1680 POLICY_HND
*hnd
, const char *keyname
,
1681 const char *valuename
,
1682 REGISTRY_VALUE
*value
)
1684 prs_struct qbuf
, rbuf
;
1685 SPOOL_Q_GETPRINTERDATAEX in
;
1686 SPOOL_R_GETPRINTERDATAEX out
;
1692 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1694 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATAEX
,
1697 spoolss_io_q_getprinterdataex
,
1698 spoolss_io_r_getprinterdataex
,
1699 WERR_GENERAL_FAILURE
);
1701 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1702 offered
= out
.needed
;
1707 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1709 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATAEX
,
1712 spoolss_io_q_getprinterdataex
,
1713 spoolss_io_r_getprinterdataex
,
1714 WERR_GENERAL_FAILURE
);
1717 if (!W_ERROR_IS_OK(out
.status
))
1720 /* Return output parameters */
1723 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1725 value
->data_p
= NULL
;
1727 value
->type
= out
.type
;
1728 value
->size
= out
.needed
;
1733 /**********************************************************************
1734 **********************************************************************/
1736 WERROR
rpccli_spoolss_setprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1737 POLICY_HND
*hnd
, REGISTRY_VALUE
*value
)
1739 prs_struct qbuf
, rbuf
;
1740 SPOOL_Q_SETPRINTERDATA in
;
1741 SPOOL_R_SETPRINTERDATA out
;
1746 make_spoolss_q_setprinterdata( &in
, hnd
, value
->valuename
,
1747 value
->type
, (char *)value
->data_p
, value
->size
);
1749 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTERDATA
,
1752 spoolss_io_q_setprinterdata
,
1753 spoolss_io_r_setprinterdata
,
1754 WERR_GENERAL_FAILURE
);
1759 /**********************************************************************
1760 **********************************************************************/
1762 WERROR
rpccli_spoolss_setprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1763 POLICY_HND
*hnd
, char *keyname
,
1764 REGISTRY_VALUE
*value
)
1766 prs_struct qbuf
, rbuf
;
1767 SPOOL_Q_SETPRINTERDATAEX in
;
1768 SPOOL_R_SETPRINTERDATAEX out
;
1773 make_spoolss_q_setprinterdataex( &in
, hnd
, keyname
, value
->valuename
,
1774 value
->type
, (char *)value
->data_p
, value
->size
);
1776 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTERDATAEX
,
1779 spoolss_io_q_setprinterdataex
,
1780 spoolss_io_r_setprinterdataex
,
1781 WERR_GENERAL_FAILURE
);
1786 /**********************************************************************
1787 **********************************************************************/
1789 WERROR
rpccli_spoolss_enumprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1790 POLICY_HND
*hnd
, uint32 ndx
,
1791 uint32 value_offered
, uint32 data_offered
,
1792 uint32
*value_needed
, uint32
*data_needed
,
1793 REGISTRY_VALUE
*value
)
1795 prs_struct qbuf
, rbuf
;
1796 SPOOL_Q_ENUMPRINTERDATA in
;
1797 SPOOL_R_ENUMPRINTERDATA out
;
1802 make_spoolss_q_enumprinterdata( &in
, hnd
, ndx
, value_offered
, data_offered
);
1804 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATA
,
1807 spoolss_io_q_enumprinterdata
,
1808 spoolss_io_r_enumprinterdata
,
1809 WERR_GENERAL_FAILURE
);
1812 *value_needed
= out
.realvaluesize
;
1814 *data_needed
= out
.realdatasize
;
1816 if (!W_ERROR_IS_OK(out
.status
))
1820 rpcstr_pull(value
->valuename
, out
.value
, sizeof(value
->valuename
), -1,
1822 if (out
.realdatasize
) {
1823 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
,
1826 value
->data_p
= NULL
;
1828 value
->type
= out
.type
;
1829 value
->size
= out
.realdatasize
;
1835 /**********************************************************************
1836 **********************************************************************/
1838 WERROR
rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1839 POLICY_HND
*hnd
, const char *keyname
,
1842 prs_struct qbuf
, rbuf
;
1843 SPOOL_Q_ENUMPRINTERDATAEX in
;
1844 SPOOL_R_ENUMPRINTERDATAEX out
;
1852 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1854 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATAEX
,
1857 spoolss_io_q_enumprinterdataex
,
1858 spoolss_io_r_enumprinterdataex
,
1859 WERR_GENERAL_FAILURE
);
1861 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1862 offered
= out
.needed
;
1867 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1869 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATAEX
,
1872 spoolss_io_q_enumprinterdataex
,
1873 spoolss_io_r_enumprinterdataex
,
1874 WERR_GENERAL_FAILURE
);
1877 if (!W_ERROR_IS_OK(out
.status
))
1880 for (i
= 0; i
< out
.returned
; i
++) {
1881 PRINTER_ENUM_VALUES
*v
= &out
.ctr
.values
[i
];
1884 rpcstr_pull(name
, v
->valuename
.buffer
, sizeof(name
), -1,
1886 regval_ctr_addvalue(ctr
, name
, v
->type
, (const char *)v
->data
, v
->data_len
);
1892 /**********************************************************************
1893 **********************************************************************/
1895 WERROR
rpccli_spoolss_writeprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1896 POLICY_HND
*hnd
, uint32 data_size
, char *data
,
1897 uint32
*num_written
)
1899 prs_struct qbuf
, rbuf
;
1900 SPOOL_Q_WRITEPRINTER in
;
1901 SPOOL_R_WRITEPRINTER out
;
1906 make_spoolss_q_writeprinter( &in
, hnd
, data_size
, data
);
1908 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_WRITEPRINTER
,
1911 spoolss_io_q_writeprinter
,
1912 spoolss_io_r_writeprinter
,
1913 WERR_GENERAL_FAILURE
);
1916 *num_written
= out
.buffer_written
;
1921 /**********************************************************************
1922 **********************************************************************/
1924 WERROR
rpccli_spoolss_deleteprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1925 POLICY_HND
*hnd
, char *valuename
)
1927 prs_struct qbuf
, rbuf
;
1928 SPOOL_Q_DELETEPRINTERDATA in
;
1929 SPOOL_R_DELETEPRINTERDATA out
;
1934 make_spoolss_q_deleteprinterdata( &in
, hnd
, valuename
);
1936 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDATA
,
1939 spoolss_io_q_deleteprinterdata
,
1940 spoolss_io_r_deleteprinterdata
,
1941 WERR_GENERAL_FAILURE
);
1946 /**********************************************************************
1947 **********************************************************************/
1949 WERROR
rpccli_spoolss_deleteprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1950 POLICY_HND
*hnd
, char *keyname
,
1953 prs_struct qbuf
, rbuf
;
1954 SPOOL_Q_DELETEPRINTERDATAEX in
;
1955 SPOOL_R_DELETEPRINTERDATAEX out
;
1960 make_spoolss_q_deleteprinterdataex( &in
, hnd
, keyname
, valuename
);
1962 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDATAEX
,
1965 spoolss_io_q_deleteprinterdataex
,
1966 spoolss_io_r_deleteprinterdataex
,
1967 WERR_GENERAL_FAILURE
);
1972 /**********************************************************************
1973 **********************************************************************/
1975 WERROR
rpccli_spoolss_enumprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1976 POLICY_HND
*hnd
, const char *keyname
,
1977 uint16
**keylist
, uint32
*len
)
1979 prs_struct qbuf
, rbuf
;
1980 SPOOL_Q_ENUMPRINTERKEY in
;
1981 SPOOL_R_ENUMPRINTERKEY out
;
1987 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
1989 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERKEY
,
1992 spoolss_io_q_enumprinterkey
,
1993 spoolss_io_r_enumprinterkey
,
1994 WERR_GENERAL_FAILURE
);
1996 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1997 offered
= out
.needed
;
2002 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
2004 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERKEY
,
2007 spoolss_io_q_enumprinterkey
,
2008 spoolss_io_r_enumprinterkey
,
2009 WERR_GENERAL_FAILURE
);
2012 if ( !W_ERROR_IS_OK(out
.status
) )
2016 *keylist
= SMB_MALLOC_ARRAY(uint16
, out
.keys
.buf_len
);
2020 memcpy(*keylist
, out
.keys
.buffer
, out
.keys
.buf_len
* 2);
2022 *len
= out
.keys
.buf_len
* 2;
2028 /**********************************************************************
2029 **********************************************************************/
2031 WERROR
rpccli_spoolss_deleteprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
2032 POLICY_HND
*hnd
, char *keyname
)
2034 prs_struct qbuf
, rbuf
;
2035 SPOOL_Q_DELETEPRINTERKEY in
;
2036 SPOOL_R_DELETEPRINTERKEY out
;
2041 make_spoolss_q_deleteprinterkey( &in
, hnd
, keyname
);
2043 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERKEY
,
2046 spoolss_io_q_deleteprinterkey
,
2047 spoolss_io_r_deleteprinterkey
,
2048 WERR_GENERAL_FAILURE
);