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
, &syntax_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
, &syntax_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 if (!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
, &syntax_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 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
543 make_spoolss_q_enumprinters( &in
, flags
, name
, level
, &buffer
, offered
);
545 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERS
,
548 spoolss_io_q_enumprinters
,
549 spoolss_io_r_enumprinters
,
550 WERR_GENERAL_FAILURE
);
553 if ( !W_ERROR_IS_OK(out
.status
) )
558 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_0
)) {
559 return WERR_GENERAL_FAILURE
;
563 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_1
)) {
564 return WERR_GENERAL_FAILURE
;
568 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_2
)) {
569 return WERR_GENERAL_FAILURE
;
573 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->printers_3
)) {
574 return WERR_GENERAL_FAILURE
;
578 return WERR_UNKNOWN_LEVEL
;
581 *num_printers
= out
.returned
;
586 /**********************************************************************
587 **********************************************************************/
589 WERROR
rpccli_spoolss_enum_ports(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
590 uint32 level
, uint32
*num_ports
, PORT_INFO_CTR
*ctr
)
592 prs_struct qbuf
, rbuf
;
593 SPOOL_Q_ENUMPORTS in
;
594 SPOOL_R_ENUMPORTS out
;
602 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
606 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
608 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
610 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPORTS
,
613 spoolss_io_q_enumports
,
614 spoolss_io_r_enumports
,
615 WERR_GENERAL_FAILURE
);
617 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
618 offered
= out
.needed
;
623 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
625 make_spoolss_q_enumports( &in
, server
, level
, &buffer
, offered
);
627 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPORTS
,
630 spoolss_io_q_enumports
,
631 spoolss_io_r_enumports
,
632 WERR_GENERAL_FAILURE
);
635 if ( !W_ERROR_IS_OK(out
.status
) )
640 if (!decode_port_info_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_1
)) {
641 return WERR_GENERAL_FAILURE
;
645 if (!decode_port_info_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->port
.info_2
)) {
646 return WERR_GENERAL_FAILURE
;
650 return WERR_UNKNOWN_LEVEL
;
653 *num_ports
= out
.returned
;
658 /**********************************************************************
659 **********************************************************************/
661 WERROR
rpccli_spoolss_getprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
662 POLICY_HND
*pol
, uint32 level
,
663 PRINTER_INFO_CTR
*ctr
)
665 prs_struct qbuf
, rbuf
;
666 SPOOL_Q_GETPRINTER in
;
667 SPOOL_R_GETPRINTER out
;
674 /* Initialise input parameters */
677 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
679 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
681 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTER
,
684 spoolss_io_q_getprinter
,
685 spoolss_io_r_getprinter
,
686 WERR_GENERAL_FAILURE
);
688 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
689 offered
= out
.needed
;
694 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
696 make_spoolss_q_getprinter( mem_ctx
, &in
, pol
, level
, &buffer
, offered
);
698 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTER
,
701 spoolss_io_q_getprinter
,
702 spoolss_io_r_getprinter
,
703 WERR_GENERAL_FAILURE
);
706 if ( !W_ERROR_IS_OK(out
.status
) )
711 if (!decode_printer_info_0(mem_ctx
, out
.buffer
, 1, &ctr
->printers_0
)) {
712 return WERR_GENERAL_FAILURE
;
716 if (!decode_printer_info_1(mem_ctx
, out
.buffer
, 1, &ctr
->printers_1
)) {
717 return WERR_GENERAL_FAILURE
;
721 if (!decode_printer_info_2(mem_ctx
, out
.buffer
, 1, &ctr
->printers_2
)) {
722 return WERR_GENERAL_FAILURE
;
726 if (!decode_printer_info_3(mem_ctx
, out
.buffer
, 1, &ctr
->printers_3
)) {
727 return WERR_GENERAL_FAILURE
;
731 if (!decode_printer_info_7(mem_ctx
, out
.buffer
, 1, &ctr
->printers_7
)) {
732 return WERR_GENERAL_FAILURE
;
736 return WERR_UNKNOWN_LEVEL
;
742 /**********************************************************************
743 **********************************************************************/
745 WERROR
rpccli_spoolss_setprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
746 POLICY_HND
*pol
, uint32 level
,
747 PRINTER_INFO_CTR
*ctr
, uint32 command
)
749 prs_struct qbuf
, rbuf
;
750 SPOOL_Q_SETPRINTER in
;
751 SPOOL_R_SETPRINTER out
;
756 make_spoolss_q_setprinter( mem_ctx
, &in
, pol
, level
, ctr
, command
);
758 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_SETPRINTER
,
761 spoolss_io_q_setprinter
,
762 spoolss_io_r_setprinter
,
763 WERR_GENERAL_FAILURE
);
768 /**********************************************************************
769 **********************************************************************/
771 WERROR
rpccli_spoolss_getprinterdriver(struct rpc_pipe_client
*cli
,
773 POLICY_HND
*pol
, uint32 level
,
774 const char *env
, int version
, PRINTER_DRIVER_CTR
*ctr
)
776 prs_struct qbuf
, rbuf
;
777 SPOOL_Q_GETPRINTERDRIVER2 in
;
778 SPOOL_R_GETPRINTERDRIVER2 out
;
786 fstrcpy(server
, cli
->desthost
);
790 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
792 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
793 version
, 2, &buffer
, offered
);
795 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDRIVER2
,
798 spoolss_io_q_getprinterdriver2
,
799 spoolss_io_r_getprinterdriver2
,
800 WERR_GENERAL_FAILURE
);
802 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
803 offered
= out
.needed
;
808 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
810 make_spoolss_q_getprinterdriver2( &in
, pol
, env
, level
,
811 version
, 2, &buffer
, offered
);
813 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDRIVER2
,
816 spoolss_io_q_getprinterdriver2
,
817 spoolss_io_r_getprinterdriver2
,
818 WERR_GENERAL_FAILURE
);
821 if ( !W_ERROR_IS_OK(out
.status
) )
826 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
827 return WERR_GENERAL_FAILURE
;
831 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, 1, &ctr
->info2
)) {
832 return WERR_GENERAL_FAILURE
;
836 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, 1, &ctr
->info3
)) {
837 return WERR_GENERAL_FAILURE
;
841 return WERR_UNKNOWN_LEVEL
;
847 /**********************************************************************
848 **********************************************************************/
850 WERROR
rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client
*cli
,
852 uint32 level
, const char *env
,
854 PRINTER_DRIVER_CTR
*ctr
)
856 prs_struct qbuf
, rbuf
;
857 SPOOL_Q_ENUMPRINTERDRIVERS in
;
858 SPOOL_R_ENUMPRINTERDRIVERS out
;
866 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
870 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
872 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
875 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDRIVERS
,
878 spoolss_io_q_enumprinterdrivers
,
879 spoolss_io_r_enumprinterdrivers
,
880 WERR_GENERAL_FAILURE
);
882 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
883 offered
= out
.needed
;
888 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
890 make_spoolss_q_enumprinterdrivers( &in
, server
, env
, level
,
893 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDRIVERS
,
896 spoolss_io_q_enumprinterdrivers
,
897 spoolss_io_r_enumprinterdrivers
,
898 WERR_GENERAL_FAILURE
);
901 *num_drivers
= out
.returned
;
903 if ( !W_ERROR_IS_OK(out
.status
) )
906 if ( out
.returned
) {
910 if (!decode_printer_driver_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info1
)) {
911 return WERR_GENERAL_FAILURE
;
915 if (!decode_printer_driver_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info2
)) {
916 return WERR_GENERAL_FAILURE
;
920 if (!decode_printer_driver_3(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->info3
)) {
921 return WERR_GENERAL_FAILURE
;
925 return WERR_UNKNOWN_LEVEL
;
933 /**********************************************************************
934 **********************************************************************/
936 WERROR
rpccli_spoolss_getprinterdriverdir (struct rpc_pipe_client
*cli
,
938 uint32 level
, char *env
,
939 DRIVER_DIRECTORY_CTR
*ctr
)
941 prs_struct qbuf
, rbuf
;
942 SPOOL_Q_GETPRINTERDRIVERDIR in
;
943 SPOOL_R_GETPRINTERDRIVERDIR out
;
951 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
955 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
957 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
960 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
963 spoolss_io_q_getprinterdriverdir
,
964 spoolss_io_r_getprinterdriverdir
,
965 WERR_GENERAL_FAILURE
);
967 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
968 offered
= out
.needed
;
973 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
975 make_spoolss_q_getprinterdriverdir( &in
, server
, env
, level
,
978 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDRIVERDIRECTORY
,
981 spoolss_io_q_getprinterdriverdir
,
982 spoolss_io_r_getprinterdriverdir
,
983 WERR_GENERAL_FAILURE
);
986 if (!W_ERROR_IS_OK(out
.status
))
989 if (!decode_printerdriverdir_1(mem_ctx
, out
.buffer
, 1, &ctr
->info1
)) {
990 return WERR_GENERAL_FAILURE
;
996 /**********************************************************************
997 **********************************************************************/
999 WERROR
rpccli_spoolss_addprinterdriver (struct rpc_pipe_client
*cli
,
1000 TALLOC_CTX
*mem_ctx
, uint32 level
,
1001 PRINTER_DRIVER_CTR
*ctr
)
1003 prs_struct qbuf
, rbuf
;
1004 SPOOL_Q_ADDPRINTERDRIVER in
;
1005 SPOOL_R_ADDPRINTERDRIVER out
;
1011 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1014 make_spoolss_q_addprinterdriver( mem_ctx
, &in
, server
, level
, ctr
);
1016 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ADDPRINTERDRIVER
,
1019 spoolss_io_q_addprinterdriver
,
1020 spoolss_io_r_addprinterdriver
,
1021 WERR_GENERAL_FAILURE
);
1026 /**********************************************************************
1027 **********************************************************************/
1029 WERROR
rpccli_spoolss_addprinterex (struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1030 uint32 level
, PRINTER_INFO_CTR
*ctr
)
1032 prs_struct qbuf
, rbuf
;
1033 SPOOL_Q_ADDPRINTEREX in
;
1034 SPOOL_R_ADDPRINTEREX out
;
1035 fstring server
, client
, user
;
1040 slprintf(client
, sizeof(fstring
)-1, "\\\\%s", global_myname());
1041 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1046 fstrcpy (user
, cli
->auth
->user_name
);
1048 make_spoolss_q_addprinterex( mem_ctx
, &in
, server
, client
,
1051 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ADDPRINTEREX
,
1054 spoolss_io_q_addprinterex
,
1055 spoolss_io_r_addprinterex
,
1056 WERR_GENERAL_FAILURE
);
1061 /**********************************************************************
1062 **********************************************************************/
1064 WERROR
rpccli_spoolss_deleteprinterdriverex(struct rpc_pipe_client
*cli
,
1065 TALLOC_CTX
*mem_ctx
, const char *arch
,
1066 const char *driver
, int version
)
1068 prs_struct qbuf
, rbuf
;
1069 SPOOL_Q_DELETEPRINTERDRIVEREX in
;
1070 SPOOL_R_DELETEPRINTERDRIVEREX out
;
1076 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1079 make_spoolss_q_deleteprinterdriverex( mem_ctx
, &in
, server
, arch
, driver
, version
);
1081 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_DELETEPRINTERDRIVEREX
,
1084 spoolss_io_q_deleteprinterdriverex
,
1085 spoolss_io_r_deleteprinterdriverex
,
1086 WERR_GENERAL_FAILURE
);
1091 /**********************************************************************
1092 **********************************************************************/
1094 WERROR
rpccli_spoolss_deleteprinterdriver (struct rpc_pipe_client
*cli
,
1095 TALLOC_CTX
*mem_ctx
, const char *arch
,
1098 prs_struct qbuf
, rbuf
;
1099 SPOOL_Q_DELETEPRINTERDRIVER in
;
1100 SPOOL_R_DELETEPRINTERDRIVER out
;
1106 slprintf(server
, sizeof(fstring
)-1, "\\\\%s", cli
->desthost
);
1109 make_spoolss_q_deleteprinterdriver( mem_ctx
, &in
, server
, arch
, driver
);
1111 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_DELETEPRINTERDRIVER
,
1114 spoolss_io_q_deleteprinterdriver
,
1115 spoolss_io_r_deleteprinterdriver
,
1116 WERR_GENERAL_FAILURE
);
1121 /**********************************************************************
1122 **********************************************************************/
1124 WERROR
rpccli_spoolss_getprintprocessordirectory(struct rpc_pipe_client
*cli
,
1125 TALLOC_CTX
*mem_ctx
,
1126 char *name
, char *environment
,
1129 prs_struct qbuf
, rbuf
;
1130 SPOOL_Q_GETPRINTPROCESSORDIRECTORY in
;
1131 SPOOL_R_GETPRINTPROCESSORDIRECTORY out
;
1140 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1142 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1143 environment
, level
, &buffer
, offered
);
1145 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1148 spoolss_io_q_getprintprocessordirectory
,
1149 spoolss_io_r_getprintprocessordirectory
,
1150 WERR_GENERAL_FAILURE
);
1152 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1153 offered
= out
.needed
;
1158 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1160 make_spoolss_q_getprintprocessordirectory( &in
, name
,
1161 environment
, level
, &buffer
, offered
);
1163 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTPROCESSORDIRECTORY
,
1166 spoolss_io_q_getprintprocessordirectory
,
1167 spoolss_io_r_getprintprocessordirectory
,
1168 WERR_GENERAL_FAILURE
);
1171 if ( !W_ERROR_IS_OK(out
.status
) )
1174 fstrcpy(procdir
, "Not implemented!");
1179 /**********************************************************************
1180 **********************************************************************/
1182 WERROR
rpccli_spoolss_addform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1183 POLICY_HND
*handle
, uint32 level
, FORM
*form
)
1185 prs_struct qbuf
, rbuf
;
1187 SPOOL_R_ADDFORM out
;
1192 make_spoolss_q_addform( &in
, handle
, level
, form
);
1194 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ADDFORM
,
1197 spoolss_io_q_addform
,
1198 spoolss_io_r_addform
,
1199 WERR_GENERAL_FAILURE
);
1204 /**********************************************************************
1205 **********************************************************************/
1207 WERROR
rpccli_spoolss_setform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1208 POLICY_HND
*handle
, uint32 level
,
1209 const char *form_name
, FORM
*form
)
1211 prs_struct qbuf
, rbuf
;
1213 SPOOL_R_SETFORM out
;
1218 make_spoolss_q_setform( &in
, handle
, level
, form_name
, form
);
1220 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_SETFORM
,
1223 spoolss_io_q_setform
,
1224 spoolss_io_r_setform
,
1225 WERR_GENERAL_FAILURE
);
1230 /**********************************************************************
1231 **********************************************************************/
1233 WERROR
rpccli_spoolss_getform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1234 POLICY_HND
*handle
, const char *formname
,
1235 uint32 level
, FORM_1
*form
)
1237 prs_struct qbuf
, rbuf
;
1239 SPOOL_R_GETFORM out
;
1247 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1249 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1251 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETFORM
,
1254 spoolss_io_q_getform
,
1255 spoolss_io_r_getform
,
1256 WERR_GENERAL_FAILURE
);
1258 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1259 offered
= out
.needed
;
1264 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1266 make_spoolss_q_getform( &in
, handle
, formname
, level
, &buffer
, offered
);
1268 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETFORM
,
1271 spoolss_io_q_getform
,
1272 spoolss_io_r_getform
,
1273 WERR_GENERAL_FAILURE
);
1276 if (!W_ERROR_IS_OK(out
.status
))
1279 if (!smb_io_form_1("", out
.buffer
, form
, 0)) {
1280 return WERR_GENERAL_FAILURE
;
1286 /**********************************************************************
1287 **********************************************************************/
1289 WERROR
rpccli_spoolss_deleteform(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1290 POLICY_HND
*handle
, const char *form_name
)
1292 prs_struct qbuf
, rbuf
;
1293 SPOOL_Q_DELETEFORM in
;
1294 SPOOL_R_DELETEFORM out
;
1299 make_spoolss_q_deleteform( &in
, handle
, form_name
);
1301 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_DELETEFORM
,
1304 spoolss_io_q_deleteform
,
1305 spoolss_io_r_deleteform
,
1306 WERR_GENERAL_FAILURE
);
1311 /**********************************************************************
1312 **********************************************************************/
1314 WERROR
rpccli_spoolss_enumforms(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1315 POLICY_HND
*handle
, int level
, uint32
*num_forms
,
1318 prs_struct qbuf
, rbuf
;
1319 SPOOL_Q_ENUMFORMS in
;
1320 SPOOL_R_ENUMFORMS out
;
1328 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1330 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1332 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMFORMS
,
1335 spoolss_io_q_enumforms
,
1336 spoolss_io_r_enumforms
,
1337 WERR_GENERAL_FAILURE
);
1339 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1340 offered
= out
.needed
;
1345 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1347 make_spoolss_q_enumforms( &in
, handle
, level
, &buffer
, offered
);
1349 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMFORMS
,
1352 spoolss_io_q_enumforms
,
1353 spoolss_io_r_enumforms
,
1354 WERR_GENERAL_FAILURE
);
1357 if (!W_ERROR_IS_OK(out
.status
))
1360 *num_forms
= out
.numofforms
;
1362 if (!decode_forms_1(mem_ctx
, out
.buffer
, *num_forms
, forms
)) {
1363 return WERR_GENERAL_FAILURE
;
1369 /**********************************************************************
1370 **********************************************************************/
1372 WERROR
rpccli_spoolss_enumjobs(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1373 POLICY_HND
*hnd
, uint32 level
, uint32 firstjob
,
1374 uint32 num_jobs
, uint32
*returned
, JOB_INFO_CTR
*ctr
)
1376 prs_struct qbuf
, rbuf
;
1377 SPOOL_Q_ENUMJOBS in
;
1378 SPOOL_R_ENUMJOBS out
;
1386 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1388 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1391 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMJOBS
,
1394 spoolss_io_q_enumjobs
,
1395 spoolss_io_r_enumjobs
,
1396 WERR_GENERAL_FAILURE
);
1398 if ( W_ERROR_EQUAL( out
.status
, WERR_INSUFFICIENT_BUFFER
) ) {
1399 offered
= out
.needed
;
1404 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1406 make_spoolss_q_enumjobs( &in
, hnd
, firstjob
, num_jobs
, level
,
1409 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMJOBS
,
1412 spoolss_io_q_enumjobs
,
1413 spoolss_io_r_enumjobs
,
1414 WERR_GENERAL_FAILURE
);
1417 if (!W_ERROR_IS_OK(out
.status
))
1422 if (!decode_jobs_1(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_1
)) {
1423 return WERR_GENERAL_FAILURE
;
1427 if (!decode_jobs_2(mem_ctx
, out
.buffer
, out
.returned
, &ctr
->job
.job_info_2
)) {
1428 return WERR_GENERAL_FAILURE
;
1432 DEBUG(3, ("unsupported info level %d", level
));
1433 return WERR_UNKNOWN_LEVEL
;
1436 *returned
= out
.returned
;
1441 /**********************************************************************
1442 **********************************************************************/
1444 WERROR
rpccli_spoolss_setjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1445 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1448 prs_struct qbuf
, rbuf
;
1455 make_spoolss_q_setjob( &in
, hnd
, jobid
, level
, command
);
1457 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_SETJOB
,
1460 spoolss_io_q_setjob
,
1461 spoolss_io_r_setjob
,
1462 WERR_GENERAL_FAILURE
);
1467 /**********************************************************************
1468 **********************************************************************/
1470 WERROR
rpccli_spoolss_getjob(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1471 POLICY_HND
*hnd
, uint32 jobid
, uint32 level
,
1474 prs_struct qbuf
, rbuf
;
1484 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1486 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1488 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETJOB
,
1491 spoolss_io_q_getjob
,
1492 spoolss_io_r_getjob
,
1493 WERR_GENERAL_FAILURE
);
1495 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1496 offered
= out
.needed
;
1501 if (!rpcbuf_init(&buffer
, offered
, mem_ctx
))
1503 make_spoolss_q_getjob( &in
, hnd
, jobid
, level
, &buffer
, offered
);
1505 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETJOB
,
1508 spoolss_io_q_getjob
,
1509 spoolss_io_r_getjob
,
1510 WERR_GENERAL_FAILURE
);
1513 if (!W_ERROR_IS_OK(out
.status
))
1518 if (!decode_jobs_1(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_1
)) {
1519 return WERR_GENERAL_FAILURE
;
1523 if (!decode_jobs_2(mem_ctx
, out
.buffer
, 1, &ctr
->job
.job_info_2
)) {
1524 return WERR_GENERAL_FAILURE
;
1528 return WERR_UNKNOWN_LEVEL
;
1534 /**********************************************************************
1535 **********************************************************************/
1537 WERROR
rpccli_spoolss_startpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1540 prs_struct qbuf
, rbuf
;
1541 SPOOL_Q_STARTPAGEPRINTER in
;
1542 SPOOL_R_STARTPAGEPRINTER out
;
1547 make_spoolss_q_startpageprinter( &in
, hnd
);
1549 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_STARTPAGEPRINTER
,
1552 spoolss_io_q_startpageprinter
,
1553 spoolss_io_r_startpageprinter
,
1554 WERR_GENERAL_FAILURE
);
1559 /**********************************************************************
1560 **********************************************************************/
1562 WERROR
rpccli_spoolss_endpageprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1565 prs_struct qbuf
, rbuf
;
1566 SPOOL_Q_ENDPAGEPRINTER in
;
1567 SPOOL_R_ENDPAGEPRINTER out
;
1572 make_spoolss_q_endpageprinter( &in
, hnd
);
1574 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENDPAGEPRINTER
,
1577 spoolss_io_q_endpageprinter
,
1578 spoolss_io_r_endpageprinter
,
1579 WERR_GENERAL_FAILURE
);
1584 /**********************************************************************
1585 **********************************************************************/
1587 WERROR
rpccli_spoolss_startdocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1588 POLICY_HND
*hnd
, char *docname
,
1589 char *outputfile
, char *datatype
,
1592 prs_struct qbuf
, rbuf
;
1593 SPOOL_Q_STARTDOCPRINTER in
;
1594 SPOOL_R_STARTDOCPRINTER out
;
1600 make_spoolss_q_startdocprinter( &in
, hnd
, level
, docname
,
1601 outputfile
, datatype
);
1603 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_STARTDOCPRINTER
,
1606 spoolss_io_q_startdocprinter
,
1607 spoolss_io_r_startdocprinter
,
1608 WERR_GENERAL_FAILURE
);
1615 /**********************************************************************
1616 **********************************************************************/
1618 WERROR
rpccli_spoolss_enddocprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1621 prs_struct qbuf
, rbuf
;
1622 SPOOL_Q_ENDDOCPRINTER in
;
1623 SPOOL_R_ENDDOCPRINTER out
;
1628 make_spoolss_q_enddocprinter( &in
, hnd
);
1630 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENDDOCPRINTER
,
1633 spoolss_io_q_enddocprinter
,
1634 spoolss_io_r_enddocprinter
,
1635 WERR_GENERAL_FAILURE
);
1640 /**********************************************************************
1641 **********************************************************************/
1643 WERROR
rpccli_spoolss_getprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1644 POLICY_HND
*hnd
, const char *valuename
,
1645 REGISTRY_VALUE
*value
)
1647 prs_struct qbuf
, rbuf
;
1648 SPOOL_Q_GETPRINTERDATA in
;
1649 SPOOL_R_GETPRINTERDATA out
;
1656 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1658 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDATA
,
1661 spoolss_io_q_getprinterdata
,
1662 spoolss_io_r_getprinterdata
,
1663 WERR_GENERAL_FAILURE
);
1665 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1666 offered
= out
.needed
;
1671 make_spoolss_q_getprinterdata( &in
, hnd
, valuename
, offered
);
1673 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDATA
,
1676 spoolss_io_q_getprinterdata
,
1677 spoolss_io_r_getprinterdata
,
1678 WERR_GENERAL_FAILURE
);
1681 if (!W_ERROR_IS_OK(out
.status
))
1684 /* Return output parameters */
1687 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1689 value
->data_p
= NULL
;
1691 value
->type
= out
.type
;
1692 value
->size
= out
.size
;
1697 /**********************************************************************
1698 **********************************************************************/
1700 WERROR
rpccli_spoolss_getprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1701 POLICY_HND
*hnd
, const char *keyname
,
1702 const char *valuename
,
1703 REGISTRY_VALUE
*value
)
1705 prs_struct qbuf
, rbuf
;
1706 SPOOL_Q_GETPRINTERDATAEX in
;
1707 SPOOL_R_GETPRINTERDATAEX out
;
1713 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1715 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDATAEX
,
1718 spoolss_io_q_getprinterdataex
,
1719 spoolss_io_r_getprinterdataex
,
1720 WERR_GENERAL_FAILURE
);
1722 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1723 offered
= out
.needed
;
1728 make_spoolss_q_getprinterdataex( &in
, hnd
, keyname
, valuename
, offered
);
1730 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_GETPRINTERDATAEX
,
1733 spoolss_io_q_getprinterdataex
,
1734 spoolss_io_r_getprinterdataex
,
1735 WERR_GENERAL_FAILURE
);
1738 if (!W_ERROR_IS_OK(out
.status
))
1741 /* Return output parameters */
1744 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
, out
.needed
);
1746 value
->data_p
= NULL
;
1748 value
->type
= out
.type
;
1749 value
->size
= out
.needed
;
1754 /**********************************************************************
1755 **********************************************************************/
1757 WERROR
rpccli_spoolss_setprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1758 POLICY_HND
*hnd
, REGISTRY_VALUE
*value
)
1760 prs_struct qbuf
, rbuf
;
1761 SPOOL_Q_SETPRINTERDATA in
;
1762 SPOOL_R_SETPRINTERDATA out
;
1767 make_spoolss_q_setprinterdata( &in
, hnd
, value
->valuename
,
1768 value
->type
, (char *)value
->data_p
, value
->size
);
1770 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_SETPRINTERDATA
,
1773 spoolss_io_q_setprinterdata
,
1774 spoolss_io_r_setprinterdata
,
1775 WERR_GENERAL_FAILURE
);
1780 /**********************************************************************
1781 **********************************************************************/
1783 WERROR
rpccli_spoolss_setprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1784 POLICY_HND
*hnd
, char *keyname
,
1785 REGISTRY_VALUE
*value
)
1787 prs_struct qbuf
, rbuf
;
1788 SPOOL_Q_SETPRINTERDATAEX in
;
1789 SPOOL_R_SETPRINTERDATAEX out
;
1794 make_spoolss_q_setprinterdataex( &in
, hnd
, keyname
, value
->valuename
,
1795 value
->type
, (char *)value
->data_p
, value
->size
);
1797 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_SETPRINTERDATAEX
,
1800 spoolss_io_q_setprinterdataex
,
1801 spoolss_io_r_setprinterdataex
,
1802 WERR_GENERAL_FAILURE
);
1807 /**********************************************************************
1808 **********************************************************************/
1810 WERROR
rpccli_spoolss_enumprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1811 POLICY_HND
*hnd
, uint32 ndx
,
1812 uint32 value_offered
, uint32 data_offered
,
1813 uint32
*value_needed
, uint32
*data_needed
,
1814 REGISTRY_VALUE
*value
)
1816 prs_struct qbuf
, rbuf
;
1817 SPOOL_Q_ENUMPRINTERDATA in
;
1818 SPOOL_R_ENUMPRINTERDATA out
;
1823 make_spoolss_q_enumprinterdata( &in
, hnd
, ndx
, value_offered
, data_offered
);
1825 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDATA
,
1828 spoolss_io_q_enumprinterdata
,
1829 spoolss_io_r_enumprinterdata
,
1830 WERR_GENERAL_FAILURE
);
1833 *value_needed
= out
.realvaluesize
;
1835 *data_needed
= out
.realdatasize
;
1837 if (!W_ERROR_IS_OK(out
.status
))
1841 rpcstr_pull(value
->valuename
, out
.value
, sizeof(value
->valuename
), -1,
1843 if (out
.realdatasize
) {
1844 value
->data_p
= (uint8
*)TALLOC_MEMDUP(mem_ctx
, out
.data
,
1847 value
->data_p
= NULL
;
1849 value
->type
= out
.type
;
1850 value
->size
= out
.realdatasize
;
1856 /**********************************************************************
1857 **********************************************************************/
1859 WERROR
rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1860 POLICY_HND
*hnd
, const char *keyname
,
1863 prs_struct qbuf
, rbuf
;
1864 SPOOL_Q_ENUMPRINTERDATAEX in
;
1865 SPOOL_R_ENUMPRINTERDATAEX out
;
1873 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1875 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDATAEX
,
1878 spoolss_io_q_enumprinterdataex
,
1879 spoolss_io_r_enumprinterdataex
,
1880 WERR_GENERAL_FAILURE
);
1882 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
1883 offered
= out
.needed
;
1888 make_spoolss_q_enumprinterdataex( &in
, hnd
, keyname
, offered
);
1890 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERDATAEX
,
1893 spoolss_io_q_enumprinterdataex
,
1894 spoolss_io_r_enumprinterdataex
,
1895 WERR_GENERAL_FAILURE
);
1898 if (!W_ERROR_IS_OK(out
.status
))
1901 for (i
= 0; i
< out
.returned
; i
++) {
1902 PRINTER_ENUM_VALUES
*v
= &out
.ctr
.values
[i
];
1905 rpcstr_pull(name
, v
->valuename
.buffer
, sizeof(name
), -1,
1907 regval_ctr_addvalue(ctr
, name
, v
->type
, (const char *)v
->data
, v
->data_len
);
1913 /**********************************************************************
1914 **********************************************************************/
1916 WERROR
rpccli_spoolss_writeprinter(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1917 POLICY_HND
*hnd
, uint32 data_size
, char *data
,
1918 uint32
*num_written
)
1920 prs_struct qbuf
, rbuf
;
1921 SPOOL_Q_WRITEPRINTER in
;
1922 SPOOL_R_WRITEPRINTER out
;
1927 make_spoolss_q_writeprinter( &in
, hnd
, data_size
, data
);
1929 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_WRITEPRINTER
,
1932 spoolss_io_q_writeprinter
,
1933 spoolss_io_r_writeprinter
,
1934 WERR_GENERAL_FAILURE
);
1937 *num_written
= out
.buffer_written
;
1942 /**********************************************************************
1943 **********************************************************************/
1945 WERROR
rpccli_spoolss_deleteprinterdata(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1946 POLICY_HND
*hnd
, char *valuename
)
1948 prs_struct qbuf
, rbuf
;
1949 SPOOL_Q_DELETEPRINTERDATA in
;
1950 SPOOL_R_DELETEPRINTERDATA out
;
1955 make_spoolss_q_deleteprinterdata( &in
, hnd
, valuename
);
1957 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_DELETEPRINTERDATA
,
1960 spoolss_io_q_deleteprinterdata
,
1961 spoolss_io_r_deleteprinterdata
,
1962 WERR_GENERAL_FAILURE
);
1967 /**********************************************************************
1968 **********************************************************************/
1970 WERROR
rpccli_spoolss_deleteprinterdataex(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1971 POLICY_HND
*hnd
, char *keyname
,
1974 prs_struct qbuf
, rbuf
;
1975 SPOOL_Q_DELETEPRINTERDATAEX in
;
1976 SPOOL_R_DELETEPRINTERDATAEX out
;
1981 make_spoolss_q_deleteprinterdataex( &in
, hnd
, keyname
, valuename
);
1983 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_DELETEPRINTERDATAEX
,
1986 spoolss_io_q_deleteprinterdataex
,
1987 spoolss_io_r_deleteprinterdataex
,
1988 WERR_GENERAL_FAILURE
);
1993 /**********************************************************************
1994 **********************************************************************/
1996 WERROR
rpccli_spoolss_enumprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
1997 POLICY_HND
*hnd
, const char *keyname
,
1998 uint16
**keylist
, uint32
*len
)
2000 prs_struct qbuf
, rbuf
;
2001 SPOOL_Q_ENUMPRINTERKEY in
;
2002 SPOOL_R_ENUMPRINTERKEY out
;
2008 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
2010 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERKEY
,
2013 spoolss_io_q_enumprinterkey
,
2014 spoolss_io_r_enumprinterkey
,
2015 WERR_GENERAL_FAILURE
);
2017 if ( W_ERROR_EQUAL( out
.status
, WERR_MORE_DATA
) ) {
2018 offered
= out
.needed
;
2023 make_spoolss_q_enumprinterkey( &in
, hnd
, keyname
, offered
);
2025 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_ENUMPRINTERKEY
,
2028 spoolss_io_q_enumprinterkey
,
2029 spoolss_io_r_enumprinterkey
,
2030 WERR_GENERAL_FAILURE
);
2033 if ( !W_ERROR_IS_OK(out
.status
) )
2037 *keylist
= SMB_MALLOC_ARRAY(uint16
, out
.keys
.buf_len
);
2041 memcpy(*keylist
, out
.keys
.buffer
, out
.keys
.buf_len
* 2);
2043 *len
= out
.keys
.buf_len
* 2;
2049 /**********************************************************************
2050 **********************************************************************/
2052 WERROR
rpccli_spoolss_deleteprinterkey(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
2053 POLICY_HND
*hnd
, char *keyname
)
2055 prs_struct qbuf
, rbuf
;
2056 SPOOL_Q_DELETEPRINTERKEY in
;
2057 SPOOL_R_DELETEPRINTERKEY out
;
2062 make_spoolss_q_deleteprinterkey( &in
, hnd
, keyname
);
2064 CLI_DO_RPC_WERR( cli
, mem_ctx
, &syntax_spoolss
, SPOOLSS_DELETEPRINTERKEY
,
2067 spoolss_io_q_deleteprinterkey
,
2068 spoolss_io_r_deleteprinterkey
,
2069 WERR_GENERAL_FAILURE
);