1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | RPC pipe client
|
---|
4 |
|
---|
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.
|
---|
10 |
|
---|
11 | This program is free software; you can redistribute it and/or modify
|
---|
12 | it under the terms of the GNU General Public License as published by
|
---|
13 | the Free Software Foundation; either version 2 of the License, or
|
---|
14 | (at your option) any later version.
|
---|
15 |
|
---|
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.
|
---|
20 |
|
---|
21 | You should have received a copy of the GNU General Public License
|
---|
22 | along with this program; if not, write to the Free Software
|
---|
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #include "includes.h"
|
---|
27 | #include "rpc_client.h"
|
---|
28 |
|
---|
29 | /*********************************************************************
|
---|
30 | Decode various spoolss rpc's and info levels
|
---|
31 | ********************************************************************/
|
---|
32 |
|
---|
33 | /**********************************************************************
|
---|
34 | **********************************************************************/
|
---|
35 |
|
---|
36 | static BOOL decode_printer_info_0(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
37 | uint32 returned, PRINTER_INFO_0 **info)
|
---|
38 | {
|
---|
39 | uint32 i;
|
---|
40 | PRINTER_INFO_0 *inf;
|
---|
41 |
|
---|
42 | if (returned) {
|
---|
43 | inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_0, returned);
|
---|
44 | if (!inf) {
|
---|
45 | return False;
|
---|
46 | }
|
---|
47 | memset(inf, 0, returned*sizeof(PRINTER_INFO_0));
|
---|
48 | } else {
|
---|
49 | inf = NULL;
|
---|
50 | }
|
---|
51 |
|
---|
52 | prs_set_offset(&buffer->prs,0);
|
---|
53 |
|
---|
54 | for (i=0; i<returned; i++) {
|
---|
55 | if (!smb_io_printer_info_0("", buffer, &inf[i], 0)) {
|
---|
56 | return False;
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | *info=inf;
|
---|
61 | return True;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**********************************************************************
|
---|
65 | **********************************************************************/
|
---|
66 |
|
---|
67 | static BOOL decode_printer_info_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
68 | uint32 returned, PRINTER_INFO_1 **info)
|
---|
69 | {
|
---|
70 | uint32 i;
|
---|
71 | PRINTER_INFO_1 *inf;
|
---|
72 |
|
---|
73 | if (returned) {
|
---|
74 | inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_1, returned);
|
---|
75 | if (!inf) {
|
---|
76 | return False;
|
---|
77 | }
|
---|
78 | memset(inf, 0, returned*sizeof(PRINTER_INFO_1));
|
---|
79 | } else {
|
---|
80 | inf = NULL;
|
---|
81 | }
|
---|
82 |
|
---|
83 | prs_set_offset(&buffer->prs,0);
|
---|
84 |
|
---|
85 | for (i=0; i<returned; i++) {
|
---|
86 | if (!smb_io_printer_info_1("", buffer, &inf[i], 0)) {
|
---|
87 | return False;
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | *info=inf;
|
---|
92 | return True;
|
---|
93 | }
|
---|
94 |
|
---|
95 | /**********************************************************************
|
---|
96 | **********************************************************************/
|
---|
97 |
|
---|
98 | static BOOL decode_printer_info_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
99 | uint32 returned, PRINTER_INFO_2 **info)
|
---|
100 | {
|
---|
101 | uint32 i;
|
---|
102 | PRINTER_INFO_2 *inf;
|
---|
103 |
|
---|
104 | if (returned) {
|
---|
105 | inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_2, returned);
|
---|
106 | if (!inf) {
|
---|
107 | return False;
|
---|
108 | }
|
---|
109 | memset(inf, 0, returned*sizeof(PRINTER_INFO_2));
|
---|
110 | } else {
|
---|
111 | inf = NULL;
|
---|
112 | }
|
---|
113 |
|
---|
114 | prs_set_offset(&buffer->prs,0);
|
---|
115 |
|
---|
116 | for (i=0; i<returned; i++) {
|
---|
117 | /* a little initialization as we go */
|
---|
118 | inf[i].secdesc = NULL;
|
---|
119 | if (!smb_io_printer_info_2("", buffer, &inf[i], 0)) {
|
---|
120 | return False;
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | *info=inf;
|
---|
125 | return True;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /**********************************************************************
|
---|
129 | **********************************************************************/
|
---|
130 |
|
---|
131 | static BOOL decode_printer_info_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
132 | uint32 returned, PRINTER_INFO_3 **info)
|
---|
133 | {
|
---|
134 | uint32 i;
|
---|
135 | PRINTER_INFO_3 *inf;
|
---|
136 |
|
---|
137 | if (returned) {
|
---|
138 | inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_3, returned);
|
---|
139 | if (!inf) {
|
---|
140 | return False;
|
---|
141 | }
|
---|
142 | memset(inf, 0, returned*sizeof(PRINTER_INFO_3));
|
---|
143 | } else {
|
---|
144 | inf = NULL;
|
---|
145 | }
|
---|
146 |
|
---|
147 | prs_set_offset(&buffer->prs,0);
|
---|
148 |
|
---|
149 | for (i=0; i<returned; i++) {
|
---|
150 | inf[i].secdesc = NULL;
|
---|
151 | if (!smb_io_printer_info_3("", buffer, &inf[i], 0)) {
|
---|
152 | return False;
|
---|
153 | }
|
---|
154 | }
|
---|
155 |
|
---|
156 | *info=inf;
|
---|
157 | return True;
|
---|
158 | }
|
---|
159 |
|
---|
160 | /**********************************************************************
|
---|
161 | **********************************************************************/
|
---|
162 |
|
---|
163 | static BOOL decode_printer_info_7(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
164 | uint32 returned, PRINTER_INFO_7 **info)
|
---|
165 | {
|
---|
166 | uint32 i;
|
---|
167 | PRINTER_INFO_7 *inf;
|
---|
168 |
|
---|
169 | if (returned) {
|
---|
170 | inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_7, returned);
|
---|
171 | if (!inf) {
|
---|
172 | return False;
|
---|
173 | }
|
---|
174 | memset(inf, 0, returned*sizeof(PRINTER_INFO_7));
|
---|
175 | } else {
|
---|
176 | inf = NULL;
|
---|
177 | }
|
---|
178 |
|
---|
179 | prs_set_offset(&buffer->prs,0);
|
---|
180 |
|
---|
181 | for (i=0; i<returned; i++) {
|
---|
182 | if (!smb_io_printer_info_7("", buffer, &inf[i], 0)) {
|
---|
183 | return False;
|
---|
184 | }
|
---|
185 | }
|
---|
186 |
|
---|
187 | *info=inf;
|
---|
188 | return True;
|
---|
189 | }
|
---|
190 |
|
---|
191 |
|
---|
192 | /**********************************************************************
|
---|
193 | **********************************************************************/
|
---|
194 |
|
---|
195 | static BOOL decode_port_info_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
196 | uint32 returned, PORT_INFO_1 **info)
|
---|
197 | {
|
---|
198 | uint32 i;
|
---|
199 | PORT_INFO_1 *inf;
|
---|
200 |
|
---|
201 | if (returned) {
|
---|
202 | inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_1, returned);
|
---|
203 | if (!inf) {
|
---|
204 | return False;
|
---|
205 | }
|
---|
206 | memset(inf, 0, returned*sizeof(PORT_INFO_1));
|
---|
207 | } else {
|
---|
208 | inf = NULL;
|
---|
209 | }
|
---|
210 |
|
---|
211 | prs_set_offset(&buffer->prs, 0);
|
---|
212 |
|
---|
213 | for (i=0; i<returned; i++) {
|
---|
214 | if (!smb_io_port_info_1("", buffer, &(inf[i]), 0)) {
|
---|
215 | return False;
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | *info=inf;
|
---|
220 | return True;
|
---|
221 | }
|
---|
222 |
|
---|
223 | /**********************************************************************
|
---|
224 | **********************************************************************/
|
---|
225 |
|
---|
226 | static BOOL decode_port_info_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
227 | uint32 returned, PORT_INFO_2 **info)
|
---|
228 | {
|
---|
229 | uint32 i;
|
---|
230 | PORT_INFO_2 *inf;
|
---|
231 |
|
---|
232 | if (returned) {
|
---|
233 | inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_2, returned);
|
---|
234 | if (!inf) {
|
---|
235 | return False;
|
---|
236 | }
|
---|
237 | memset(inf, 0, returned*sizeof(PORT_INFO_2));
|
---|
238 | } else {
|
---|
239 | inf = NULL;
|
---|
240 | }
|
---|
241 |
|
---|
242 | prs_set_offset(&buffer->prs, 0);
|
---|
243 |
|
---|
244 | for (i=0; i<returned; i++) {
|
---|
245 | if (!smb_io_port_info_2("", buffer, &(inf[i]), 0)) {
|
---|
246 | return False;
|
---|
247 | }
|
---|
248 | }
|
---|
249 |
|
---|
250 | *info=inf;
|
---|
251 | return True;
|
---|
252 | }
|
---|
253 |
|
---|
254 | /**********************************************************************
|
---|
255 | **********************************************************************/
|
---|
256 |
|
---|
257 | static BOOL decode_printer_driver_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
258 | uint32 returned, DRIVER_INFO_1 **info)
|
---|
259 | {
|
---|
260 | uint32 i;
|
---|
261 | DRIVER_INFO_1 *inf;
|
---|
262 |
|
---|
263 | if (returned) {
|
---|
264 | inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_1, returned);
|
---|
265 | if (!inf) {
|
---|
266 | return False;
|
---|
267 | }
|
---|
268 | memset(inf, 0, returned*sizeof(DRIVER_INFO_1));
|
---|
269 | } else {
|
---|
270 | inf = NULL;
|
---|
271 | }
|
---|
272 |
|
---|
273 | prs_set_offset(&buffer->prs,0);
|
---|
274 |
|
---|
275 | for (i=0; i<returned; i++) {
|
---|
276 | if (!smb_io_printer_driver_info_1("", buffer, &(inf[i]), 0)) {
|
---|
277 | return False;
|
---|
278 | }
|
---|
279 | }
|
---|
280 |
|
---|
281 | *info=inf;
|
---|
282 | return True;
|
---|
283 | }
|
---|
284 |
|
---|
285 | /**********************************************************************
|
---|
286 | **********************************************************************/
|
---|
287 |
|
---|
288 | static BOOL decode_printer_driver_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
289 | uint32 returned, DRIVER_INFO_2 **info)
|
---|
290 | {
|
---|
291 | uint32 i;
|
---|
292 | DRIVER_INFO_2 *inf;
|
---|
293 |
|
---|
294 | if (returned) {
|
---|
295 | inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_2, returned);
|
---|
296 | if (!inf) {
|
---|
297 | return False;
|
---|
298 | }
|
---|
299 | memset(inf, 0, returned*sizeof(DRIVER_INFO_2));
|
---|
300 | } else {
|
---|
301 | inf = NULL;
|
---|
302 | }
|
---|
303 |
|
---|
304 | prs_set_offset(&buffer->prs,0);
|
---|
305 |
|
---|
306 | for (i=0; i<returned; i++) {
|
---|
307 | if (!smb_io_printer_driver_info_2("", buffer, &(inf[i]), 0)) {
|
---|
308 | return False;
|
---|
309 | }
|
---|
310 | }
|
---|
311 |
|
---|
312 | *info=inf;
|
---|
313 | return True;
|
---|
314 | }
|
---|
315 |
|
---|
316 | /**********************************************************************
|
---|
317 | **********************************************************************/
|
---|
318 |
|
---|
319 | static BOOL decode_printer_driver_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
320 | uint32 returned, DRIVER_INFO_3 **info)
|
---|
321 | {
|
---|
322 | uint32 i;
|
---|
323 | DRIVER_INFO_3 *inf;
|
---|
324 |
|
---|
325 | if (returned) {
|
---|
326 | inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_3, returned);
|
---|
327 | if (!inf) {
|
---|
328 | return False;
|
---|
329 | }
|
---|
330 | memset(inf, 0, returned*sizeof(DRIVER_INFO_3));
|
---|
331 | } else {
|
---|
332 | inf = NULL;
|
---|
333 | }
|
---|
334 |
|
---|
335 | prs_set_offset(&buffer->prs,0);
|
---|
336 |
|
---|
337 | for (i=0; i<returned; i++) {
|
---|
338 | if (!smb_io_printer_driver_info_3("", buffer, &(inf[i]), 0)) {
|
---|
339 | return False;
|
---|
340 | }
|
---|
341 | }
|
---|
342 |
|
---|
343 | *info=inf;
|
---|
344 | return True;
|
---|
345 | }
|
---|
346 |
|
---|
347 | /**********************************************************************
|
---|
348 | **********************************************************************/
|
---|
349 |
|
---|
350 | static BOOL decode_printerdriverdir_1 (TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
351 | uint32 returned, DRIVER_DIRECTORY_1 **info
|
---|
352 | )
|
---|
353 | {
|
---|
354 | DRIVER_DIRECTORY_1 *inf;
|
---|
355 |
|
---|
356 | inf=TALLOC_P(mem_ctx, DRIVER_DIRECTORY_1);
|
---|
357 | if (!inf) {
|
---|
358 | return False;
|
---|
359 | }
|
---|
360 | memset(inf, 0, sizeof(DRIVER_DIRECTORY_1));
|
---|
361 |
|
---|
362 | prs_set_offset(&buffer->prs, 0);
|
---|
363 |
|
---|
364 | if (!smb_io_driverdir_1("", buffer, inf, 0)) {
|
---|
365 | return False;
|
---|
366 | }
|
---|
367 |
|
---|
368 | *info=inf;
|
---|
369 | return True;
|
---|
370 | }
|
---|
371 |
|
---|
372 | /**********************************************************************
|
---|
373 | **********************************************************************/
|
---|
374 |
|
---|
375 | static BOOL decode_jobs_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
376 | uint32 num_jobs, JOB_INFO_1 **jobs)
|
---|
377 | {
|
---|
378 | uint32 i;
|
---|
379 |
|
---|
380 | if (num_jobs) {
|
---|
381 | *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_1, num_jobs);
|
---|
382 | if (*jobs == NULL) {
|
---|
383 | return False;
|
---|
384 | }
|
---|
385 | } else {
|
---|
386 | *jobs = NULL;
|
---|
387 | }
|
---|
388 | prs_set_offset(&buffer->prs,0);
|
---|
389 |
|
---|
390 | for (i = 0; i < num_jobs; i++) {
|
---|
391 | if (!smb_io_job_info_1("", buffer, &((*jobs)[i]), 0)) {
|
---|
392 | return False;
|
---|
393 | }
|
---|
394 | }
|
---|
395 |
|
---|
396 | return True;
|
---|
397 | }
|
---|
398 |
|
---|
399 | /**********************************************************************
|
---|
400 | **********************************************************************/
|
---|
401 |
|
---|
402 | static BOOL decode_jobs_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
403 | uint32 num_jobs, JOB_INFO_2 **jobs)
|
---|
404 | {
|
---|
405 | uint32 i;
|
---|
406 |
|
---|
407 | if (num_jobs) {
|
---|
408 | *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_2, num_jobs);
|
---|
409 | if (*jobs == NULL) {
|
---|
410 | return False;
|
---|
411 | }
|
---|
412 | } else {
|
---|
413 | *jobs = NULL;
|
---|
414 | }
|
---|
415 | prs_set_offset(&buffer->prs,0);
|
---|
416 |
|
---|
417 | for (i = 0; i < num_jobs; i++) {
|
---|
418 | if (!smb_io_job_info_2("", buffer, &((*jobs)[i]), 0)) {
|
---|
419 | return False;
|
---|
420 | }
|
---|
421 | }
|
---|
422 |
|
---|
423 | return True;
|
---|
424 | }
|
---|
425 |
|
---|
426 | /**********************************************************************
|
---|
427 | **********************************************************************/
|
---|
428 |
|
---|
429 | static BOOL decode_forms_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
|
---|
430 | uint32 num_forms, FORM_1 **forms)
|
---|
431 | {
|
---|
432 | int i;
|
---|
433 |
|
---|
434 | if (num_forms) {
|
---|
435 | *forms = TALLOC_ARRAY(mem_ctx, FORM_1, num_forms);
|
---|
436 | if (*forms == NULL) {
|
---|
437 | return False;
|
---|
438 | }
|
---|
439 | } else {
|
---|
440 | *forms = NULL;
|
---|
441 | }
|
---|
442 |
|
---|
443 | prs_set_offset(&buffer->prs,0);
|
---|
444 |
|
---|
445 | for (i = 0; i < num_forms; i++) {
|
---|
446 | if (!smb_io_form_1("", buffer, &((*forms)[i]), 0)) {
|
---|
447 | return False;
|
---|
448 | }
|
---|
449 | }
|
---|
450 |
|
---|
451 | return True;
|
---|
452 | }
|
---|
453 |
|
---|
454 | /**********************************************************************
|
---|
455 | **********************************************************************/
|
---|
456 |
|
---|
457 | WERROR rpccli_spoolss_open_printer_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
458 | const char *printername, const char *datatype, uint32 access_required,
|
---|
459 | const char *station, const char *username, POLICY_HND *pol)
|
---|
460 | {
|
---|
461 | prs_struct qbuf, rbuf;
|
---|
462 | SPOOL_Q_OPEN_PRINTER_EX in;
|
---|
463 | SPOOL_R_OPEN_PRINTER_EX out;
|
---|
464 |
|
---|
465 | ZERO_STRUCT(in);
|
---|
466 | ZERO_STRUCT(out);
|
---|
467 |
|
---|
468 | make_spoolss_q_open_printer_ex( &in, printername, datatype,
|
---|
469 | access_required, station, username );
|
---|
470 |
|
---|
471 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_OPENPRINTEREX,
|
---|
472 | in, out,
|
---|
473 | qbuf, rbuf,
|
---|
474 | spoolss_io_q_open_printer_ex,
|
---|
475 | spoolss_io_r_open_printer_ex,
|
---|
476 | WERR_GENERAL_FAILURE );
|
---|
477 |
|
---|
478 | memcpy( pol, &out.handle, sizeof(POLICY_HND) );
|
---|
479 |
|
---|
480 | return out.status;
|
---|
481 | }
|
---|
482 |
|
---|
483 | /**********************************************************************
|
---|
484 | **********************************************************************/
|
---|
485 |
|
---|
486 | WERROR rpccli_spoolss_close_printer(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
487 | POLICY_HND *pol)
|
---|
488 | {
|
---|
489 | prs_struct qbuf, rbuf;
|
---|
490 | SPOOL_Q_CLOSEPRINTER in;
|
---|
491 | SPOOL_R_CLOSEPRINTER out;
|
---|
492 |
|
---|
493 | ZERO_STRUCT(in);
|
---|
494 | ZERO_STRUCT(out);
|
---|
495 |
|
---|
496 | make_spoolss_q_closeprinter( &in, pol );
|
---|
497 |
|
---|
498 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_CLOSEPRINTER,
|
---|
499 | in, out,
|
---|
500 | qbuf, rbuf,
|
---|
501 | spoolss_io_q_closeprinter,
|
---|
502 | spoolss_io_r_closeprinter,
|
---|
503 | WERR_GENERAL_FAILURE );
|
---|
504 |
|
---|
505 | return out.status;
|
---|
506 | }
|
---|
507 |
|
---|
508 | /**********************************************************************
|
---|
509 | **********************************************************************/
|
---|
510 |
|
---|
511 | WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
512 | char *name, uint32 flags, uint32 level,
|
---|
513 | uint32 *num_printers, PRINTER_INFO_CTR *ctr)
|
---|
514 | {
|
---|
515 | prs_struct qbuf, rbuf;
|
---|
516 | SPOOL_Q_ENUMPRINTERS in;
|
---|
517 | SPOOL_R_ENUMPRINTERS out;
|
---|
518 | RPC_BUFFER buffer;
|
---|
519 | uint32 offered;
|
---|
520 |
|
---|
521 | ZERO_STRUCT(in);
|
---|
522 | ZERO_STRUCT(out);
|
---|
523 |
|
---|
524 | offered = 0;
|
---|
525 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
526 | make_spoolss_q_enumprinters( &in, flags, name, level, &buffer, offered );
|
---|
527 |
|
---|
528 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERS,
|
---|
529 | in, out,
|
---|
530 | qbuf, rbuf,
|
---|
531 | spoolss_io_q_enumprinters,
|
---|
532 | spoolss_io_r_enumprinters,
|
---|
533 | WERR_GENERAL_FAILURE );
|
---|
534 |
|
---|
535 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
536 | offered = out.needed;
|
---|
537 |
|
---|
538 | ZERO_STRUCT(in);
|
---|
539 | ZERO_STRUCT(out);
|
---|
540 |
|
---|
541 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
542 | make_spoolss_q_enumprinters( &in, flags, name, level, &buffer, offered );
|
---|
543 |
|
---|
544 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERS,
|
---|
545 | in, out,
|
---|
546 | qbuf, rbuf,
|
---|
547 | spoolss_io_q_enumprinters,
|
---|
548 | spoolss_io_r_enumprinters,
|
---|
549 | WERR_GENERAL_FAILURE );
|
---|
550 | }
|
---|
551 |
|
---|
552 | if ( !W_ERROR_IS_OK(out.status) )
|
---|
553 | return out.status;
|
---|
554 |
|
---|
555 | switch (level) {
|
---|
556 | case 0:
|
---|
557 | if (!decode_printer_info_0(mem_ctx, out.buffer, out.returned, &ctr->printers_0)) {
|
---|
558 | return WERR_GENERAL_FAILURE;
|
---|
559 | }
|
---|
560 | break;
|
---|
561 | case 1:
|
---|
562 | if (!decode_printer_info_1(mem_ctx, out.buffer, out.returned, &ctr->printers_1)) {
|
---|
563 | return WERR_GENERAL_FAILURE;
|
---|
564 | }
|
---|
565 | break;
|
---|
566 | case 2:
|
---|
567 | if (!decode_printer_info_2(mem_ctx, out.buffer, out.returned, &ctr->printers_2)) {
|
---|
568 | return WERR_GENERAL_FAILURE;
|
---|
569 | }
|
---|
570 | break;
|
---|
571 | case 3:
|
---|
572 | if (!decode_printer_info_3(mem_ctx, out.buffer, out.returned, &ctr->printers_3)) {
|
---|
573 | return WERR_GENERAL_FAILURE;
|
---|
574 | }
|
---|
575 | break;
|
---|
576 | default:
|
---|
577 | return WERR_UNKNOWN_LEVEL;
|
---|
578 | }
|
---|
579 |
|
---|
580 | *num_printers = out.returned;
|
---|
581 |
|
---|
582 | return out.status;
|
---|
583 | }
|
---|
584 |
|
---|
585 | /**********************************************************************
|
---|
586 | **********************************************************************/
|
---|
587 |
|
---|
588 | WERROR rpccli_spoolss_enum_ports(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
589 | uint32 level, uint32 *num_ports, PORT_INFO_CTR *ctr)
|
---|
590 | {
|
---|
591 | prs_struct qbuf, rbuf;
|
---|
592 | SPOOL_Q_ENUMPORTS in;
|
---|
593 | SPOOL_R_ENUMPORTS out;
|
---|
594 | RPC_BUFFER buffer;
|
---|
595 | fstring server;
|
---|
596 | uint32 offered;
|
---|
597 |
|
---|
598 | ZERO_STRUCT(in);
|
---|
599 | ZERO_STRUCT(out);
|
---|
600 |
|
---|
601 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
---|
602 | strupper_m(server);
|
---|
603 |
|
---|
604 | offered = 0;
|
---|
605 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
606 | make_spoolss_q_enumports( &in, server, level, &buffer, offered );
|
---|
607 |
|
---|
608 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPORTS,
|
---|
609 | in, out,
|
---|
610 | qbuf, rbuf,
|
---|
611 | spoolss_io_q_enumports,
|
---|
612 | spoolss_io_r_enumports,
|
---|
613 | WERR_GENERAL_FAILURE );
|
---|
614 |
|
---|
615 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
616 | offered = out.needed;
|
---|
617 |
|
---|
618 | ZERO_STRUCT(in);
|
---|
619 | ZERO_STRUCT(out);
|
---|
620 |
|
---|
621 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
622 | make_spoolss_q_enumports( &in, server, level, &buffer, offered );
|
---|
623 |
|
---|
624 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPORTS,
|
---|
625 | in, out,
|
---|
626 | qbuf, rbuf,
|
---|
627 | spoolss_io_q_enumports,
|
---|
628 | spoolss_io_r_enumports,
|
---|
629 | WERR_GENERAL_FAILURE );
|
---|
630 | }
|
---|
631 |
|
---|
632 | if ( !W_ERROR_IS_OK(out.status) )
|
---|
633 | return out.status;
|
---|
634 |
|
---|
635 | switch (level) {
|
---|
636 | case 1:
|
---|
637 | if (!decode_port_info_1(mem_ctx, out.buffer, out.returned, &ctr->port.info_1)) {
|
---|
638 | return WERR_GENERAL_FAILURE;
|
---|
639 | }
|
---|
640 | break;
|
---|
641 | case 2:
|
---|
642 | if (!decode_port_info_2(mem_ctx, out.buffer, out.returned, &ctr->port.info_2)) {
|
---|
643 | return WERR_GENERAL_FAILURE;
|
---|
644 | }
|
---|
645 | break;
|
---|
646 | default:
|
---|
647 | return WERR_UNKNOWN_LEVEL;
|
---|
648 | }
|
---|
649 |
|
---|
650 | *num_ports = out.returned;
|
---|
651 |
|
---|
652 | return out.status;
|
---|
653 | }
|
---|
654 |
|
---|
655 | /**********************************************************************
|
---|
656 | **********************************************************************/
|
---|
657 |
|
---|
658 | WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
659 | POLICY_HND *pol, uint32 level,
|
---|
660 | PRINTER_INFO_CTR *ctr)
|
---|
661 | {
|
---|
662 | prs_struct qbuf, rbuf;
|
---|
663 | SPOOL_Q_GETPRINTER in;
|
---|
664 | SPOOL_R_GETPRINTER out;
|
---|
665 | RPC_BUFFER buffer;
|
---|
666 | uint32 offered;
|
---|
667 |
|
---|
668 | ZERO_STRUCT(in);
|
---|
669 | ZERO_STRUCT(out);
|
---|
670 |
|
---|
671 | /* Initialise input parameters */
|
---|
672 |
|
---|
673 | offered = 0;
|
---|
674 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
675 | make_spoolss_q_getprinter( mem_ctx, &in, pol, level, &buffer, offered );
|
---|
676 |
|
---|
677 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTER,
|
---|
678 | in, out,
|
---|
679 | qbuf, rbuf,
|
---|
680 | spoolss_io_q_getprinter,
|
---|
681 | spoolss_io_r_getprinter,
|
---|
682 | WERR_GENERAL_FAILURE );
|
---|
683 |
|
---|
684 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
685 | offered = out.needed;
|
---|
686 |
|
---|
687 | ZERO_STRUCT(in);
|
---|
688 | ZERO_STRUCT(out);
|
---|
689 |
|
---|
690 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
691 | make_spoolss_q_getprinter( mem_ctx, &in, pol, level, &buffer, offered );
|
---|
692 |
|
---|
693 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTER,
|
---|
694 | in, out,
|
---|
695 | qbuf, rbuf,
|
---|
696 | spoolss_io_q_getprinter,
|
---|
697 | spoolss_io_r_getprinter,
|
---|
698 | WERR_GENERAL_FAILURE );
|
---|
699 | }
|
---|
700 |
|
---|
701 | if ( !W_ERROR_IS_OK(out.status) )
|
---|
702 | return out.status;
|
---|
703 |
|
---|
704 | switch (level) {
|
---|
705 | case 0:
|
---|
706 | if (!decode_printer_info_0(mem_ctx, out.buffer, 1, &ctr->printers_0)) {
|
---|
707 | return WERR_GENERAL_FAILURE;
|
---|
708 | }
|
---|
709 | break;
|
---|
710 | case 1:
|
---|
711 | if (!decode_printer_info_1(mem_ctx, out.buffer, 1, &ctr->printers_1)) {
|
---|
712 | return WERR_GENERAL_FAILURE;
|
---|
713 | }
|
---|
714 | break;
|
---|
715 | case 2:
|
---|
716 | if (!decode_printer_info_2(mem_ctx, out.buffer, 1, &ctr->printers_2)) {
|
---|
717 | return WERR_GENERAL_FAILURE;
|
---|
718 | }
|
---|
719 | break;
|
---|
720 | case 3:
|
---|
721 | if (!decode_printer_info_3(mem_ctx, out.buffer, 1, &ctr->printers_3)) {
|
---|
722 | return WERR_GENERAL_FAILURE;
|
---|
723 | }
|
---|
724 | break;
|
---|
725 | case 7:
|
---|
726 | if (!decode_printer_info_7(mem_ctx, out.buffer, 1, &ctr->printers_7)) {
|
---|
727 | return WERR_GENERAL_FAILURE;
|
---|
728 | }
|
---|
729 | break;
|
---|
730 | default:
|
---|
731 | return WERR_UNKNOWN_LEVEL;
|
---|
732 | }
|
---|
733 |
|
---|
734 | return out.status;
|
---|
735 | }
|
---|
736 |
|
---|
737 | /**********************************************************************
|
---|
738 | **********************************************************************/
|
---|
739 |
|
---|
740 | WERROR rpccli_spoolss_setprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
741 | POLICY_HND *pol, uint32 level,
|
---|
742 | PRINTER_INFO_CTR *ctr, uint32 command)
|
---|
743 | {
|
---|
744 | prs_struct qbuf, rbuf;
|
---|
745 | SPOOL_Q_SETPRINTER in;
|
---|
746 | SPOOL_R_SETPRINTER out;
|
---|
747 |
|
---|
748 | ZERO_STRUCT(in);
|
---|
749 | ZERO_STRUCT(out);
|
---|
750 |
|
---|
751 | make_spoolss_q_setprinter( mem_ctx, &in, pol, level, ctr, command );
|
---|
752 |
|
---|
753 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_SETPRINTER,
|
---|
754 | in, out,
|
---|
755 | qbuf, rbuf,
|
---|
756 | spoolss_io_q_setprinter,
|
---|
757 | spoolss_io_r_setprinter,
|
---|
758 | WERR_GENERAL_FAILURE );
|
---|
759 |
|
---|
760 | return out.status;
|
---|
761 | }
|
---|
762 |
|
---|
763 | /**********************************************************************
|
---|
764 | **********************************************************************/
|
---|
765 |
|
---|
766 | WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
|
---|
767 | TALLOC_CTX *mem_ctx,
|
---|
768 | POLICY_HND *pol, uint32 level,
|
---|
769 | const char *env, int version, PRINTER_DRIVER_CTR *ctr)
|
---|
770 | {
|
---|
771 | prs_struct qbuf, rbuf;
|
---|
772 | SPOOL_Q_GETPRINTERDRIVER2 in;
|
---|
773 | SPOOL_R_GETPRINTERDRIVER2 out;
|
---|
774 | RPC_BUFFER buffer;
|
---|
775 | fstring server;
|
---|
776 | uint32 offered;
|
---|
777 |
|
---|
778 | ZERO_STRUCT(in);
|
---|
779 | ZERO_STRUCT(out);
|
---|
780 |
|
---|
781 | fstrcpy(server, cli->cli->desthost);
|
---|
782 | strupper_m(server);
|
---|
783 |
|
---|
784 | offered = 0;
|
---|
785 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
786 | make_spoolss_q_getprinterdriver2( &in, pol, env, level,
|
---|
787 | version, 2, &buffer, offered);
|
---|
788 |
|
---|
789 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDRIVER2,
|
---|
790 | in, out,
|
---|
791 | qbuf, rbuf,
|
---|
792 | spoolss_io_q_getprinterdriver2,
|
---|
793 | spoolss_io_r_getprinterdriver2,
|
---|
794 | WERR_GENERAL_FAILURE );
|
---|
795 |
|
---|
796 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
797 | offered = out.needed;
|
---|
798 |
|
---|
799 | ZERO_STRUCT(in);
|
---|
800 | ZERO_STRUCT(out);
|
---|
801 |
|
---|
802 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
803 | make_spoolss_q_getprinterdriver2( &in, pol, env, level,
|
---|
804 | version, 2, &buffer, offered);
|
---|
805 |
|
---|
806 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDRIVER2,
|
---|
807 | in, out,
|
---|
808 | qbuf, rbuf,
|
---|
809 | spoolss_io_q_getprinterdriver2,
|
---|
810 | spoolss_io_r_getprinterdriver2,
|
---|
811 | WERR_GENERAL_FAILURE );
|
---|
812 | }
|
---|
813 |
|
---|
814 | if ( !W_ERROR_IS_OK(out.status) )
|
---|
815 | return out.status;
|
---|
816 |
|
---|
817 | switch (level) {
|
---|
818 | case 1:
|
---|
819 | if (!decode_printer_driver_1(mem_ctx, out.buffer, 1, &ctr->info1)) {
|
---|
820 | return WERR_GENERAL_FAILURE;
|
---|
821 | }
|
---|
822 | break;
|
---|
823 | case 2:
|
---|
824 | if (!decode_printer_driver_2(mem_ctx, out.buffer, 1, &ctr->info2)) {
|
---|
825 | return WERR_GENERAL_FAILURE;
|
---|
826 | }
|
---|
827 | break;
|
---|
828 | case 3:
|
---|
829 | if (!decode_printer_driver_3(mem_ctx, out.buffer, 1, &ctr->info3)) {
|
---|
830 | return WERR_GENERAL_FAILURE;
|
---|
831 | }
|
---|
832 | break;
|
---|
833 | default:
|
---|
834 | return WERR_UNKNOWN_LEVEL;
|
---|
835 | }
|
---|
836 |
|
---|
837 | return out.status;
|
---|
838 | }
|
---|
839 |
|
---|
840 | /**********************************************************************
|
---|
841 | **********************************************************************/
|
---|
842 |
|
---|
843 | WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
|
---|
844 | TALLOC_CTX *mem_ctx,
|
---|
845 | uint32 level, const char *env,
|
---|
846 | uint32 *num_drivers,
|
---|
847 | PRINTER_DRIVER_CTR *ctr)
|
---|
848 | {
|
---|
849 | prs_struct qbuf, rbuf;
|
---|
850 | SPOOL_Q_ENUMPRINTERDRIVERS in;
|
---|
851 | SPOOL_R_ENUMPRINTERDRIVERS out;
|
---|
852 | RPC_BUFFER buffer;
|
---|
853 | fstring server;
|
---|
854 | uint32 offered;
|
---|
855 |
|
---|
856 | ZERO_STRUCT(in);
|
---|
857 | ZERO_STRUCT(out);
|
---|
858 |
|
---|
859 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
---|
860 | strupper_m(server);
|
---|
861 |
|
---|
862 | offered = 0;
|
---|
863 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
864 | make_spoolss_q_enumprinterdrivers( &in, server, env, level,
|
---|
865 | &buffer, offered);
|
---|
866 |
|
---|
867 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERDRIVERS,
|
---|
868 | in, out,
|
---|
869 | qbuf, rbuf,
|
---|
870 | spoolss_io_q_enumprinterdrivers,
|
---|
871 | spoolss_io_r_enumprinterdrivers,
|
---|
872 | WERR_GENERAL_FAILURE );
|
---|
873 |
|
---|
874 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
875 | offered = out.needed;
|
---|
876 |
|
---|
877 | ZERO_STRUCT(in);
|
---|
878 | ZERO_STRUCT(out);
|
---|
879 |
|
---|
880 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
881 | make_spoolss_q_enumprinterdrivers( &in, server, env, level,
|
---|
882 | &buffer, offered);
|
---|
883 |
|
---|
884 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERDRIVERS,
|
---|
885 | in, out,
|
---|
886 | qbuf, rbuf,
|
---|
887 | spoolss_io_q_enumprinterdrivers,
|
---|
888 | spoolss_io_r_enumprinterdrivers,
|
---|
889 | WERR_GENERAL_FAILURE );
|
---|
890 | }
|
---|
891 |
|
---|
892 | *num_drivers = out.returned;
|
---|
893 |
|
---|
894 | if ( !W_ERROR_IS_OK(out.status) )
|
---|
895 | return out.status;
|
---|
896 |
|
---|
897 | if ( out.returned ) {
|
---|
898 |
|
---|
899 | switch (level) {
|
---|
900 | case 1:
|
---|
901 | if (!decode_printer_driver_1(mem_ctx, out.buffer, out.returned, &ctr->info1)) {
|
---|
902 | return WERR_GENERAL_FAILURE;
|
---|
903 | }
|
---|
904 | break;
|
---|
905 | case 2:
|
---|
906 | if (!decode_printer_driver_2(mem_ctx, out.buffer, out.returned, &ctr->info2)) {
|
---|
907 | return WERR_GENERAL_FAILURE;
|
---|
908 | }
|
---|
909 | break;
|
---|
910 | case 3:
|
---|
911 | if (!decode_printer_driver_3(mem_ctx, out.buffer, out.returned, &ctr->info3)) {
|
---|
912 | return WERR_GENERAL_FAILURE;
|
---|
913 | }
|
---|
914 | break;
|
---|
915 | default:
|
---|
916 | return WERR_UNKNOWN_LEVEL;
|
---|
917 | }
|
---|
918 | }
|
---|
919 |
|
---|
920 | return out.status;
|
---|
921 | }
|
---|
922 |
|
---|
923 |
|
---|
924 | /**********************************************************************
|
---|
925 | **********************************************************************/
|
---|
926 |
|
---|
927 | WERROR rpccli_spoolss_getprinterdriverdir (struct rpc_pipe_client *cli,
|
---|
928 | TALLOC_CTX *mem_ctx,
|
---|
929 | uint32 level, char *env,
|
---|
930 | DRIVER_DIRECTORY_CTR *ctr)
|
---|
931 | {
|
---|
932 | prs_struct qbuf, rbuf;
|
---|
933 | SPOOL_Q_GETPRINTERDRIVERDIR in;
|
---|
934 | SPOOL_R_GETPRINTERDRIVERDIR out;
|
---|
935 | RPC_BUFFER buffer;
|
---|
936 | fstring server;
|
---|
937 | uint32 offered;
|
---|
938 |
|
---|
939 | ZERO_STRUCT(in);
|
---|
940 | ZERO_STRUCT(out);
|
---|
941 |
|
---|
942 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
---|
943 | strupper_m(server);
|
---|
944 |
|
---|
945 | offered = 0;
|
---|
946 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
947 | make_spoolss_q_getprinterdriverdir( &in, server, env, level,
|
---|
948 | &buffer, offered );
|
---|
949 |
|
---|
950 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDRIVERDIRECTORY,
|
---|
951 | in, out,
|
---|
952 | qbuf, rbuf,
|
---|
953 | spoolss_io_q_getprinterdriverdir,
|
---|
954 | spoolss_io_r_getprinterdriverdir,
|
---|
955 | WERR_GENERAL_FAILURE );
|
---|
956 |
|
---|
957 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
958 | offered = out.needed;
|
---|
959 |
|
---|
960 | ZERO_STRUCT(in);
|
---|
961 | ZERO_STRUCT(out);
|
---|
962 |
|
---|
963 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
964 | make_spoolss_q_getprinterdriverdir( &in, server, env, level,
|
---|
965 | &buffer, offered );
|
---|
966 |
|
---|
967 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDRIVERDIRECTORY,
|
---|
968 | in, out,
|
---|
969 | qbuf, rbuf,
|
---|
970 | spoolss_io_q_getprinterdriverdir,
|
---|
971 | spoolss_io_r_getprinterdriverdir,
|
---|
972 | WERR_GENERAL_FAILURE );
|
---|
973 | }
|
---|
974 |
|
---|
975 | if (!W_ERROR_IS_OK(out.status))
|
---|
976 | return out.status;
|
---|
977 |
|
---|
978 | if (!decode_printerdriverdir_1(mem_ctx, out.buffer, 1, &ctr->info1)) {
|
---|
979 | return WERR_GENERAL_FAILURE;
|
---|
980 | }
|
---|
981 |
|
---|
982 | return out.status;
|
---|
983 | }
|
---|
984 |
|
---|
985 | /**********************************************************************
|
---|
986 | **********************************************************************/
|
---|
987 |
|
---|
988 | WERROR rpccli_spoolss_addprinterdriver (struct rpc_pipe_client *cli,
|
---|
989 | TALLOC_CTX *mem_ctx, uint32 level,
|
---|
990 | PRINTER_DRIVER_CTR *ctr)
|
---|
991 | {
|
---|
992 | prs_struct qbuf, rbuf;
|
---|
993 | SPOOL_Q_ADDPRINTERDRIVER in;
|
---|
994 | SPOOL_R_ADDPRINTERDRIVER out;
|
---|
995 | fstring server;
|
---|
996 |
|
---|
997 | ZERO_STRUCT(in);
|
---|
998 | ZERO_STRUCT(out);
|
---|
999 |
|
---|
1000 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
---|
1001 | strupper_m(server);
|
---|
1002 |
|
---|
1003 | make_spoolss_q_addprinterdriver( mem_ctx, &in, server, level, ctr );
|
---|
1004 |
|
---|
1005 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ADDPRINTERDRIVER,
|
---|
1006 | in, out,
|
---|
1007 | qbuf, rbuf,
|
---|
1008 | spoolss_io_q_addprinterdriver,
|
---|
1009 | spoolss_io_r_addprinterdriver,
|
---|
1010 | WERR_GENERAL_FAILURE );
|
---|
1011 |
|
---|
1012 | return out.status;
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | /**********************************************************************
|
---|
1016 | **********************************************************************/
|
---|
1017 |
|
---|
1018 | WERROR rpccli_spoolss_addprinterex (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1019 | uint32 level, PRINTER_INFO_CTR*ctr)
|
---|
1020 | {
|
---|
1021 | prs_struct qbuf, rbuf;
|
---|
1022 | SPOOL_Q_ADDPRINTEREX in;
|
---|
1023 | SPOOL_R_ADDPRINTEREX out;
|
---|
1024 | fstring server, client, user;
|
---|
1025 |
|
---|
1026 | ZERO_STRUCT(in);
|
---|
1027 | ZERO_STRUCT(out);
|
---|
1028 |
|
---|
1029 | slprintf(client, sizeof(fstring)-1, "\\\\%s", global_myname());
|
---|
1030 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
---|
1031 |
|
---|
1032 | strupper_m(client);
|
---|
1033 | strupper_m(server);
|
---|
1034 |
|
---|
1035 | fstrcpy (user, cli->user_name);
|
---|
1036 |
|
---|
1037 | make_spoolss_q_addprinterex( mem_ctx, &in, server, client,
|
---|
1038 | user, level, ctr);
|
---|
1039 |
|
---|
1040 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ADDPRINTEREX,
|
---|
1041 | in, out,
|
---|
1042 | qbuf, rbuf,
|
---|
1043 | spoolss_io_q_addprinterex,
|
---|
1044 | spoolss_io_r_addprinterex,
|
---|
1045 | WERR_GENERAL_FAILURE );
|
---|
1046 |
|
---|
1047 | return out.status;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | /**********************************************************************
|
---|
1051 | **********************************************************************/
|
---|
1052 |
|
---|
1053 | WERROR rpccli_spoolss_deleteprinterdriverex(struct rpc_pipe_client *cli,
|
---|
1054 | TALLOC_CTX *mem_ctx, const char *arch,
|
---|
1055 | const char *driver, int version)
|
---|
1056 | {
|
---|
1057 | prs_struct qbuf, rbuf;
|
---|
1058 | SPOOL_Q_DELETEPRINTERDRIVEREX in;
|
---|
1059 | SPOOL_R_DELETEPRINTERDRIVEREX out;
|
---|
1060 | fstring server;
|
---|
1061 |
|
---|
1062 | ZERO_STRUCT(in);
|
---|
1063 | ZERO_STRUCT(out);
|
---|
1064 |
|
---|
1065 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
---|
1066 | strupper_m(server);
|
---|
1067 |
|
---|
1068 | make_spoolss_q_deleteprinterdriverex( mem_ctx, &in, server, arch, driver, version );
|
---|
1069 |
|
---|
1070 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_DELETEPRINTERDRIVEREX,
|
---|
1071 | in, out,
|
---|
1072 | qbuf, rbuf,
|
---|
1073 | spoolss_io_q_deleteprinterdriverex,
|
---|
1074 | spoolss_io_r_deleteprinterdriverex,
|
---|
1075 | WERR_GENERAL_FAILURE );
|
---|
1076 |
|
---|
1077 | return out.status;
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | /**********************************************************************
|
---|
1081 | **********************************************************************/
|
---|
1082 |
|
---|
1083 | WERROR rpccli_spoolss_deleteprinterdriver (struct rpc_pipe_client *cli,
|
---|
1084 | TALLOC_CTX *mem_ctx, const char *arch,
|
---|
1085 | const char *driver)
|
---|
1086 | {
|
---|
1087 | prs_struct qbuf, rbuf;
|
---|
1088 | SPOOL_Q_DELETEPRINTERDRIVER in;
|
---|
1089 | SPOOL_R_DELETEPRINTERDRIVER out;
|
---|
1090 | fstring server;
|
---|
1091 |
|
---|
1092 | ZERO_STRUCT(in);
|
---|
1093 | ZERO_STRUCT(out);
|
---|
1094 |
|
---|
1095 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
---|
1096 | strupper_m(server);
|
---|
1097 |
|
---|
1098 | make_spoolss_q_deleteprinterdriver( mem_ctx, &in, server, arch, driver );
|
---|
1099 |
|
---|
1100 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_DELETEPRINTERDRIVER,
|
---|
1101 | in, out,
|
---|
1102 | qbuf, rbuf,
|
---|
1103 | spoolss_io_q_deleteprinterdriver,
|
---|
1104 | spoolss_io_r_deleteprinterdriver,
|
---|
1105 | WERR_GENERAL_FAILURE );
|
---|
1106 |
|
---|
1107 | return out.status;
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | /**********************************************************************
|
---|
1111 | **********************************************************************/
|
---|
1112 |
|
---|
1113 | WERROR rpccli_spoolss_getprintprocessordirectory(struct rpc_pipe_client *cli,
|
---|
1114 | TALLOC_CTX *mem_ctx,
|
---|
1115 | char *name, char *environment,
|
---|
1116 | fstring procdir)
|
---|
1117 | {
|
---|
1118 | prs_struct qbuf, rbuf;
|
---|
1119 | SPOOL_Q_GETPRINTPROCESSORDIRECTORY in;
|
---|
1120 | SPOOL_R_GETPRINTPROCESSORDIRECTORY out;
|
---|
1121 | int level = 1;
|
---|
1122 | RPC_BUFFER buffer;
|
---|
1123 | uint32 offered;
|
---|
1124 |
|
---|
1125 | ZERO_STRUCT(in);
|
---|
1126 | ZERO_STRUCT(out);
|
---|
1127 |
|
---|
1128 | offered = 0;
|
---|
1129 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1130 | make_spoolss_q_getprintprocessordirectory( &in, name,
|
---|
1131 | environment, level, &buffer, offered );
|
---|
1132 |
|
---|
1133 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTPROCESSORDIRECTORY,
|
---|
1134 | in, out,
|
---|
1135 | qbuf, rbuf,
|
---|
1136 | spoolss_io_q_getprintprocessordirectory,
|
---|
1137 | spoolss_io_r_getprintprocessordirectory,
|
---|
1138 | WERR_GENERAL_FAILURE );
|
---|
1139 |
|
---|
1140 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
1141 | offered = out.needed;
|
---|
1142 |
|
---|
1143 | ZERO_STRUCT(in);
|
---|
1144 | ZERO_STRUCT(out);
|
---|
1145 |
|
---|
1146 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1147 | make_spoolss_q_getprintprocessordirectory( &in, name,
|
---|
1148 | environment, level, &buffer, offered );
|
---|
1149 |
|
---|
1150 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTPROCESSORDIRECTORY,
|
---|
1151 | in, out,
|
---|
1152 | qbuf, rbuf,
|
---|
1153 | spoolss_io_q_getprintprocessordirectory,
|
---|
1154 | spoolss_io_r_getprintprocessordirectory,
|
---|
1155 | WERR_GENERAL_FAILURE );
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | if ( !W_ERROR_IS_OK(out.status) )
|
---|
1159 | return out.status;
|
---|
1160 |
|
---|
1161 | fstrcpy(procdir, "Not implemented!");
|
---|
1162 |
|
---|
1163 | return out.status;
|
---|
1164 | }
|
---|
1165 |
|
---|
1166 | /**********************************************************************
|
---|
1167 | **********************************************************************/
|
---|
1168 |
|
---|
1169 | WERROR rpccli_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1170 | POLICY_HND *handle, uint32 level, FORM *form)
|
---|
1171 | {
|
---|
1172 | prs_struct qbuf, rbuf;
|
---|
1173 | SPOOL_Q_ADDFORM in;
|
---|
1174 | SPOOL_R_ADDFORM out;
|
---|
1175 |
|
---|
1176 | ZERO_STRUCT(in);
|
---|
1177 | ZERO_STRUCT(out);
|
---|
1178 |
|
---|
1179 | make_spoolss_q_addform( &in, handle, level, form );
|
---|
1180 |
|
---|
1181 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ADDFORM,
|
---|
1182 | in, out,
|
---|
1183 | qbuf, rbuf,
|
---|
1184 | spoolss_io_q_addform,
|
---|
1185 | spoolss_io_r_addform,
|
---|
1186 | WERR_GENERAL_FAILURE );
|
---|
1187 |
|
---|
1188 | return out.status;
|
---|
1189 | }
|
---|
1190 |
|
---|
1191 | /**********************************************************************
|
---|
1192 | **********************************************************************/
|
---|
1193 |
|
---|
1194 | WERROR rpccli_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1195 | POLICY_HND *handle, uint32 level,
|
---|
1196 | const char *form_name, FORM *form)
|
---|
1197 | {
|
---|
1198 | prs_struct qbuf, rbuf;
|
---|
1199 | SPOOL_Q_SETFORM in;
|
---|
1200 | SPOOL_R_SETFORM out;
|
---|
1201 |
|
---|
1202 | ZERO_STRUCT(in);
|
---|
1203 | ZERO_STRUCT(out);
|
---|
1204 |
|
---|
1205 | make_spoolss_q_setform( &in, handle, level, form_name, form );
|
---|
1206 |
|
---|
1207 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_SETFORM,
|
---|
1208 | in, out,
|
---|
1209 | qbuf, rbuf,
|
---|
1210 | spoolss_io_q_setform,
|
---|
1211 | spoolss_io_r_setform,
|
---|
1212 | WERR_GENERAL_FAILURE );
|
---|
1213 |
|
---|
1214 | return out.status;
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | /**********************************************************************
|
---|
1218 | **********************************************************************/
|
---|
1219 |
|
---|
1220 | WERROR rpccli_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1221 | POLICY_HND *handle, const char *formname,
|
---|
1222 | uint32 level, FORM_1 *form)
|
---|
1223 | {
|
---|
1224 | prs_struct qbuf, rbuf;
|
---|
1225 | SPOOL_Q_GETFORM in;
|
---|
1226 | SPOOL_R_GETFORM out;
|
---|
1227 | RPC_BUFFER buffer;
|
---|
1228 | uint32 offered;
|
---|
1229 |
|
---|
1230 | ZERO_STRUCT(in);
|
---|
1231 | ZERO_STRUCT(out);
|
---|
1232 |
|
---|
1233 | offered = 0;
|
---|
1234 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1235 | make_spoolss_q_getform( &in, handle, formname, level, &buffer, offered );
|
---|
1236 |
|
---|
1237 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETFORM,
|
---|
1238 | in, out,
|
---|
1239 | qbuf, rbuf,
|
---|
1240 | spoolss_io_q_getform,
|
---|
1241 | spoolss_io_r_getform,
|
---|
1242 | WERR_GENERAL_FAILURE );
|
---|
1243 |
|
---|
1244 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
1245 | offered = out.needed;
|
---|
1246 |
|
---|
1247 | ZERO_STRUCT(in);
|
---|
1248 | ZERO_STRUCT(out);
|
---|
1249 |
|
---|
1250 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1251 | make_spoolss_q_getform( &in, handle, formname, level, &buffer, offered );
|
---|
1252 |
|
---|
1253 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETFORM,
|
---|
1254 | in, out,
|
---|
1255 | qbuf, rbuf,
|
---|
1256 | spoolss_io_q_getform,
|
---|
1257 | spoolss_io_r_getform,
|
---|
1258 | WERR_GENERAL_FAILURE );
|
---|
1259 | }
|
---|
1260 |
|
---|
1261 | if (!W_ERROR_IS_OK(out.status))
|
---|
1262 | return out.status;
|
---|
1263 |
|
---|
1264 | if (!smb_io_form_1("", out.buffer, form, 0)) {
|
---|
1265 | return WERR_GENERAL_FAILURE;
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 | return out.status;
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | /**********************************************************************
|
---|
1272 | **********************************************************************/
|
---|
1273 |
|
---|
1274 | WERROR rpccli_spoolss_deleteform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1275 | POLICY_HND *handle, const char *form_name)
|
---|
1276 | {
|
---|
1277 | prs_struct qbuf, rbuf;
|
---|
1278 | SPOOL_Q_DELETEFORM in;
|
---|
1279 | SPOOL_R_DELETEFORM out;
|
---|
1280 |
|
---|
1281 | ZERO_STRUCT(in);
|
---|
1282 | ZERO_STRUCT(out);
|
---|
1283 |
|
---|
1284 | make_spoolss_q_deleteform( &in, handle, form_name );
|
---|
1285 |
|
---|
1286 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_DELETEFORM,
|
---|
1287 | in, out,
|
---|
1288 | qbuf, rbuf,
|
---|
1289 | spoolss_io_q_deleteform,
|
---|
1290 | spoolss_io_r_deleteform,
|
---|
1291 | WERR_GENERAL_FAILURE );
|
---|
1292 |
|
---|
1293 | return out.status;
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | /**********************************************************************
|
---|
1297 | **********************************************************************/
|
---|
1298 |
|
---|
1299 | WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1300 | POLICY_HND *handle, int level, uint32 *num_forms,
|
---|
1301 | FORM_1 **forms)
|
---|
1302 | {
|
---|
1303 | prs_struct qbuf, rbuf;
|
---|
1304 | SPOOL_Q_ENUMFORMS in;
|
---|
1305 | SPOOL_R_ENUMFORMS out;
|
---|
1306 | RPC_BUFFER buffer;
|
---|
1307 | uint32 offered;
|
---|
1308 |
|
---|
1309 | ZERO_STRUCT(in);
|
---|
1310 | ZERO_STRUCT(out);
|
---|
1311 |
|
---|
1312 | offered = 0;
|
---|
1313 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1314 | make_spoolss_q_enumforms( &in, handle, level, &buffer, offered );
|
---|
1315 |
|
---|
1316 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMFORMS,
|
---|
1317 | in, out,
|
---|
1318 | qbuf, rbuf,
|
---|
1319 | spoolss_io_q_enumforms,
|
---|
1320 | spoolss_io_r_enumforms,
|
---|
1321 | WERR_GENERAL_FAILURE );
|
---|
1322 |
|
---|
1323 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
1324 | offered = out.needed;
|
---|
1325 |
|
---|
1326 | ZERO_STRUCT(in);
|
---|
1327 | ZERO_STRUCT(out);
|
---|
1328 |
|
---|
1329 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1330 | make_spoolss_q_enumforms( &in, handle, level, &buffer, offered );
|
---|
1331 |
|
---|
1332 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMFORMS,
|
---|
1333 | in, out,
|
---|
1334 | qbuf, rbuf,
|
---|
1335 | spoolss_io_q_enumforms,
|
---|
1336 | spoolss_io_r_enumforms,
|
---|
1337 | WERR_GENERAL_FAILURE );
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | if (!W_ERROR_IS_OK(out.status))
|
---|
1341 | return out.status;
|
---|
1342 |
|
---|
1343 | *num_forms = out.numofforms;
|
---|
1344 |
|
---|
1345 | if (!decode_forms_1(mem_ctx, out.buffer, *num_forms, forms)) {
|
---|
1346 | return WERR_GENERAL_FAILURE;
|
---|
1347 | }
|
---|
1348 |
|
---|
1349 | return out.status;
|
---|
1350 | }
|
---|
1351 |
|
---|
1352 | /**********************************************************************
|
---|
1353 | **********************************************************************/
|
---|
1354 |
|
---|
1355 | WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1356 | POLICY_HND *hnd, uint32 level, uint32 firstjob,
|
---|
1357 | uint32 num_jobs, uint32 *returned, JOB_INFO_CTR *ctr)
|
---|
1358 | {
|
---|
1359 | prs_struct qbuf, rbuf;
|
---|
1360 | SPOOL_Q_ENUMJOBS in;
|
---|
1361 | SPOOL_R_ENUMJOBS out;
|
---|
1362 | RPC_BUFFER buffer;
|
---|
1363 | uint32 offered;
|
---|
1364 |
|
---|
1365 | ZERO_STRUCT(in);
|
---|
1366 | ZERO_STRUCT(out);
|
---|
1367 |
|
---|
1368 | offered = 0;
|
---|
1369 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1370 | make_spoolss_q_enumjobs( &in, hnd, firstjob, num_jobs, level,
|
---|
1371 | &buffer, offered );
|
---|
1372 |
|
---|
1373 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMJOBS,
|
---|
1374 | in, out,
|
---|
1375 | qbuf, rbuf,
|
---|
1376 | spoolss_io_q_enumjobs,
|
---|
1377 | spoolss_io_r_enumjobs,
|
---|
1378 | WERR_GENERAL_FAILURE );
|
---|
1379 |
|
---|
1380 | if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
|
---|
1381 | offered = out.needed;
|
---|
1382 |
|
---|
1383 | ZERO_STRUCT(in);
|
---|
1384 | ZERO_STRUCT(out);
|
---|
1385 |
|
---|
1386 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1387 | make_spoolss_q_enumjobs( &in, hnd, firstjob, num_jobs, level,
|
---|
1388 | &buffer, offered );
|
---|
1389 |
|
---|
1390 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMJOBS,
|
---|
1391 | in, out,
|
---|
1392 | qbuf, rbuf,
|
---|
1393 | spoolss_io_q_enumjobs,
|
---|
1394 | spoolss_io_r_enumjobs,
|
---|
1395 | WERR_GENERAL_FAILURE );
|
---|
1396 | }
|
---|
1397 |
|
---|
1398 | if (!W_ERROR_IS_OK(out.status))
|
---|
1399 | return out.status;
|
---|
1400 |
|
---|
1401 | switch(level) {
|
---|
1402 | case 1:
|
---|
1403 | if (!decode_jobs_1(mem_ctx, out.buffer, out.returned, &ctr->job.job_info_1)) {
|
---|
1404 | return WERR_GENERAL_FAILURE;
|
---|
1405 | }
|
---|
1406 | break;
|
---|
1407 | case 2:
|
---|
1408 | if (!decode_jobs_2(mem_ctx, out.buffer, out.returned, &ctr->job.job_info_2)) {
|
---|
1409 | return WERR_GENERAL_FAILURE;
|
---|
1410 | }
|
---|
1411 | break;
|
---|
1412 | default:
|
---|
1413 | DEBUG(3, ("unsupported info level %d", level));
|
---|
1414 | return WERR_UNKNOWN_LEVEL;
|
---|
1415 | }
|
---|
1416 |
|
---|
1417 | *returned = out.returned;
|
---|
1418 |
|
---|
1419 | return out.status;
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | /**********************************************************************
|
---|
1423 | **********************************************************************/
|
---|
1424 |
|
---|
1425 | WERROR rpccli_spoolss_setjob(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1426 | POLICY_HND *hnd, uint32 jobid, uint32 level,
|
---|
1427 | uint32 command)
|
---|
1428 | {
|
---|
1429 | prs_struct qbuf, rbuf;
|
---|
1430 | SPOOL_Q_SETJOB in;
|
---|
1431 | SPOOL_R_SETJOB out;
|
---|
1432 |
|
---|
1433 | ZERO_STRUCT(in);
|
---|
1434 | ZERO_STRUCT(out);
|
---|
1435 |
|
---|
1436 | make_spoolss_q_setjob( &in, hnd, jobid, level, command );
|
---|
1437 |
|
---|
1438 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_SETJOB,
|
---|
1439 | in, out,
|
---|
1440 | qbuf, rbuf,
|
---|
1441 | spoolss_io_q_setjob,
|
---|
1442 | spoolss_io_r_setjob,
|
---|
1443 | WERR_GENERAL_FAILURE );
|
---|
1444 |
|
---|
1445 | return out.status;
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 | /**********************************************************************
|
---|
1449 | **********************************************************************/
|
---|
1450 |
|
---|
1451 | WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1452 | POLICY_HND *hnd, uint32 jobid, uint32 level,
|
---|
1453 | JOB_INFO_CTR *ctr)
|
---|
1454 | {
|
---|
1455 | prs_struct qbuf, rbuf;
|
---|
1456 | SPOOL_Q_GETJOB in;
|
---|
1457 | SPOOL_R_GETJOB out;
|
---|
1458 | RPC_BUFFER buffer;
|
---|
1459 | uint32 offered;
|
---|
1460 |
|
---|
1461 | ZERO_STRUCT(in);
|
---|
1462 | ZERO_STRUCT(out);
|
---|
1463 |
|
---|
1464 | offered = 0;
|
---|
1465 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1466 | make_spoolss_q_getjob( &in, hnd, jobid, level, &buffer, offered );
|
---|
1467 |
|
---|
1468 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETJOB,
|
---|
1469 | in, out,
|
---|
1470 | qbuf, rbuf,
|
---|
1471 | spoolss_io_q_getjob,
|
---|
1472 | spoolss_io_r_getjob,
|
---|
1473 | WERR_GENERAL_FAILURE );
|
---|
1474 |
|
---|
1475 | if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
|
---|
1476 | offered = out.needed;
|
---|
1477 |
|
---|
1478 | ZERO_STRUCT(in);
|
---|
1479 | ZERO_STRUCT(out);
|
---|
1480 |
|
---|
1481 | rpcbuf_init(&buffer, offered, mem_ctx);
|
---|
1482 | make_spoolss_q_getjob( &in, hnd, jobid, level, &buffer, offered );
|
---|
1483 |
|
---|
1484 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETJOB,
|
---|
1485 | in, out,
|
---|
1486 | qbuf, rbuf,
|
---|
1487 | spoolss_io_q_getjob,
|
---|
1488 | spoolss_io_r_getjob,
|
---|
1489 | WERR_GENERAL_FAILURE );
|
---|
1490 | }
|
---|
1491 |
|
---|
1492 | if (!W_ERROR_IS_OK(out.status))
|
---|
1493 | return out.status;
|
---|
1494 |
|
---|
1495 | switch(level) {
|
---|
1496 | case 1:
|
---|
1497 | if (!decode_jobs_1(mem_ctx, out.buffer, 1, &ctr->job.job_info_1)) {
|
---|
1498 | return WERR_GENERAL_FAILURE;
|
---|
1499 | }
|
---|
1500 | break;
|
---|
1501 | case 2:
|
---|
1502 | if (!decode_jobs_2(mem_ctx, out.buffer, 1, &ctr->job.job_info_2)) {
|
---|
1503 | return WERR_GENERAL_FAILURE;
|
---|
1504 | }
|
---|
1505 | break;
|
---|
1506 | default:
|
---|
1507 | return WERR_UNKNOWN_LEVEL;
|
---|
1508 | }
|
---|
1509 |
|
---|
1510 | return out.status;
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 | /**********************************************************************
|
---|
1514 | **********************************************************************/
|
---|
1515 |
|
---|
1516 | WERROR rpccli_spoolss_startpageprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1517 | POLICY_HND *hnd)
|
---|
1518 | {
|
---|
1519 | prs_struct qbuf, rbuf;
|
---|
1520 | SPOOL_Q_STARTPAGEPRINTER in;
|
---|
1521 | SPOOL_R_STARTPAGEPRINTER out;
|
---|
1522 |
|
---|
1523 | ZERO_STRUCT(in);
|
---|
1524 | ZERO_STRUCT(out);
|
---|
1525 |
|
---|
1526 | make_spoolss_q_startpageprinter( &in, hnd );
|
---|
1527 |
|
---|
1528 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_STARTPAGEPRINTER,
|
---|
1529 | in, out,
|
---|
1530 | qbuf, rbuf,
|
---|
1531 | spoolss_io_q_startpageprinter,
|
---|
1532 | spoolss_io_r_startpageprinter,
|
---|
1533 | WERR_GENERAL_FAILURE );
|
---|
1534 |
|
---|
1535 | return out.status;
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 | /**********************************************************************
|
---|
1539 | **********************************************************************/
|
---|
1540 |
|
---|
1541 | WERROR rpccli_spoolss_endpageprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1542 | POLICY_HND *hnd)
|
---|
1543 | {
|
---|
1544 | prs_struct qbuf, rbuf;
|
---|
1545 | SPOOL_Q_ENDPAGEPRINTER in;
|
---|
1546 | SPOOL_R_ENDPAGEPRINTER out;
|
---|
1547 |
|
---|
1548 | ZERO_STRUCT(in);
|
---|
1549 | ZERO_STRUCT(out);
|
---|
1550 |
|
---|
1551 | make_spoolss_q_endpageprinter( &in, hnd );
|
---|
1552 |
|
---|
1553 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENDPAGEPRINTER,
|
---|
1554 | in, out,
|
---|
1555 | qbuf, rbuf,
|
---|
1556 | spoolss_io_q_endpageprinter,
|
---|
1557 | spoolss_io_r_endpageprinter,
|
---|
1558 | WERR_GENERAL_FAILURE );
|
---|
1559 |
|
---|
1560 | return out.status;
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | /**********************************************************************
|
---|
1564 | **********************************************************************/
|
---|
1565 |
|
---|
1566 | WERROR rpccli_spoolss_startdocprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1567 | POLICY_HND *hnd, char *docname,
|
---|
1568 | char *outputfile, char *datatype,
|
---|
1569 | uint32 *jobid)
|
---|
1570 | {
|
---|
1571 | prs_struct qbuf, rbuf;
|
---|
1572 | SPOOL_Q_STARTDOCPRINTER in;
|
---|
1573 | SPOOL_R_STARTDOCPRINTER out;
|
---|
1574 | uint32 level = 1;
|
---|
1575 |
|
---|
1576 | ZERO_STRUCT(in);
|
---|
1577 | ZERO_STRUCT(out);
|
---|
1578 |
|
---|
1579 | make_spoolss_q_startdocprinter( &in, hnd, level, docname,
|
---|
1580 | outputfile, datatype );
|
---|
1581 |
|
---|
1582 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_STARTDOCPRINTER,
|
---|
1583 | in, out,
|
---|
1584 | qbuf, rbuf,
|
---|
1585 | spoolss_io_q_startdocprinter,
|
---|
1586 | spoolss_io_r_startdocprinter,
|
---|
1587 | WERR_GENERAL_FAILURE );
|
---|
1588 |
|
---|
1589 | *jobid = out.jobid;
|
---|
1590 |
|
---|
1591 | return out.status;
|
---|
1592 | }
|
---|
1593 |
|
---|
1594 | /**********************************************************************
|
---|
1595 | **********************************************************************/
|
---|
1596 |
|
---|
1597 | WERROR rpccli_spoolss_enddocprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1598 | POLICY_HND *hnd)
|
---|
1599 | {
|
---|
1600 | prs_struct qbuf, rbuf;
|
---|
1601 | SPOOL_Q_ENDDOCPRINTER in;
|
---|
1602 | SPOOL_R_ENDDOCPRINTER out;
|
---|
1603 |
|
---|
1604 | ZERO_STRUCT(in);
|
---|
1605 | ZERO_STRUCT(out);
|
---|
1606 |
|
---|
1607 | make_spoolss_q_enddocprinter( &in, hnd );
|
---|
1608 |
|
---|
1609 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENDDOCPRINTER,
|
---|
1610 | in, out,
|
---|
1611 | qbuf, rbuf,
|
---|
1612 | spoolss_io_q_enddocprinter,
|
---|
1613 | spoolss_io_r_enddocprinter,
|
---|
1614 | WERR_GENERAL_FAILURE );
|
---|
1615 |
|
---|
1616 | return out.status;
|
---|
1617 | }
|
---|
1618 |
|
---|
1619 | /**********************************************************************
|
---|
1620 | **********************************************************************/
|
---|
1621 |
|
---|
1622 | WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1623 | POLICY_HND *hnd, const char *valuename,
|
---|
1624 | REGISTRY_VALUE *value)
|
---|
1625 | {
|
---|
1626 | prs_struct qbuf, rbuf;
|
---|
1627 | SPOOL_Q_GETPRINTERDATA in;
|
---|
1628 | SPOOL_R_GETPRINTERDATA out;
|
---|
1629 | uint32 offered;
|
---|
1630 |
|
---|
1631 | ZERO_STRUCT(in);
|
---|
1632 | ZERO_STRUCT(out);
|
---|
1633 |
|
---|
1634 | offered = 0;
|
---|
1635 | make_spoolss_q_getprinterdata( &in, hnd, valuename, offered );
|
---|
1636 |
|
---|
1637 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDATA,
|
---|
1638 | in, out,
|
---|
1639 | qbuf, rbuf,
|
---|
1640 | spoolss_io_q_getprinterdata,
|
---|
1641 | spoolss_io_r_getprinterdata,
|
---|
1642 | WERR_GENERAL_FAILURE );
|
---|
1643 |
|
---|
1644 | if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
|
---|
1645 | offered = out.needed;
|
---|
1646 |
|
---|
1647 | ZERO_STRUCT(in);
|
---|
1648 | ZERO_STRUCT(out);
|
---|
1649 |
|
---|
1650 | make_spoolss_q_getprinterdata( &in, hnd, valuename, offered );
|
---|
1651 |
|
---|
1652 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDATA,
|
---|
1653 | in, out,
|
---|
1654 | qbuf, rbuf,
|
---|
1655 | spoolss_io_q_getprinterdata,
|
---|
1656 | spoolss_io_r_getprinterdata,
|
---|
1657 | WERR_GENERAL_FAILURE );
|
---|
1658 | }
|
---|
1659 |
|
---|
1660 | if (!W_ERROR_IS_OK(out.status))
|
---|
1661 | return out.status;
|
---|
1662 |
|
---|
1663 | /* Return output parameters */
|
---|
1664 |
|
---|
1665 | if (out.needed) {
|
---|
1666 | value->data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, out.data, out.needed);
|
---|
1667 | } else {
|
---|
1668 | value->data_p = NULL;
|
---|
1669 | }
|
---|
1670 | value->type = out.type;
|
---|
1671 | value->size = out.size;
|
---|
1672 |
|
---|
1673 | return out.status;
|
---|
1674 | }
|
---|
1675 |
|
---|
1676 | /**********************************************************************
|
---|
1677 | **********************************************************************/
|
---|
1678 |
|
---|
1679 | WERROR rpccli_spoolss_getprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1680 | POLICY_HND *hnd, const char *keyname,
|
---|
1681 | const char *valuename,
|
---|
1682 | REGISTRY_VALUE *value)
|
---|
1683 | {
|
---|
1684 | prs_struct qbuf, rbuf;
|
---|
1685 | SPOOL_Q_GETPRINTERDATAEX in;
|
---|
1686 | SPOOL_R_GETPRINTERDATAEX out;
|
---|
1687 | uint32 offered = 0;
|
---|
1688 |
|
---|
1689 | ZERO_STRUCT(in);
|
---|
1690 | ZERO_STRUCT(out);
|
---|
1691 |
|
---|
1692 | make_spoolss_q_getprinterdataex( &in, hnd, keyname, valuename, offered );
|
---|
1693 |
|
---|
1694 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDATAEX,
|
---|
1695 | in, out,
|
---|
1696 | qbuf, rbuf,
|
---|
1697 | spoolss_io_q_getprinterdataex,
|
---|
1698 | spoolss_io_r_getprinterdataex,
|
---|
1699 | WERR_GENERAL_FAILURE );
|
---|
1700 |
|
---|
1701 | if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
|
---|
1702 | offered = out.needed;
|
---|
1703 |
|
---|
1704 | ZERO_STRUCT(in);
|
---|
1705 | ZERO_STRUCT(out);
|
---|
1706 |
|
---|
1707 | make_spoolss_q_getprinterdataex( &in, hnd, keyname, valuename, offered );
|
---|
1708 |
|
---|
1709 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_GETPRINTERDATAEX,
|
---|
1710 | in, out,
|
---|
1711 | qbuf, rbuf,
|
---|
1712 | spoolss_io_q_getprinterdataex,
|
---|
1713 | spoolss_io_r_getprinterdataex,
|
---|
1714 | WERR_GENERAL_FAILURE );
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 | if (!W_ERROR_IS_OK(out.status))
|
---|
1718 | return out.status;
|
---|
1719 |
|
---|
1720 | /* Return output parameters */
|
---|
1721 |
|
---|
1722 | if (out.needed) {
|
---|
1723 | value->data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, out.data, out.needed);
|
---|
1724 | } else {
|
---|
1725 | value->data_p = NULL;
|
---|
1726 | }
|
---|
1727 | value->type = out.type;
|
---|
1728 | value->size = out.needed;
|
---|
1729 |
|
---|
1730 | return out.status;
|
---|
1731 | }
|
---|
1732 |
|
---|
1733 | /**********************************************************************
|
---|
1734 | **********************************************************************/
|
---|
1735 |
|
---|
1736 | WERROR rpccli_spoolss_setprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1737 | POLICY_HND *hnd, REGISTRY_VALUE *value)
|
---|
1738 | {
|
---|
1739 | prs_struct qbuf, rbuf;
|
---|
1740 | SPOOL_Q_SETPRINTERDATA in;
|
---|
1741 | SPOOL_R_SETPRINTERDATA out;
|
---|
1742 |
|
---|
1743 | ZERO_STRUCT(in);
|
---|
1744 | ZERO_STRUCT(out);
|
---|
1745 |
|
---|
1746 | make_spoolss_q_setprinterdata( &in, hnd, value->valuename,
|
---|
1747 | value->type, (char *)value->data_p, value->size);
|
---|
1748 |
|
---|
1749 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_SETPRINTERDATA,
|
---|
1750 | in, out,
|
---|
1751 | qbuf, rbuf,
|
---|
1752 | spoolss_io_q_setprinterdata,
|
---|
1753 | spoolss_io_r_setprinterdata,
|
---|
1754 | WERR_GENERAL_FAILURE );
|
---|
1755 |
|
---|
1756 | return out.status;
|
---|
1757 | }
|
---|
1758 |
|
---|
1759 | /**********************************************************************
|
---|
1760 | **********************************************************************/
|
---|
1761 |
|
---|
1762 | WERROR rpccli_spoolss_setprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1763 | POLICY_HND *hnd, char *keyname,
|
---|
1764 | REGISTRY_VALUE *value)
|
---|
1765 | {
|
---|
1766 | prs_struct qbuf, rbuf;
|
---|
1767 | SPOOL_Q_SETPRINTERDATAEX in;
|
---|
1768 | SPOOL_R_SETPRINTERDATAEX out;
|
---|
1769 |
|
---|
1770 | ZERO_STRUCT(in);
|
---|
1771 | ZERO_STRUCT(out);
|
---|
1772 |
|
---|
1773 | make_spoolss_q_setprinterdataex( &in, hnd, keyname, value->valuename,
|
---|
1774 | value->type, (char *)value->data_p, value->size);
|
---|
1775 |
|
---|
1776 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_SETPRINTERDATAEX,
|
---|
1777 | in, out,
|
---|
1778 | qbuf, rbuf,
|
---|
1779 | spoolss_io_q_setprinterdataex,
|
---|
1780 | spoolss_io_r_setprinterdataex,
|
---|
1781 | WERR_GENERAL_FAILURE );
|
---|
1782 |
|
---|
1783 | return out.status;
|
---|
1784 | }
|
---|
1785 |
|
---|
1786 | /**********************************************************************
|
---|
1787 | **********************************************************************/
|
---|
1788 |
|
---|
1789 | WERROR rpccli_spoolss_enumprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1790 | POLICY_HND *hnd, uint32 ndx,
|
---|
1791 | uint32 value_offered, uint32 data_offered,
|
---|
1792 | uint32 *value_needed, uint32 *data_needed,
|
---|
1793 | REGISTRY_VALUE *value)
|
---|
1794 | {
|
---|
1795 | prs_struct qbuf, rbuf;
|
---|
1796 | SPOOL_Q_ENUMPRINTERDATA in;
|
---|
1797 | SPOOL_R_ENUMPRINTERDATA out;
|
---|
1798 |
|
---|
1799 | ZERO_STRUCT(in);
|
---|
1800 | ZERO_STRUCT(out);
|
---|
1801 |
|
---|
1802 | make_spoolss_q_enumprinterdata( &in, hnd, ndx, value_offered, data_offered );
|
---|
1803 |
|
---|
1804 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERDATA,
|
---|
1805 | in, out,
|
---|
1806 | qbuf, rbuf,
|
---|
1807 | spoolss_io_q_enumprinterdata,
|
---|
1808 | spoolss_io_r_enumprinterdata,
|
---|
1809 | WERR_GENERAL_FAILURE );
|
---|
1810 |
|
---|
1811 | if ( value_needed )
|
---|
1812 | *value_needed = out.realvaluesize;
|
---|
1813 | if ( data_needed )
|
---|
1814 | *data_needed = out.realdatasize;
|
---|
1815 |
|
---|
1816 | if (!W_ERROR_IS_OK(out.status))
|
---|
1817 | return out.status;
|
---|
1818 |
|
---|
1819 | if (value) {
|
---|
1820 | rpcstr_pull(value->valuename, out.value, sizeof(value->valuename), -1,
|
---|
1821 | STR_TERMINATE);
|
---|
1822 | if (out.realdatasize) {
|
---|
1823 | value->data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, out.data,
|
---|
1824 | out.realdatasize);
|
---|
1825 | } else {
|
---|
1826 | value->data_p = NULL;
|
---|
1827 | }
|
---|
1828 | value->type = out.type;
|
---|
1829 | value->size = out.realdatasize;
|
---|
1830 | }
|
---|
1831 |
|
---|
1832 | return out.status;
|
---|
1833 | }
|
---|
1834 |
|
---|
1835 | /**********************************************************************
|
---|
1836 | **********************************************************************/
|
---|
1837 |
|
---|
1838 | WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1839 | POLICY_HND *hnd, const char *keyname,
|
---|
1840 | REGVAL_CTR *ctr)
|
---|
1841 | {
|
---|
1842 | prs_struct qbuf, rbuf;
|
---|
1843 | SPOOL_Q_ENUMPRINTERDATAEX in;
|
---|
1844 | SPOOL_R_ENUMPRINTERDATAEX out;
|
---|
1845 | int i;
|
---|
1846 | uint32 offered;
|
---|
1847 |
|
---|
1848 | ZERO_STRUCT(in);
|
---|
1849 | ZERO_STRUCT(out);
|
---|
1850 |
|
---|
1851 | offered = 0;
|
---|
1852 | make_spoolss_q_enumprinterdataex( &in, hnd, keyname, offered );
|
---|
1853 |
|
---|
1854 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERDATAEX,
|
---|
1855 | in, out,
|
---|
1856 | qbuf, rbuf,
|
---|
1857 | spoolss_io_q_enumprinterdataex,
|
---|
1858 | spoolss_io_r_enumprinterdataex,
|
---|
1859 | WERR_GENERAL_FAILURE );
|
---|
1860 |
|
---|
1861 | if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
|
---|
1862 | offered = out.needed;
|
---|
1863 |
|
---|
1864 | ZERO_STRUCT(in);
|
---|
1865 | ZERO_STRUCT(out);
|
---|
1866 |
|
---|
1867 | make_spoolss_q_enumprinterdataex( &in, hnd, keyname, offered );
|
---|
1868 |
|
---|
1869 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERDATAEX,
|
---|
1870 | in, out,
|
---|
1871 | qbuf, rbuf,
|
---|
1872 | spoolss_io_q_enumprinterdataex,
|
---|
1873 | spoolss_io_r_enumprinterdataex,
|
---|
1874 | WERR_GENERAL_FAILURE );
|
---|
1875 | }
|
---|
1876 |
|
---|
1877 | if (!W_ERROR_IS_OK(out.status))
|
---|
1878 | return out.status;
|
---|
1879 |
|
---|
1880 | for (i = 0; i < out.returned; i++) {
|
---|
1881 | PRINTER_ENUM_VALUES *v = &out.ctr.values[i];
|
---|
1882 | fstring name;
|
---|
1883 |
|
---|
1884 | rpcstr_pull(name, v->valuename.buffer, sizeof(name), -1,
|
---|
1885 | STR_TERMINATE);
|
---|
1886 | regval_ctr_addvalue(ctr, name, v->type, (const char *)v->data, v->data_len);
|
---|
1887 | }
|
---|
1888 |
|
---|
1889 | return out.status;
|
---|
1890 | }
|
---|
1891 |
|
---|
1892 | /**********************************************************************
|
---|
1893 | **********************************************************************/
|
---|
1894 |
|
---|
1895 | WERROR rpccli_spoolss_writeprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1896 | POLICY_HND *hnd, uint32 data_size, char *data,
|
---|
1897 | uint32 *num_written)
|
---|
1898 | {
|
---|
1899 | prs_struct qbuf, rbuf;
|
---|
1900 | SPOOL_Q_WRITEPRINTER in;
|
---|
1901 | SPOOL_R_WRITEPRINTER out;
|
---|
1902 |
|
---|
1903 | ZERO_STRUCT(in);
|
---|
1904 | ZERO_STRUCT(out);
|
---|
1905 |
|
---|
1906 | make_spoolss_q_writeprinter( &in, hnd, data_size, data );
|
---|
1907 |
|
---|
1908 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_WRITEPRINTER,
|
---|
1909 | in, out,
|
---|
1910 | qbuf, rbuf,
|
---|
1911 | spoolss_io_q_writeprinter,
|
---|
1912 | spoolss_io_r_writeprinter,
|
---|
1913 | WERR_GENERAL_FAILURE );
|
---|
1914 |
|
---|
1915 | if (num_written)
|
---|
1916 | *num_written = out.buffer_written;
|
---|
1917 |
|
---|
1918 | return out.status;
|
---|
1919 | }
|
---|
1920 |
|
---|
1921 | /**********************************************************************
|
---|
1922 | **********************************************************************/
|
---|
1923 |
|
---|
1924 | WERROR rpccli_spoolss_deleteprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1925 | POLICY_HND *hnd, char *valuename)
|
---|
1926 | {
|
---|
1927 | prs_struct qbuf, rbuf;
|
---|
1928 | SPOOL_Q_DELETEPRINTERDATA in;
|
---|
1929 | SPOOL_R_DELETEPRINTERDATA out;
|
---|
1930 |
|
---|
1931 | ZERO_STRUCT(in);
|
---|
1932 | ZERO_STRUCT(out);
|
---|
1933 |
|
---|
1934 | make_spoolss_q_deleteprinterdata( &in, hnd, valuename );
|
---|
1935 |
|
---|
1936 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_DELETEPRINTERDATA,
|
---|
1937 | in, out,
|
---|
1938 | qbuf, rbuf,
|
---|
1939 | spoolss_io_q_deleteprinterdata,
|
---|
1940 | spoolss_io_r_deleteprinterdata,
|
---|
1941 | WERR_GENERAL_FAILURE );
|
---|
1942 |
|
---|
1943 | return out.status;
|
---|
1944 | }
|
---|
1945 |
|
---|
1946 | /**********************************************************************
|
---|
1947 | **********************************************************************/
|
---|
1948 |
|
---|
1949 | WERROR rpccli_spoolss_deleteprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1950 | POLICY_HND *hnd, char *keyname,
|
---|
1951 | char *valuename)
|
---|
1952 | {
|
---|
1953 | prs_struct qbuf, rbuf;
|
---|
1954 | SPOOL_Q_DELETEPRINTERDATAEX in;
|
---|
1955 | SPOOL_R_DELETEPRINTERDATAEX out;
|
---|
1956 |
|
---|
1957 | ZERO_STRUCT(in);
|
---|
1958 | ZERO_STRUCT(out);
|
---|
1959 |
|
---|
1960 | make_spoolss_q_deleteprinterdataex( &in, hnd, keyname, valuename );
|
---|
1961 |
|
---|
1962 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_DELETEPRINTERDATAEX,
|
---|
1963 | in, out,
|
---|
1964 | qbuf, rbuf,
|
---|
1965 | spoolss_io_q_deleteprinterdataex,
|
---|
1966 | spoolss_io_r_deleteprinterdataex,
|
---|
1967 | WERR_GENERAL_FAILURE );
|
---|
1968 |
|
---|
1969 | return out.status;
|
---|
1970 | }
|
---|
1971 |
|
---|
1972 | /**********************************************************************
|
---|
1973 | **********************************************************************/
|
---|
1974 |
|
---|
1975 | WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
1976 | POLICY_HND *hnd, const char *keyname,
|
---|
1977 | uint16 **keylist, uint32 *len)
|
---|
1978 | {
|
---|
1979 | prs_struct qbuf, rbuf;
|
---|
1980 | SPOOL_Q_ENUMPRINTERKEY in;
|
---|
1981 | SPOOL_R_ENUMPRINTERKEY out;
|
---|
1982 | uint32 offered = 0;
|
---|
1983 |
|
---|
1984 | ZERO_STRUCT(in);
|
---|
1985 | ZERO_STRUCT(out);
|
---|
1986 |
|
---|
1987 | make_spoolss_q_enumprinterkey( &in, hnd, keyname, offered );
|
---|
1988 |
|
---|
1989 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERKEY,
|
---|
1990 | in, out,
|
---|
1991 | qbuf, rbuf,
|
---|
1992 | spoolss_io_q_enumprinterkey,
|
---|
1993 | spoolss_io_r_enumprinterkey,
|
---|
1994 | WERR_GENERAL_FAILURE );
|
---|
1995 |
|
---|
1996 | if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
|
---|
1997 | offered = out.needed;
|
---|
1998 |
|
---|
1999 | ZERO_STRUCT(in);
|
---|
2000 | ZERO_STRUCT(out);
|
---|
2001 |
|
---|
2002 | make_spoolss_q_enumprinterkey( &in, hnd, keyname, offered );
|
---|
2003 |
|
---|
2004 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ENUMPRINTERKEY,
|
---|
2005 | in, out,
|
---|
2006 | qbuf, rbuf,
|
---|
2007 | spoolss_io_q_enumprinterkey,
|
---|
2008 | spoolss_io_r_enumprinterkey,
|
---|
2009 | WERR_GENERAL_FAILURE );
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | if ( !W_ERROR_IS_OK(out.status) )
|
---|
2013 | return out.status;
|
---|
2014 |
|
---|
2015 | if (keylist) {
|
---|
2016 | *keylist = SMB_MALLOC_ARRAY(uint16, out.keys.buf_len);
|
---|
2017 | if (!*keylist) {
|
---|
2018 | return WERR_NOMEM;
|
---|
2019 | }
|
---|
2020 | memcpy(*keylist, out.keys.buffer, out.keys.buf_len * 2);
|
---|
2021 | if (len)
|
---|
2022 | *len = out.keys.buf_len * 2;
|
---|
2023 | }
|
---|
2024 |
|
---|
2025 | return out.status;
|
---|
2026 | }
|
---|
2027 |
|
---|
2028 | /**********************************************************************
|
---|
2029 | **********************************************************************/
|
---|
2030 |
|
---|
2031 | WERROR rpccli_spoolss_deleteprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
---|
2032 | POLICY_HND *hnd, char *keyname)
|
---|
2033 | {
|
---|
2034 | prs_struct qbuf, rbuf;
|
---|
2035 | SPOOL_Q_DELETEPRINTERKEY in;
|
---|
2036 | SPOOL_R_DELETEPRINTERKEY out;
|
---|
2037 |
|
---|
2038 | ZERO_STRUCT(in);
|
---|
2039 | ZERO_STRUCT(out);
|
---|
2040 |
|
---|
2041 | make_spoolss_q_deleteprinterkey( &in, hnd, keyname );
|
---|
2042 |
|
---|
2043 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_DELETEPRINTERKEY,
|
---|
2044 | in, out,
|
---|
2045 | qbuf, rbuf,
|
---|
2046 | spoolss_io_q_deleteprinterkey,
|
---|
2047 | spoolss_io_r_deleteprinterkey,
|
---|
2048 | WERR_GENERAL_FAILURE );
|
---|
2049 |
|
---|
2050 | return out.status;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | /** @} **/
|
---|