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 Decode various spoolss rpc's and info levels
30 ********************************************************************/
32 /**********************************************************************
33 **********************************************************************/
35 static bool decode_printer_info_0(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
36 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
));
51 prs_set_offset(&buffer
->prs
,0);
53 for (i
=0; i
<returned
; i
++) {
54 if (!smb_io_printer_info_0("", buffer
, &inf
[i
], 0)) {
63 /**********************************************************************
64 **********************************************************************/
66 static bool decode_printer_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
67 uint32 returned
, PRINTER_INFO_1
**info
)
73 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_1
, returned
);
77 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_1
));
82 prs_set_offset(&buffer
->prs
,0);
84 for (i
=0; i
<returned
; i
++) {
85 if (!smb_io_printer_info_1("", buffer
, &inf
[i
], 0)) {
94 /**********************************************************************
95 **********************************************************************/
97 static bool decode_printer_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
98 uint32 returned
, PRINTER_INFO_2
**info
)
104 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_2
, returned
);
108 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_2
));
113 prs_set_offset(&buffer
->prs
,0);
115 for (i
=0; i
<returned
; i
++) {
116 /* a little initialization as we go */
117 inf
[i
].secdesc
= NULL
;
118 if (!smb_io_printer_info_2("", buffer
, &inf
[i
], 0)) {
127 /**********************************************************************
128 **********************************************************************/
130 static bool decode_printer_info_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
131 uint32 returned
, PRINTER_INFO_3
**info
)
137 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_3
, returned
);
141 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_3
));
146 prs_set_offset(&buffer
->prs
,0);
148 for (i
=0; i
<returned
; i
++) {
149 inf
[i
].secdesc
= NULL
;
150 if (!smb_io_printer_info_3("", buffer
, &inf
[i
], 0)) {
159 /**********************************************************************
160 **********************************************************************/
162 static bool decode_printer_info_7(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
163 uint32 returned
, PRINTER_INFO_7
**info
)
169 inf
=TALLOC_ARRAY(mem_ctx
, PRINTER_INFO_7
, returned
);
173 memset(inf
, 0, returned
*sizeof(PRINTER_INFO_7
));
178 prs_set_offset(&buffer
->prs
,0);
180 for (i
=0; i
<returned
; i
++) {
181 if (!smb_io_printer_info_7("", buffer
, &inf
[i
], 0)) {
191 /**********************************************************************
192 **********************************************************************/
194 static bool decode_port_info_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
195 uint32 returned
, PORT_INFO_1
**info
)
201 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_1
, returned
);
205 memset(inf
, 0, returned
*sizeof(PORT_INFO_1
));
210 prs_set_offset(&buffer
->prs
, 0);
212 for (i
=0; i
<returned
; i
++) {
213 if (!smb_io_port_info_1("", buffer
, &(inf
[i
]), 0)) {
222 /**********************************************************************
223 **********************************************************************/
225 static bool decode_port_info_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
226 uint32 returned
, PORT_INFO_2
**info
)
232 inf
=TALLOC_ARRAY(mem_ctx
, PORT_INFO_2
, returned
);
236 memset(inf
, 0, returned
*sizeof(PORT_INFO_2
));
241 prs_set_offset(&buffer
->prs
, 0);
243 for (i
=0; i
<returned
; i
++) {
244 if (!smb_io_port_info_2("", buffer
, &(inf
[i
]), 0)) {
253 /**********************************************************************
254 **********************************************************************/
256 static bool decode_printer_driver_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
257 uint32 returned
, DRIVER_INFO_1
**info
)
263 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_1
, returned
);
267 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_1
));
272 prs_set_offset(&buffer
->prs
,0);
274 for (i
=0; i
<returned
; i
++) {
275 if (!smb_io_printer_driver_info_1("", buffer
, &(inf
[i
]), 0)) {
284 /**********************************************************************
285 **********************************************************************/
287 static bool decode_printer_driver_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
288 uint32 returned
, DRIVER_INFO_2
**info
)
294 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_2
, returned
);
298 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_2
));
303 prs_set_offset(&buffer
->prs
,0);
305 for (i
=0; i
<returned
; i
++) {
306 if (!smb_io_printer_driver_info_2("", buffer
, &(inf
[i
]), 0)) {
315 /**********************************************************************
316 **********************************************************************/
318 static bool decode_printer_driver_3(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
319 uint32 returned
, DRIVER_INFO_3
**info
)
325 inf
=TALLOC_ARRAY(mem_ctx
, DRIVER_INFO_3
, returned
);
329 memset(inf
, 0, returned
*sizeof(DRIVER_INFO_3
));
334 prs_set_offset(&buffer
->prs
,0);
336 for (i
=0; i
<returned
; i
++) {
337 if (!smb_io_printer_driver_info_3("", buffer
, &(inf
[i
]), 0)) {
346 /**********************************************************************
347 **********************************************************************/
349 static bool decode_printerdriverdir_1 (TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
350 uint32 returned
, DRIVER_DIRECTORY_1
**info
353 DRIVER_DIRECTORY_1
*inf
;
355 inf
=TALLOC_P(mem_ctx
, DRIVER_DIRECTORY_1
);
359 memset(inf
, 0, sizeof(DRIVER_DIRECTORY_1
));
361 prs_set_offset(&buffer
->prs
, 0);
363 if (!smb_io_driverdir_1("", buffer
, inf
, 0)) {
371 /**********************************************************************
372 **********************************************************************/
374 static bool decode_jobs_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
375 uint32 num_jobs
, JOB_INFO_1
**jobs
)
380 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_1
, num_jobs
);
387 prs_set_offset(&buffer
->prs
,0);
389 for (i
= 0; i
< num_jobs
; i
++) {
390 if (!smb_io_job_info_1("", buffer
, &((*jobs
)[i
]), 0)) {
398 /**********************************************************************
399 **********************************************************************/
401 static bool decode_jobs_2(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
402 uint32 num_jobs
, JOB_INFO_2
**jobs
)
407 *jobs
= TALLOC_ARRAY(mem_ctx
, JOB_INFO_2
, num_jobs
);
414 prs_set_offset(&buffer
->prs
,0);
416 for (i
= 0; i
< num_jobs
; i
++) {
417 if (!smb_io_job_info_2("", buffer
, &((*jobs
)[i
]), 0)) {
425 /**********************************************************************
426 **********************************************************************/
428 static bool decode_forms_1(TALLOC_CTX
*mem_ctx
, RPC_BUFFER
*buffer
,
429 uint32 num_forms
, FORM_1
**forms
)
434 *forms
= TALLOC_ARRAY(mem_ctx
, FORM_1
, num_forms
);
435 if (*forms
== NULL
) {
442 prs_set_offset(&buffer
->prs
,0);
444 for (i
= 0; i
< num_forms
; i
++) {
445 if (!smb_io_form_1("", buffer
, &((*forms
)[i
]), 0)) {
453 /**********************************************************************
454 **********************************************************************/
456 WERROR
rpccli_spoolss_open_printer_ex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
457 const char *printername
, const char *datatype
, uint32 access_required
,
458 const char *station
, const char *username
, POLICY_HND
*pol
)
460 prs_struct qbuf
, rbuf
;
461 SPOOL_Q_OPEN_PRINTER_EX in
;
462 SPOOL_R_OPEN_PRINTER_EX out
;
467 make_spoolss_q_open_printer_ex( &in
, printername
, datatype
,
468 access_required
, station
, username
);
470 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_OPENPRINTEREX
,
473 spoolss_io_q_open_printer_ex
,
474 spoolss_io_r_open_printer_ex
,
475 WERR_GENERAL_FAILURE
);
477 memcpy( pol
, &out
.handle
, sizeof(POLICY_HND
) );
482 /**********************************************************************
483 **********************************************************************/
485 WERROR
rpccli_spoolss_close_printer(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
488 prs_struct qbuf
, rbuf
;
489 SPOOL_Q_CLOSEPRINTER in
;
490 SPOOL_R_CLOSEPRINTER out
;
495 make_spoolss_q_closeprinter( &in
, pol
);
497 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_CLOSEPRINTER
,
500 spoolss_io_q_closeprinter
,
501 spoolss_io_r_closeprinter
,
502 WERR_GENERAL_FAILURE
);
507 /**********************************************************************
508 **********************************************************************/
510 WERROR
rpccli_spoolss_enum_printers(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
511 char *name
, uint32 flags
, uint32 level
,
512 uint32
*num_printers
, PRINTER_INFO_CTR
*ctr
)
514 prs_struct qbuf
, rbuf
;
515 SPOOL_Q_ENUMPRINTERS in
;
516 SPOOL_R_ENUMPRINTERS out
;
524 rpcbuf_init(&buffer
, offered
, mem_ctx
);
525 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
527 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERS
,
530 spoolss_io_q_enumprinters
,
531 spoolss_io_r_enumprinters
,
532 WERR_GENERAL_FAILURE
);
534 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
535 offered
= out
.needed
;
540 rpcbuf_init(&buffer
, offered
, mem_ctx
);
541 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
543 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERS
,
546 spoolss_io_q_enumprinters
,
547 spoolss_io_r_enumprinters
,
548 WERR_GENERAL_FAILURE
);
551 if ( !W_ERROR_IS_OK(out
.status
) )
556 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_0
)) {
557 return WERR_GENERAL_FAILURE
;
561 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_1
)) {
562 return WERR_GENERAL_FAILURE
;
566 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_2
)) {
567 return WERR_GENERAL_FAILURE
;
571 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_3
)) {
572 return WERR_GENERAL_FAILURE
;
576 return WERR_UNKNOWN_LEVEL
;
579 *num_printers
= out
.returned
;
584 /**********************************************************************
585 **********************************************************************/
587 WERROR
rpccli_spoolss_enum_ports(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
588 uint32 level
, uint32
*num_ports
, PORT_INFO_CTR
*ctr
)
590 prs_struct qbuf
, rbuf
;
591 SPOOL_Q_ENUMPORTS in
;
592 SPOOL_R_ENUMPORTS out
;
600 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
604 rpcbuf_init(&buffer
, offered
, mem_ctx
);
605 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
607 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPORTS
,
610 spoolss_io_q_enumports
,
611 spoolss_io_r_enumports
,
612 WERR_GENERAL_FAILURE
);
614 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
615 offered
= out
.needed
;
620 rpcbuf_init(&buffer
, offered
, mem_ctx
);
621 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
623 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPORTS
,
626 spoolss_io_q_enumports
,
627 spoolss_io_r_enumports
,
628 WERR_GENERAL_FAILURE
);
631 if ( !W_ERROR_IS_OK(out
.status
) )
636 if (!decode_port_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_1
)) {
637 return WERR_GENERAL_FAILURE
;
641 if (!decode_port_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_2
)) {
642 return WERR_GENERAL_FAILURE
;
646 return WERR_UNKNOWN_LEVEL
;
649 *num_ports
= out
.returned
;
654 /**********************************************************************
655 **********************************************************************/
657 WERROR
rpccli_spoolss_getprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
658 POLICY_HND
*pol
, uint32 level
,
659 PRINTER_INFO_CTR
*ctr
)
661 prs_struct qbuf
, rbuf
;
662 SPOOL_Q_GETPRINTER in
;
663 SPOOL_R_GETPRINTER out
;
670 /* Initialise input parameters */
673 rpcbuf_init(&buffer
, offered
, mem_ctx
);
674 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
676 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTER
,
679 spoolss_io_q_getprinter
,
680 spoolss_io_r_getprinter
,
681 WERR_GENERAL_FAILURE
);
683 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
684 offered
= out
.needed
;
689 rpcbuf_init(&buffer
, offered
, mem_ctx
);
690 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
692 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTER
,
695 spoolss_io_q_getprinter
,
696 spoolss_io_r_getprinter
,
697 WERR_GENERAL_FAILURE
);
700 if ( !W_ERROR_IS_OK(out
.status
) )
705 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, 1, &ctr
->printers_0
)) {
706 return WERR_GENERAL_FAILURE
;
710 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, 1, &ctr
->printers_1
)) {
711 return WERR_GENERAL_FAILURE
;
715 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, 1, &ctr
->printers_2
)) {
716 return WERR_GENERAL_FAILURE
;
720 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, 1, &ctr
->printers_3
)) {
721 return WERR_GENERAL_FAILURE
;
725 if (!decode_printer_info_7(mem_ctx
, out
.buffer
, 1, &ctr
->printers_7
)) {
726 return WERR_GENERAL_FAILURE
;
730 return WERR_UNKNOWN_LEVEL
;
736 /**********************************************************************
737 **********************************************************************/
739 WERROR
rpccli_spoolss_setprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
740 POLICY_HND
*pol
, uint32 level
,
741 PRINTER_INFO_CTR
*ctr
, uint32 command
)
743 prs_struct qbuf
, rbuf
;
744 SPOOL_Q_SETPRINTER in
;
745 SPOOL_R_SETPRINTER out
;
750 make_spoolss_q_setprinter( mem_ctx
, &in
, pol
, level
, ctr
, command
);
752 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTER
,
755 spoolss_io_q_setprinter
,
756 spoolss_io_r_setprinter
,
757 WERR_GENERAL_FAILURE
);
762 /**********************************************************************
763 **********************************************************************/
765 WERROR
rpccli_spoolss_getprinterdriver(struct rpc_pipe_client
*cli
,
767 POLICY_HND
*pol
, uint32 level
,
768 const char *env
, int version
, PRINTER_DRIVER_CTR
*ctr
)
770 prs_struct qbuf
, rbuf
;
771 SPOOL_Q_GETPRINTERDRIVER2 in
;
772 SPOOL_R_GETPRINTERDRIVER2 out
;
780 fstrcpy(server
, cli
->desthost
);
784 rpcbuf_init(&buffer
, offered
, mem_ctx
);
785 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
786 version
, 2, &buffer
, offered
);
788 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVER2
,
791 spoolss_io_q_getprinterdriver2
,
792 spoolss_io_r_getprinterdriver2
,
793 WERR_GENERAL_FAILURE
);
795 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
796 offered
= out
.needed
;
801 rpcbuf_init(&buffer
, offered
, mem_ctx
);
802 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
803 version
, 2, &buffer
, offered
);
805 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVER2
,
808 spoolss_io_q_getprinterdriver2
,
809 spoolss_io_r_getprinterdriver2
,
810 WERR_GENERAL_FAILURE
);
813 if ( !W_ERROR_IS_OK(out
.status
) )
818 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
819 return WERR_GENERAL_FAILURE
;
823 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, 1, &ctr
->info2
)) {
824 return WERR_GENERAL_FAILURE
;
828 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, 1, &ctr
->info3
)) {
829 return WERR_GENERAL_FAILURE
;
833 return WERR_UNKNOWN_LEVEL
;
839 /**********************************************************************
840 **********************************************************************/
842 WERROR
rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client
*cli
,
844 uint32 level
, const char *env
,
846 PRINTER_DRIVER_CTR
*ctr
)
848 prs_struct qbuf
, rbuf
;
849 SPOOL_Q_ENUMPRINTERDRIVERS in
;
850 SPOOL_R_ENUMPRINTERDRIVERS out
;
858 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
862 rpcbuf_init(&buffer
, offered
, mem_ctx
);
863 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
866 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDRIVERS
,
869 spoolss_io_q_enumprinterdrivers
,
870 spoolss_io_r_enumprinterdrivers
,
871 WERR_GENERAL_FAILURE
);
873 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
874 offered
= out
.needed
;
879 rpcbuf_init(&buffer
, offered
, mem_ctx
);
880 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
883 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDRIVERS
,
886 spoolss_io_q_enumprinterdrivers
,
887 spoolss_io_r_enumprinterdrivers
,
888 WERR_GENERAL_FAILURE
);
891 *num_drivers
= out
.returned
;
893 if ( !W_ERROR_IS_OK(out
.status
) )
896 if ( out
.returned
) {
900 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info1
)) {
901 return WERR_GENERAL_FAILURE
;
905 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info2
)) {
906 return WERR_GENERAL_FAILURE
;
910 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info3
)) {
911 return WERR_GENERAL_FAILURE
;
915 return WERR_UNKNOWN_LEVEL
;
923 /**********************************************************************
924 **********************************************************************/
926 WERROR
rpccli_spoolss_getprinterdriverdir (struct rpc_pipe_client
*cli
,
928 uint32 level
, char *env
,
929 DRIVER_DIRECTORY_CTR
*ctr
)
931 prs_struct qbuf
, rbuf
;
932 SPOOL_Q_GETPRINTERDRIVERDIR in
;
933 SPOOL_R_GETPRINTERDRIVERDIR out
;
941 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
945 rpcbuf_init(&buffer
, offered
, mem_ctx
);
946 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
949 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
952 spoolss_io_q_getprinterdriverdir
,
953 spoolss_io_r_getprinterdriverdir
,
954 WERR_GENERAL_FAILURE
);
956 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
957 offered
= out
.needed
;
962 rpcbuf_init(&buffer
, offered
, mem_ctx
);
963 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
966 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
969 spoolss_io_q_getprinterdriverdir
,
970 spoolss_io_r_getprinterdriverdir
,
971 WERR_GENERAL_FAILURE
);
974 if (!W_ERROR_IS_OK(out
.status
))
977 if (!decode_printerdriverdir_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
978 return WERR_GENERAL_FAILURE
;
984 /**********************************************************************
985 **********************************************************************/
987 WERROR
rpccli_spoolss_addprinterdriver (struct rpc_pipe_client
*cli
,
988 TALLOC_CTX
*mem_ctx
, uint32 level
,
989 PRINTER_DRIVER_CTR
*ctr
)
991 prs_struct qbuf
, rbuf
;
992 SPOOL_Q_ADDPRINTERDRIVER in
;
993 SPOOL_R_ADDPRINTERDRIVER out
;
999 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1002 make_spoolss_q_addprinterdriver( mem_ctx
, &in
, server
, level
, ctr
);
1004 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDPRINTERDRIVER
,
1007 spoolss_io_q_addprinterdriver
,
1008 spoolss_io_r_addprinterdriver
,
1009 WERR_GENERAL_FAILURE
);
1014 /**********************************************************************
1015 **********************************************************************/
1017 WERROR
rpccli_spoolss_addprinterex (struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1018 uint32 level
, PRINTER_INFO_CTR
*ctr
)
1020 prs_struct qbuf
, rbuf
;
1021 SPOOL_Q_ADDPRINTEREX in
;
1022 SPOOL_R_ADDPRINTEREX out
;
1023 fstring server
, client
, user
;
1028 slprintf(client
, sizeof(fstring
)-1, "\\\\%s", global_myname());
1029 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1034 fstrcpy (user
, cli
->auth
->user_name
);
1036 make_spoolss_q_addprinterex( mem_ctx
, &in
, server
, client
,
1039 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDPRINTEREX
,
1042 spoolss_io_q_addprinterex
,
1043 spoolss_io_r_addprinterex
,
1044 WERR_GENERAL_FAILURE
);
1049 /**********************************************************************
1050 **********************************************************************/
1052 WERROR
rpccli_spoolss_deleteprinterdriverex(struct rpc_pipe_client
*cli
,
1053 TALLOC_CTX
*mem_ctx
, const char *arch
,
1054 const char *driver
, int version
)
1056 prs_struct qbuf
, rbuf
;
1057 SPOOL_Q_DELETEPRINTERDRIVEREX in
;
1058 SPOOL_R_DELETEPRINTERDRIVEREX out
;
1064 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1067 make_spoolss_q_deleteprinterdriverex( mem_ctx
, &in
, server
, arch
, driver
, version
);
1069 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDRIVEREX
,
1072 spoolss_io_q_deleteprinterdriverex
,
1073 spoolss_io_r_deleteprinterdriverex
,
1074 WERR_GENERAL_FAILURE
);
1079 /**********************************************************************
1080 **********************************************************************/
1082 WERROR
rpccli_spoolss_deleteprinterdriver (struct rpc_pipe_client
*cli
,
1083 TALLOC_CTX
*mem_ctx
, const char *arch
,
1086 prs_struct qbuf
, rbuf
;
1087 SPOOL_Q_DELETEPRINTERDRIVER in
;
1088 SPOOL_R_DELETEPRINTERDRIVER out
;
1094 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1097 make_spoolss_q_deleteprinterdriver( mem_ctx
, &in
, server
, arch
, driver
);
1099 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDRIVER
,
1102 spoolss_io_q_deleteprinterdriver
,
1103 spoolss_io_r_deleteprinterdriver
,
1104 WERR_GENERAL_FAILURE
);
1109 /**********************************************************************
1110 **********************************************************************/
1112 WERROR
rpccli_spoolss_getprintprocessordirectory(struct rpc_pipe_client
*cli
,
1113 TALLOC_CTX
*mem_ctx
,
1114 char *name
, char *environment
,
1117 prs_struct qbuf
, rbuf
;
1118 SPOOL_Q_GETPRINTPROCESSORDIRECTORY in
;
1119 SPOOL_R_GETPRINTPROCESSORDIRECTORY out
;
1128 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1129 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1130 environment
, level
, &buffer
, offered
);
1132 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1135 spoolss_io_q_getprintprocessordirectory
,
1136 spoolss_io_r_getprintprocessordirectory
,
1137 WERR_GENERAL_FAILURE
);
1139 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1140 offered
= out
.needed
;
1145 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1146 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1147 environment
, level
, &buffer
, offered
);
1149 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1152 spoolss_io_q_getprintprocessordirectory
,
1153 spoolss_io_r_getprintprocessordirectory
,
1154 WERR_GENERAL_FAILURE
);
1157 if ( !W_ERROR_IS_OK(out
.status
) )
1160 fstrcpy(procdir
, "Not implemented!");
1165 /**********************************************************************
1166 **********************************************************************/
1168 WERROR
rpccli_spoolss_addform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1169 POLICY_HND
*handle
, uint32 level
, FORM
*form
)
1171 prs_struct qbuf
, rbuf
;
1173 SPOOL_R_ADDFORM out
;
1178 make_spoolss_q_addform( &in
, handle
, level
, form
);
1180 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ADDFORM
,
1183 spoolss_io_q_addform
,
1184 spoolss_io_r_addform
,
1185 WERR_GENERAL_FAILURE
);
1190 /**********************************************************************
1191 **********************************************************************/
1193 WERROR
rpccli_spoolss_setform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1194 POLICY_HND
*handle
, uint32 level
,
1195 const char *form_name
, FORM
*form
)
1197 prs_struct qbuf
, rbuf
;
1199 SPOOL_R_SETFORM out
;
1204 make_spoolss_q_setform( &in
, handle
, level
, form_name
, form
);
1206 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETFORM
,
1209 spoolss_io_q_setform
,
1210 spoolss_io_r_setform
,
1211 WERR_GENERAL_FAILURE
);
1216 /**********************************************************************
1217 **********************************************************************/
1219 WERROR
rpccli_spoolss_getform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1220 POLICY_HND
*handle
, const char *formname
,
1221 uint32 level
, FORM_1
*form
)
1223 prs_struct qbuf
, rbuf
;
1225 SPOOL_R_GETFORM out
;
1233 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1234 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1236 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETFORM
,
1239 spoolss_io_q_getform
,
1240 spoolss_io_r_getform
,
1241 WERR_GENERAL_FAILURE
);
1243 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1244 offered
= out
.needed
;
1249 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1250 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1252 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETFORM
,
1255 spoolss_io_q_getform
,
1256 spoolss_io_r_getform
,
1257 WERR_GENERAL_FAILURE
);
1260 if (!W_ERROR_IS_OK(out
.status
))
1263 if (!smb_io_form_1("", out
.buffer
, form
, 0)) {
1264 return WERR_GENERAL_FAILURE
;
1270 /**********************************************************************
1271 **********************************************************************/
1273 WERROR
rpccli_spoolss_deleteform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1274 POLICY_HND
*handle
, const char *form_name
)
1276 prs_struct qbuf
, rbuf
;
1277 SPOOL_Q_DELETEFORM in
;
1278 SPOOL_R_DELETEFORM out
;
1283 make_spoolss_q_deleteform( &in
, handle
, form_name
);
1285 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEFORM
,
1288 spoolss_io_q_deleteform
,
1289 spoolss_io_r_deleteform
,
1290 WERR_GENERAL_FAILURE
);
1295 /**********************************************************************
1296 **********************************************************************/
1298 WERROR
rpccli_spoolss_enumforms(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1299 POLICY_HND
*handle
, int level
, uint32
*num_forms
,
1302 prs_struct qbuf
, rbuf
;
1303 SPOOL_Q_ENUMFORMS in
;
1304 SPOOL_R_ENUMFORMS out
;
1312 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1313 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1315 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMFORMS
,
1318 spoolss_io_q_enumforms
,
1319 spoolss_io_r_enumforms
,
1320 WERR_GENERAL_FAILURE
);
1322 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1323 offered
= out
.needed
;
1328 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1329 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1331 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMFORMS
,
1334 spoolss_io_q_enumforms
,
1335 spoolss_io_r_enumforms
,
1336 WERR_GENERAL_FAILURE
);
1339 if (!W_ERROR_IS_OK(out
.status
))
1342 *num_forms
= out
.numofforms
;
1344 if (!decode_forms_1(mem_ctx
, out
.buffer
, *num_forms
, forms
)) {
1345 return WERR_GENERAL_FAILURE
;
1351 /**********************************************************************
1352 **********************************************************************/
1354 WERROR
rpccli_spoolss_enumjobs(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1355 POLICY_HND
*hnd
, uint32 level
, uint32 firstjob
,
1356 uint32 num_jobs
, uint32
*returned
, JOB_INFO_CTR
*ctr
)
1358 prs_struct qbuf
, rbuf
;
1359 SPOOL_Q_ENUMJOBS in
;
1360 SPOOL_R_ENUMJOBS out
;
1368 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1369 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1372 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMJOBS
,
1375 spoolss_io_q_enumjobs
,
1376 spoolss_io_r_enumjobs
,
1377 WERR_GENERAL_FAILURE
);
1379 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1380 offered
= out
.needed
;
1385 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1386 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1389 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMJOBS
,
1392 spoolss_io_q_enumjobs
,
1393 spoolss_io_r_enumjobs
,
1394 WERR_GENERAL_FAILURE
);
1397 if (!W_ERROR_IS_OK(out
.status
))
1402 if (!decode_jobs_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_1
)) {
1403 return WERR_GENERAL_FAILURE
;
1407 if (!decode_jobs_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_2
)) {
1408 return WERR_GENERAL_FAILURE
;
1412 DEBUG(3, ("unsupported info level %d", level
));
1413 return WERR_UNKNOWN_LEVEL
;
1416 *returned
= out
.returned
;
1421 /**********************************************************************
1422 **********************************************************************/
1424 WERROR
rpccli_spoolss_setjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1425 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1428 prs_struct qbuf
, rbuf
;
1435 make_spoolss_q_setjob( &in
, hnd
, jobid
, level
, command
);
1437 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETJOB
,
1440 spoolss_io_q_setjob
,
1441 spoolss_io_r_setjob
,
1442 WERR_GENERAL_FAILURE
);
1447 /**********************************************************************
1448 **********************************************************************/
1450 WERROR
rpccli_spoolss_getjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1451 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1454 prs_struct qbuf
, rbuf
;
1464 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1465 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1467 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETJOB
,
1470 spoolss_io_q_getjob
,
1471 spoolss_io_r_getjob
,
1472 WERR_GENERAL_FAILURE
);
1474 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1475 offered
= out
.needed
;
1480 rpcbuf_init(&buffer
, offered
, mem_ctx
);
1481 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1483 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETJOB
,
1486 spoolss_io_q_getjob
,
1487 spoolss_io_r_getjob
,
1488 WERR_GENERAL_FAILURE
);
1491 if (!W_ERROR_IS_OK(out
.status
))
1496 if (!decode_jobs_1(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_1
)) {
1497 return WERR_GENERAL_FAILURE
;
1501 if (!decode_jobs_2(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_2
)) {
1502 return WERR_GENERAL_FAILURE
;
1506 return WERR_UNKNOWN_LEVEL
;
1512 /**********************************************************************
1513 **********************************************************************/
1515 WERROR
rpccli_spoolss_startpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1518 prs_struct qbuf
, rbuf
;
1519 SPOOL_Q_STARTPAGEPRINTER in
;
1520 SPOOL_R_STARTPAGEPRINTER out
;
1525 make_spoolss_q_startpageprinter( &in
, hnd
);
1527 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_STARTPAGEPRINTER
,
1530 spoolss_io_q_startpageprinter
,
1531 spoolss_io_r_startpageprinter
,
1532 WERR_GENERAL_FAILURE
);
1537 /**********************************************************************
1538 **********************************************************************/
1540 WERROR
rpccli_spoolss_endpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1543 prs_struct qbuf
, rbuf
;
1544 SPOOL_Q_ENDPAGEPRINTER in
;
1545 SPOOL_R_ENDPAGEPRINTER out
;
1550 make_spoolss_q_endpageprinter( &in
, hnd
);
1552 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENDPAGEPRINTER
,
1555 spoolss_io_q_endpageprinter
,
1556 spoolss_io_r_endpageprinter
,
1557 WERR_GENERAL_FAILURE
);
1562 /**********************************************************************
1563 **********************************************************************/
1565 WERROR
rpccli_spoolss_startdocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1566 POLICY_HND
*hnd
, char *docname
,
1567 char *outputfile
, char *datatype
,
1570 prs_struct qbuf
, rbuf
;
1571 SPOOL_Q_STARTDOCPRINTER in
;
1572 SPOOL_R_STARTDOCPRINTER out
;
1578 make_spoolss_q_startdocprinter( &in
, hnd
, level
, docname
,
1579 outputfile
, datatype
);
1581 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_STARTDOCPRINTER
,
1584 spoolss_io_q_startdocprinter
,
1585 spoolss_io_r_startdocprinter
,
1586 WERR_GENERAL_FAILURE
);
1593 /**********************************************************************
1594 **********************************************************************/
1596 WERROR
rpccli_spoolss_enddocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1599 prs_struct qbuf
, rbuf
;
1600 SPOOL_Q_ENDDOCPRINTER in
;
1601 SPOOL_R_ENDDOCPRINTER out
;
1606 make_spoolss_q_enddocprinter( &in
, hnd
);
1608 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENDDOCPRINTER
,
1611 spoolss_io_q_enddocprinter
,
1612 spoolss_io_r_enddocprinter
,
1613 WERR_GENERAL_FAILURE
);
1618 /**********************************************************************
1619 **********************************************************************/
1621 WERROR
rpccli_spoolss_getprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1622 POLICY_HND
*hnd
, const char *valuename
,
1623 REGISTRY_VALUE
*value
)
1625 prs_struct qbuf
, rbuf
;
1626 SPOOL_Q_GETPRINTERDATA in
;
1627 SPOOL_R_GETPRINTERDATA out
;
1634 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1636 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATA
,
1639 spoolss_io_q_getprinterdata
,
1640 spoolss_io_r_getprinterdata
,
1641 WERR_GENERAL_FAILURE
);
1643 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1644 offered
= out
.needed
;
1649 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1651 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATA
,
1654 spoolss_io_q_getprinterdata
,
1655 spoolss_io_r_getprinterdata
,
1656 WERR_GENERAL_FAILURE
);
1659 if (!W_ERROR_IS_OK(out
.status
))
1662 /* Return output parameters */
1665 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1667 value
->data_p
= NULL
;
1669 value
->type
= out
.type
;
1670 value
->size
= out
.size
;
1675 /**********************************************************************
1676 **********************************************************************/
1678 WERROR
rpccli_spoolss_getprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1679 POLICY_HND
*hnd
, const char *keyname
,
1680 const char *valuename
,
1681 REGISTRY_VALUE
*value
)
1683 prs_struct qbuf
, rbuf
;
1684 SPOOL_Q_GETPRINTERDATAEX in
;
1685 SPOOL_R_GETPRINTERDATAEX out
;
1691 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1693 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATAEX
,
1696 spoolss_io_q_getprinterdataex
,
1697 spoolss_io_r_getprinterdataex
,
1698 WERR_GENERAL_FAILURE
);
1700 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1701 offered
= out
.needed
;
1706 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1708 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_GETPRINTERDATAEX
,
1711 spoolss_io_q_getprinterdataex
,
1712 spoolss_io_r_getprinterdataex
,
1713 WERR_GENERAL_FAILURE
);
1716 if (!W_ERROR_IS_OK(out
.status
))
1719 /* Return output parameters */
1722 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1724 value
->data_p
= NULL
;
1726 value
->type
= out
.type
;
1727 value
->size
= out
.needed
;
1732 /**********************************************************************
1733 **********************************************************************/
1735 WERROR
rpccli_spoolss_setprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1736 POLICY_HND
*hnd
, REGISTRY_VALUE
*value
)
1738 prs_struct qbuf
, rbuf
;
1739 SPOOL_Q_SETPRINTERDATA in
;
1740 SPOOL_R_SETPRINTERDATA out
;
1745 make_spoolss_q_setprinterdata( &in
, hnd
, value
->valuename
,
1746 value
->type
, (char *)value
->data_p
, value
->size
);
1748 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTERDATA
,
1751 spoolss_io_q_setprinterdata
,
1752 spoolss_io_r_setprinterdata
,
1753 WERR_GENERAL_FAILURE
);
1758 /**********************************************************************
1759 **********************************************************************/
1761 WERROR
rpccli_spoolss_setprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1762 POLICY_HND
*hnd
, char *keyname
,
1763 REGISTRY_VALUE
*value
)
1765 prs_struct qbuf
, rbuf
;
1766 SPOOL_Q_SETPRINTERDATAEX in
;
1767 SPOOL_R_SETPRINTERDATAEX out
;
1772 make_spoolss_q_setprinterdataex( &in
, hnd
, keyname
, value
->valuename
,
1773 value
->type
, (char *)value
->data_p
, value
->size
);
1775 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_SETPRINTERDATAEX
,
1778 spoolss_io_q_setprinterdataex
,
1779 spoolss_io_r_setprinterdataex
,
1780 WERR_GENERAL_FAILURE
);
1785 /**********************************************************************
1786 **********************************************************************/
1788 WERROR
rpccli_spoolss_enumprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1789 POLICY_HND
*hnd
, uint32 ndx
,
1790 uint32 value_offered
, uint32 data_offered
,
1791 uint32
*value_needed
, uint32
*data_needed
,
1792 REGISTRY_VALUE
*value
)
1794 prs_struct qbuf
, rbuf
;
1795 SPOOL_Q_ENUMPRINTERDATA in
;
1796 SPOOL_R_ENUMPRINTERDATA out
;
1801 make_spoolss_q_enumprinterdata( &in
, hnd
, ndx
, value_offered
, data_offered
);
1803 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATA
,
1806 spoolss_io_q_enumprinterdata
,
1807 spoolss_io_r_enumprinterdata
,
1808 WERR_GENERAL_FAILURE
);
1811 *value_needed
= out
.realvaluesize
;
1813 *data_needed
= out
.realdatasize
;
1815 if (!W_ERROR_IS_OK(out
.status
))
1819 rpcstr_pull(value
->valuename
, out
.value
, sizeof(value
->valuename
), -1,
1821 if (out
.realdatasize
) {
1822 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
,
1825 value
->data_p
= NULL
;
1827 value
->type
= out
.type
;
1828 value
->size
= out
.realdatasize
;
1834 /**********************************************************************
1835 **********************************************************************/
1837 WERROR
rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1838 POLICY_HND
*hnd
, const char *keyname
,
1841 prs_struct qbuf
, rbuf
;
1842 SPOOL_Q_ENUMPRINTERDATAEX in
;
1843 SPOOL_R_ENUMPRINTERDATAEX out
;
1851 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1853 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATAEX
,
1856 spoolss_io_q_enumprinterdataex
,
1857 spoolss_io_r_enumprinterdataex
,
1858 WERR_GENERAL_FAILURE
);
1860 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1861 offered
= out
.needed
;
1866 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1868 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERDATAEX
,
1871 spoolss_io_q_enumprinterdataex
,
1872 spoolss_io_r_enumprinterdataex
,
1873 WERR_GENERAL_FAILURE
);
1876 if (!W_ERROR_IS_OK(out
.status
))
1879 for (i
= 0; i
< out
.returned
; i
++) {
1880 PRINTER_ENUM_VALUES
*v
= &out
.ctr
.values
[i
];
1883 rpcstr_pull(name
, v
->valuename
.buffer
, sizeof(name
), -1,
1885 regval_ctr_addvalue(ctr
, name
, v
->type
, (const char *)v
->data
, v
->data_len
);
1891 /**********************************************************************
1892 **********************************************************************/
1894 WERROR
rpccli_spoolss_writeprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1895 POLICY_HND
*hnd
, uint32 data_size
, char *data
,
1896 uint32
*num_written
)
1898 prs_struct qbuf
, rbuf
;
1899 SPOOL_Q_WRITEPRINTER in
;
1900 SPOOL_R_WRITEPRINTER out
;
1905 make_spoolss_q_writeprinter( &in
, hnd
, data_size
, data
);
1907 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_WRITEPRINTER
,
1910 spoolss_io_q_writeprinter
,
1911 spoolss_io_r_writeprinter
,
1912 WERR_GENERAL_FAILURE
);
1915 *num_written
= out
.buffer_written
;
1920 /**********************************************************************
1921 **********************************************************************/
1923 WERROR
rpccli_spoolss_deleteprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1924 POLICY_HND
*hnd
, char *valuename
)
1926 prs_struct qbuf
, rbuf
;
1927 SPOOL_Q_DELETEPRINTERDATA in
;
1928 SPOOL_R_DELETEPRINTERDATA out
;
1933 make_spoolss_q_deleteprinterdata( &in
, hnd
, valuename
);
1935 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDATA
,
1938 spoolss_io_q_deleteprinterdata
,
1939 spoolss_io_r_deleteprinterdata
,
1940 WERR_GENERAL_FAILURE
);
1945 /**********************************************************************
1946 **********************************************************************/
1948 WERROR
rpccli_spoolss_deleteprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1949 POLICY_HND
*hnd
, char *keyname
,
1952 prs_struct qbuf
, rbuf
;
1953 SPOOL_Q_DELETEPRINTERDATAEX in
;
1954 SPOOL_R_DELETEPRINTERDATAEX out
;
1959 make_spoolss_q_deleteprinterdataex( &in
, hnd
, keyname
, valuename
);
1961 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERDATAEX
,
1964 spoolss_io_q_deleteprinterdataex
,
1965 spoolss_io_r_deleteprinterdataex
,
1966 WERR_GENERAL_FAILURE
);
1971 /**********************************************************************
1972 **********************************************************************/
1974 WERROR
rpccli_spoolss_enumprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1975 POLICY_HND
*hnd
, const char *keyname
,
1976 uint16
**keylist
, uint32
*len
)
1978 prs_struct qbuf
, rbuf
;
1979 SPOOL_Q_ENUMPRINTERKEY in
;
1980 SPOOL_R_ENUMPRINTERKEY out
;
1986 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
1988 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERKEY
,
1991 spoolss_io_q_enumprinterkey
,
1992 spoolss_io_r_enumprinterkey
,
1993 WERR_GENERAL_FAILURE
);
1995 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1996 offered
= out
.needed
;
2001 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
2003 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_ENUMPRINTERKEY
,
2006 spoolss_io_q_enumprinterkey
,
2007 spoolss_io_r_enumprinterkey
,
2008 WERR_GENERAL_FAILURE
);
2011 if ( !W_ERROR_IS_OK(out
.status
) )
2015 *keylist
= SMB_MALLOC_ARRAY(uint16
, out
.keys
.buf_len
);
2019 memcpy(*keylist
, out
.keys
.buffer
, out
.keys
.buf_len
* 2);
2021 *len
= out
.keys
.buf_len
* 2;
2027 /**********************************************************************
2028 **********************************************************************/
2030 WERROR
rpccli_spoolss_deleteprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
2031 POLICY_HND
*hnd
, char *keyname
)
2033 prs_struct qbuf
, rbuf
;
2034 SPOOL_Q_DELETEPRINTERKEY in
;
2035 SPOOL_R_DELETEPRINTERKEY out
;
2040 make_spoolss_q_deleteprinterkey( &in
, hnd
, keyname
);
2042 CLI_DO_RPC_WERR( cli
, mem_ctx
, PI_SPOOLSS
, SPOOLSS_DELETEPRINTERKEY
,
2045 spoolss_io_q_deleteprinterkey
,
2046 spoolss_io_r_deleteprinterkey
,
2047 WERR_GENERAL_FAILURE
);