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 3 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, see <http://www.gnu.org/licenses/>.
26 #include "rpc_client.h"
28 /**********************************************************************
29 convencience wrapper around rpccli_spoolss_OpenPrinterEx
30 **********************************************************************/
32 WERROR
rpccli_spoolss_openprinter_ex(struct rpc_pipe_client
*cli
,
34 const char *printername
,
35 uint32_t access_desired
,
36 struct policy_handle
*handle
)
40 struct spoolss_DevmodeContainer devmode_ctr
;
41 union spoolss_UserLevel userlevel
;
42 struct spoolss_UserLevel1 level1
;
44 ZERO_STRUCT(devmode_ctr
);
47 level1
.client
= talloc_asprintf(mem_ctx
, "\\\\%s", global_myname());
48 W_ERROR_HAVE_NO_MEMORY(level1
.client
);
49 level1
.user
= cli
->auth
->user_name
;
55 userlevel
.level1
= &level1
;
57 status
= rpccli_spoolss_OpenPrinterEx(cli
, mem_ctx
,
67 if (!W_ERROR_IS_OK(werror
)) {
71 if (!NT_STATUS_IS_OK(status
)) {
72 return ntstatus_to_werror(status
);
78 /**********************************************************************
79 convencience wrapper around rpccli_spoolss_GetPrinterDriver2
80 **********************************************************************/
82 WERROR
rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client
*cli
,
84 struct policy_handle
*handle
,
85 const char *architecture
,
88 uint32_t client_major_version
,
89 uint32_t client_minor_version
,
90 union spoolss_DriverInfo
*info
,
91 uint32_t *server_major_version
,
92 uint32_t *server_minor_version
)
100 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
101 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
104 status
= rpccli_spoolss_GetPrinterDriver2(cli
, mem_ctx
,
108 (offered
> 0) ? &buffer
: NULL
,
110 client_major_version
,
111 client_minor_version
,
114 server_major_version
,
115 server_minor_version
,
117 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
119 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
120 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
122 status
= rpccli_spoolss_GetPrinterDriver2(cli
, mem_ctx
,
128 client_major_version
,
129 client_minor_version
,
132 server_major_version
,
133 server_minor_version
,
140 /**********************************************************************
141 convencience wrapper around rpccli_spoolss_AddPrinterEx
142 **********************************************************************/
144 WERROR
rpccli_spoolss_addprinterex(struct rpc_pipe_client
*cli
,
146 struct spoolss_SetPrinterInfoCtr
*info_ctr
)
150 struct spoolss_DevmodeContainer devmode_ctr
;
151 struct sec_desc_buf secdesc_ctr
;
152 struct spoolss_UserLevelCtr userlevel_ctr
;
153 struct spoolss_UserLevel1 level1
;
154 struct policy_handle handle
;
156 ZERO_STRUCT(devmode_ctr
);
157 ZERO_STRUCT(secdesc_ctr
);
163 level1
.processor
= 0;
164 level1
.client
= talloc_asprintf(mem_ctx
, "\\\\%s", global_myname());
165 W_ERROR_HAVE_NO_MEMORY(level1
.client
);
166 level1
.user
= cli
->auth
->user_name
;
168 userlevel_ctr
.level
= 1;
169 userlevel_ctr
.user_info
.level1
= &level1
;
171 status
= rpccli_spoolss_AddPrinterEx(cli
, mem_ctx
,
182 /**********************************************************************
183 convencience wrapper around rpccli_spoolss_GetPrinter
184 **********************************************************************/
186 WERROR
rpccli_spoolss_getprinter(struct rpc_pipe_client
*cli
,
188 struct policy_handle
*handle
,
191 union spoolss_PrinterInfo
*info
)
199 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
200 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
203 status
= rpccli_spoolss_GetPrinter(cli
, mem_ctx
,
206 (offered
> 0) ? &buffer
: NULL
,
212 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
215 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
216 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
218 status
= rpccli_spoolss_GetPrinter(cli
, mem_ctx
,
231 /*********************************************************************
232 Decode various spoolss rpc's and info levels
233 ********************************************************************/
235 /**********************************************************************
236 **********************************************************************/
238 static bool decode_printer_info_0(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
239 uint32 returned
, PRINTER_INFO_0
**info
)
245 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_0
, returned
);
249 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_0
));
254 prs_set_offset(&buffer
->prs
,0);
256 for (i
=0; i
<returned
; i
++) {
257 if (!smb_io_printer_info_0("", buffer
, &inf
[i
], 0)) {
266 /**********************************************************************
267 **********************************************************************/
269 static bool decode_printer_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
270 uint32 returned
, PRINTER_INFO_1
**info
)
276 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_1
, returned
);
280 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_1
));
285 prs_set_offset(&buffer
->prs
,0);
287 for (i
=0; i
<returned
; i
++) {
288 if (!smb_io_printer_info_1("", buffer
, &inf
[i
], 0)) {
297 /**********************************************************************
298 **********************************************************************/
300 static bool decode_printer_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
301 uint32 returned
, PRINTER_INFO_2
**info
)
307 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_2
, returned
);
311 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_2
));
316 prs_set_offset(&buffer
->prs
,0);
318 for (i
=0; i
<returned
; i
++) {
319 /* a little initialization as we go */
320 inf
[i
].secdesc
= NULL
;
321 if (!smb_io_printer_info_2("", buffer
, &inf
[i
], 0)) {
330 /**********************************************************************
331 **********************************************************************/
333 static bool decode_printer_info_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
334 uint32 returned
, PRINTER_INFO_3
**info
)
340 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_3
, returned
);
344 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_3
));
349 prs_set_offset(&buffer
->prs
,0);
351 for (i
=0; i
<returned
; i
++) {
352 inf
[i
].secdesc
= NULL
;
353 if (!smb_io_printer_info_3("", buffer
, &inf
[i
], 0)) {
362 /**********************************************************************
363 **********************************************************************/
365 static bool decode_printer_info_7(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
366 uint32 returned
, PRINTER_INFO_7
**info
)
372 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_7
, returned
);
376 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_7
));
381 prs_set_offset(&buffer
->prs
,0);
383 for (i
=0; i
<returned
; i
++) {
384 if (!smb_io_printer_info_7("", buffer
, &inf
[i
], 0)) {
394 /**********************************************************************
395 **********************************************************************/
397 static bool decode_port_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
398 uint32 returned
, PORT_INFO_1
**info
)
404 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_1
, returned
);
408 memset(inf
, 0, returned
*sizeof(PORT_INFO_1
));
413 prs_set_offset(&buffer
->prs
, 0);
415 for (i
=0; i
<returned
; i
++) {
416 if (!smb_io_port_info_1("", buffer
, &(inf
[i
]), 0)) {
425 /**********************************************************************
426 **********************************************************************/
428 static bool decode_port_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
429 uint32 returned
, PORT_INFO_2
**info
)
435 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_2
, returned
);
439 memset(inf
, 0, returned
*sizeof(PORT_INFO_2
));
444 prs_set_offset(&buffer
->prs
, 0);
446 for (i
=0; i
<returned
; i
++) {
447 if (!smb_io_port_info_2("", buffer
, &(inf
[i
]), 0)) {
456 /**********************************************************************
457 **********************************************************************/
459 static bool decode_printer_driver_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
460 uint32 returned
, DRIVER_INFO_1
**info
)
466 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_1
, returned
);
470 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_1
));
475 prs_set_offset(&buffer
->prs
,0);
477 for (i
=0; i
<returned
; i
++) {
478 if (!smb_io_printer_driver_info_1("", buffer
, &(inf
[i
]), 0)) {
487 /**********************************************************************
488 **********************************************************************/
490 static bool decode_printer_driver_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
491 uint32 returned
, DRIVER_INFO_2
**info
)
497 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_2
, returned
);
501 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_2
));
506 prs_set_offset(&buffer
->prs
,0);
508 for (i
=0; i
<returned
; i
++) {
509 if (!smb_io_printer_driver_info_2("", buffer
, &(inf
[i
]), 0)) {
518 /**********************************************************************
519 **********************************************************************/
521 static bool decode_printer_driver_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
522 uint32 returned
, DRIVER_INFO_3
**info
)
528 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_3
, returned
);
532 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_3
));
537 prs_set_offset(&buffer
->prs
,0);
539 for (i
=0; i
<returned
; i
++) {
540 if (!smb_io_printer_driver_info_3("", buffer
, &(inf
[i
]), 0)) {
549 /**********************************************************************
550 **********************************************************************/
552 static bool decode_jobs_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
553 uint32 num_jobs
, JOB_INFO_1
**jobs
)
558 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_1
, num_jobs
);
565 prs_set_offset(&buffer
->prs
,0);
567 for (i
= 0; i
< num_jobs
; i
++) {
568 if (!smb_io_job_info_1("", buffer
, &((*jobs
)[i
]), 0)) {
576 /**********************************************************************
577 **********************************************************************/
579 static bool decode_jobs_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
580 uint32 num_jobs
, JOB_INFO_2
**jobs
)
585 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_2
, num_jobs
);
592 prs_set_offset(&buffer
->prs
,0);
594 for (i
= 0; i
< num_jobs
; i
++) {
595 if (!smb_io_job_info_2("", buffer
, &((*jobs
)[i
]), 0)) {
603 /**********************************************************************
604 **********************************************************************/
606 static bool decode_forms_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
607 uint32 num_forms
, FORM_1
**forms
)
612 *forms
= TALLOC_ARRAY(mem_ctx
, FORM_1
, num_forms
);
613 if (*forms
== NULL
) {
620 prs_set_offset(&buffer
->prs
,0);
622 for (i
= 0; i
< num_forms
; i
++) {
623 if (!smb_io_form_1("", buffer
, &((*forms
)[i
]), 0)) {
631 /**********************************************************************
632 **********************************************************************/
634 WERROR
rpccli_spoolss_enum_printers(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
635 char *name
, uint32 flags
, uint32 level
,
636 uint32
*num_printers
, PRINTER_INFO_CTR
*ctr
)
638 prs_struct qbuf
, rbuf
;
639 SPOOL_Q_ENUMPRINTERS in
;
640 SPOOL_R_ENUMPRINTERS out
;
648 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
650 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
652 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERS
,
655 spoolss_io_q_enumprinters
,
656 spoolss_io_r_enumprinters
,
657 WERR_GENERAL_FAILURE
);
659 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
660 offered
= out
.needed
;
665 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
667 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
669 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERS
,
672 spoolss_io_q_enumprinters
,
673 spoolss_io_r_enumprinters
,
674 WERR_GENERAL_FAILURE
);
677 if ( !W_ERROR_IS_OK(out
.status
) )
682 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_0
)) {
683 return WERR_GENERAL_FAILURE
;
687 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_1
)) {
688 return WERR_GENERAL_FAILURE
;
692 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_2
)) {
693 return WERR_GENERAL_FAILURE
;
697 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_3
)) {
698 return WERR_GENERAL_FAILURE
;
702 return WERR_UNKNOWN_LEVEL
;
705 *num_printers
= out
.returned
;
710 /**********************************************************************
711 **********************************************************************/
713 WERROR
rpccli_spoolss_enum_ports(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
714 uint32 level
, uint32
*num_ports
, PORT_INFO_CTR
*ctr
)
716 prs_struct qbuf
, rbuf
;
717 SPOOL_Q_ENUMPORTS in
;
718 SPOOL_R_ENUMPORTS out
;
726 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
730 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
732 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
734 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPORTS
,
737 spoolss_io_q_enumports
,
738 spoolss_io_r_enumports
,
739 WERR_GENERAL_FAILURE
);
741 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
742 offered
= out
.needed
;
747 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
749 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
751 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPORTS
,
754 spoolss_io_q_enumports
,
755 spoolss_io_r_enumports
,
756 WERR_GENERAL_FAILURE
);
759 if ( !W_ERROR_IS_OK(out
.status
) )
764 if (!decode_port_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_1
)) {
765 return WERR_GENERAL_FAILURE
;
769 if (!decode_port_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_2
)) {
770 return WERR_GENERAL_FAILURE
;
774 return WERR_UNKNOWN_LEVEL
;
777 *num_ports
= out
.returned
;
782 /**********************************************************************
783 **********************************************************************/
785 WERROR
rpccli_spoolss_getprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
786 POLICY_HND
*pol
, uint32 level
,
787 PRINTER_INFO_CTR
*ctr
)
789 prs_struct qbuf
, rbuf
;
790 SPOOL_Q_GETPRINTER in
;
791 SPOOL_R_GETPRINTER out
;
798 /* Initialise input parameters */
801 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
803 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
805 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTER
,
808 spoolss_io_q_getprinter
,
809 spoolss_io_r_getprinter
,
810 WERR_GENERAL_FAILURE
);
812 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
813 offered
= out
.needed
;
818 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
820 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
822 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTER
,
825 spoolss_io_q_getprinter
,
826 spoolss_io_r_getprinter
,
827 WERR_GENERAL_FAILURE
);
830 if ( !W_ERROR_IS_OK(out
.status
) )
835 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, 1, &ctr
->printers_0
)) {
836 return WERR_GENERAL_FAILURE
;
840 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, 1, &ctr
->printers_1
)) {
841 return WERR_GENERAL_FAILURE
;
845 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, 1, &ctr
->printers_2
)) {
846 return WERR_GENERAL_FAILURE
;
850 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, 1, &ctr
->printers_3
)) {
851 return WERR_GENERAL_FAILURE
;
855 if (!decode_printer_info_7(mem_ctx
, out
.buffer
, 1, &ctr
->printers_7
)) {
856 return WERR_GENERAL_FAILURE
;
860 return WERR_UNKNOWN_LEVEL
;
866 /**********************************************************************
867 **********************************************************************/
869 WERROR
rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client
*cli
,
871 uint32 level
, const char *env
,
873 PRINTER_DRIVER_CTR
*ctr
)
875 prs_struct qbuf
, rbuf
;
876 SPOOL_Q_ENUMPRINTERDRIVERS in
;
877 SPOOL_R_ENUMPRINTERDRIVERS out
;
885 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
889 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
891 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
894 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDRIVERS
,
897 spoolss_io_q_enumprinterdrivers
,
898 spoolss_io_r_enumprinterdrivers
,
899 WERR_GENERAL_FAILURE
);
901 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
902 offered
= out
.needed
;
907 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
909 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
912 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDRIVERS
,
915 spoolss_io_q_enumprinterdrivers
,
916 spoolss_io_r_enumprinterdrivers
,
917 WERR_GENERAL_FAILURE
);
920 *num_drivers
= out
.returned
;
922 if ( !W_ERROR_IS_OK(out
.status
) )
925 if ( out
.returned
) {
929 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info1
)) {
930 return WERR_GENERAL_FAILURE
;
934 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info2
)) {
935 return WERR_GENERAL_FAILURE
;
939 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info3
)) {
940 return WERR_GENERAL_FAILURE
;
944 return WERR_UNKNOWN_LEVEL
;
951 /**********************************************************************
952 **********************************************************************/
954 WERROR
rpccli_spoolss_enumforms(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
955 POLICY_HND
*handle
, int level
, uint32
*num_forms
,
958 prs_struct qbuf
, rbuf
;
959 SPOOL_Q_ENUMFORMS in
;
960 SPOOL_R_ENUMFORMS out
;
968 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
970 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
972 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMFORMS
,
975 spoolss_io_q_enumforms
,
976 spoolss_io_r_enumforms
,
977 WERR_GENERAL_FAILURE
);
979 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
980 offered
= out
.needed
;
985 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
987 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
989 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMFORMS
,
992 spoolss_io_q_enumforms
,
993 spoolss_io_r_enumforms
,
994 WERR_GENERAL_FAILURE
);
997 if (!W_ERROR_IS_OK(out
.status
))
1000 *num_forms
= out
.numofforms
;
1002 if (!decode_forms_1(mem_ctx
, out
.buffer
, *num_forms
, forms
)) {
1003 return WERR_GENERAL_FAILURE
;
1009 /**********************************************************************
1010 **********************************************************************/
1012 WERROR
rpccli_spoolss_enumjobs(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1013 POLICY_HND
*hnd
, uint32 level
, uint32 firstjob
,
1014 uint32 num_jobs
, uint32
*returned
, JOB_INFO_CTR
*ctr
)
1016 prs_struct qbuf
, rbuf
;
1017 SPOOL_Q_ENUMJOBS in
;
1018 SPOOL_R_ENUMJOBS out
;
1026 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1028 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1031 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMJOBS
,
1034 spoolss_io_q_enumjobs
,
1035 spoolss_io_r_enumjobs
,
1036 WERR_GENERAL_FAILURE
);
1038 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1039 offered
= out
.needed
;
1044 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1046 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1049 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMJOBS
,
1052 spoolss_io_q_enumjobs
,
1053 spoolss_io_r_enumjobs
,
1054 WERR_GENERAL_FAILURE
);
1057 if (!W_ERROR_IS_OK(out
.status
))
1062 if (!decode_jobs_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_1
)) {
1063 return WERR_GENERAL_FAILURE
;
1067 if (!decode_jobs_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_2
)) {
1068 return WERR_GENERAL_FAILURE
;
1072 DEBUG(3, ("unsupported info level %d", level
));
1073 return WERR_UNKNOWN_LEVEL
;
1076 *returned
= out
.returned
;
1081 /**********************************************************************
1082 **********************************************************************/
1084 WERROR
rpccli_spoolss_getjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1085 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1088 prs_struct qbuf
, rbuf
;
1098 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1100 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1102 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETJOB
,
1105 spoolss_io_q_getjob
,
1106 spoolss_io_r_getjob
,
1107 WERR_GENERAL_FAILURE
);
1109 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1110 offered
= out
.needed
;
1115 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1117 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1119 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETJOB
,
1122 spoolss_io_q_getjob
,
1123 spoolss_io_r_getjob
,
1124 WERR_GENERAL_FAILURE
);
1127 if (!W_ERROR_IS_OK(out
.status
))
1132 if (!decode_jobs_1(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_1
)) {
1133 return WERR_GENERAL_FAILURE
;
1137 if (!decode_jobs_2(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_2
)) {
1138 return WERR_GENERAL_FAILURE
;
1142 return WERR_UNKNOWN_LEVEL
;
1148 /**********************************************************************
1149 **********************************************************************/
1151 WERROR
rpccli_spoolss_getprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1152 POLICY_HND
*hnd
, const char *valuename
,
1153 REGISTRY_VALUE
*value
)
1155 prs_struct qbuf
, rbuf
;
1156 SPOOL_Q_GETPRINTERDATA in
;
1157 SPOOL_R_GETPRINTERDATA out
;
1164 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1166 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDATA
,
1169 spoolss_io_q_getprinterdata
,
1170 spoolss_io_r_getprinterdata
,
1171 WERR_GENERAL_FAILURE
);
1173 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1174 offered
= out
.needed
;
1179 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1181 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDATA
,
1184 spoolss_io_q_getprinterdata
,
1185 spoolss_io_r_getprinterdata
,
1186 WERR_GENERAL_FAILURE
);
1189 if (!W_ERROR_IS_OK(out
.status
))
1192 /* Return output parameters */
1195 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1197 value
->data_p
= NULL
;
1199 value
->type
= out
.type
;
1200 value
->size
= out
.size
;
1205 /**********************************************************************
1206 **********************************************************************/
1208 WERROR
rpccli_spoolss_setprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1209 POLICY_HND
*hnd
, REGISTRY_VALUE
*value
)
1211 prs_struct qbuf
, rbuf
;
1212 SPOOL_Q_SETPRINTERDATA in
;
1213 SPOOL_R_SETPRINTERDATA out
;
1218 make_spoolss_q_setprinterdata( &in
, hnd
, value
->valuename
,
1219 value
->type
, (char *)value
->data_p
, value
->size
);
1221 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_SETPRINTERDATA
,
1224 spoolss_io_q_setprinterdata
,
1225 spoolss_io_r_setprinterdata
,
1226 WERR_GENERAL_FAILURE
);
1231 /**********************************************************************
1232 **********************************************************************/
1234 WERROR
rpccli_spoolss_enumprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1235 POLICY_HND
*hnd
, uint32 ndx
,
1236 uint32 value_offered
, uint32 data_offered
,
1237 uint32
*value_needed
, uint32
*data_needed
,
1238 REGISTRY_VALUE
*value
)
1240 prs_struct qbuf
, rbuf
;
1241 SPOOL_Q_ENUMPRINTERDATA in
;
1242 SPOOL_R_ENUMPRINTERDATA out
;
1247 make_spoolss_q_enumprinterdata( &in
, hnd
, ndx
, value_offered
, data_offered
);
1249 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDATA
,
1252 spoolss_io_q_enumprinterdata
,
1253 spoolss_io_r_enumprinterdata
,
1254 WERR_GENERAL_FAILURE
);
1257 *value_needed
= out
.realvaluesize
;
1259 *data_needed
= out
.realdatasize
;
1261 if (!W_ERROR_IS_OK(out
.status
))
1265 rpcstr_pull(value
->valuename
, out
.value
, sizeof(value
->valuename
), -1,
1267 if (out
.realdatasize
) {
1268 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
,
1271 value
->data_p
= NULL
;
1273 value
->type
= out
.type
;
1274 value
->size
= out
.realdatasize
;
1280 /**********************************************************************
1281 **********************************************************************/
1283 WERROR
rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1284 POLICY_HND
*hnd
, const char *keyname
,
1287 prs_struct qbuf
, rbuf
;
1288 SPOOL_Q_ENUMPRINTERDATAEX in
;
1289 SPOOL_R_ENUMPRINTERDATAEX out
;
1297 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1299 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDATAEX
,
1302 spoolss_io_q_enumprinterdataex
,
1303 spoolss_io_r_enumprinterdataex
,
1304 WERR_GENERAL_FAILURE
);
1306 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1307 offered
= out
.needed
;
1312 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1314 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDATAEX
,
1317 spoolss_io_q_enumprinterdataex
,
1318 spoolss_io_r_enumprinterdataex
,
1319 WERR_GENERAL_FAILURE
);
1322 if (!W_ERROR_IS_OK(out
.status
))
1325 for (i
= 0; i
< out
.returned
; i
++) {
1326 PRINTER_ENUM_VALUES
*v
= &out
.ctr
.values
[i
];
1329 rpcstr_pull(name
, v
->valuename
.buffer
, sizeof(name
), -1,
1331 regval_ctr_addvalue(ctr
, name
, v
->type
, (const char *)v
->data
, v
->data_len
);
1337 /**********************************************************************
1338 **********************************************************************/
1340 WERROR
rpccli_spoolss_enumprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1341 POLICY_HND
*hnd
, const char *keyname
,
1342 uint16
**keylist
, uint32
*len
)
1344 prs_struct qbuf
, rbuf
;
1345 SPOOL_Q_ENUMPRINTERKEY in
;
1346 SPOOL_R_ENUMPRINTERKEY out
;
1352 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
1354 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERKEY
,
1357 spoolss_io_q_enumprinterkey
,
1358 spoolss_io_r_enumprinterkey
,
1359 WERR_GENERAL_FAILURE
);
1361 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1362 offered
= out
.needed
;
1367 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
1369 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERKEY
,
1372 spoolss_io_q_enumprinterkey
,
1373 spoolss_io_r_enumprinterkey
,
1374 WERR_GENERAL_FAILURE
);
1377 if ( !W_ERROR_IS_OK(out
.status
) )
1381 *keylist
= SMB_MALLOC_ARRAY(uint16
, out
.keys
.buf_len
);
1385 memcpy(*keylist
, out
.keys
.buffer
, out
.keys
.buf_len
* 2);
1387 *len
= out
.keys
.buf_len
* 2;