r18799: Prepare query_disp_info to use the next idx from the last result entry
[Samba/bb.git] / source / rpc_parse / parse_spoolss.c
blobe878744a1bee91a6548ccc99adf5ca1972248972
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Jean François Micouleau 1998-2000,
7 * Copyright (C) Gerald Carter 2000-2002,
8 * Copyright (C) Tim Potter 2001-2002.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "includes.h"
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_RPC_PARSE
31 /*******************************************************************
32 This should be moved in a more generic lib.
33 ********************************************************************/
35 BOOL spoolss_io_system_time(const char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime)
37 if(!prs_uint16("year", ps, depth, &systime->year))
38 return False;
39 if(!prs_uint16("month", ps, depth, &systime->month))
40 return False;
41 if(!prs_uint16("dayofweek", ps, depth, &systime->dayofweek))
42 return False;
43 if(!prs_uint16("day", ps, depth, &systime->day))
44 return False;
45 if(!prs_uint16("hour", ps, depth, &systime->hour))
46 return False;
47 if(!prs_uint16("minute", ps, depth, &systime->minute))
48 return False;
49 if(!prs_uint16("second", ps, depth, &systime->second))
50 return False;
51 if(!prs_uint16("milliseconds", ps, depth, &systime->milliseconds))
52 return False;
54 return True;
57 /*******************************************************************
58 ********************************************************************/
60 BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime)
62 systime->year=unixtime->tm_year+1900;
63 systime->month=unixtime->tm_mon+1;
64 systime->dayofweek=unixtime->tm_wday;
65 systime->day=unixtime->tm_mday;
66 systime->hour=unixtime->tm_hour;
67 systime->minute=unixtime->tm_min;
68 systime->second=unixtime->tm_sec;
69 systime->milliseconds=0;
71 return True;
74 /*******************************************************************
75 reads or writes an DOC_INFO structure.
76 ********************************************************************/
78 static BOOL smb_io_doc_info_1(const char *desc, DOC_INFO_1 *info_1, prs_struct *ps, int depth)
80 if (info_1 == NULL) return False;
82 prs_debug(ps, depth, desc, "smb_io_doc_info_1");
83 depth++;
85 if(!prs_align(ps))
86 return False;
88 if(!prs_uint32("p_docname", ps, depth, &info_1->p_docname))
89 return False;
90 if(!prs_uint32("p_outputfile", ps, depth, &info_1->p_outputfile))
91 return False;
92 if(!prs_uint32("p_datatype", ps, depth, &info_1->p_datatype))
93 return False;
95 if(!smb_io_unistr2("", &info_1->docname, info_1->p_docname, ps, depth))
96 return False;
97 if(!smb_io_unistr2("", &info_1->outputfile, info_1->p_outputfile, ps, depth))
98 return False;
99 if(!smb_io_unistr2("", &info_1->datatype, info_1->p_datatype, ps, depth))
100 return False;
102 return True;
105 /*******************************************************************
106 reads or writes an DOC_INFO structure.
107 ********************************************************************/
109 static BOOL smb_io_doc_info(const char *desc, DOC_INFO *info, prs_struct *ps, int depth)
111 uint32 useless_ptr=0;
113 if (info == NULL) return False;
115 prs_debug(ps, depth, desc, "smb_io_doc_info");
116 depth++;
118 if(!prs_align(ps))
119 return False;
121 if(!prs_uint32("switch_value", ps, depth, &info->switch_value))
122 return False;
124 if(!prs_uint32("doc_info_X ptr", ps, depth, &useless_ptr))
125 return False;
127 switch (info->switch_value)
129 case 1:
130 if(!smb_io_doc_info_1("",&info->doc_info_1, ps, depth))
131 return False;
132 break;
133 case 2:
135 this is just a placeholder
137 MSDN July 1998 says doc_info_2 is only on
138 Windows 95, and as Win95 doesn't do RPC to print
139 this case is nearly impossible
141 Maybe one day with Windows for dishwasher 2037 ...
144 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
145 break;
146 default:
147 DEBUG(0,("Something is obviously wrong somewhere !\n"));
148 break;
151 return True;
154 /*******************************************************************
155 reads or writes an DOC_INFO_CONTAINER structure.
156 ********************************************************************/
158 static BOOL smb_io_doc_info_container(const char *desc, DOC_INFO_CONTAINER *cont, prs_struct *ps, int depth)
160 if (cont == NULL) return False;
162 prs_debug(ps, depth, desc, "smb_io_doc_info_container");
163 depth++;
165 if(!prs_align(ps))
166 return False;
168 if(!prs_uint32("level", ps, depth, &cont->level))
169 return False;
171 if(!smb_io_doc_info("",&cont->docinfo, ps, depth))
172 return False;
174 return True;
177 /*******************************************************************
178 reads or writes an NOTIFY OPTION TYPE structure.
179 ********************************************************************/
181 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
182 structure. The _TYPE structure is really the deferred referrants (i.e
183 the notify fields array) of the _TYPE structure. -tpot */
185 static BOOL smb_io_notify_option_type(const char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
187 prs_debug(ps, depth, desc, "smb_io_notify_option_type");
188 depth++;
190 if (!prs_align(ps))
191 return False;
193 if(!prs_uint16("type", ps, depth, &type->type))
194 return False;
195 if(!prs_uint16("reserved0", ps, depth, &type->reserved0))
196 return False;
197 if(!prs_uint32("reserved1", ps, depth, &type->reserved1))
198 return False;
199 if(!prs_uint32("reserved2", ps, depth, &type->reserved2))
200 return False;
201 if(!prs_uint32("count", ps, depth, &type->count))
202 return False;
203 if(!prs_uint32("fields_ptr", ps, depth, &type->fields_ptr))
204 return False;
206 return True;
209 /*******************************************************************
210 reads or writes an NOTIFY OPTION TYPE DATA.
211 ********************************************************************/
213 static BOOL smb_io_notify_option_type_data(const char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
215 int i;
217 prs_debug(ps, depth, desc, "smb_io_notify_option_type_data");
218 depth++;
220 /* if there are no fields just return */
221 if (type->fields_ptr==0)
222 return True;
224 if(!prs_align(ps))
225 return False;
227 if(!prs_uint32("count2", ps, depth, &type->count2))
228 return False;
230 if (type->count2 != type->count)
231 DEBUG(4,("What a mess, count was %x now is %x !\n", type->count, type->count2));
233 /* parse the option type data */
234 for(i=0;i<type->count2;i++)
235 if(!prs_uint16("fields",ps,depth,&type->fields[i]))
236 return False;
237 return True;
240 /*******************************************************************
241 reads or writes an NOTIFY OPTION structure.
242 ********************************************************************/
244 static BOOL smb_io_notify_option_type_ctr(const char *desc, SPOOL_NOTIFY_OPTION_TYPE_CTR *ctr , prs_struct *ps, int depth)
246 int i;
248 prs_debug(ps, depth, desc, "smb_io_notify_option_type_ctr");
249 depth++;
251 if(!prs_uint32("count", ps, depth, &ctr->count))
252 return False;
254 /* reading */
255 if (UNMARSHALLING(ps))
256 if((ctr->type=PRS_ALLOC_MEM(ps,SPOOL_NOTIFY_OPTION_TYPE,ctr->count)) == NULL)
257 return False;
259 /* the option type struct */
260 for(i=0;i<ctr->count;i++)
261 if(!smb_io_notify_option_type("", &ctr->type[i] , ps, depth))
262 return False;
264 /* the type associated with the option type struct */
265 for(i=0;i<ctr->count;i++)
266 if(!smb_io_notify_option_type_data("", &ctr->type[i] , ps, depth))
267 return False;
269 return True;
272 /*******************************************************************
273 reads or writes an NOTIFY OPTION structure.
274 ********************************************************************/
276 static BOOL smb_io_notify_option(const char *desc, SPOOL_NOTIFY_OPTION *option, prs_struct *ps, int depth)
278 prs_debug(ps, depth, desc, "smb_io_notify_option");
279 depth++;
281 if(!prs_uint32("version", ps, depth, &option->version))
282 return False;
283 if(!prs_uint32("flags", ps, depth, &option->flags))
284 return False;
285 if(!prs_uint32("count", ps, depth, &option->count))
286 return False;
287 if(!prs_uint32("option_type_ptr", ps, depth, &option->option_type_ptr))
288 return False;
290 /* marshalling or unmarshalling, that would work */
291 if (option->option_type_ptr!=0) {
292 if(!smb_io_notify_option_type_ctr("", &option->ctr ,ps, depth))
293 return False;
295 else {
296 option->ctr.type=NULL;
297 option->ctr.count=0;
300 return True;
303 /*******************************************************************
304 reads or writes an NOTIFY INFO DATA structure.
305 ********************************************************************/
307 static BOOL smb_io_notify_info_data(const char *desc,SPOOL_NOTIFY_INFO_DATA *data, prs_struct *ps, int depth)
309 uint32 useless_ptr=0x0FF0ADDE;
311 prs_debug(ps, depth, desc, "smb_io_notify_info_data");
312 depth++;
314 if(!prs_align(ps))
315 return False;
316 if(!prs_uint16("type", ps, depth, &data->type))
317 return False;
318 if(!prs_uint16("field", ps, depth, &data->field))
319 return False;
321 if(!prs_uint32("how many words", ps, depth, &data->size))
322 return False;
323 if(!prs_uint32("id", ps, depth, &data->id))
324 return False;
325 if(!prs_uint32("how many words", ps, depth, &data->size))
326 return False;
328 switch (data->enc_type) {
330 /* One and two value data has two uint32 values */
332 case NOTIFY_ONE_VALUE:
333 case NOTIFY_TWO_VALUE:
335 if(!prs_uint32("value[0]", ps, depth, &data->notify_data.value[0]))
336 return False;
337 if(!prs_uint32("value[1]", ps, depth, &data->notify_data.value[1]))
338 return False;
339 break;
341 /* Pointers and strings have a string length and a
342 pointer. For a string the length is expressed as
343 the number of uint16 characters plus a trailing
344 \0\0. */
346 case NOTIFY_POINTER:
348 if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length ))
349 return False;
350 if(!prs_uint32("pointer", ps, depth, &useless_ptr))
351 return False;
353 break;
355 case NOTIFY_STRING:
357 if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length))
358 return False;
360 if(!prs_uint32("pointer", ps, depth, &useless_ptr))
361 return False;
363 break;
365 case NOTIFY_SECDESC:
366 if( !prs_uint32( "sd size", ps, depth, &data->notify_data.sd.size ) )
367 return False;
368 if( !prs_uint32( "pointer", ps, depth, &useless_ptr ) )
369 return False;
371 break;
373 default:
374 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data\n",
375 data->enc_type));
376 break;
379 return True;
382 /*******************************************************************
383 reads or writes an NOTIFY INFO DATA structure.
384 ********************************************************************/
386 BOOL smb_io_notify_info_data_strings(const char *desc,SPOOL_NOTIFY_INFO_DATA *data,
387 prs_struct *ps, int depth)
389 prs_debug(ps, depth, desc, "smb_io_notify_info_data_strings");
390 depth++;
392 if(!prs_align(ps))
393 return False;
395 switch(data->enc_type) {
397 /* No data for values */
399 case NOTIFY_ONE_VALUE:
400 case NOTIFY_TWO_VALUE:
402 break;
404 /* Strings start with a length in uint16s */
406 case NOTIFY_STRING:
408 if (MARSHALLING(ps))
409 data->notify_data.data.length /= 2;
411 if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length))
412 return False;
414 if (UNMARSHALLING(ps)) {
415 data->notify_data.data.string = PRS_ALLOC_MEM(ps, uint16,
416 data->notify_data.data.length);
418 if (!data->notify_data.data.string)
419 return False;
422 if (!prs_uint16uni(True, "string", ps, depth, data->notify_data.data.string,
423 data->notify_data.data.length))
424 return False;
426 if (MARSHALLING(ps))
427 data->notify_data.data.length *= 2;
429 break;
431 case NOTIFY_POINTER:
433 if (UNMARSHALLING(ps)) {
434 data->notify_data.data.string = PRS_ALLOC_MEM(ps, uint16,
435 data->notify_data.data.length);
437 if (!data->notify_data.data.string)
438 return False;
441 if(!prs_uint8s(True,"buffer",ps,depth,(uint8*)data->notify_data.data.string,data->notify_data.data.length))
442 return False;
444 break;
446 case NOTIFY_SECDESC:
447 if( !prs_uint32("secdesc size ", ps, depth, &data->notify_data.sd.size ) )
448 return False;
449 if ( !sec_io_desc( "sec_desc", &data->notify_data.sd.desc, ps, depth ) )
450 return False;
451 break;
453 default:
454 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data_strings\n",
455 data->enc_type));
456 break;
459 #if 0
460 if (isvalue==False) {
462 /* length of string in unicode include \0 */
463 x=data->notify_data.data.length+1;
465 if (data->field != 16)
466 if(!prs_uint32("string length", ps, depth, &x ))
467 return False;
469 if (MARSHALLING(ps)) {
470 /* These are already in little endian format. Don't byte swap. */
471 if (x == 1) {
473 /* No memory allocated for this string
474 therefore following the data.string
475 pointer is a bad idea. Use a pointer to
476 the uint32 length union member to
477 provide a source for a unicode NULL */
479 if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2))
480 return False;
481 } else {
483 if (data->field == 16)
484 x /= 2;
486 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
487 return False;
489 } else {
491 /* Tallocate memory for string */
493 data->notify_data.data.string = PRS_ALLOC_MEM(ps, uint16, x * 2);
494 if (!data->notify_data.data.string)
495 return False;
497 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
498 return False;
502 #endif
504 #if 0 /* JERRY */
505 /* Win2k does not seem to put this parse align here */
506 if(!prs_align(ps))
507 return False;
508 #endif
510 return True;
513 /*******************************************************************
514 reads or writes an NOTIFY INFO structure.
515 ********************************************************************/
517 static BOOL smb_io_notify_info(const char *desc, SPOOL_NOTIFY_INFO *info, prs_struct *ps, int depth)
519 int i;
521 prs_debug(ps, depth, desc, "smb_io_notify_info");
522 depth++;
524 if(!prs_align(ps))
525 return False;
527 if(!prs_uint32("count", ps, depth, &info->count))
528 return False;
529 if(!prs_uint32("version", ps, depth, &info->version))
530 return False;
531 if(!prs_uint32("flags", ps, depth, &info->flags))
532 return False;
533 if(!prs_uint32("count", ps, depth, &info->count))
534 return False;
536 for (i=0;i<info->count;i++) {
537 if(!smb_io_notify_info_data(desc, &info->data[i], ps, depth))
538 return False;
541 /* now do the strings at the end of the stream */
542 for (i=0;i<info->count;i++) {
543 if(!smb_io_notify_info_data_strings(desc, &info->data[i], ps, depth))
544 return False;
547 return True;
550 /*******************************************************************
551 ********************************************************************/
553 BOOL spool_io_user_level_1( const char *desc, prs_struct *ps, int depth, SPOOL_USER_1 *q_u )
555 prs_debug(ps, depth, desc, "");
556 depth++;
558 if (!prs_align(ps))
559 return False;
561 if (!prs_uint32("size", ps, depth, &q_u->size))
562 return False;
564 if (!prs_io_unistr2_p("", ps, depth, &q_u->client_name))
565 return False;
566 if (!prs_io_unistr2_p("", ps, depth, &q_u->user_name))
567 return False;
569 if (!prs_uint32("build", ps, depth, &q_u->build))
570 return False;
571 if (!prs_uint32("major", ps, depth, &q_u->major))
572 return False;
573 if (!prs_uint32("minor", ps, depth, &q_u->minor))
574 return False;
575 if (!prs_uint32("processor", ps, depth, &q_u->processor))
576 return False;
578 if (!prs_io_unistr2("", ps, depth, q_u->client_name))
579 return False;
580 if (!prs_align(ps))
581 return False;
583 if (!prs_io_unistr2("", ps, depth, q_u->user_name))
584 return False;
586 return True;
589 /*******************************************************************
590 ********************************************************************/
592 static BOOL spool_io_user_level(const char *desc, SPOOL_USER_CTR *q_u, prs_struct *ps, int depth)
594 if (q_u==NULL)
595 return False;
597 prs_debug(ps, depth, desc, "spool_io_user_level");
598 depth++;
600 if (!prs_align(ps))
601 return False;
603 if (!prs_uint32("level", ps, depth, &q_u->level))
604 return False;
606 switch ( q_u->level )
608 case 1:
609 if ( !prs_pointer( "" , ps, depth, (void*)&q_u->user.user1,
610 sizeof(SPOOL_USER_1), (PRS_POINTER_CAST)spool_io_user_level_1 ))
612 return False;
614 break;
615 default:
616 return False;
619 return True;
622 /*******************************************************************
623 * read or write a DEVICEMODE struct.
624 * on reading allocate memory for the private member
625 ********************************************************************/
627 #define DM_NUM_OPTIONAL_FIELDS 8
629 BOOL spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode)
631 int available_space; /* size of the device mode left to parse */
632 /* only important on unmarshalling */
633 int i = 0;
634 uint16 *unistr_buffer;
635 int j;
637 struct optional_fields {
638 fstring name;
639 uint32* field;
640 } opt_fields[DM_NUM_OPTIONAL_FIELDS] = {
641 { "icmmethod", NULL },
642 { "icmintent", NULL },
643 { "mediatype", NULL },
644 { "dithertype", NULL },
645 { "reserved1", NULL },
646 { "reserved2", NULL },
647 { "panningwidth", NULL },
648 { "panningheight", NULL }
651 /* assign at run time to keep non-gcc compilers happy */
653 opt_fields[0].field = &devmode->icmmethod;
654 opt_fields[1].field = &devmode->icmintent;
655 opt_fields[2].field = &devmode->mediatype;
656 opt_fields[3].field = &devmode->dithertype;
657 opt_fields[4].field = &devmode->reserved1;
658 opt_fields[5].field = &devmode->reserved2;
659 opt_fields[6].field = &devmode->panningwidth;
660 opt_fields[7].field = &devmode->panningheight;
663 prs_debug(ps, depth, desc, "spoolss_io_devmode");
664 depth++;
666 if (UNMARSHALLING(ps)) {
667 devmode->devicename.buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
668 if (devmode->devicename.buffer == NULL)
669 return False;
670 unistr_buffer = devmode->devicename.buffer;
672 else {
673 /* devicename is a static sized string but the buffer we set is not */
674 unistr_buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
675 memset( unistr_buffer, 0x0, MAXDEVICENAME );
676 for ( j=0; devmode->devicename.buffer[j]; j++ )
677 unistr_buffer[j] = devmode->devicename.buffer[j];
680 if (!prs_uint16uni(True,"devicename", ps, depth, unistr_buffer, MAXDEVICENAME))
681 return False;
683 if (!prs_uint16("specversion", ps, depth, &devmode->specversion))
684 return False;
686 if (!prs_uint16("driverversion", ps, depth, &devmode->driverversion))
687 return False;
688 if (!prs_uint16("size", ps, depth, &devmode->size))
689 return False;
690 if (!prs_uint16("driverextra", ps, depth, &devmode->driverextra))
691 return False;
692 if (!prs_uint32("fields", ps, depth, &devmode->fields))
693 return False;
694 if (!prs_uint16("orientation", ps, depth, &devmode->orientation))
695 return False;
696 if (!prs_uint16("papersize", ps, depth, &devmode->papersize))
697 return False;
698 if (!prs_uint16("paperlength", ps, depth, &devmode->paperlength))
699 return False;
700 if (!prs_uint16("paperwidth", ps, depth, &devmode->paperwidth))
701 return False;
702 if (!prs_uint16("scale", ps, depth, &devmode->scale))
703 return False;
704 if (!prs_uint16("copies", ps, depth, &devmode->copies))
705 return False;
706 if (!prs_uint16("defaultsource", ps, depth, &devmode->defaultsource))
707 return False;
708 if (!prs_uint16("printquality", ps, depth, &devmode->printquality))
709 return False;
710 if (!prs_uint16("color", ps, depth, &devmode->color))
711 return False;
712 if (!prs_uint16("duplex", ps, depth, &devmode->duplex))
713 return False;
714 if (!prs_uint16("yresolution", ps, depth, &devmode->yresolution))
715 return False;
716 if (!prs_uint16("ttoption", ps, depth, &devmode->ttoption))
717 return False;
718 if (!prs_uint16("collate", ps, depth, &devmode->collate))
719 return False;
721 if (UNMARSHALLING(ps)) {
722 devmode->formname.buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
723 if (devmode->formname.buffer == NULL)
724 return False;
725 unistr_buffer = devmode->formname.buffer;
727 else {
728 /* devicename is a static sized string but the buffer we set is not */
729 unistr_buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
730 memset( unistr_buffer, 0x0, MAXDEVICENAME );
731 for ( j=0; devmode->formname.buffer[j]; j++ )
732 unistr_buffer[j] = devmode->formname.buffer[j];
735 if (!prs_uint16uni(True, "formname", ps, depth, unistr_buffer, MAXDEVICENAME))
736 return False;
737 if (!prs_uint16("logpixels", ps, depth, &devmode->logpixels))
738 return False;
739 if (!prs_uint32("bitsperpel", ps, depth, &devmode->bitsperpel))
740 return False;
741 if (!prs_uint32("pelswidth", ps, depth, &devmode->pelswidth))
742 return False;
743 if (!prs_uint32("pelsheight", ps, depth, &devmode->pelsheight))
744 return False;
745 if (!prs_uint32("displayflags", ps, depth, &devmode->displayflags))
746 return False;
747 if (!prs_uint32("displayfrequency", ps, depth, &devmode->displayfrequency))
748 return False;
750 * every device mode I've ever seen on the wire at least has up
751 * to the displayfrequency field. --jerry (05-09-2002)
754 /* add uint32's + uint16's + two UNICODE strings */
756 available_space = devmode->size - (sizeof(uint32)*6 + sizeof(uint16)*18 + sizeof(uint16)*64);
758 /* Sanity check - we only have uint32's left tp parse */
760 if ( available_space && ((available_space % sizeof(uint32)) != 0) ) {
761 DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n",
762 available_space, devmode->size));
763 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
764 return False;
768 * Conditional parsing. Assume that the DeviceMode has been
769 * zero'd by the caller.
772 while ((available_space > 0) && (i < DM_NUM_OPTIONAL_FIELDS))
774 DEBUG(11, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space));
775 if (!prs_uint32(opt_fields[i].name, ps, depth, opt_fields[i].field))
776 return False;
777 available_space -= sizeof(uint32);
778 i++;
781 /* Sanity Check - we should no available space at this point unless
782 MS changes the device mode structure */
784 if (available_space) {
785 DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n"));
786 DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n",
787 available_space, devmode->size));
788 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
789 return False;
793 if (devmode->driverextra!=0) {
794 if (UNMARSHALLING(ps)) {
795 devmode->dev_private=PRS_ALLOC_MEM(ps, uint8, devmode->driverextra);
796 if(devmode->dev_private == NULL)
797 return False;
798 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for dev_private\n",devmode->driverextra));
801 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of dev_private\n",devmode->driverextra));
802 if (!prs_uint8s(False, "dev_private", ps, depth,
803 devmode->dev_private, devmode->driverextra))
804 return False;
807 return True;
810 /*******************************************************************
811 Read or write a DEVICEMODE container
812 ********************************************************************/
814 static BOOL spoolss_io_devmode_cont(const char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth)
816 if (dm_c==NULL)
817 return False;
819 prs_debug(ps, depth, desc, "spoolss_io_devmode_cont");
820 depth++;
822 if(!prs_align(ps))
823 return False;
825 if (!prs_uint32("size", ps, depth, &dm_c->size))
826 return False;
828 if (!prs_uint32("devmode_ptr", ps, depth, &dm_c->devmode_ptr))
829 return False;
831 if (dm_c->size==0 || dm_c->devmode_ptr==0) {
832 if (UNMARSHALLING(ps))
833 /* if while reading there is no DEVMODE ... */
834 dm_c->devmode=NULL;
835 return True;
838 /* so we have a DEVICEMODE to follow */
839 if (UNMARSHALLING(ps)) {
840 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
841 dm_c->devmode=PRS_ALLOC_MEM(ps,DEVICEMODE,1);
842 if(dm_c->devmode == NULL)
843 return False;
846 /* this is bad code, shouldn't be there */
847 if (!prs_uint32("size", ps, depth, &dm_c->size))
848 return False;
850 if (!spoolss_io_devmode(desc, ps, depth, dm_c->devmode))
851 return False;
853 return True;
856 /*******************************************************************
857 ********************************************************************/
859 static BOOL spoolss_io_printer_default(const char *desc, PRINTER_DEFAULT *pd, prs_struct *ps, int depth)
861 if (pd==NULL)
862 return False;
864 prs_debug(ps, depth, desc, "spoolss_io_printer_default");
865 depth++;
867 if (!prs_uint32("datatype_ptr", ps, depth, &pd->datatype_ptr))
868 return False;
870 if (!smb_io_unistr2("datatype", &pd->datatype, pd->datatype_ptr, ps,depth))
871 return False;
873 if (!prs_align(ps))
874 return False;
876 if (!spoolss_io_devmode_cont("", &pd->devmode_cont, ps, depth))
877 return False;
879 if (!prs_align(ps))
880 return False;
882 if (!prs_uint32("access_required", ps, depth, &pd->access_required))
883 return False;
885 return True;
888 /*******************************************************************
889 * init a structure.
890 ********************************************************************/
892 BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
893 const fstring printername,
894 const fstring datatype,
895 uint32 access_required,
896 const fstring clientname,
897 const fstring user_name)
899 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
901 q_u->printername = TALLOC_P( get_talloc_ctx(), UNISTR2 );
902 if (!q_u->printername) {
903 return False;
905 init_unistr2(q_u->printername, printername, UNI_STR_TERMINATE);
907 q_u->printer_default.datatype_ptr = 0;
909 q_u->printer_default.devmode_cont.size=0;
910 q_u->printer_default.devmode_cont.devmode_ptr=0;
911 q_u->printer_default.devmode_cont.devmode=NULL;
912 q_u->printer_default.access_required=access_required;
914 q_u->user_switch = 1;
916 q_u->user_ctr.level = 1;
917 q_u->user_ctr.user.user1 = TALLOC_P( get_talloc_ctx(), SPOOL_USER_1 );
918 if (!q_u->user_ctr.user.user1) {
919 return False;
921 q_u->user_ctr.user.user1->size = strlen(clientname) + strlen(user_name) + 10;
922 q_u->user_ctr.user.user1->build = 1381;
923 q_u->user_ctr.user.user1->major = 2;
924 q_u->user_ctr.user.user1->minor = 0;
925 q_u->user_ctr.user.user1->processor = 0;
927 q_u->user_ctr.user.user1->client_name = TALLOC_P( get_talloc_ctx(), UNISTR2 );
928 if (!q_u->user_ctr.user.user1->client_name) {
929 return False;
931 q_u->user_ctr.user.user1->user_name = TALLOC_P( get_talloc_ctx(), UNISTR2 );
932 if (!q_u->user_ctr.user.user1->user_name) {
933 return False;
936 init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE);
937 init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE);
939 return True;
942 /*******************************************************************
943 * init a structure.
944 ********************************************************************/
946 BOOL make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u,
947 const char *srv_name, const char* clientname, const char* user_name,
948 uint32 level, PRINTER_INFO_CTR *ctr)
950 DEBUG(5,("make_spoolss_q_addprinterex\n"));
952 if (!ctr || !ctr->printers_2)
953 return False;
955 ZERO_STRUCTP(q_u);
957 q_u->server_name = TALLOC_P( mem_ctx, UNISTR2 );
958 if (!q_u->server_name) {
959 return False;
961 init_unistr2(q_u->server_name, srv_name, UNI_FLAGS_NONE);
963 q_u->level = level;
965 q_u->info.level = level;
966 q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0;
967 switch (level) {
968 case 2:
969 /* init q_u->info.info2 from *info */
970 if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) {
971 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
972 return False;
974 break;
975 default :
976 break;
979 q_u->user_switch=1;
981 q_u->user_ctr.level = 1;
982 q_u->user_ctr.user.user1 = TALLOC_P( get_talloc_ctx(), SPOOL_USER_1 );
983 if (!q_u->user_ctr.user.user1) {
984 return False;
986 q_u->user_ctr.user.user1->build = 1381;
987 q_u->user_ctr.user.user1->major = 2;
988 q_u->user_ctr.user.user1->minor = 0;
989 q_u->user_ctr.user.user1->processor = 0;
991 q_u->user_ctr.user.user1->client_name = TALLOC_P( mem_ctx, UNISTR2 );
992 if (!q_u->user_ctr.user.user1->client_name) {
993 return False;
995 q_u->user_ctr.user.user1->user_name = TALLOC_P( mem_ctx, UNISTR2 );
996 if (!q_u->user_ctr.user.user1->user_name) {
997 return False;
999 init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE);
1000 init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE);
1002 q_u->user_ctr.user.user1->size = q_u->user_ctr.user.user1->user_name->uni_str_len +
1003 q_u->user_ctr.user.user1->client_name->uni_str_len + 2;
1005 return True;
1008 /*******************************************************************
1009 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
1010 *******************************************************************/
1012 BOOL make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
1013 PRINTER_INFO_2 *info)
1016 SPOOL_PRINTER_INFO_LEVEL_2 *inf;
1018 /* allocate the necessary memory */
1019 if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2))) {
1020 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
1021 return False;
1024 inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
1025 inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
1026 inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
1027 inf->portname_ptr = (info->portname.buffer!=NULL)?1:0;
1028 inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0;
1029 inf->comment_ptr = (info->comment.buffer!=NULL)?1:0;
1030 inf->location_ptr = (info->location.buffer!=NULL)?1:0;
1031 inf->devmode_ptr = (info->devmode!=NULL)?1:0;
1032 inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0;
1033 inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0;
1034 inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0;
1035 inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0;
1036 inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
1037 inf->attributes = info->attributes;
1038 inf->priority = info->priority;
1039 inf->default_priority = info->defaultpriority;
1040 inf->starttime = info->starttime;
1041 inf->untiltime = info->untiltime;
1042 inf->cjobs = info->cjobs;
1043 inf->averageppm = info->averageppm;
1044 init_unistr2_from_unistr(&inf->servername, &info->servername);
1045 init_unistr2_from_unistr(&inf->printername, &info->printername);
1046 init_unistr2_from_unistr(&inf->sharename, &info->sharename);
1047 init_unistr2_from_unistr(&inf->portname, &info->portname);
1048 init_unistr2_from_unistr(&inf->drivername, &info->drivername);
1049 init_unistr2_from_unistr(&inf->comment, &info->comment);
1050 init_unistr2_from_unistr(&inf->location, &info->location);
1051 init_unistr2_from_unistr(&inf->sepfile, &info->sepfile);
1052 init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor);
1053 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
1054 init_unistr2_from_unistr(&inf->parameters, &info->parameters);
1055 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
1057 *spool_info2 = inf;
1059 return True;
1062 /*******************************************************************
1063 create a SPOOL_PRINTER_INFO_3 struct from a PRINTER_INFO_3 struct
1064 *******************************************************************/
1066 BOOL make_spoolss_printer_info_3(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3 **spool_info3,
1067 PRINTER_INFO_3 *info)
1070 SPOOL_PRINTER_INFO_LEVEL_3 *inf;
1072 /* allocate the necessary memory */
1073 if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3))) {
1074 DEBUG(0,("make_spoolss_printer_info_3: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_3 sruct!\n"));
1075 return False;
1078 inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
1080 *spool_info3 = inf;
1082 return True;
1085 /*******************************************************************
1086 create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
1087 *******************************************************************/
1089 BOOL make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7 **spool_info7,
1090 PRINTER_INFO_7 *info)
1093 SPOOL_PRINTER_INFO_LEVEL_7 *inf;
1095 /* allocate the necessary memory */
1096 if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7))) {
1097 DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
1098 return False;
1101 inf->guid_ptr = (info->guid.buffer!=NULL)?1:0;
1102 inf->action = info->action;
1103 init_unistr2_from_unistr(&inf->guid, &info->guid);
1105 *spool_info7 = inf;
1107 return True;
1111 /*******************************************************************
1112 * read a structure.
1113 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1114 ********************************************************************/
1116 BOOL spoolss_io_q_open_printer(const char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth)
1118 if (q_u == NULL)
1119 return False;
1121 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer");
1122 depth++;
1124 if (!prs_align(ps))
1125 return False;
1127 if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername))
1128 return False;
1129 if (!prs_io_unistr2("printername", ps, depth, q_u->printername))
1130 return False;
1132 if (!prs_align(ps))
1133 return False;
1135 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
1136 return False;
1138 return True;
1141 /*******************************************************************
1142 * write a structure.
1143 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1144 * called from spoolss_open_printer_ex (cli_spoolss.c)
1145 ********************************************************************/
1147 BOOL spoolss_io_r_open_printer(const char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth)
1149 if (r_u == NULL) return False;
1151 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer");
1152 depth++;
1154 if (!prs_align(ps))
1155 return False;
1157 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
1158 return False;
1160 if (!prs_werror("status code", ps, depth, &(r_u->status)))
1161 return False;
1163 return True;
1167 /*******************************************************************
1168 * read a structure.
1169 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1170 ********************************************************************/
1172 BOOL spoolss_io_q_open_printer_ex(const char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
1174 if (q_u == NULL)
1175 return False;
1177 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
1178 depth++;
1180 if (!prs_align(ps))
1181 return False;
1183 if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername))
1184 return False;
1185 if (!prs_io_unistr2("printername", ps, depth, q_u->printername))
1186 return False;
1188 if (!prs_align(ps))
1189 return False;
1191 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
1192 return False;
1194 if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
1195 return False;
1196 if (!spool_io_user_level("", &q_u->user_ctr, ps, depth))
1197 return False;
1199 return True;
1202 /*******************************************************************
1203 * write a structure.
1204 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1205 * called from spoolss_open_printer_ex (cli_spoolss.c)
1206 ********************************************************************/
1208 BOOL spoolss_io_r_open_printer_ex(const char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth)
1210 if (r_u == NULL) return False;
1212 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex");
1213 depth++;
1215 if (!prs_align(ps))
1216 return False;
1218 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
1219 return False;
1221 if (!prs_werror("status code", ps, depth, &(r_u->status)))
1222 return False;
1224 return True;
1227 /*******************************************************************
1228 * init a structure.
1229 ********************************************************************/
1230 BOOL make_spoolss_q_deleteprinterdriverex( TALLOC_CTX *mem_ctx,
1231 SPOOL_Q_DELETEPRINTERDRIVEREX *q_u,
1232 const char *server,
1233 const char* arch,
1234 const char* driver,
1235 int version)
1237 DEBUG(5,("make_spoolss_q_deleteprinterdriverex\n"));
1239 q_u->server_ptr = (server!=NULL)?1:0;
1240 q_u->delete_flags = DPD_DELETE_UNUSED_FILES;
1242 /* these must be NULL terminated or else NT4 will
1243 complain about invalid parameters --jerry */
1244 init_unistr2(&q_u->server, server, UNI_STR_TERMINATE);
1245 init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE);
1246 init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE);
1248 if (version >= 0) {
1249 q_u->delete_flags |= DPD_DELETE_SPECIFIC_VERSION;
1250 q_u->version = version;
1253 return True;
1257 /*******************************************************************
1258 * init a structure.
1259 ********************************************************************/
1260 BOOL make_spoolss_q_deleteprinterdriver(
1261 TALLOC_CTX *mem_ctx,
1262 SPOOL_Q_DELETEPRINTERDRIVER *q_u,
1263 const char *server,
1264 const char* arch,
1265 const char* driver
1268 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1270 q_u->server_ptr = (server!=NULL)?1:0;
1272 /* these must be NULL terminated or else NT4 will
1273 complain about invalid parameters --jerry */
1274 init_unistr2(&q_u->server, server, UNI_STR_TERMINATE);
1275 init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE);
1276 init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE);
1278 return True;
1281 /*******************************************************************
1282 * make a structure.
1283 ********************************************************************/
1285 BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
1286 const POLICY_HND *handle,
1287 const char *valuename, uint32 size)
1289 if (q_u == NULL) return False;
1291 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1293 q_u->handle = *handle;
1294 init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
1295 q_u->size = size;
1297 return True;
1300 /*******************************************************************
1301 * make a structure.
1302 ********************************************************************/
1304 BOOL make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX *q_u,
1305 const POLICY_HND *handle,
1306 const char *keyname,
1307 const char *valuename, uint32 size)
1309 if (q_u == NULL) return False;
1311 DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
1313 q_u->handle = *handle;
1314 init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
1315 init_unistr2(&q_u->keyname, keyname, UNI_STR_TERMINATE);
1316 q_u->size = size;
1318 return True;
1321 /*******************************************************************
1322 * read a structure.
1323 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1324 ********************************************************************/
1326 BOOL spoolss_io_q_getprinterdata(const char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth)
1328 if (q_u == NULL)
1329 return False;
1331 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata");
1332 depth++;
1334 if (!prs_align(ps))
1335 return False;
1336 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1337 return False;
1338 if (!prs_align(ps))
1339 return False;
1340 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1341 return False;
1342 if (!prs_align(ps))
1343 return False;
1344 if (!prs_uint32("size", ps, depth, &q_u->size))
1345 return False;
1347 return True;
1350 /*******************************************************************
1351 * read a structure.
1352 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1353 ********************************************************************/
1355 BOOL spoolss_io_q_deleteprinterdata(const char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth)
1357 if (q_u == NULL)
1358 return False;
1360 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata");
1361 depth++;
1363 if (!prs_align(ps))
1364 return False;
1365 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1366 return False;
1367 if (!prs_align(ps))
1368 return False;
1369 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1370 return False;
1372 return True;
1375 /*******************************************************************
1376 * write a structure.
1377 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1378 ********************************************************************/
1380 BOOL spoolss_io_r_deleteprinterdata(const char *desc, SPOOL_R_DELETEPRINTERDATA *r_u, prs_struct *ps, int depth)
1382 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdata");
1383 depth++;
1384 if(!prs_werror("status", ps, depth, &r_u->status))
1385 return False;
1387 return True;
1390 /*******************************************************************
1391 * read a structure.
1392 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1393 ********************************************************************/
1395 BOOL spoolss_io_q_deleteprinterdataex(const char *desc, SPOOL_Q_DELETEPRINTERDATAEX *q_u, prs_struct *ps, int depth)
1397 if (q_u == NULL)
1398 return False;
1400 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdataex");
1401 depth++;
1403 if (!prs_align(ps))
1404 return False;
1405 if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
1406 return False;
1408 if (!smb_io_unistr2("keyname ", &q_u->keyname, True, ps, depth))
1409 return False;
1410 if (!smb_io_unistr2("valuename", &q_u->valuename, True, ps, depth))
1411 return False;
1413 return True;
1416 /*******************************************************************
1417 * write a structure.
1418 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1419 ********************************************************************/
1421 BOOL spoolss_io_r_deleteprinterdataex(const char *desc, SPOOL_R_DELETEPRINTERDATAEX *r_u, prs_struct *ps, int depth)
1423 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdataex");
1424 depth++;
1426 if(!prs_werror("status", ps, depth, &r_u->status))
1427 return False;
1429 return True;
1432 /*******************************************************************
1433 * write a structure.
1434 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1435 ********************************************************************/
1437 BOOL spoolss_io_r_getprinterdata(const char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth)
1439 if (r_u == NULL)
1440 return False;
1442 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata");
1443 depth++;
1445 if (!prs_align(ps))
1446 return False;
1447 if (!prs_uint32("type", ps, depth, &r_u->type))
1448 return False;
1449 if (!prs_uint32("size", ps, depth, &r_u->size))
1450 return False;
1452 if (UNMARSHALLING(ps) && r_u->size) {
1453 r_u->data = PRS_ALLOC_MEM(ps, unsigned char, r_u->size);
1454 if(!r_u->data)
1455 return False;
1458 if (!prs_uint8s( False, "data", ps, depth, r_u->data, r_u->size ))
1459 return False;
1461 if (!prs_align(ps))
1462 return False;
1464 if (!prs_uint32("needed", ps, depth, &r_u->needed))
1465 return False;
1466 if (!prs_werror("status", ps, depth, &r_u->status))
1467 return False;
1469 return True;
1472 /*******************************************************************
1473 * make a structure.
1474 ********************************************************************/
1476 BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
1478 if (q_u == NULL) return False;
1480 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1482 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
1484 return True;
1487 /*******************************************************************
1488 * read a structure.
1489 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1490 * called from spoolss_abortprinter (cli_spoolss.c)
1491 ********************************************************************/
1493 BOOL spoolss_io_q_abortprinter(const char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth)
1495 if (q_u == NULL) return False;
1497 prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter");
1498 depth++;
1500 if (!prs_align(ps))
1501 return False;
1503 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1504 return False;
1506 return True;
1509 /*******************************************************************
1510 * write a structure.
1511 * called from spoolss_r_abortprinter (srv_spoolss.c)
1512 ********************************************************************/
1514 BOOL spoolss_io_r_abortprinter(const char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth)
1516 prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter");
1517 depth++;
1518 if(!prs_werror("status", ps, depth, &r_u->status))
1519 return False;
1521 return True;
1524 /*******************************************************************
1525 * read a structure.
1526 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1527 * called from spoolss_deleteprinter (cli_spoolss.c)
1528 ********************************************************************/
1530 BOOL spoolss_io_q_deleteprinter(const char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
1532 if (q_u == NULL) return False;
1534 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
1535 depth++;
1537 if (!prs_align(ps))
1538 return False;
1540 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1541 return False;
1543 return True;
1546 /*******************************************************************
1547 * write a structure.
1548 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1549 * called from spoolss_deleteprinter (cli_spoolss.c)
1550 ********************************************************************/
1552 BOOL spoolss_io_r_deleteprinter(const char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
1554 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
1555 depth++;
1557 if (!prs_align(ps))
1558 return False;
1560 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1561 return False;
1562 if (!prs_werror("status", ps, depth, &r_u->status))
1563 return False;
1565 return True;
1569 /*******************************************************************
1570 * read a structure.
1571 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1572 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1573 ********************************************************************/
1575 BOOL spoolss_io_q_deleteprinterdriver(const char *desc, SPOOL_Q_DELETEPRINTERDRIVER *q_u, prs_struct *ps, int depth)
1577 if (q_u == NULL) return False;
1579 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriver");
1580 depth++;
1582 if (!prs_align(ps))
1583 return False;
1585 if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
1586 return False;
1587 if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
1588 return False;
1589 if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth))
1590 return False;
1591 if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth))
1592 return False;
1595 return True;
1599 /*******************************************************************
1600 * write a structure.
1601 ********************************************************************/
1602 BOOL spoolss_io_r_deleteprinterdriver(const char *desc, SPOOL_R_DELETEPRINTERDRIVER *r_u, prs_struct *ps, int depth)
1604 if (r_u == NULL) return False;
1606 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriver");
1607 depth++;
1609 if (!prs_align(ps))
1610 return False;
1612 if (!prs_werror("status", ps, depth, &r_u->status))
1613 return False;
1615 return True;
1619 /*******************************************************************
1620 * read a structure.
1621 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1622 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1623 ********************************************************************/
1625 BOOL spoolss_io_q_deleteprinterdriverex(const char *desc, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, prs_struct *ps, int depth)
1627 if (q_u == NULL) return False;
1629 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriverex");
1630 depth++;
1632 if (!prs_align(ps))
1633 return False;
1635 if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
1636 return False;
1637 if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
1638 return False;
1639 if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth))
1640 return False;
1641 if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth))
1642 return False;
1644 if (!prs_align(ps))
1645 return False;
1647 if(!prs_uint32("delete_flags ", ps, depth, &q_u->delete_flags))
1648 return False;
1649 if(!prs_uint32("version ", ps, depth, &q_u->version))
1650 return False;
1653 return True;
1657 /*******************************************************************
1658 * write a structure.
1659 ********************************************************************/
1660 BOOL spoolss_io_r_deleteprinterdriverex(const char *desc, SPOOL_R_DELETEPRINTERDRIVEREX *r_u, prs_struct *ps, int depth)
1662 if (r_u == NULL) return False;
1664 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriverex");
1665 depth++;
1667 if (!prs_align(ps))
1668 return False;
1670 if (!prs_werror("status", ps, depth, &r_u->status))
1671 return False;
1673 return True;
1678 /*******************************************************************
1679 * read a structure.
1680 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1681 * called from spoolss_closeprinter (cli_spoolss.c)
1682 ********************************************************************/
1684 BOOL spoolss_io_q_closeprinter(const char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
1686 if (q_u == NULL) return False;
1688 prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
1689 depth++;
1691 if (!prs_align(ps))
1692 return False;
1694 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1695 return False;
1697 return True;
1700 /*******************************************************************
1701 * write a structure.
1702 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1703 * called from spoolss_closeprinter (cli_spoolss.c)
1704 ********************************************************************/
1706 BOOL spoolss_io_r_closeprinter(const char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth)
1708 prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter");
1709 depth++;
1711 if (!prs_align(ps))
1712 return False;
1714 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1715 return False;
1716 if (!prs_werror("status", ps, depth, &r_u->status))
1717 return False;
1719 return True;
1722 /*******************************************************************
1723 * read a structure.
1724 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1725 ********************************************************************/
1727 BOOL spoolss_io_q_startdocprinter(const char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth)
1729 if (q_u == NULL) return False;
1731 prs_debug(ps, depth, desc, "spoolss_io_q_startdocprinter");
1732 depth++;
1734 if(!prs_align(ps))
1735 return False;
1737 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1738 return False;
1740 if(!smb_io_doc_info_container("",&q_u->doc_info_container, ps, depth))
1741 return False;
1743 return True;
1746 /*******************************************************************
1747 * write a structure.
1748 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1749 ********************************************************************/
1751 BOOL spoolss_io_r_startdocprinter(const char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth)
1753 prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter");
1754 depth++;
1755 if(!prs_uint32("jobid", ps, depth, &r_u->jobid))
1756 return False;
1757 if(!prs_werror("status", ps, depth, &r_u->status))
1758 return False;
1760 return True;
1763 /*******************************************************************
1764 * read a structure.
1765 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1766 ********************************************************************/
1768 BOOL spoolss_io_q_enddocprinter(const char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth)
1770 if (q_u == NULL) return False;
1772 prs_debug(ps, depth, desc, "spoolss_io_q_enddocprinter");
1773 depth++;
1775 if(!prs_align(ps))
1776 return False;
1778 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1779 return False;
1781 return True;
1784 /*******************************************************************
1785 * write a structure.
1786 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1787 ********************************************************************/
1789 BOOL spoolss_io_r_enddocprinter(const char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth)
1791 prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter");
1792 depth++;
1793 if(!prs_werror("status", ps, depth, &r_u->status))
1794 return False;
1796 return True;
1799 /*******************************************************************
1800 * read a structure.
1801 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1802 ********************************************************************/
1804 BOOL spoolss_io_q_startpageprinter(const char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth)
1806 if (q_u == NULL) return False;
1808 prs_debug(ps, depth, desc, "spoolss_io_q_startpageprinter");
1809 depth++;
1811 if(!prs_align(ps))
1812 return False;
1814 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1815 return False;
1817 return True;
1820 /*******************************************************************
1821 * write a structure.
1822 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1823 ********************************************************************/
1825 BOOL spoolss_io_r_startpageprinter(const char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth)
1827 prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter");
1828 depth++;
1829 if(!prs_werror("status", ps, depth, &r_u->status))
1830 return False;
1832 return True;
1835 /*******************************************************************
1836 * read a structure.
1837 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1838 ********************************************************************/
1840 BOOL spoolss_io_q_endpageprinter(const char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth)
1842 if (q_u == NULL) return False;
1844 prs_debug(ps, depth, desc, "spoolss_io_q_endpageprinter");
1845 depth++;
1847 if(!prs_align(ps))
1848 return False;
1850 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1851 return False;
1853 return True;
1856 /*******************************************************************
1857 * write a structure.
1858 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1859 ********************************************************************/
1861 BOOL spoolss_io_r_endpageprinter(const char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth)
1863 prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter");
1864 depth++;
1865 if(!prs_werror("status", ps, depth, &r_u->status))
1866 return False;
1868 return True;
1871 /*******************************************************************
1872 * read a structure.
1873 * called from spoolss_q_writeprinter (srv_spoolss.c)
1874 ********************************************************************/
1876 BOOL spoolss_io_q_writeprinter(const char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth)
1878 if (q_u == NULL) return False;
1880 prs_debug(ps, depth, desc, "spoolss_io_q_writeprinter");
1881 depth++;
1883 if(!prs_align(ps))
1884 return False;
1886 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1887 return False;
1888 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1889 return False;
1891 if (q_u->buffer_size!=0)
1893 if (UNMARSHALLING(ps))
1894 q_u->buffer=PRS_ALLOC_MEM(ps, uint8, q_u->buffer_size);
1895 if(q_u->buffer == NULL)
1896 return False;
1897 if(!prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size))
1898 return False;
1900 if(!prs_align(ps))
1901 return False;
1902 if(!prs_uint32("buffer_size2", ps, depth, &q_u->buffer_size2))
1903 return False;
1905 return True;
1908 /*******************************************************************
1909 * write a structure.
1910 * called from spoolss_r_writeprinter (srv_spoolss.c)
1911 ********************************************************************/
1913 BOOL spoolss_io_r_writeprinter(const char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth)
1915 prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter");
1916 depth++;
1917 if(!prs_uint32("buffer_written", ps, depth, &r_u->buffer_written))
1918 return False;
1919 if(!prs_werror("status", ps, depth, &r_u->status))
1920 return False;
1922 return True;
1925 /*******************************************************************
1926 * read a structure.
1927 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1928 ********************************************************************/
1930 BOOL spoolss_io_q_rffpcnex(const char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, int depth)
1932 prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex");
1933 depth++;
1935 if(!prs_align(ps))
1936 return False;
1938 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
1939 return False;
1940 if(!prs_uint32("flags", ps, depth, &q_u->flags))
1941 return False;
1942 if(!prs_uint32("options", ps, depth, &q_u->options))
1943 return False;
1944 if(!prs_uint32("localmachine_ptr", ps, depth, &q_u->localmachine_ptr))
1945 return False;
1946 if(!smb_io_unistr2("localmachine", &q_u->localmachine, q_u->localmachine_ptr, ps, depth))
1947 return False;
1949 if(!prs_align(ps))
1950 return False;
1952 if(!prs_uint32("printerlocal", ps, depth, &q_u->printerlocal))
1953 return False;
1955 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1956 return False;
1958 if (q_u->option_ptr!=0) {
1960 if (UNMARSHALLING(ps))
1961 if((q_u->option=PRS_ALLOC_MEM(ps,SPOOL_NOTIFY_OPTION,1)) == NULL)
1962 return False;
1964 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1965 return False;
1968 return True;
1971 /*******************************************************************
1972 * write a structure.
1973 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1974 ********************************************************************/
1976 BOOL spoolss_io_r_rffpcnex(const char *desc, SPOOL_R_RFFPCNEX *r_u, prs_struct *ps, int depth)
1978 prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex");
1979 depth++;
1981 if(!prs_werror("status", ps, depth, &r_u->status))
1982 return False;
1984 return True;
1987 /*******************************************************************
1988 * read a structure.
1989 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1990 ********************************************************************/
1992 BOOL spoolss_io_q_rfnpcnex(const char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, int depth)
1994 prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex");
1995 depth++;
1997 if(!prs_align(ps))
1998 return False;
2000 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
2001 return False;
2003 if(!prs_uint32("change", ps, depth, &q_u->change))
2004 return False;
2006 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
2007 return False;
2009 if (q_u->option_ptr!=0) {
2011 if (UNMARSHALLING(ps))
2012 if((q_u->option=PRS_ALLOC_MEM(ps,SPOOL_NOTIFY_OPTION,1)) == NULL)
2013 return False;
2015 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
2016 return False;
2019 return True;
2022 /*******************************************************************
2023 * write a structure.
2024 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
2025 ********************************************************************/
2027 BOOL spoolss_io_r_rfnpcnex(const char *desc, SPOOL_R_RFNPCNEX *r_u, prs_struct *ps, int depth)
2029 prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex");
2030 depth++;
2032 if(!prs_align(ps))
2033 return False;
2035 if (!prs_uint32("info_ptr", ps, depth, &r_u->info_ptr))
2036 return False;
2038 if(!smb_io_notify_info("notify info", &r_u->info ,ps,depth))
2039 return False;
2041 if(!prs_align(ps))
2042 return False;
2043 if(!prs_werror("status", ps, depth, &r_u->status))
2044 return False;
2046 return True;
2049 /*******************************************************************
2050 * return the length of a uint16 (obvious, but the code is clean)
2051 ********************************************************************/
2053 static uint32 size_of_uint16(uint16 *value)
2055 return (sizeof(*value));
2058 /*******************************************************************
2059 * return the length of a uint32 (obvious, but the code is clean)
2060 ********************************************************************/
2062 static uint32 size_of_uint32(uint32 *value)
2064 return (sizeof(*value));
2067 /*******************************************************************
2068 * return the length of a NTTIME (obvious, but the code is clean)
2069 ********************************************************************/
2071 static uint32 size_of_nttime(NTTIME *value)
2073 return (sizeof(*value));
2076 /*******************************************************************
2077 * return the length of a uint32 (obvious, but the code is clean)
2078 ********************************************************************/
2080 static uint32 size_of_device_mode(DEVICEMODE *devmode)
2082 if (devmode==NULL)
2083 return (4);
2084 else
2085 return (4+devmode->size+devmode->driverextra);
2088 /*******************************************************************
2089 * return the length of a uint32 (obvious, but the code is clean)
2090 ********************************************************************/
2092 static uint32 size_of_systemtime(SYSTEMTIME *systime)
2094 if (systime==NULL)
2095 return (4);
2096 else
2097 return (sizeof(SYSTEMTIME) +4);
2100 /*******************************************************************
2101 Parse a DEVMODE structure and its relative pointer.
2102 ********************************************************************/
2104 static BOOL smb_io_reldevmode(const char *desc, RPC_BUFFER *buffer, int depth, DEVICEMODE **devmode)
2106 prs_struct *ps=&buffer->prs;
2108 prs_debug(ps, depth, desc, "smb_io_reldevmode");
2109 depth++;
2111 if (MARSHALLING(ps)) {
2112 uint32 struct_offset = prs_offset(ps);
2113 uint32 relative_offset;
2115 if (*devmode == NULL) {
2116 relative_offset=0;
2117 if (!prs_uint32("offset", ps, depth, &relative_offset))
2118 return False;
2119 DEBUG(8, ("boing, the devmode was NULL\n"));
2121 return True;
2124 buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra);
2126 if(!prs_set_offset(ps, buffer->string_at_end))
2127 return False;
2129 /* write the DEVMODE */
2130 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2131 return False;
2133 if(!prs_set_offset(ps, struct_offset))
2134 return False;
2136 relative_offset=buffer->string_at_end - buffer->struct_start;
2137 /* write its offset */
2138 if (!prs_uint32("offset", ps, depth, &relative_offset))
2139 return False;
2141 else {
2142 uint32 old_offset;
2144 /* read the offset */
2145 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
2146 return False;
2147 if (buffer->string_at_end == 0) {
2148 *devmode = NULL;
2149 return True;
2152 old_offset = prs_offset(ps);
2153 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
2154 return False;
2156 /* read the string */
2157 if((*devmode=PRS_ALLOC_MEM(ps,DEVICEMODE,1)) == NULL)
2158 return False;
2159 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2160 return False;
2162 if(!prs_set_offset(ps, old_offset))
2163 return False;
2165 return True;
2168 /*******************************************************************
2169 Parse a PRINTER_INFO_0 structure.
2170 ********************************************************************/
2172 BOOL smb_io_printer_info_0(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
2174 prs_struct *ps=&buffer->prs;
2176 prs_debug(ps, depth, desc, "smb_io_printer_info_0");
2177 depth++;
2179 buffer->struct_start=prs_offset(ps);
2181 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2182 return False;
2183 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2184 return False;
2186 if(!prs_uint32("cjobs", ps, depth, &info->cjobs))
2187 return False;
2188 if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs))
2189 return False;
2190 if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes))
2191 return False;
2193 if(!prs_uint16("year", ps, depth, &info->year))
2194 return False;
2195 if(!prs_uint16("month", ps, depth, &info->month))
2196 return False;
2197 if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek))
2198 return False;
2199 if(!prs_uint16("day", ps, depth, &info->day))
2200 return False;
2201 if(!prs_uint16("hour", ps, depth, &info->hour))
2202 return False;
2203 if(!prs_uint16("minute", ps, depth, &info->minute))
2204 return False;
2205 if(!prs_uint16("second", ps, depth, &info->second))
2206 return False;
2207 if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds))
2208 return False;
2210 if(!prs_uint32("global_counter", ps, depth, &info->global_counter))
2211 return False;
2212 if(!prs_uint32("total_pages", ps, depth, &info->total_pages))
2213 return False;
2215 if(!prs_uint16("major_version", ps, depth, &info->major_version))
2216 return False;
2217 if(!prs_uint16("build_version", ps, depth, &info->build_version))
2218 return False;
2219 if(!prs_uint32("unknown7", ps, depth, &info->unknown7))
2220 return False;
2221 if(!prs_uint32("unknown8", ps, depth, &info->unknown8))
2222 return False;
2223 if(!prs_uint32("unknown9", ps, depth, &info->unknown9))
2224 return False;
2225 if(!prs_uint32("session_counter", ps, depth, &info->session_counter))
2226 return False;
2227 if(!prs_uint32("unknown11", ps, depth, &info->unknown11))
2228 return False;
2229 if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors))
2230 return False;
2231 if(!prs_uint32("unknown13", ps, depth, &info->unknown13))
2232 return False;
2233 if(!prs_uint32("unknown14", ps, depth, &info->unknown14))
2234 return False;
2235 if(!prs_uint32("unknown15", ps, depth, &info->unknown15))
2236 return False;
2237 if(!prs_uint32("unknown16", ps, depth, &info->unknown16))
2238 return False;
2239 if(!prs_uint32("change_id", ps, depth, &info->change_id))
2240 return False;
2241 if(!prs_uint32("unknown18", ps, depth, &info->unknown18))
2242 return False;
2243 if(!prs_uint32("status" , ps, depth, &info->status))
2244 return False;
2245 if(!prs_uint32("unknown20", ps, depth, &info->unknown20))
2246 return False;
2247 if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter))
2248 return False;
2249 if(!prs_uint16("unknown22", ps, depth, &info->unknown22))
2250 return False;
2251 if(!prs_uint16("unknown23", ps, depth, &info->unknown23))
2252 return False;
2253 if(!prs_uint16("unknown24", ps, depth, &info->unknown24))
2254 return False;
2255 if(!prs_uint16("unknown25", ps, depth, &info->unknown25))
2256 return False;
2257 if(!prs_uint16("unknown26", ps, depth, &info->unknown26))
2258 return False;
2259 if(!prs_uint16("unknown27", ps, depth, &info->unknown27))
2260 return False;
2261 if(!prs_uint16("unknown28", ps, depth, &info->unknown28))
2262 return False;
2263 if(!prs_uint16("unknown29", ps, depth, &info->unknown29))
2264 return False;
2266 return True;
2269 /*******************************************************************
2270 Parse a PRINTER_INFO_1 structure.
2271 ********************************************************************/
2273 BOOL smb_io_printer_info_1(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
2275 prs_struct *ps=&buffer->prs;
2277 prs_debug(ps, depth, desc, "smb_io_printer_info_1");
2278 depth++;
2280 buffer->struct_start=prs_offset(ps);
2282 if (!prs_uint32("flags", ps, depth, &info->flags))
2283 return False;
2284 if (!smb_io_relstr("description", buffer, depth, &info->description))
2285 return False;
2286 if (!smb_io_relstr("name", buffer, depth, &info->name))
2287 return False;
2288 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2289 return False;
2291 return True;
2294 /*******************************************************************
2295 Parse a PRINTER_INFO_2 structure.
2296 ********************************************************************/
2298 BOOL smb_io_printer_info_2(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
2300 prs_struct *ps=&buffer->prs;
2301 uint32 dm_offset, sd_offset, current_offset;
2302 uint32 dummy_value = 0, has_secdesc = 0;
2304 prs_debug(ps, depth, desc, "smb_io_printer_info_2");
2305 depth++;
2307 buffer->struct_start=prs_offset(ps);
2309 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2310 return False;
2311 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2312 return False;
2313 if (!smb_io_relstr("sharename", buffer, depth, &info->sharename))
2314 return False;
2315 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2316 return False;
2317 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2318 return False;
2319 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2320 return False;
2321 if (!smb_io_relstr("location", buffer, depth, &info->location))
2322 return False;
2324 /* save current offset and wind forwared by a uint32 */
2325 dm_offset = prs_offset(ps);
2326 if (!prs_uint32("devmode", ps, depth, &dummy_value))
2327 return False;
2329 if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
2330 return False;
2331 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2332 return False;
2333 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2334 return False;
2335 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2336 return False;
2338 /* save current offset for the sec_desc */
2339 sd_offset = prs_offset(ps);
2340 if (!prs_uint32("sec_desc", ps, depth, &has_secdesc))
2341 return False;
2344 /* save current location so we can pick back up here */
2345 current_offset = prs_offset(ps);
2347 /* parse the devmode */
2348 if (!prs_set_offset(ps, dm_offset))
2349 return False;
2350 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2351 return False;
2353 /* parse the sec_desc */
2354 if (info->secdesc) {
2355 if (!prs_set_offset(ps, sd_offset))
2356 return False;
2357 if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
2358 return False;
2361 /* pick up where we left off */
2362 if (!prs_set_offset(ps, current_offset))
2363 return False;
2365 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2366 return False;
2367 if (!prs_uint32("priority", ps, depth, &info->priority))
2368 return False;
2369 if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority))
2370 return False;
2371 if (!prs_uint32("starttime", ps, depth, &info->starttime))
2372 return False;
2373 if (!prs_uint32("untiltime", ps, depth, &info->untiltime))
2374 return False;
2375 if (!prs_uint32("status", ps, depth, &info->status))
2376 return False;
2377 if (!prs_uint32("jobs", ps, depth, &info->cjobs))
2378 return False;
2379 if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
2380 return False;
2382 return True;
2385 /*******************************************************************
2386 Parse a PRINTER_INFO_3 structure.
2387 ********************************************************************/
2389 BOOL smb_io_printer_info_3(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
2391 prs_struct *ps=&buffer->prs;
2393 prs_debug(ps, depth, desc, "smb_io_printer_info_3");
2394 depth++;
2396 buffer->struct_start=prs_offset(ps);
2398 if (!prs_uint32("flags", ps, depth, &info->flags))
2399 return False;
2400 if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth))
2401 return False;
2403 return True;
2406 /*******************************************************************
2407 Parse a PRINTER_INFO_4 structure.
2408 ********************************************************************/
2410 BOOL smb_io_printer_info_4(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_4 *info, int depth)
2412 prs_struct *ps=&buffer->prs;
2414 prs_debug(ps, depth, desc, "smb_io_printer_info_4");
2415 depth++;
2417 buffer->struct_start=prs_offset(ps);
2419 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2420 return False;
2421 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2422 return False;
2423 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2424 return False;
2425 return True;
2428 /*******************************************************************
2429 Parse a PRINTER_INFO_5 structure.
2430 ********************************************************************/
2432 BOOL smb_io_printer_info_5(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_5 *info, int depth)
2434 prs_struct *ps=&buffer->prs;
2436 prs_debug(ps, depth, desc, "smb_io_printer_info_5");
2437 depth++;
2439 buffer->struct_start=prs_offset(ps);
2441 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2442 return False;
2443 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2444 return False;
2445 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2446 return False;
2447 if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout))
2448 return False;
2449 if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout))
2450 return False;
2451 return True;
2454 /*******************************************************************
2455 Parse a PRINTER_INFO_7 structure.
2456 ********************************************************************/
2458 BOOL smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth)
2460 prs_struct *ps=&buffer->prs;
2462 prs_debug(ps, depth, desc, "smb_io_printer_info_7");
2463 depth++;
2465 buffer->struct_start=prs_offset(ps);
2467 if (!smb_io_relstr("guid", buffer, depth, &info->guid))
2468 return False;
2469 if (!prs_uint32("action", ps, depth, &info->action))
2470 return False;
2471 return True;
2474 /*******************************************************************
2475 Parse a PORT_INFO_1 structure.
2476 ********************************************************************/
2478 BOOL smb_io_port_info_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2480 prs_struct *ps=&buffer->prs;
2482 prs_debug(ps, depth, desc, "smb_io_port_info_1");
2483 depth++;
2485 buffer->struct_start=prs_offset(ps);
2487 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2488 return False;
2490 return True;
2493 /*******************************************************************
2494 Parse a PORT_INFO_2 structure.
2495 ********************************************************************/
2497 BOOL smb_io_port_info_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2499 prs_struct *ps=&buffer->prs;
2501 prs_debug(ps, depth, desc, "smb_io_port_info_2");
2502 depth++;
2504 buffer->struct_start=prs_offset(ps);
2506 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2507 return False;
2508 if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2509 return False;
2510 if (!smb_io_relstr("description", buffer, depth, &info->description))
2511 return False;
2512 if (!prs_uint32("port_type", ps, depth, &info->port_type))
2513 return False;
2514 if (!prs_uint32("reserved", ps, depth, &info->reserved))
2515 return False;
2517 return True;
2520 /*******************************************************************
2521 Parse a DRIVER_INFO_1 structure.
2522 ********************************************************************/
2524 BOOL smb_io_printer_driver_info_1(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
2526 prs_struct *ps=&buffer->prs;
2528 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
2529 depth++;
2531 buffer->struct_start=prs_offset(ps);
2533 if (!smb_io_relstr("name", buffer, depth, &info->name))
2534 return False;
2536 return True;
2539 /*******************************************************************
2540 Parse a DRIVER_INFO_2 structure.
2541 ********************************************************************/
2543 BOOL smb_io_printer_driver_info_2(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
2545 prs_struct *ps=&buffer->prs;
2547 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
2548 depth++;
2550 buffer->struct_start=prs_offset(ps);
2552 if (!prs_uint32("version", ps, depth, &info->version))
2553 return False;
2554 if (!smb_io_relstr("name", buffer, depth, &info->name))
2555 return False;
2556 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2557 return False;
2558 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2559 return False;
2560 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2561 return False;
2562 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2563 return False;
2565 return True;
2568 /*******************************************************************
2569 Parse a DRIVER_INFO_3 structure.
2570 ********************************************************************/
2572 BOOL smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
2574 prs_struct *ps=&buffer->prs;
2576 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
2577 depth++;
2579 buffer->struct_start=prs_offset(ps);
2581 if (!prs_uint32("version", ps, depth, &info->version))
2582 return False;
2583 if (!smb_io_relstr("name", buffer, depth, &info->name))
2584 return False;
2585 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2586 return False;
2587 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2588 return False;
2589 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2590 return False;
2591 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2592 return False;
2593 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2594 return False;
2596 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2597 return False;
2599 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2600 return False;
2601 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2602 return False;
2604 return True;
2607 /*******************************************************************
2608 Parse a DRIVER_INFO_6 structure.
2609 ********************************************************************/
2611 BOOL smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
2613 prs_struct *ps=&buffer->prs;
2615 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
2616 depth++;
2618 buffer->struct_start=prs_offset(ps);
2620 if (!prs_uint32("version", ps, depth, &info->version))
2621 return False;
2622 if (!smb_io_relstr("name", buffer, depth, &info->name))
2623 return False;
2624 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2625 return False;
2626 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2627 return False;
2628 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2629 return False;
2630 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2631 return False;
2632 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2633 return False;
2635 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2636 return False;
2638 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2639 return False;
2640 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2641 return False;
2643 if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
2644 return False;
2646 if (!prs_uint64("date", ps, depth, &info->driver_date))
2647 return False;
2649 if (!prs_uint32("padding", ps, depth, &info->padding))
2650 return False;
2652 if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
2653 return False;
2655 if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
2656 return False;
2658 if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
2659 return False;
2660 if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
2661 return False;
2662 if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
2663 return False;
2664 if (!smb_io_relstr("provider", buffer, depth, &info->provider))
2665 return False;
2667 return True;
2670 /*******************************************************************
2671 Parse a JOB_INFO_1 structure.
2672 ********************************************************************/
2674 BOOL smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, int depth)
2676 prs_struct *ps=&buffer->prs;
2678 prs_debug(ps, depth, desc, "smb_io_job_info_1");
2679 depth++;
2681 buffer->struct_start=prs_offset(ps);
2683 if (!prs_uint32("jobid", ps, depth, &info->jobid))
2684 return False;
2685 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2686 return False;
2687 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2688 return False;
2689 if (!smb_io_relstr("username", buffer, depth, &info->username))
2690 return False;
2691 if (!smb_io_relstr("document", buffer, depth, &info->document))
2692 return False;
2693 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2694 return False;
2695 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2696 return False;
2697 if (!prs_uint32("status", ps, depth, &info->status))
2698 return False;
2699 if (!prs_uint32("priority", ps, depth, &info->priority))
2700 return False;
2701 if (!prs_uint32("position", ps, depth, &info->position))
2702 return False;
2703 if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
2704 return False;
2705 if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
2706 return False;
2707 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
2708 return False;
2710 return True;
2713 /*******************************************************************
2714 Parse a JOB_INFO_2 structure.
2715 ********************************************************************/
2717 BOOL smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth)
2719 uint32 pipo=0;
2720 prs_struct *ps=&buffer->prs;
2722 prs_debug(ps, depth, desc, "smb_io_job_info_2");
2723 depth++;
2725 buffer->struct_start=prs_offset(ps);
2727 if (!prs_uint32("jobid",ps, depth, &info->jobid))
2728 return False;
2729 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2730 return False;
2731 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2732 return False;
2733 if (!smb_io_relstr("username", buffer, depth, &info->username))
2734 return False;
2735 if (!smb_io_relstr("document", buffer, depth, &info->document))
2736 return False;
2737 if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
2738 return False;
2739 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2740 return False;
2742 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2743 return False;
2744 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2745 return False;
2746 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2747 return False;
2748 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2749 return False;
2750 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2751 return False;
2753 /* SEC_DESC sec_desc;*/
2754 if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
2755 return False;
2757 if (!prs_uint32("status",ps, depth, &info->status))
2758 return False;
2759 if (!prs_uint32("priority",ps, depth, &info->priority))
2760 return False;
2761 if (!prs_uint32("position",ps, depth, &info->position))
2762 return False;
2763 if (!prs_uint32("starttime",ps, depth, &info->starttime))
2764 return False;
2765 if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
2766 return False;
2767 if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
2768 return False;
2769 if (!prs_uint32("size",ps, depth, &info->size))
2770 return False;
2771 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
2772 return False;
2773 if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
2774 return False;
2775 if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
2776 return False;
2778 return True;
2781 /*******************************************************************
2782 ********************************************************************/
2784 BOOL smb_io_form_1(const char *desc, RPC_BUFFER *buffer, FORM_1 *info, int depth)
2786 prs_struct *ps=&buffer->prs;
2788 prs_debug(ps, depth, desc, "smb_io_form_1");
2789 depth++;
2791 buffer->struct_start=prs_offset(ps);
2793 if (!prs_uint32("flag", ps, depth, &info->flag))
2794 return False;
2796 if (!smb_io_relstr("name", buffer, depth, &info->name))
2797 return False;
2799 if (!prs_uint32("width", ps, depth, &info->width))
2800 return False;
2801 if (!prs_uint32("length", ps, depth, &info->length))
2802 return False;
2803 if (!prs_uint32("left", ps, depth, &info->left))
2804 return False;
2805 if (!prs_uint32("top", ps, depth, &info->top))
2806 return False;
2807 if (!prs_uint32("right", ps, depth, &info->right))
2808 return False;
2809 if (!prs_uint32("bottom", ps, depth, &info->bottom))
2810 return False;
2812 return True;
2817 /*******************************************************************
2818 Parse a DRIVER_DIRECTORY_1 structure.
2819 ********************************************************************/
2821 BOOL smb_io_driverdir_1(const char *desc, RPC_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
2823 prs_struct *ps=&buffer->prs;
2825 prs_debug(ps, depth, desc, "smb_io_driverdir_1");
2826 depth++;
2828 buffer->struct_start=prs_offset(ps);
2830 if (!smb_io_unistr(desc, &info->name, ps, depth))
2831 return False;
2833 return True;
2836 /*******************************************************************
2837 Parse a PORT_INFO_1 structure.
2838 ********************************************************************/
2840 BOOL smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2842 prs_struct *ps=&buffer->prs;
2844 prs_debug(ps, depth, desc, "smb_io_port_1");
2845 depth++;
2847 buffer->struct_start=prs_offset(ps);
2849 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2850 return False;
2852 return True;
2855 /*******************************************************************
2856 Parse a PORT_INFO_2 structure.
2857 ********************************************************************/
2859 BOOL smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2861 prs_struct *ps=&buffer->prs;
2863 prs_debug(ps, depth, desc, "smb_io_port_2");
2864 depth++;
2866 buffer->struct_start=prs_offset(ps);
2868 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2869 return False;
2870 if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2871 return False;
2872 if(!smb_io_relstr("description", buffer, depth, &info->description))
2873 return False;
2874 if(!prs_uint32("port_type", ps, depth, &info->port_type))
2875 return False;
2876 if(!prs_uint32("reserved", ps, depth, &info->reserved))
2877 return False;
2879 return True;
2882 /*******************************************************************
2883 ********************************************************************/
2885 BOOL smb_io_printprocessor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
2887 prs_struct *ps=&buffer->prs;
2889 prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1");
2890 depth++;
2892 buffer->struct_start=prs_offset(ps);
2894 if (smb_io_relstr("name", buffer, depth, &info->name))
2895 return False;
2897 return True;
2900 /*******************************************************************
2901 ********************************************************************/
2903 BOOL smb_io_printprocdatatype_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth)
2905 prs_struct *ps=&buffer->prs;
2907 prs_debug(ps, depth, desc, "smb_io_printprocdatatype_info_1");
2908 depth++;
2910 buffer->struct_start=prs_offset(ps);
2912 if (smb_io_relstr("name", buffer, depth, &info->name))
2913 return False;
2915 return True;
2918 /*******************************************************************
2919 ********************************************************************/
2921 BOOL smb_io_printmonitor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
2923 prs_struct *ps=&buffer->prs;
2925 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1");
2926 depth++;
2928 buffer->struct_start=prs_offset(ps);
2930 if (!smb_io_relstr("name", buffer, depth, &info->name))
2931 return False;
2933 return True;
2936 /*******************************************************************
2937 ********************************************************************/
2939 BOOL smb_io_printmonitor_info_2(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
2941 prs_struct *ps=&buffer->prs;
2943 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
2944 depth++;
2946 buffer->struct_start=prs_offset(ps);
2948 if (!smb_io_relstr("name", buffer, depth, &info->name))
2949 return False;
2950 if (!smb_io_relstr("environment", buffer, depth, &info->environment))
2951 return False;
2952 if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
2953 return False;
2955 return True;
2958 /*******************************************************************
2959 return the size required by a struct in the stream
2960 ********************************************************************/
2962 uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
2964 int size=0;
2966 size+=size_of_relative_string( &info->printername );
2967 size+=size_of_relative_string( &info->servername );
2969 size+=size_of_uint32( &info->cjobs);
2970 size+=size_of_uint32( &info->total_jobs);
2971 size+=size_of_uint32( &info->total_bytes);
2973 size+=size_of_uint16( &info->year);
2974 size+=size_of_uint16( &info->month);
2975 size+=size_of_uint16( &info->dayofweek);
2976 size+=size_of_uint16( &info->day);
2977 size+=size_of_uint16( &info->hour);
2978 size+=size_of_uint16( &info->minute);
2979 size+=size_of_uint16( &info->second);
2980 size+=size_of_uint16( &info->milliseconds);
2982 size+=size_of_uint32( &info->global_counter);
2983 size+=size_of_uint32( &info->total_pages);
2985 size+=size_of_uint16( &info->major_version);
2986 size+=size_of_uint16( &info->build_version);
2988 size+=size_of_uint32( &info->unknown7);
2989 size+=size_of_uint32( &info->unknown8);
2990 size+=size_of_uint32( &info->unknown9);
2991 size+=size_of_uint32( &info->session_counter);
2992 size+=size_of_uint32( &info->unknown11);
2993 size+=size_of_uint32( &info->printer_errors);
2994 size+=size_of_uint32( &info->unknown13);
2995 size+=size_of_uint32( &info->unknown14);
2996 size+=size_of_uint32( &info->unknown15);
2997 size+=size_of_uint32( &info->unknown16);
2998 size+=size_of_uint32( &info->change_id);
2999 size+=size_of_uint32( &info->unknown18);
3000 size+=size_of_uint32( &info->status);
3001 size+=size_of_uint32( &info->unknown20);
3002 size+=size_of_uint32( &info->c_setprinter);
3004 size+=size_of_uint16( &info->unknown22);
3005 size+=size_of_uint16( &info->unknown23);
3006 size+=size_of_uint16( &info->unknown24);
3007 size+=size_of_uint16( &info->unknown25);
3008 size+=size_of_uint16( &info->unknown26);
3009 size+=size_of_uint16( &info->unknown27);
3010 size+=size_of_uint16( &info->unknown28);
3011 size+=size_of_uint16( &info->unknown29);
3013 return size;
3016 /*******************************************************************
3017 return the size required by a struct in the stream
3018 ********************************************************************/
3020 uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
3022 int size=0;
3024 size+=size_of_uint32( &info->flags );
3025 size+=size_of_relative_string( &info->description );
3026 size+=size_of_relative_string( &info->name );
3027 size+=size_of_relative_string( &info->comment );
3029 return size;
3032 /*******************************************************************
3033 return the size required by a struct in the stream
3034 ********************************************************************/
3036 uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
3038 uint32 size=0;
3040 size += 4;
3042 size += sec_desc_size( info->secdesc );
3044 size+=size_of_device_mode( info->devmode );
3046 size+=size_of_relative_string( &info->servername );
3047 size+=size_of_relative_string( &info->printername );
3048 size+=size_of_relative_string( &info->sharename );
3049 size+=size_of_relative_string( &info->portname );
3050 size+=size_of_relative_string( &info->drivername );
3051 size+=size_of_relative_string( &info->comment );
3052 size+=size_of_relative_string( &info->location );
3054 size+=size_of_relative_string( &info->sepfile );
3055 size+=size_of_relative_string( &info->printprocessor );
3056 size+=size_of_relative_string( &info->datatype );
3057 size+=size_of_relative_string( &info->parameters );
3059 size+=size_of_uint32( &info->attributes );
3060 size+=size_of_uint32( &info->priority );
3061 size+=size_of_uint32( &info->defaultpriority );
3062 size+=size_of_uint32( &info->starttime );
3063 size+=size_of_uint32( &info->untiltime );
3064 size+=size_of_uint32( &info->status );
3065 size+=size_of_uint32( &info->cjobs );
3066 size+=size_of_uint32( &info->averageppm );
3069 * add any adjustments for alignment. This is
3070 * not optimal since we could be calling this
3071 * function from a loop (e.g. enumprinters), but
3072 * it is easier to maintain the calculation here and
3073 * not place the burden on the caller to remember. --jerry
3075 if ((size % 4) != 0)
3076 size += 4 - (size % 4);
3078 return size;
3081 /*******************************************************************
3082 return the size required by a struct in the stream
3083 ********************************************************************/
3085 uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
3087 uint32 size=0;
3089 size+=size_of_relative_string( &info->printername );
3090 size+=size_of_relative_string( &info->servername );
3092 size+=size_of_uint32( &info->attributes );
3093 return size;
3096 /*******************************************************************
3097 return the size required by a struct in the stream
3098 ********************************************************************/
3100 uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
3102 uint32 size=0;
3104 size+=size_of_relative_string( &info->printername );
3105 size+=size_of_relative_string( &info->portname );
3107 size+=size_of_uint32( &info->attributes );
3108 size+=size_of_uint32( &info->device_not_selected_timeout );
3109 size+=size_of_uint32( &info->transmission_retry_timeout );
3110 return size;
3114 /*******************************************************************
3115 return the size required by a struct in the stream
3116 ********************************************************************/
3118 uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
3120 /* The 4 is for the self relative pointer.. */
3121 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3122 return 4 + (uint32)sec_desc_size( info->secdesc );
3125 /*******************************************************************
3126 return the size required by a struct in the stream
3127 ********************************************************************/
3129 uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info)
3131 uint32 size=0;
3133 size+=size_of_relative_string( &info->guid );
3134 size+=size_of_uint32( &info->action );
3135 return size;
3138 /*******************************************************************
3139 return the size required by a struct in the stream
3140 ********************************************************************/
3142 uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
3144 int size=0;
3145 size+=size_of_relative_string( &info->name );
3147 return size;
3150 /*******************************************************************
3151 return the size required by a struct in the stream
3152 ********************************************************************/
3154 uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
3156 int size=0;
3157 size+=size_of_uint32( &info->version );
3158 size+=size_of_relative_string( &info->name );
3159 size+=size_of_relative_string( &info->architecture );
3160 size+=size_of_relative_string( &info->driverpath );
3161 size+=size_of_relative_string( &info->datafile );
3162 size+=size_of_relative_string( &info->configfile );
3164 return size;
3167 /*******************************************************************
3168 return the size required by a string array.
3169 ********************************************************************/
3171 uint32 spoolss_size_string_array(uint16 *string)
3173 uint32 i = 0;
3175 if (string) {
3176 for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
3178 i=i+2; /* to count all chars including the leading zero */
3179 i=2*i; /* because we need the value in bytes */
3180 i=i+4; /* the offset pointer size */
3182 return i;
3185 /*******************************************************************
3186 return the size required by a struct in the stream
3187 ********************************************************************/
3189 uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
3191 int size=0;
3193 size+=size_of_uint32( &info->version );
3194 size+=size_of_relative_string( &info->name );
3195 size+=size_of_relative_string( &info->architecture );
3196 size+=size_of_relative_string( &info->driverpath );
3197 size+=size_of_relative_string( &info->datafile );
3198 size+=size_of_relative_string( &info->configfile );
3199 size+=size_of_relative_string( &info->helpfile );
3200 size+=size_of_relative_string( &info->monitorname );
3201 size+=size_of_relative_string( &info->defaultdatatype );
3203 size+=spoolss_size_string_array(info->dependentfiles);
3205 return size;
3208 /*******************************************************************
3209 return the size required by a struct in the stream
3210 ********************************************************************/
3212 uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
3214 uint32 size=0;
3216 size+=size_of_uint32( &info->version );
3217 size+=size_of_relative_string( &info->name );
3218 size+=size_of_relative_string( &info->architecture );
3219 size+=size_of_relative_string( &info->driverpath );
3220 size+=size_of_relative_string( &info->datafile );
3221 size+=size_of_relative_string( &info->configfile );
3222 size+=size_of_relative_string( &info->helpfile );
3224 size+=spoolss_size_string_array(info->dependentfiles);
3226 size+=size_of_relative_string( &info->monitorname );
3227 size+=size_of_relative_string( &info->defaultdatatype );
3229 size+=spoolss_size_string_array(info->previousdrivernames);
3231 size+=size_of_nttime(&info->driver_date);
3232 size+=size_of_uint32( &info->padding );
3233 size+=size_of_uint32( &info->driver_version_low );
3234 size+=size_of_uint32( &info->driver_version_high );
3235 size+=size_of_relative_string( &info->mfgname );
3236 size+=size_of_relative_string( &info->oem_url );
3237 size+=size_of_relative_string( &info->hardware_id );
3238 size+=size_of_relative_string( &info->provider );
3240 return size;
3243 /*******************************************************************
3244 return the size required by a struct in the stream
3245 ********************************************************************/
3247 uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
3249 int size=0;
3250 size+=size_of_uint32( &info->jobid );
3251 size+=size_of_relative_string( &info->printername );
3252 size+=size_of_relative_string( &info->machinename );
3253 size+=size_of_relative_string( &info->username );
3254 size+=size_of_relative_string( &info->document );
3255 size+=size_of_relative_string( &info->datatype );
3256 size+=size_of_relative_string( &info->text_status );
3257 size+=size_of_uint32( &info->status );
3258 size+=size_of_uint32( &info->priority );
3259 size+=size_of_uint32( &info->position );
3260 size+=size_of_uint32( &info->totalpages );
3261 size+=size_of_uint32( &info->pagesprinted );
3262 size+=size_of_systemtime( &info->submitted );
3264 return size;
3267 /*******************************************************************
3268 return the size required by a struct in the stream
3269 ********************************************************************/
3271 uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
3273 int size=0;
3275 size+=4; /* size of sec desc ptr */
3277 size+=size_of_uint32( &info->jobid );
3278 size+=size_of_relative_string( &info->printername );
3279 size+=size_of_relative_string( &info->machinename );
3280 size+=size_of_relative_string( &info->username );
3281 size+=size_of_relative_string( &info->document );
3282 size+=size_of_relative_string( &info->notifyname );
3283 size+=size_of_relative_string( &info->datatype );
3284 size+=size_of_relative_string( &info->printprocessor );
3285 size+=size_of_relative_string( &info->parameters );
3286 size+=size_of_relative_string( &info->drivername );
3287 size+=size_of_device_mode( info->devmode );
3288 size+=size_of_relative_string( &info->text_status );
3289 /* SEC_DESC sec_desc;*/
3290 size+=size_of_uint32( &info->status );
3291 size+=size_of_uint32( &info->priority );
3292 size+=size_of_uint32( &info->position );
3293 size+=size_of_uint32( &info->starttime );
3294 size+=size_of_uint32( &info->untiltime );
3295 size+=size_of_uint32( &info->totalpages );
3296 size+=size_of_uint32( &info->size );
3297 size+=size_of_systemtime( &info->submitted );
3298 size+=size_of_uint32( &info->timeelapsed );
3299 size+=size_of_uint32( &info->pagesprinted );
3301 return size;
3304 /*******************************************************************
3305 return the size required by a struct in the stream
3306 ********************************************************************/
3308 uint32 spoolss_size_form_1(FORM_1 *info)
3310 int size=0;
3312 size+=size_of_uint32( &info->flag );
3313 size+=size_of_relative_string( &info->name );
3314 size+=size_of_uint32( &info->width );
3315 size+=size_of_uint32( &info->length );
3316 size+=size_of_uint32( &info->left );
3317 size+=size_of_uint32( &info->top );
3318 size+=size_of_uint32( &info->right );
3319 size+=size_of_uint32( &info->bottom );
3321 return size;
3324 /*******************************************************************
3325 return the size required by a struct in the stream
3326 ********************************************************************/
3328 uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
3330 int size=0;
3332 size+=size_of_relative_string( &info->port_name );
3334 return size;
3337 /*******************************************************************
3338 return the size required by a struct in the stream
3339 ********************************************************************/
3341 uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info)
3343 int size=0;
3345 size=str_len_uni(&info->name); /* the string length */
3346 size=size+1; /* add the leading zero */
3347 size=size*2; /* convert in char */
3349 return size;
3352 /*******************************************************************
3353 return the size required by a struct in the stream
3354 ********************************************************************/
3356 uint32 spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1 *info)
3358 int size=0;
3360 size=str_len_uni(&info->name); /* the string length */
3361 size=size+1; /* add the leading zero */
3362 size=size*2; /* convert in char */
3364 return size;
3367 /*******************************************************************
3368 return the size required by a struct in the stream
3369 ********************************************************************/
3371 uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
3373 int size=0;
3375 size+=size_of_relative_string( &info->port_name );
3376 size+=size_of_relative_string( &info->monitor_name );
3377 size+=size_of_relative_string( &info->description );
3379 size+=size_of_uint32( &info->port_type );
3380 size+=size_of_uint32( &info->reserved );
3382 return size;
3385 /*******************************************************************
3386 return the size required by a struct in the stream
3387 ********************************************************************/
3389 uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
3391 int size=0;
3392 size+=size_of_relative_string( &info->name );
3394 return size;
3397 /*******************************************************************
3398 return the size required by a struct in the stream
3399 ********************************************************************/
3401 uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info)
3403 int size=0;
3404 size+=size_of_relative_string( &info->name );
3406 return size;
3409 /*******************************************************************
3410 return the size required by a struct in the stream
3411 ********************************************************************/
3412 uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
3414 uint32 size = 0;
3416 if (!p)
3417 return 0;
3419 /* uint32(offset) + uint32(length) + length) */
3420 size += (size_of_uint32(&p->value_len)*2) + p->value_len;
3421 size += (size_of_uint32(&p->data_len)*2) + p->data_len + (p->data_len%2) ;
3423 size += size_of_uint32(&p->type);
3425 return size;
3428 /*******************************************************************
3429 return the size required by a struct in the stream
3430 ********************************************************************/
3432 uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
3434 int size=0;
3435 size+=size_of_relative_string( &info->name );
3437 return size;
3440 /*******************************************************************
3441 return the size required by a struct in the stream
3442 ********************************************************************/
3444 uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
3446 int size=0;
3447 size+=size_of_relative_string( &info->name);
3448 size+=size_of_relative_string( &info->environment);
3449 size+=size_of_relative_string( &info->dll_name);
3451 return size;
3454 /*******************************************************************
3455 * init a structure.
3456 ********************************************************************/
3458 BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
3459 const POLICY_HND *hnd,
3460 const fstring architecture,
3461 uint32 level, uint32 clientmajor, uint32 clientminor,
3462 RPC_BUFFER *buffer, uint32 offered)
3464 if (q_u == NULL)
3465 return False;
3467 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3469 init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture);
3471 q_u->level=level;
3472 q_u->clientmajorversion=clientmajor;
3473 q_u->clientminorversion=clientminor;
3475 q_u->buffer=buffer;
3476 q_u->offered=offered;
3478 return True;
3481 /*******************************************************************
3482 * read a structure.
3483 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3484 ********************************************************************/
3486 BOOL spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
3488 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
3489 depth++;
3491 if(!prs_align(ps))
3492 return False;
3494 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3495 return False;
3496 if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr))
3497 return False;
3498 if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth))
3499 return False;
3501 if(!prs_align(ps))
3502 return False;
3503 if(!prs_uint32("level", ps, depth, &q_u->level))
3504 return False;
3506 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3507 return False;
3509 if(!prs_align(ps))
3510 return False;
3512 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3513 return False;
3515 if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion))
3516 return False;
3517 if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion))
3518 return False;
3520 return True;
3523 /*******************************************************************
3524 * read a structure.
3525 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3526 ********************************************************************/
3528 BOOL spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
3530 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
3531 depth++;
3533 if (!prs_align(ps))
3534 return False;
3536 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3537 return False;
3539 if (!prs_align(ps))
3540 return False;
3541 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3542 return False;
3543 if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion))
3544 return False;
3545 if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
3546 return False;
3547 if (!prs_werror("status", ps, depth, &r_u->status))
3548 return False;
3550 return True;
3553 /*******************************************************************
3554 * init a structure.
3555 ********************************************************************/
3557 BOOL make_spoolss_q_enumprinters(
3558 SPOOL_Q_ENUMPRINTERS *q_u,
3559 uint32 flags,
3560 char *servername,
3561 uint32 level,
3562 RPC_BUFFER *buffer,
3563 uint32 offered
3566 q_u->flags=flags;
3568 q_u->servername_ptr = (servername != NULL) ? 1 : 0;
3569 init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
3571 q_u->level=level;
3572 q_u->buffer=buffer;
3573 q_u->offered=offered;
3575 return True;
3578 /*******************************************************************
3579 * init a structure.
3580 ********************************************************************/
3582 BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u,
3583 fstring servername, uint32 level,
3584 RPC_BUFFER *buffer, uint32 offered)
3586 q_u->name_ptr = (servername != NULL) ? 1 : 0;
3587 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
3589 q_u->level=level;
3590 q_u->buffer=buffer;
3591 q_u->offered=offered;
3593 return True;
3596 /*******************************************************************
3597 * read a structure.
3598 * called from spoolss_enumprinters (srv_spoolss.c)
3599 ********************************************************************/
3601 BOOL spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
3603 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
3604 depth++;
3606 if (!prs_align(ps))
3607 return False;
3609 if (!prs_uint32("flags", ps, depth, &q_u->flags))
3610 return False;
3611 if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
3612 return False;
3614 if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
3615 return False;
3617 if (!prs_align(ps))
3618 return False;
3619 if (!prs_uint32("level", ps, depth, &q_u->level))
3620 return False;
3622 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3623 return False;
3625 if (!prs_align(ps))
3626 return False;
3627 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3628 return False;
3630 return True;
3633 /*******************************************************************
3634 Parse a SPOOL_R_ENUMPRINTERS structure.
3635 ********************************************************************/
3637 BOOL spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
3639 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
3640 depth++;
3642 if (!prs_align(ps))
3643 return False;
3645 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3646 return False;
3648 if (!prs_align(ps))
3649 return False;
3651 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3652 return False;
3654 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3655 return False;
3657 if (!prs_werror("status", ps, depth, &r_u->status))
3658 return False;
3660 return True;
3663 /*******************************************************************
3664 * write a structure.
3665 * called from spoolss_r_enum_printers (srv_spoolss.c)
3667 ********************************************************************/
3669 BOOL spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
3671 prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
3672 depth++;
3674 if (!prs_align(ps))
3675 return False;
3677 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3678 return False;
3680 if (!prs_align(ps))
3681 return False;
3683 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3684 return False;
3686 if (!prs_werror("status", ps, depth, &r_u->status))
3687 return False;
3689 return True;
3692 /*******************************************************************
3693 * read a structure.
3694 * called from spoolss_getprinter (srv_spoolss.c)
3695 ********************************************************************/
3697 BOOL spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
3699 prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
3700 depth++;
3702 if (!prs_align(ps))
3703 return False;
3705 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3706 return False;
3707 if (!prs_uint32("level", ps, depth, &q_u->level))
3708 return False;
3710 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3711 return False;
3713 if (!prs_align(ps))
3714 return False;
3715 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3716 return False;
3718 return True;
3721 /*******************************************************************
3722 * init a structure.
3723 ********************************************************************/
3725 BOOL make_spoolss_q_getprinter(
3726 TALLOC_CTX *mem_ctx,
3727 SPOOL_Q_GETPRINTER *q_u,
3728 const POLICY_HND *hnd,
3729 uint32 level,
3730 RPC_BUFFER *buffer,
3731 uint32 offered
3734 if (q_u == NULL)
3736 return False;
3738 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3740 q_u->level=level;
3741 q_u->buffer=buffer;
3742 q_u->offered=offered;
3744 return True;
3747 /*******************************************************************
3748 * init a structure.
3749 ********************************************************************/
3750 BOOL make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
3751 const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
3752 uint32 command)
3754 SEC_DESC *secdesc;
3755 DEVICEMODE *devmode;
3757 if (!q_u || !info)
3758 return False;
3760 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3762 q_u->level = level;
3763 q_u->info.level = level;
3764 q_u->info.info_ptr = 1; /* Info is != NULL, see above */
3765 switch (level) {
3767 /* There's no such thing as a setprinter level 1 */
3769 case 2:
3770 secdesc = info->printers_2->secdesc;
3771 devmode = info->printers_2->devmode;
3773 make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2);
3774 #if 1 /* JERRY TEST */
3775 q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
3776 if (!q_u->secdesc_ctr)
3777 return False;
3778 q_u->secdesc_ctr->sd = secdesc;
3779 q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3781 q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
3782 q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0;
3783 q_u->devmode_ctr.devmode = devmode;
3784 #else
3785 q_u->secdesc_ctr = NULL;
3787 q_u->devmode_ctr.devmode_ptr = 0;
3788 q_u->devmode_ctr.size = 0;
3789 q_u->devmode_ctr.devmode = NULL;
3790 #endif
3791 break;
3792 case 3:
3793 secdesc = info->printers_3->secdesc;
3795 make_spoolss_printer_info_3 (mem_ctx, &q_u->info.info_3, info->printers_3);
3797 q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
3798 if (!q_u->secdesc_ctr)
3799 return False;
3800 q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3801 q_u->secdesc_ctr->sd = secdesc;
3803 break;
3804 case 7:
3805 make_spoolss_printer_info_7 (mem_ctx, &q_u->info.info_7, info->printers_7);
3806 break;
3808 default:
3809 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
3810 break;
3814 q_u->command = command;
3816 return True;
3820 /*******************************************************************
3821 ********************************************************************/
3823 BOOL spoolss_io_r_setprinter(const char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
3825 prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
3826 depth++;
3828 if(!prs_align(ps))
3829 return False;
3831 if(!prs_werror("status", ps, depth, &r_u->status))
3832 return False;
3834 return True;
3837 /*******************************************************************
3838 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3839 ********************************************************************/
3841 BOOL spoolss_io_q_setprinter(const char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
3843 uint32 ptr_sec_desc = 0;
3845 prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
3846 depth++;
3848 if(!prs_align(ps))
3849 return False;
3851 if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
3852 return False;
3853 if(!prs_uint32("level", ps, depth, &q_u->level))
3854 return False;
3856 /* check for supported levels and structures we know about */
3858 switch ( q_u->level ) {
3859 case 0:
3860 case 2:
3861 case 3:
3862 case 7:
3863 /* supported levels */
3864 break;
3865 default:
3866 DEBUG(0,("spoolss_io_q_setprinter: unsupported printer info level [%d]\n",
3867 q_u->level));
3868 return True;
3872 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
3873 return False;
3875 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
3876 return False;
3878 if(!prs_align(ps))
3879 return False;
3881 switch (q_u->level)
3883 case 2:
3885 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
3886 break;
3888 case 3:
3890 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
3891 break;
3894 if (ptr_sec_desc)
3896 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
3897 return False;
3898 } else {
3899 uint32 dummy = 0;
3901 /* Parse a NULL security descriptor. This should really
3902 happen inside the sec_io_desc_buf() function. */
3904 prs_debug(ps, depth, "", "sec_io_desc_buf");
3905 if (!prs_uint32("size", ps, depth + 1, &dummy))
3906 return False;
3907 if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return
3908 False;
3911 if(!prs_uint32("command", ps, depth, &q_u->command))
3912 return False;
3914 return True;
3917 /*******************************************************************
3918 ********************************************************************/
3920 BOOL spoolss_io_r_fcpn(const char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
3922 prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
3923 depth++;
3925 if(!prs_align(ps))
3926 return False;
3928 if(!prs_werror("status", ps, depth, &r_u->status))
3929 return False;
3931 return True;
3934 /*******************************************************************
3935 ********************************************************************/
3937 BOOL spoolss_io_q_fcpn(const char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
3940 prs_debug(ps, depth, desc, "spoolss_io_q_fcpn");
3941 depth++;
3943 if(!prs_align(ps))
3944 return False;
3946 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3947 return False;
3949 return True;
3953 /*******************************************************************
3954 ********************************************************************/
3956 BOOL spoolss_io_r_addjob(const char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
3958 prs_debug(ps, depth, desc, "");
3959 depth++;
3961 if(!prs_align(ps))
3962 return False;
3964 if(!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3965 return False;
3967 if(!prs_align(ps))
3968 return False;
3970 if(!prs_uint32("needed", ps, depth, &r_u->needed))
3971 return False;
3973 if(!prs_werror("status", ps, depth, &r_u->status))
3974 return False;
3976 return True;
3979 /*******************************************************************
3980 ********************************************************************/
3982 BOOL spoolss_io_q_addjob(const char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
3984 prs_debug(ps, depth, desc, "");
3985 depth++;
3987 if(!prs_align(ps))
3988 return False;
3990 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3991 return False;
3992 if(!prs_uint32("level", ps, depth, &q_u->level))
3993 return False;
3995 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3996 return False;
3998 if(!prs_align(ps))
3999 return False;
4001 if(!prs_uint32("offered", ps, depth, &q_u->offered))
4002 return False;
4004 return True;
4007 /*******************************************************************
4008 ********************************************************************/
4010 BOOL spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
4012 prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
4013 depth++;
4015 if (!prs_align(ps))
4016 return False;
4018 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4019 return False;
4021 if (!prs_align(ps))
4022 return False;
4024 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4025 return False;
4027 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4028 return False;
4030 if (!prs_werror("status", ps, depth, &r_u->status))
4031 return False;
4033 return True;
4036 /*******************************************************************
4037 ********************************************************************/
4039 BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
4040 uint32 firstjob,
4041 uint32 numofjobs,
4042 uint32 level,
4043 RPC_BUFFER *buffer,
4044 uint32 offered)
4046 if (q_u == NULL)
4048 return False;
4050 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
4051 q_u->firstjob = firstjob;
4052 q_u->numofjobs = numofjobs;
4053 q_u->level = level;
4054 q_u->buffer= buffer;
4055 q_u->offered = offered;
4056 return True;
4059 /*******************************************************************
4060 ********************************************************************/
4062 BOOL spoolss_io_q_enumjobs(const char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
4064 prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
4065 depth++;
4067 if (!prs_align(ps))
4068 return False;
4070 if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth))
4071 return False;
4073 if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
4074 return False;
4075 if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
4076 return False;
4077 if (!prs_uint32("level", ps, depth, &q_u->level))
4078 return False;
4080 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4081 return False;
4083 if(!prs_align(ps))
4084 return False;
4086 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4087 return False;
4089 return True;
4092 /*******************************************************************
4093 ********************************************************************/
4095 BOOL spoolss_io_r_schedulejob(const char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth)
4097 prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob");
4098 depth++;
4100 if(!prs_align(ps))
4101 return False;
4103 if(!prs_werror("status", ps, depth, &r_u->status))
4104 return False;
4106 return True;
4109 /*******************************************************************
4110 ********************************************************************/
4112 BOOL spoolss_io_q_schedulejob(const char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth)
4114 prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob");
4115 depth++;
4117 if(!prs_align(ps))
4118 return False;
4120 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4121 return False;
4122 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4123 return False;
4125 return True;
4128 /*******************************************************************
4129 ********************************************************************/
4131 BOOL spoolss_io_r_setjob(const char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth)
4133 prs_debug(ps, depth, desc, "spoolss_io_r_setjob");
4134 depth++;
4136 if(!prs_align(ps))
4137 return False;
4139 if(!prs_werror("status", ps, depth, &r_u->status))
4140 return False;
4142 return True;
4145 /*******************************************************************
4146 ********************************************************************/
4148 BOOL spoolss_io_q_setjob(const char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth)
4150 prs_debug(ps, depth, desc, "spoolss_io_q_setjob");
4151 depth++;
4153 if(!prs_align(ps))
4154 return False;
4156 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4157 return False;
4158 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4159 return False;
4161 * level is usually 0. If (level!=0) then I'm in trouble !
4162 * I will try to generate setjob command with level!=0, one day.
4164 if(!prs_uint32("level", ps, depth, &q_u->level))
4165 return False;
4166 if(!prs_uint32("command", ps, depth, &q_u->command))
4167 return False;
4169 return True;
4172 /*******************************************************************
4173 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4174 ********************************************************************/
4176 BOOL spoolss_io_r_enumprinterdrivers(const char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
4178 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
4179 depth++;
4181 if (!prs_align(ps))
4182 return False;
4184 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4185 return False;
4187 if (!prs_align(ps))
4188 return False;
4190 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4191 return False;
4193 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4194 return False;
4196 if (!prs_werror("status", ps, depth, &r_u->status))
4197 return False;
4199 return True;
4202 /*******************************************************************
4203 * init a structure.
4204 ********************************************************************/
4206 BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
4207 const char *name,
4208 const char *environment,
4209 uint32 level,
4210 RPC_BUFFER *buffer, uint32 offered)
4212 init_buf_unistr2(&q_u->name, &q_u->name_ptr, name);
4213 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment);
4215 q_u->level=level;
4216 q_u->buffer=buffer;
4217 q_u->offered=offered;
4219 return True;
4222 /*******************************************************************
4223 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4224 ********************************************************************/
4226 BOOL spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
4229 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
4230 depth++;
4232 if (!prs_align(ps))
4233 return False;
4235 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
4236 return False;
4237 if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
4238 return False;
4240 if (!prs_align(ps))
4241 return False;
4242 if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
4243 return False;
4244 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
4245 return False;
4247 if (!prs_align(ps))
4248 return False;
4249 if (!prs_uint32("level", ps, depth, &q_u->level))
4250 return False;
4252 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4253 return False;
4255 if (!prs_align(ps))
4256 return False;
4258 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4259 return False;
4261 return True;
4264 /*******************************************************************
4265 ********************************************************************/
4267 BOOL spoolss_io_q_enumforms(const char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
4270 prs_debug(ps, depth, desc, "spoolss_io_q_enumforms");
4271 depth++;
4273 if (!prs_align(ps))
4274 return False;
4275 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4276 return False;
4277 if (!prs_uint32("level", ps, depth, &q_u->level))
4278 return False;
4280 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4281 return False;
4283 if (!prs_align(ps))
4284 return False;
4285 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4286 return False;
4288 return True;
4291 /*******************************************************************
4292 ********************************************************************/
4294 BOOL spoolss_io_r_enumforms(const char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
4296 prs_debug(ps, depth, desc, "spoolss_io_r_enumforms");
4297 depth++;
4299 if (!prs_align(ps))
4300 return False;
4302 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4303 return False;
4305 if (!prs_align(ps))
4306 return False;
4308 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4309 return False;
4311 if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
4312 return False;
4314 if (!prs_werror("status", ps, depth, &r_u->status))
4315 return False;
4317 return True;
4320 /*******************************************************************
4321 ********************************************************************/
4323 BOOL spoolss_io_q_getform(const char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
4326 prs_debug(ps, depth, desc, "spoolss_io_q_getform");
4327 depth++;
4329 if (!prs_align(ps))
4330 return False;
4331 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4332 return False;
4333 if (!smb_io_unistr2("", &q_u->formname,True,ps,depth))
4334 return False;
4336 if (!prs_align(ps))
4337 return False;
4339 if (!prs_uint32("level", ps, depth, &q_u->level))
4340 return False;
4342 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4343 return False;
4345 if (!prs_align(ps))
4346 return False;
4347 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4348 return False;
4350 return True;
4353 /*******************************************************************
4354 ********************************************************************/
4356 BOOL spoolss_io_r_getform(const char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
4358 prs_debug(ps, depth, desc, "spoolss_io_r_getform");
4359 depth++;
4361 if (!prs_align(ps))
4362 return False;
4364 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4365 return False;
4367 if (!prs_align(ps))
4368 return False;
4370 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4371 return False;
4373 if (!prs_werror("status", ps, depth, &r_u->status))
4374 return False;
4376 return True;
4379 /*******************************************************************
4380 Parse a SPOOL_R_ENUMPORTS structure.
4381 ********************************************************************/
4383 BOOL spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
4385 prs_debug(ps, depth, desc, "spoolss_io_r_enumports");
4386 depth++;
4388 if (!prs_align(ps))
4389 return False;
4391 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4392 return False;
4394 if (!prs_align(ps))
4395 return False;
4397 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4398 return False;
4400 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4401 return False;
4403 if (!prs_werror("status", ps, depth, &r_u->status))
4404 return False;
4406 return True;
4409 /*******************************************************************
4410 ********************************************************************/
4412 BOOL spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
4414 prs_debug(ps, depth, desc, "");
4415 depth++;
4417 if (!prs_align(ps))
4418 return False;
4420 if (!prs_uint32("", ps, depth, &q_u->name_ptr))
4421 return False;
4422 if (!smb_io_unistr2("", &q_u->name,True,ps,depth))
4423 return False;
4425 if (!prs_align(ps))
4426 return False;
4427 if (!prs_uint32("level", ps, depth, &q_u->level))
4428 return False;
4430 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4431 return False;
4433 if (!prs_align(ps))
4434 return False;
4435 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4436 return False;
4438 return True;
4441 /*******************************************************************
4442 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4443 ********************************************************************/
4445 BOOL spool_io_printer_info_level_1(const char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
4447 prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
4448 depth++;
4450 if(!prs_align(ps))
4451 return False;
4453 if(!prs_uint32("flags", ps, depth, &il->flags))
4454 return False;
4455 if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr))
4456 return False;
4457 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4458 return False;
4459 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4460 return False;
4462 if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth))
4463 return False;
4464 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4465 return False;
4466 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4467 return False;
4469 return True;
4472 /*******************************************************************
4473 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4474 ********************************************************************/
4476 BOOL spool_io_printer_info_level_3(const char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
4478 prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
4479 depth++;
4481 if(!prs_align(ps))
4482 return False;
4484 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4485 return False;
4487 return True;
4490 /*******************************************************************
4491 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4492 ********************************************************************/
4494 BOOL spool_io_printer_info_level_2(const char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
4496 prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
4497 depth++;
4499 if(!prs_align(ps))
4500 return False;
4502 if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr))
4503 return False;
4504 if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr))
4505 return False;
4506 if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr))
4507 return False;
4508 if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
4509 return False;
4511 if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
4512 return False;
4513 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4514 return False;
4515 if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr))
4516 return False;
4517 if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr))
4518 return False;
4519 if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr))
4520 return False;
4521 if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr))
4522 return False;
4523 if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr))
4524 return False;
4525 if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr))
4526 return False;
4527 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4528 return False;
4530 if(!prs_uint32("attributes", ps, depth, &il->attributes))
4531 return False;
4532 if(!prs_uint32("priority", ps, depth, &il->priority))
4533 return False;
4534 if(!prs_uint32("default_priority", ps, depth, &il->default_priority))
4535 return False;
4536 if(!prs_uint32("starttime", ps, depth, &il->starttime))
4537 return False;
4538 if(!prs_uint32("untiltime", ps, depth, &il->untiltime))
4539 return False;
4540 if(!prs_uint32("status", ps, depth, &il->status))
4541 return False;
4542 if(!prs_uint32("cjobs", ps, depth, &il->cjobs))
4543 return False;
4544 if(!prs_uint32("averageppm", ps, depth, &il->averageppm))
4545 return False;
4547 if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth))
4548 return False;
4549 if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth))
4550 return False;
4551 if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth))
4552 return False;
4553 if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth))
4554 return False;
4555 if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth))
4556 return False;
4557 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4558 return False;
4559 if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth))
4560 return False;
4561 if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth))
4562 return False;
4563 if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth))
4564 return False;
4565 if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth))
4566 return False;
4567 if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth))
4568 return False;
4570 return True;
4573 BOOL spool_io_printer_info_level_7(const char *desc, SPOOL_PRINTER_INFO_LEVEL_7 *il, prs_struct *ps, int depth)
4575 prs_debug(ps, depth, desc, "spool_io_printer_info_level_7");
4576 depth++;
4578 if(!prs_align(ps))
4579 return False;
4581 if(!prs_uint32("guid_ptr", ps, depth, &il->guid_ptr))
4582 return False;
4583 if(!prs_uint32("action", ps, depth, &il->action))
4584 return False;
4586 if(!smb_io_unistr2("servername", &il->guid, il->guid_ptr, ps, depth))
4587 return False;
4588 return True;
4591 /*******************************************************************
4592 ********************************************************************/
4594 BOOL spool_io_printer_info_level(const char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
4596 prs_debug(ps, depth, desc, "spool_io_printer_info_level");
4597 depth++;
4599 if(!prs_align(ps))
4600 return False;
4601 if(!prs_uint32("level", ps, depth, &il->level))
4602 return False;
4603 if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr))
4604 return False;
4606 /* if no struct inside just return */
4607 if (il->info_ptr==0) {
4608 if (UNMARSHALLING(ps)) {
4609 il->info_1=NULL;
4610 il->info_2=NULL;
4612 return True;
4615 switch (il->level) {
4617 * level 0 is used by setprinter when managing the queue
4618 * (hold, stop, start a queue)
4620 case 0:
4621 break;
4622 /* DOCUMENT ME!!! What is level 1 used for? */
4623 case 1:
4625 if (UNMARSHALLING(ps)) {
4626 if ((il->info_1=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_1,1)) == NULL)
4627 return False;
4629 if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
4630 return False;
4631 break;
4634 * level 2 is used by addprinter
4635 * and by setprinter when updating printer's info
4637 case 2:
4638 if (UNMARSHALLING(ps)) {
4639 if ((il->info_2=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_2,1)) == NULL)
4640 return False;
4642 if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
4643 return False;
4644 break;
4645 /* DOCUMENT ME!!! What is level 3 used for? */
4646 case 3:
4648 if (UNMARSHALLING(ps)) {
4649 if ((il->info_3=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_3,1)) == NULL)
4650 return False;
4652 if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
4653 return False;
4654 break;
4656 case 7:
4657 if (UNMARSHALLING(ps))
4658 if ((il->info_7=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_7,1)) == NULL)
4659 return False;
4660 if (!spool_io_printer_info_level_7("", il->info_7, ps, depth))
4661 return False;
4662 break;
4665 return True;
4668 /*******************************************************************
4669 ********************************************************************/
4671 BOOL spoolss_io_q_addprinterex(const char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
4673 uint32 ptr_sec_desc = 0;
4675 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
4676 depth++;
4678 if(!prs_align(ps))
4679 return False;
4681 if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->server_name))
4682 return False;
4683 if (!prs_io_unistr2("servername", ps, depth, q_u->server_name))
4684 return False;
4686 if(!prs_align(ps))
4687 return False;
4689 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4690 return False;
4692 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
4693 return False;
4695 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
4696 return False;
4698 if(!prs_align(ps))
4699 return False;
4701 switch (q_u->level) {
4702 case 2:
4703 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
4704 break;
4705 case 3:
4706 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
4707 break;
4709 if (ptr_sec_desc) {
4710 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
4711 return False;
4712 } else {
4713 uint32 dummy;
4715 /* Parse a NULL security descriptor. This should really
4716 happen inside the sec_io_desc_buf() function. */
4718 prs_debug(ps, depth, "", "sec_io_desc_buf");
4719 if (!prs_uint32("size", ps, depth + 1, &dummy))
4720 return False;
4721 if (!prs_uint32("ptr", ps, depth + 1, &dummy))
4722 return False;
4725 if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
4726 return False;
4727 if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
4728 return False;
4730 return True;
4733 /*******************************************************************
4734 ********************************************************************/
4736 BOOL spoolss_io_r_addprinterex(const char *desc, SPOOL_R_ADDPRINTEREX *r_u,
4737 prs_struct *ps, int depth)
4739 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
4740 depth++;
4742 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
4743 return False;
4745 if(!prs_werror("status", ps, depth, &r_u->status))
4746 return False;
4748 return True;
4751 /*******************************************************************
4752 ********************************************************************/
4754 BOOL spool_io_printer_driver_info_level_3(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
4755 prs_struct *ps, int depth)
4757 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il;
4759 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3");
4760 depth++;
4762 /* reading */
4763 if (UNMARSHALLING(ps)) {
4764 il=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_DRIVER_INFO_LEVEL_3,1);
4765 if(il == NULL)
4766 return False;
4767 *q_u=il;
4769 else {
4770 il=*q_u;
4773 if(!prs_align(ps))
4774 return False;
4776 if(!prs_uint32("cversion", ps, depth, &il->cversion))
4777 return False;
4778 if(!prs_uint32("name", ps, depth, &il->name_ptr))
4779 return False;
4780 if(!prs_uint32("environment", ps, depth, &il->environment_ptr))
4781 return False;
4782 if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr))
4783 return False;
4784 if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr))
4785 return False;
4786 if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr))
4787 return False;
4788 if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr))
4789 return False;
4790 if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr))
4791 return False;
4792 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4793 return False;
4794 if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize))
4795 return False;
4796 if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr))
4797 return False;
4799 if(!prs_align(ps))
4800 return False;
4802 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4803 return False;
4804 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4805 return False;
4806 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4807 return False;
4808 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4809 return False;
4810 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4811 return False;
4812 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4813 return False;
4814 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4815 return False;
4816 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4817 return False;
4819 if(!prs_align(ps))
4820 return False;
4822 if (il->dependentfiles_ptr)
4823 smb_io_buffer5("", &il->dependentfiles, ps, depth);
4825 return True;
4828 /*******************************************************************
4829 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4830 ********************************************************************/
4832 BOOL spool_io_printer_driver_info_level_6(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
4833 prs_struct *ps, int depth)
4835 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il;
4837 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6");
4838 depth++;
4840 /* reading */
4841 if (UNMARSHALLING(ps)) {
4842 il=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_DRIVER_INFO_LEVEL_6,1);
4843 if(il == NULL)
4844 return False;
4845 *q_u=il;
4847 else {
4848 il=*q_u;
4851 if(!prs_align(ps))
4852 return False;
4855 * I know this seems weird, but I have no other explanation.
4856 * This is observed behavior on both NT4 and 2K servers.
4857 * --jerry
4860 if (!prs_align_uint64(ps))
4861 return False;
4863 /* parse the main elements the packet */
4865 if(!prs_uint32("cversion ", ps, depth, &il->version))
4866 return False;
4867 if(!prs_uint32("name ", ps, depth, &il->name_ptr))
4868 return False;
4869 if(!prs_uint32("environment ", ps, depth, &il->environment_ptr))
4870 return False;
4871 if(!prs_uint32("driverpath ", ps, depth, &il->driverpath_ptr))
4872 return False;
4873 if(!prs_uint32("datafile ", ps, depth, &il->datafile_ptr))
4874 return False;
4875 if(!prs_uint32("configfile ", ps, depth, &il->configfile_ptr))
4876 return False;
4877 if(!prs_uint32("helpfile ", ps, depth, &il->helpfile_ptr))
4878 return False;
4879 if(!prs_uint32("monitorname ", ps, depth, &il->monitorname_ptr))
4880 return False;
4881 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4882 return False;
4883 if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_len))
4884 return False;
4885 if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_ptr))
4886 return False;
4887 if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_len))
4888 return False;
4889 if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_ptr))
4890 return False;
4891 if(!smb_io_time("driverdate ", &il->driverdate, ps, depth))
4892 return False;
4893 if(!prs_uint32("dummy4 ", ps, depth, &il->dummy4))
4894 return False;
4895 if(!prs_uint64("driverversion ", ps, depth, &il->driverversion))
4896 return False;
4897 if(!prs_uint32("mfgname ", ps, depth, &il->mfgname_ptr))
4898 return False;
4899 if(!prs_uint32("oemurl ", ps, depth, &il->oemurl_ptr))
4900 return False;
4901 if(!prs_uint32("hardwareid ", ps, depth, &il->hardwareid_ptr))
4902 return False;
4903 if(!prs_uint32("provider ", ps, depth, &il->provider_ptr))
4904 return False;
4906 /* parse the structures in the packet */
4908 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4909 return False;
4910 if(!prs_align(ps))
4911 return False;
4913 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4914 return False;
4915 if(!prs_align(ps))
4916 return False;
4918 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4919 return False;
4920 if(!prs_align(ps))
4921 return False;
4923 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4924 return False;
4925 if(!prs_align(ps))
4926 return False;
4928 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4929 return False;
4930 if(!prs_align(ps))
4931 return False;
4933 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4934 return False;
4935 if(!prs_align(ps))
4936 return False;
4938 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4939 return False;
4940 if(!prs_align(ps))
4941 return False;
4943 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4944 return False;
4945 if(!prs_align(ps))
4946 return False;
4947 if (il->dependentfiles_ptr) {
4948 if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth))
4949 return False;
4950 if(!prs_align(ps))
4951 return False;
4953 if (il->previousnames_ptr) {
4954 if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth))
4955 return False;
4956 if(!prs_align(ps))
4957 return False;
4959 if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth))
4960 return False;
4961 if(!prs_align(ps))
4962 return False;
4963 if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth))
4964 return False;
4965 if(!prs_align(ps))
4966 return False;
4967 if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth))
4968 return False;
4969 if(!prs_align(ps))
4970 return False;
4971 if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth))
4972 return False;
4974 return True;
4977 /*******************************************************************
4978 convert a buffer of UNICODE strings null terminated
4979 the buffer is terminated by a NULL
4981 convert to an dos codepage array (null terminated)
4983 dynamically allocate memory
4985 ********************************************************************/
4987 static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
4989 fstring f;
4990 int n = 0;
4991 char *src;
4993 if (buf5==NULL)
4994 return False;
4996 src = (char *)buf5->buffer;
4997 *ar = SMB_MALLOC_ARRAY(fstring, 1);
4998 if (!*ar) {
4999 return False;
5002 while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
5003 rpcstr_pull(f, src, sizeof(f)-1, -1, STR_TERMINATE);
5004 src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
5005 *ar = SMB_REALLOC_ARRAY(*ar, fstring, n+2);
5006 if (!*ar) {
5007 return False;
5009 fstrcpy((*ar)[n], f);
5010 n++;
5013 fstrcpy((*ar)[n], "");
5015 return True;
5018 /*******************************************************************
5019 read a UNICODE array with null terminated strings
5020 and null terminated array
5021 and size of array at beginning
5022 ********************************************************************/
5024 BOOL smb_io_unibuffer(const char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
5026 if (buffer==NULL) return False;
5028 buffer->offset=0;
5029 buffer->uni_str_len=buffer->uni_max_len;
5031 if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
5032 return False;
5034 if(!prs_unistr2(True, "buffer ", ps, depth, buffer))
5035 return False;
5037 return True;
5040 /*******************************************************************
5041 ********************************************************************/
5043 BOOL spool_io_printer_driver_info_level(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
5045 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
5046 depth++;
5048 if(!prs_align(ps))
5049 return False;
5050 if(!prs_uint32("level", ps, depth, &il->level))
5051 return False;
5052 if(!prs_uint32("ptr", ps, depth, &il->ptr))
5053 return False;
5055 if (il->ptr==0)
5056 return True;
5058 switch (il->level) {
5059 case 3:
5060 if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth))
5061 return False;
5062 break;
5063 case 6:
5064 if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth))
5065 return False;
5066 break;
5067 default:
5068 return False;
5071 return True;
5074 /*******************************************************************
5075 init a SPOOL_Q_ADDPRINTERDRIVER struct
5076 ******************************************************************/
5078 BOOL make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
5079 SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name,
5080 uint32 level, PRINTER_DRIVER_CTR *info)
5082 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5084 if (!srv_name || !info) {
5085 return False;
5088 q_u->server_name_ptr = 1; /* srv_name is != NULL, see above */
5089 init_unistr2(&q_u->server_name, srv_name, UNI_STR_TERMINATE);
5091 q_u->level = level;
5093 q_u->info.level = level;
5094 q_u->info.ptr = 1; /* Info is != NULL, see above */
5095 switch (level)
5097 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5098 case 3 :
5099 make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3);
5100 break;
5102 default:
5103 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level));
5104 break;
5107 return True;
5110 BOOL make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
5111 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
5112 DRIVER_INFO_3 *info3)
5114 uint32 len = 0;
5115 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf;
5117 if (!(inf=TALLOC_ZERO_P(mem_ctx, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)))
5118 return False;
5120 inf->cversion = info3->version;
5121 inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
5122 inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
5123 inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
5124 inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
5125 inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
5126 inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
5127 inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
5128 inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
5130 init_unistr2_from_unistr(&inf->name, &info3->name);
5131 init_unistr2_from_unistr(&inf->environment, &info3->architecture);
5132 init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
5133 init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
5134 init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
5135 init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
5136 init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
5137 init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
5139 if (info3->dependentfiles) {
5140 BOOL done = False;
5141 BOOL null_char = False;
5142 uint16 *ptr = info3->dependentfiles;
5144 while (!done) {
5145 switch (*ptr) {
5146 case 0:
5147 /* the null_char BOOL is used to help locate
5148 two '\0's back to back */
5149 if (null_char) {
5150 done = True;
5151 } else {
5152 null_char = True;
5154 break;
5156 default:
5157 null_char = False;
5158 break;
5160 len++;
5161 ptr++;
5165 inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0;
5166 inf->dependentfilessize = (info3->dependentfiles != NULL) ? len : 0;
5167 if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles)) {
5168 SAFE_FREE(inf);
5169 return False;
5172 *spool_drv_info = inf;
5174 return True;
5177 /*******************************************************************
5178 make a BUFFER5 struct from a uint16*
5179 ******************************************************************/
5181 BOOL make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src)
5184 buf5->buf_len = len;
5185 if (src) {
5186 if((buf5->buffer=(uint16*)TALLOC_MEMDUP(mem_ctx, src, sizeof(uint16)*len)) == NULL) {
5187 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5188 return False;
5190 } else {
5191 buf5->buffer=NULL;
5194 return True;
5197 /*******************************************************************
5198 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5199 ********************************************************************/
5201 BOOL spoolss_io_q_addprinterdriver(const char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5203 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
5204 depth++;
5206 if(!prs_align(ps))
5207 return False;
5209 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
5210 return False;
5211 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
5212 return False;
5214 if(!prs_align(ps))
5215 return False;
5216 if(!prs_uint32("info_level", ps, depth, &q_u->level))
5217 return False;
5219 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
5220 return False;
5222 return True;
5225 /*******************************************************************
5226 ********************************************************************/
5228 BOOL spoolss_io_r_addprinterdriver(const char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5230 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
5231 depth++;
5233 if(!prs_werror("status", ps, depth, &q_u->status))
5234 return False;
5236 return True;
5239 /*******************************************************************
5240 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5241 ********************************************************************/
5243 BOOL spoolss_io_q_addprinterdriverex(const char *desc, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, prs_struct *ps, int depth)
5245 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriverex");
5246 depth++;
5248 if(!prs_align(ps))
5249 return False;
5251 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
5252 return False;
5253 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
5254 return False;
5256 if(!prs_align(ps))
5257 return False;
5258 if(!prs_uint32("info_level", ps, depth, &q_u->level))
5259 return False;
5261 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
5262 return False;
5264 if(!prs_align(ps))
5265 return False;
5266 if(!prs_uint32("copy flags", ps, depth, &q_u->copy_flags))
5267 return False;
5269 return True;
5272 /*******************************************************************
5273 ********************************************************************/
5275 BOOL spoolss_io_r_addprinterdriverex(const char *desc, SPOOL_R_ADDPRINTERDRIVEREX *q_u, prs_struct *ps, int depth)
5277 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriverex");
5278 depth++;
5280 if(!prs_werror("status", ps, depth, &q_u->status))
5281 return False;
5283 return True;
5286 /*******************************************************************
5287 ********************************************************************/
5289 BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
5290 NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc)
5292 NT_PRINTER_DRIVER_INFO_LEVEL_3 *d;
5294 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5296 if (*asc==NULL)
5298 *asc=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_3);
5299 if(*asc == NULL)
5300 return False;
5301 ZERO_STRUCTP(*asc);
5304 d=*asc;
5306 d->cversion=uni->cversion;
5308 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5309 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5310 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5311 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5312 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5313 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5314 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5315 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5317 DEBUGADD(8,( "version: %d\n", d->cversion));
5318 DEBUGADD(8,( "name: %s\n", d->name));
5319 DEBUGADD(8,( "environment: %s\n", d->environment));
5320 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5321 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5322 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5323 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5324 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5325 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5327 if (uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5328 return True;
5330 SAFE_FREE(*asc);
5331 return False;
5334 /*******************************************************************
5335 ********************************************************************/
5336 BOOL uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *uni,
5337 NT_PRINTER_DRIVER_INFO_LEVEL_6 **asc)
5339 NT_PRINTER_DRIVER_INFO_LEVEL_6 *d;
5341 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5343 if (*asc==NULL)
5345 *asc=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_6);
5346 if(*asc == NULL)
5347 return False;
5348 ZERO_STRUCTP(*asc);
5351 d=*asc;
5353 d->version=uni->version;
5355 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5356 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5357 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5358 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5359 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5360 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5361 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5362 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5364 DEBUGADD(8,( "version: %d\n", d->version));
5365 DEBUGADD(8,( "name: %s\n", d->name));
5366 DEBUGADD(8,( "environment: %s\n", d->environment));
5367 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5368 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5369 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5370 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5371 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5372 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5374 if (!uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5375 goto error;
5376 if (!uniarray_2_dosarray(&uni->previousnames, &d->previousnames ))
5377 goto error;
5379 return True;
5381 error:
5382 SAFE_FREE(*asc);
5383 return False;
5386 BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
5387 NT_PRINTER_INFO_LEVEL_2 *d)
5389 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5391 d->attributes=uni->attributes;
5392 d->priority=uni->priority;
5393 d->default_priority=uni->default_priority;
5394 d->starttime=uni->starttime;
5395 d->untiltime=uni->untiltime;
5396 d->status=uni->status;
5397 d->cjobs=uni->cjobs;
5399 unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1);
5400 unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1);
5401 unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
5402 unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
5403 unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
5404 unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
5405 unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
5406 unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
5407 unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
5408 unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype)-1);
5409 unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters)-1);
5411 return True;
5414 /*******************************************************************
5415 * init a structure.
5416 ********************************************************************/
5418 BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u,
5419 fstring servername, fstring env_name, uint32 level,
5420 RPC_BUFFER *buffer, uint32 offered)
5422 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
5423 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name);
5425 q_u->level=level;
5426 q_u->buffer=buffer;
5427 q_u->offered=offered;
5429 return True;
5432 /*******************************************************************
5433 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5434 ********************************************************************/
5436 BOOL spoolss_io_q_getprinterdriverdir(const char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth)
5438 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir");
5439 depth++;
5441 if(!prs_align(ps))
5442 return False;
5443 if(!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5444 return False;
5445 if(!smb_io_unistr2("", &q_u->name, q_u->name_ptr, ps, depth))
5446 return False;
5448 if(!prs_align(ps))
5449 return False;
5451 if(!prs_uint32("", ps, depth, &q_u->environment_ptr))
5452 return False;
5453 if(!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5454 return False;
5456 if(!prs_align(ps))
5457 return False;
5459 if(!prs_uint32("level", ps, depth, &q_u->level))
5460 return False;
5462 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
5463 return False;
5465 if(!prs_align(ps))
5466 return False;
5468 if(!prs_uint32("offered", ps, depth, &q_u->offered))
5469 return False;
5471 return True;
5474 /*******************************************************************
5475 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5476 ********************************************************************/
5478 BOOL spoolss_io_r_getprinterdriverdir(const char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth)
5480 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir");
5481 depth++;
5483 if (!prs_align(ps))
5484 return False;
5486 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
5487 return False;
5489 if (!prs_align(ps))
5490 return False;
5492 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5493 return False;
5495 if (!prs_werror("status", ps, depth, &r_u->status))
5496 return False;
5498 return True;
5501 /*******************************************************************
5502 ********************************************************************/
5504 BOOL spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
5506 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
5507 depth++;
5509 if (!prs_align(ps))
5510 return False;
5512 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
5513 return False;
5515 if (!prs_align(ps))
5516 return False;
5518 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5519 return False;
5521 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5522 return False;
5524 if (!prs_werror("status", ps, depth, &r_u->status))
5525 return False;
5527 return True;
5530 /*******************************************************************
5531 ********************************************************************/
5533 BOOL spoolss_io_q_enumprintprocessors(const char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth)
5535 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
5536 depth++;
5538 if (!prs_align(ps))
5539 return False;
5541 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5542 return False;
5543 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5544 return False;
5546 if (!prs_align(ps))
5547 return False;
5549 if (!prs_uint32("", ps, depth, &q_u->environment_ptr))
5550 return False;
5551 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5552 return False;
5554 if (!prs_align(ps))
5555 return False;
5557 if (!prs_uint32("level", ps, depth, &q_u->level))
5558 return False;
5560 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
5561 return False;
5563 if (!prs_align(ps))
5564 return False;
5566 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5567 return False;
5569 return True;
5572 /*******************************************************************
5573 ********************************************************************/
5575 BOOL spoolss_io_q_addprintprocessor(const char *desc, SPOOL_Q_ADDPRINTPROCESSOR *q_u, prs_struct *ps, int depth)
5577 prs_debug(ps, depth, desc, "spoolss_io_q_addprintprocessor");
5578 depth++;
5580 if (!prs_align(ps))
5581 return False;
5583 if (!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
5584 return False;
5585 if (!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
5586 return False;
5588 if (!prs_align(ps))
5589 return False;
5590 if (!smb_io_unistr2("environment", &q_u->environment, True, ps, depth))
5591 return False;
5593 if (!prs_align(ps))
5594 return False;
5595 if (!smb_io_unistr2("path", &q_u->path, True, ps, depth))
5596 return False;
5598 if (!prs_align(ps))
5599 return False;
5600 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5601 return False;
5603 return True;
5606 /*******************************************************************
5607 ********************************************************************/
5609 BOOL spoolss_io_r_addprintprocessor(const char *desc, SPOOL_R_ADDPRINTPROCESSOR *r_u, prs_struct *ps, int depth)
5611 prs_debug(ps, depth, desc, "spoolss_io_r_addprintproicessor");
5612 depth++;
5614 if (!prs_align(ps))
5615 return False;
5617 if (!prs_werror("status", ps, depth, &r_u->status))
5618 return False;
5620 return True;
5623 /*******************************************************************
5624 ********************************************************************/
5626 BOOL spoolss_io_r_enumprintprocdatatypes(const char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth)
5628 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes");
5629 depth++;
5631 if (!prs_align(ps))
5632 return False;
5634 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
5635 return False;
5637 if (!prs_align(ps))
5638 return False;
5640 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5641 return False;
5643 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5644 return False;
5646 if (!prs_werror("status", ps, depth, &r_u->status))
5647 return False;
5649 return True;
5652 /*******************************************************************
5653 ********************************************************************/
5655 BOOL spoolss_io_q_enumprintprocdatatypes(const char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth)
5657 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes");
5658 depth++;
5660 if (!prs_align(ps))
5661 return False;
5663 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5664 return False;
5665 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5666 return False;
5668 if (!prs_align(ps))
5669 return False;
5671 if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr))
5672 return False;
5673 if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth))
5674 return False;
5676 if (!prs_align(ps))
5677 return False;
5679 if (!prs_uint32("level", ps, depth, &q_u->level))
5680 return False;
5682 if(!prs_rpcbuffer_p("buffer", ps, depth, &q_u->buffer))
5683 return False;
5685 if (!prs_align(ps))
5686 return False;
5688 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5689 return False;
5691 return True;
5694 /*******************************************************************
5695 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5696 ********************************************************************/
5698 BOOL spoolss_io_q_enumprintmonitors(const char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
5700 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
5701 depth++;
5703 if (!prs_align(ps))
5704 return False;
5706 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5707 return False;
5708 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5709 return False;
5711 if (!prs_align(ps))
5712 return False;
5714 if (!prs_uint32("level", ps, depth, &q_u->level))
5715 return False;
5717 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
5718 return False;
5720 if (!prs_align(ps))
5721 return False;
5723 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5724 return False;
5726 return True;
5729 /*******************************************************************
5730 ********************************************************************/
5732 BOOL spoolss_io_r_enumprintmonitors(const char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
5734 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
5735 depth++;
5737 if (!prs_align(ps))
5738 return False;
5740 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
5741 return False;
5743 if (!prs_align(ps))
5744 return False;
5746 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5747 return False;
5749 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5750 return False;
5752 if (!prs_werror("status", ps, depth, &r_u->status))
5753 return False;
5755 return True;
5758 /*******************************************************************
5759 ********************************************************************/
5761 BOOL spoolss_io_r_enumprinterdata(const char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth)
5763 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata");
5764 depth++;
5766 if(!prs_align(ps))
5767 return False;
5768 if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize))
5769 return False;
5771 if (UNMARSHALLING(ps) && r_u->valuesize) {
5772 r_u->value = PRS_ALLOC_MEM(ps, uint16, r_u->valuesize);
5773 if (!r_u->value) {
5774 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
5775 return False;
5779 if(!prs_uint16uni(False, "value", ps, depth, r_u->value, r_u->valuesize ))
5780 return False;
5782 if(!prs_align(ps))
5783 return False;
5785 if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize))
5786 return False;
5788 if(!prs_uint32("type", ps, depth, &r_u->type))
5789 return False;
5791 if(!prs_uint32("datasize", ps, depth, &r_u->datasize))
5792 return False;
5794 if (UNMARSHALLING(ps) && r_u->datasize) {
5795 r_u->data = PRS_ALLOC_MEM(ps, uint8, r_u->datasize);
5796 if (!r_u->data) {
5797 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
5798 return False;
5802 if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize))
5803 return False;
5804 if(!prs_align(ps))
5805 return False;
5807 if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize))
5808 return False;
5809 if(!prs_werror("status", ps, depth, &r_u->status))
5810 return False;
5812 return True;
5815 /*******************************************************************
5816 ********************************************************************/
5818 BOOL spoolss_io_q_enumprinterdata(const char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth)
5820 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata");
5821 depth++;
5823 if(!prs_align(ps))
5824 return False;
5825 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5826 return False;
5827 if(!prs_uint32("index", ps, depth, &q_u->index))
5828 return False;
5829 if(!prs_uint32("valuesize", ps, depth, &q_u->valuesize))
5830 return False;
5831 if(!prs_uint32("datasize", ps, depth, &q_u->datasize))
5832 return False;
5834 return True;
5837 /*******************************************************************
5838 ********************************************************************/
5840 BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
5841 const POLICY_HND *hnd,
5842 uint32 idx, uint32 valuelen, uint32 datalen)
5844 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5845 q_u->index=idx;
5846 q_u->valuesize=valuelen;
5847 q_u->datasize=datalen;
5849 return True;
5852 /*******************************************************************
5853 ********************************************************************/
5855 BOOL make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
5856 const POLICY_HND *hnd, const char *key,
5857 uint32 size)
5859 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5860 init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
5861 q_u->size = size;
5863 return True;
5866 /*******************************************************************
5867 ********************************************************************/
5868 BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND *hnd,
5869 char* value, uint32 data_type, char* data, uint32 data_size)
5871 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5872 q_u->type = data_type;
5873 init_unistr2(&q_u->value, value, UNI_STR_TERMINATE);
5875 q_u->max_len = q_u->real_len = data_size;
5876 q_u->data = (unsigned char *)data;
5878 return True;
5881 /*******************************************************************
5882 ********************************************************************/
5883 BOOL make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX *q_u, const POLICY_HND *hnd,
5884 char *key, char* value, uint32 data_type, char* data,
5885 uint32 data_size)
5887 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5888 q_u->type = data_type;
5889 init_unistr2(&q_u->value, value, UNI_STR_TERMINATE);
5890 init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
5892 q_u->max_len = q_u->real_len = data_size;
5893 q_u->data = (unsigned char *)data;
5895 return True;
5898 /*******************************************************************
5899 ********************************************************************/
5901 BOOL spoolss_io_q_setprinterdata(const char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
5903 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
5904 depth++;
5906 if(!prs_align(ps))
5907 return False;
5908 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5909 return False;
5910 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
5911 return False;
5913 if(!prs_align(ps))
5914 return False;
5916 if(!prs_uint32("type", ps, depth, &q_u->type))
5917 return False;
5919 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
5920 return False;
5922 switch (q_u->type)
5924 case REG_SZ:
5925 case REG_BINARY:
5926 case REG_DWORD:
5927 case REG_MULTI_SZ:
5928 if (q_u->max_len) {
5929 if (UNMARSHALLING(ps))
5930 q_u->data=PRS_ALLOC_MEM(ps, uint8, q_u->max_len);
5931 if(q_u->data == NULL)
5932 return False;
5933 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
5934 return False;
5936 if(!prs_align(ps))
5937 return False;
5938 break;
5941 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
5942 return False;
5944 return True;
5947 /*******************************************************************
5948 ********************************************************************/
5950 BOOL spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
5952 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
5953 depth++;
5955 if(!prs_align(ps))
5956 return False;
5957 if(!prs_werror("status", ps, depth, &r_u->status))
5958 return False;
5960 return True;
5963 /*******************************************************************
5964 ********************************************************************/
5965 BOOL spoolss_io_q_resetprinter(const char *desc, SPOOL_Q_RESETPRINTER *q_u, prs_struct *ps, int depth)
5967 prs_debug(ps, depth, desc, "spoolss_io_q_resetprinter");
5968 depth++;
5970 if (!prs_align(ps))
5971 return False;
5972 if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5973 return False;
5975 if (!prs_uint32("datatype_ptr", ps, depth, &q_u->datatype_ptr))
5976 return False;
5978 if (q_u->datatype_ptr) {
5979 if (!smb_io_unistr2("datatype", &q_u->datatype, q_u->datatype_ptr?True:False, ps, depth))
5980 return False;
5983 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
5984 return False;
5986 return True;
5990 /*******************************************************************
5991 ********************************************************************/
5992 BOOL spoolss_io_r_resetprinter(const char *desc, SPOOL_R_RESETPRINTER *r_u, prs_struct *ps, int depth)
5994 prs_debug(ps, depth, desc, "spoolss_io_r_resetprinter");
5995 depth++;
5997 if(!prs_align(ps))
5998 return False;
5999 if(!prs_werror("status", ps, depth, &r_u->status))
6000 return False;
6002 return True;
6005 /*******************************************************************
6006 ********************************************************************/
6008 static BOOL spoolss_io_addform(const char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth)
6010 prs_debug(ps, depth, desc, "spoolss_io_addform");
6011 depth++;
6012 if(!prs_align(ps))
6013 return False;
6015 if (ptr!=0)
6017 if(!prs_uint32("flags", ps, depth, &f->flags))
6018 return False;
6019 if(!prs_uint32("name_ptr", ps, depth, &f->name_ptr))
6020 return False;
6021 if(!prs_uint32("size_x", ps, depth, &f->size_x))
6022 return False;
6023 if(!prs_uint32("size_y", ps, depth, &f->size_y))
6024 return False;
6025 if(!prs_uint32("left", ps, depth, &f->left))
6026 return False;
6027 if(!prs_uint32("top", ps, depth, &f->top))
6028 return False;
6029 if(!prs_uint32("right", ps, depth, &f->right))
6030 return False;
6031 if(!prs_uint32("bottom", ps, depth, &f->bottom))
6032 return False;
6034 if(!smb_io_unistr2("", &f->name, f->name_ptr, ps, depth))
6035 return False;
6038 return True;
6041 /*******************************************************************
6042 ********************************************************************/
6044 BOOL spoolss_io_q_deleteform(const char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth)
6046 prs_debug(ps, depth, desc, "spoolss_io_q_deleteform");
6047 depth++;
6049 if(!prs_align(ps))
6050 return False;
6051 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6052 return False;
6053 if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth))
6054 return False;
6056 return True;
6059 /*******************************************************************
6060 ********************************************************************/
6062 BOOL spoolss_io_r_deleteform(const char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth)
6064 prs_debug(ps, depth, desc, "spoolss_io_r_deleteform");
6065 depth++;
6067 if(!prs_align(ps))
6068 return False;
6069 if(!prs_werror("status", ps, depth, &r_u->status))
6070 return False;
6072 return True;
6075 /*******************************************************************
6076 ********************************************************************/
6078 BOOL spoolss_io_q_addform(const char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth)
6080 uint32 useless_ptr=1;
6081 prs_debug(ps, depth, desc, "spoolss_io_q_addform");
6082 depth++;
6084 if(!prs_align(ps))
6085 return False;
6086 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6087 return False;
6088 if(!prs_uint32("level", ps, depth, &q_u->level))
6089 return False;
6090 if(!prs_uint32("level2", ps, depth, &q_u->level2))
6091 return False;
6093 if (q_u->level==1)
6095 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
6096 return False;
6097 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
6098 return False;
6101 return True;
6104 /*******************************************************************
6105 ********************************************************************/
6107 BOOL spoolss_io_r_addform(const char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth)
6109 prs_debug(ps, depth, desc, "spoolss_io_r_addform");
6110 depth++;
6112 if(!prs_align(ps))
6113 return False;
6114 if(!prs_werror("status", ps, depth, &r_u->status))
6115 return False;
6117 return True;
6120 /*******************************************************************
6121 ********************************************************************/
6123 BOOL spoolss_io_q_setform(const char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth)
6125 uint32 useless_ptr=1;
6126 prs_debug(ps, depth, desc, "spoolss_io_q_setform");
6127 depth++;
6129 if(!prs_align(ps))
6130 return False;
6131 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6132 return False;
6133 if(!smb_io_unistr2("", &q_u->name, True, ps, depth))
6134 return False;
6136 if(!prs_align(ps))
6137 return False;
6139 if(!prs_uint32("level", ps, depth, &q_u->level))
6140 return False;
6141 if(!prs_uint32("level2", ps, depth, &q_u->level2))
6142 return False;
6144 if (q_u->level==1)
6146 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
6147 return False;
6148 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
6149 return False;
6152 return True;
6155 /*******************************************************************
6156 ********************************************************************/
6158 BOOL spoolss_io_r_setform(const char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth)
6160 prs_debug(ps, depth, desc, "spoolss_io_r_setform");
6161 depth++;
6163 if(!prs_align(ps))
6164 return False;
6165 if(!prs_werror("status", ps, depth, &r_u->status))
6166 return False;
6168 return True;
6171 /*******************************************************************
6172 Parse a SPOOL_R_GETJOB structure.
6173 ********************************************************************/
6175 BOOL spoolss_io_r_getjob(const char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
6177 prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
6178 depth++;
6180 if (!prs_align(ps))
6181 return False;
6183 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
6184 return False;
6186 if (!prs_align(ps))
6187 return False;
6189 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6190 return False;
6192 if (!prs_werror("status", ps, depth, &r_u->status))
6193 return False;
6195 return True;
6198 /*******************************************************************
6199 Parse a SPOOL_Q_GETJOB structure.
6200 ********************************************************************/
6202 BOOL spoolss_io_q_getjob(const char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
6204 prs_debug(ps, depth, desc, "");
6205 depth++;
6207 if(!prs_align(ps))
6208 return False;
6210 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6211 return False;
6212 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
6213 return False;
6214 if(!prs_uint32("level", ps, depth, &q_u->level))
6215 return False;
6217 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
6218 return False;
6220 if(!prs_align(ps))
6221 return False;
6223 if(!prs_uint32("offered", ps, depth, &q_u->offered))
6224 return False;
6226 return True;
6229 void free_devmode(DEVICEMODE *devmode)
6231 if (devmode!=NULL) {
6232 SAFE_FREE(devmode->dev_private);
6233 SAFE_FREE(devmode);
6237 void free_printer_info_1(PRINTER_INFO_1 *printer)
6239 SAFE_FREE(printer);
6242 void free_printer_info_2(PRINTER_INFO_2 *printer)
6244 if (printer!=NULL) {
6245 free_devmode(printer->devmode);
6246 printer->devmode = NULL;
6247 SAFE_FREE(printer);
6251 void free_printer_info_3(PRINTER_INFO_3 *printer)
6253 SAFE_FREE(printer);
6256 void free_printer_info_4(PRINTER_INFO_4 *printer)
6258 SAFE_FREE(printer);
6261 void free_printer_info_5(PRINTER_INFO_5 *printer)
6263 SAFE_FREE(printer);
6266 void free_printer_info_7(PRINTER_INFO_7 *printer)
6268 SAFE_FREE(printer);
6271 void free_job_info_2(JOB_INFO_2 *job)
6273 if (job!=NULL)
6274 free_devmode(job->devmode);
6277 /*******************************************************************
6278 * init a structure.
6279 ********************************************************************/
6281 BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
6282 const fstring string, uint32 printer, uint32 type)
6284 if (q_u == NULL)
6285 return False;
6287 init_unistr2(&q_u->string, string, UNI_STR_TERMINATE);
6289 q_u->printer=printer;
6290 q_u->type=type;
6292 q_u->unknown0=0x0;
6293 q_u->unknown1=0x0;
6295 return True;
6298 /*******************************************************************
6299 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6300 ********************************************************************/
6302 BOOL spoolss_io_q_replyopenprinter(const char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
6304 prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
6305 depth++;
6307 if(!prs_align(ps))
6308 return False;
6310 if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
6311 return False;
6313 if(!prs_align(ps))
6314 return False;
6316 if(!prs_uint32("printer", ps, depth, &q_u->printer))
6317 return False;
6318 if(!prs_uint32("type", ps, depth, &q_u->type))
6319 return False;
6321 if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6322 return False;
6323 if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6324 return False;
6326 return True;
6329 /*******************************************************************
6330 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6331 ********************************************************************/
6333 BOOL spoolss_io_r_replyopenprinter(const char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
6335 prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
6336 depth++;
6338 if (!prs_align(ps))
6339 return False;
6341 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6342 return False;
6344 if (!prs_werror("status", ps, depth, &r_u->status))
6345 return False;
6347 return True;
6350 /*******************************************************************
6351 * init a structure.
6352 ********************************************************************/
6353 BOOL make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER *q_u, POLICY_HND *hnd,
6354 uint32 condition, uint32 change_id)
6357 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6359 q_u->condition = condition;
6360 q_u->change_id = change_id;
6362 /* magic values */
6363 q_u->unknown1 = 0x1;
6364 memset(q_u->unknown2, 0x0, 5);
6365 q_u->unknown2[0] = 0x1;
6367 return True;
6370 /*******************************************************************
6371 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6372 ********************************************************************/
6373 BOOL spoolss_io_q_routerreplyprinter (const char *desc, SPOOL_Q_ROUTERREPLYPRINTER *q_u, prs_struct *ps, int depth)
6376 prs_debug(ps, depth, desc, "spoolss_io_q_routerreplyprinter");
6377 depth++;
6379 if (!prs_align(ps))
6380 return False;
6382 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6383 return False;
6385 if (!prs_uint32("condition", ps, depth, &q_u->condition))
6386 return False;
6388 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6389 return False;
6391 if (!prs_uint32("change_id", ps, depth, &q_u->change_id))
6392 return False;
6394 if (!prs_uint8s(False, "dev_private", ps, depth, q_u->unknown2, 5))
6395 return False;
6397 return True;
6400 /*******************************************************************
6401 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6402 ********************************************************************/
6403 BOOL spoolss_io_r_routerreplyprinter (const char *desc, SPOOL_R_ROUTERREPLYPRINTER *r_u, prs_struct *ps, int depth)
6405 prs_debug(ps, depth, desc, "spoolss_io_r_routerreplyprinter");
6406 depth++;
6408 if (!prs_align(ps))
6409 return False;
6411 if (!prs_werror("status", ps, depth, &r_u->status))
6412 return False;
6414 return True;
6417 /*******************************************************************
6418 * init a structure.
6419 ********************************************************************/
6421 BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd)
6423 if (q_u == NULL)
6424 return False;
6426 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6428 return True;
6431 /*******************************************************************
6432 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6433 ********************************************************************/
6435 BOOL spoolss_io_q_replycloseprinter(const char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth)
6437 prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
6438 depth++;
6440 if(!prs_align(ps))
6441 return False;
6443 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6444 return False;
6446 return True;
6449 /*******************************************************************
6450 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6451 ********************************************************************/
6453 BOOL spoolss_io_r_replycloseprinter(const char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth)
6455 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
6456 depth++;
6458 if (!prs_align(ps))
6459 return False;
6461 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6462 return False;
6464 if (!prs_werror("status", ps, depth, &r_u->status))
6465 return False;
6467 return True;
6470 #if 0 /* JERRY - not currently used but could be :-) */
6472 /*******************************************************************
6473 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6474 ******************************************************************/
6475 static BOOL copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA *dst,
6476 SPOOL_NOTIFY_INFO_DATA *src, int n)
6478 int i;
6480 memcpy(dst, src, sizeof(SPOOL_NOTIFY_INFO_DATA)*n);
6482 for (i=0; i<n; i++) {
6483 int len;
6484 uint16 *s = NULL;
6486 if (src->size != POINTER)
6487 continue;
6488 len = src->notify_data.data.length;
6489 s = SMB_MALLOC_ARRAY(uint16, len);
6490 if (s == NULL) {
6491 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6492 return False;
6495 memcpy(s, src->notify_data.data.string, len*2);
6496 dst->notify_data.data.string = s;
6499 return True;
6502 /*******************************************************************
6503 Deep copy a SPOOL_NOTIFY_INFO structure
6504 ******************************************************************/
6505 static BOOL copy_spool_notify_info(SPOOL_NOTIFY_INFO *dst, SPOOL_NOTIFY_INFO *src)
6507 if (!dst) {
6508 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6509 return False;
6512 dst->version = src->version;
6513 dst->flags = src->flags;
6514 dst->count = src->count;
6516 if (dst->count)
6518 dst->data = SMB_MALLOC_ARRAY(SPOOL_NOTIFY_INFO_DATA, dst->count);
6520 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6521 dst->count));
6523 if (dst->data == NULL) {
6524 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6525 dst->count));
6526 return False;
6529 return (copy_spool_notify_info_data(dst->data, src->data, src->count));
6532 return True;
6534 #endif /* JERRY */
6536 /*******************************************************************
6537 * init a structure.
6538 ********************************************************************/
6540 BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
6541 uint32 change_low, uint32 change_high,
6542 SPOOL_NOTIFY_INFO *info)
6544 if (q_u == NULL)
6545 return False;
6547 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6549 q_u->change_low=change_low;
6550 q_u->change_high=change_high;
6552 q_u->unknown0=0x0;
6553 q_u->unknown1=0x0;
6555 q_u->info_ptr=0x0FF0ADDE;
6557 q_u->info.version=2;
6559 if (info->count) {
6560 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6561 info->count));
6562 q_u->info.version = info->version;
6563 q_u->info.flags = info->flags;
6564 q_u->info.count = info->count;
6565 /* pointer field - be careful! */
6566 q_u->info.data = info->data;
6568 else {
6569 q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
6570 q_u->info.count=0;
6573 return True;
6576 /*******************************************************************
6577 Parse a SPOOL_Q_REPLY_RRPCN structure.
6578 ********************************************************************/
6580 BOOL spoolss_io_q_reply_rrpcn(const char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
6582 prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
6583 depth++;
6585 if(!prs_align(ps))
6586 return False;
6588 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6589 return False;
6591 if (!prs_uint32("change_low", ps, depth, &q_u->change_low))
6592 return False;
6594 if (!prs_uint32("change_high", ps, depth, &q_u->change_high))
6595 return False;
6597 if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6598 return False;
6600 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6601 return False;
6603 if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr))
6604 return False;
6606 if(q_u->info_ptr!=0)
6607 if(!smb_io_notify_info(desc, &q_u->info, ps, depth))
6608 return False;
6610 return True;
6613 /*******************************************************************
6614 Parse a SPOOL_R_REPLY_RRPCN structure.
6615 ********************************************************************/
6617 BOOL spoolss_io_r_reply_rrpcn(const char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth)
6619 prs_debug(ps, depth, desc, "spoolss_io_r_reply_rrpcn");
6620 depth++;
6622 if (!prs_align(ps))
6623 return False;
6625 if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0))
6626 return False;
6628 if (!prs_werror("status", ps, depth, &r_u->status))
6629 return False;
6631 return True;
6634 /*******************************************************************
6635 * read a structure.
6636 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6637 ********************************************************************/
6639 BOOL spoolss_io_q_getprinterdataex(const char *desc, SPOOL_Q_GETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6641 if (q_u == NULL)
6642 return False;
6644 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdataex");
6645 depth++;
6647 if (!prs_align(ps))
6648 return False;
6649 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6650 return False;
6651 if (!prs_align(ps))
6652 return False;
6653 if (!smb_io_unistr2("keyname", &q_u->keyname,True,ps,depth))
6654 return False;
6655 if (!prs_align(ps))
6656 return False;
6657 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
6658 return False;
6659 if (!prs_align(ps))
6660 return False;
6661 if (!prs_uint32("size", ps, depth, &q_u->size))
6662 return False;
6664 return True;
6667 /*******************************************************************
6668 * write a structure.
6669 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6670 ********************************************************************/
6672 BOOL spoolss_io_r_getprinterdataex(const char *desc, SPOOL_R_GETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6674 if (r_u == NULL)
6675 return False;
6677 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdataex");
6678 depth++;
6680 if (!prs_align(ps))
6681 return False;
6682 if (!prs_uint32("type", ps, depth, &r_u->type))
6683 return False;
6684 if (!prs_uint32("size", ps, depth, &r_u->size))
6685 return False;
6687 if (UNMARSHALLING(ps) && r_u->size) {
6688 r_u->data = PRS_ALLOC_MEM(ps, unsigned char, r_u->size);
6689 if(!r_u->data)
6690 return False;
6693 if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
6694 return False;
6696 if (!prs_align(ps))
6697 return False;
6699 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6700 return False;
6701 if (!prs_werror("status", ps, depth, &r_u->status))
6702 return False;
6704 return True;
6707 /*******************************************************************
6708 * read a structure.
6709 ********************************************************************/
6711 BOOL spoolss_io_q_setprinterdataex(const char *desc, SPOOL_Q_SETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6713 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdataex");
6714 depth++;
6716 if(!prs_align(ps))
6717 return False;
6718 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6719 return False;
6720 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6721 return False;
6723 if(!prs_align(ps))
6724 return False;
6726 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
6727 return False;
6729 if(!prs_align(ps))
6730 return False;
6732 if(!prs_uint32("type", ps, depth, &q_u->type))
6733 return False;
6735 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
6736 return False;
6738 switch (q_u->type)
6740 case 0x1:
6741 case 0x3:
6742 case 0x4:
6743 case 0x7:
6744 if (q_u->max_len) {
6745 if (UNMARSHALLING(ps))
6746 q_u->data=PRS_ALLOC_MEM(ps, uint8, q_u->max_len);
6747 if(q_u->data == NULL)
6748 return False;
6749 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
6750 return False;
6752 if(!prs_align(ps))
6753 return False;
6754 break;
6757 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
6758 return False;
6760 return True;
6763 /*******************************************************************
6764 * write a structure.
6765 ********************************************************************/
6767 BOOL spoolss_io_r_setprinterdataex(const char *desc, SPOOL_R_SETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6769 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdataex");
6770 depth++;
6772 if(!prs_align(ps))
6773 return False;
6774 if(!prs_werror("status", ps, depth, &r_u->status))
6775 return False;
6777 return True;
6780 /*******************************************************************
6781 * read a structure.
6782 ********************************************************************/
6783 BOOL make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u,
6784 POLICY_HND *hnd, const char *key,
6785 uint32 size)
6787 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
6789 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6790 init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
6791 q_u->size = size;
6793 return True;
6796 /*******************************************************************
6797 * read a structure.
6798 ********************************************************************/
6800 BOOL spoolss_io_q_enumprinterkey(const char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth)
6802 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterkey");
6803 depth++;
6805 if(!prs_align(ps))
6806 return False;
6807 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6808 return False;
6810 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6811 return False;
6813 if(!prs_align(ps))
6814 return False;
6816 if(!prs_uint32("size", ps, depth, &q_u->size))
6817 return False;
6819 return True;
6822 /*******************************************************************
6823 * write a structure.
6824 ********************************************************************/
6826 BOOL spoolss_io_r_enumprinterkey(const char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth)
6828 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterkey");
6829 depth++;
6831 if(!prs_align(ps))
6832 return False;
6834 if (!smb_io_buffer5("", &r_u->keys, ps, depth))
6835 return False;
6837 if(!prs_align(ps))
6838 return False;
6840 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6841 return False;
6843 if(!prs_werror("status", ps, depth, &r_u->status))
6844 return False;
6846 return True;
6849 /*******************************************************************
6850 * read a structure.
6851 ********************************************************************/
6853 BOOL make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY *q_u,
6854 POLICY_HND *hnd, char *keyname)
6856 DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
6858 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6859 init_unistr2(&q_u->keyname, keyname, UNI_STR_TERMINATE);
6861 return True;
6864 /*******************************************************************
6865 * read a structure.
6866 ********************************************************************/
6868 BOOL spoolss_io_q_deleteprinterkey(const char *desc, SPOOL_Q_DELETEPRINTERKEY *q_u, prs_struct *ps, int depth)
6870 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterkey");
6871 depth++;
6873 if(!prs_align(ps))
6874 return False;
6875 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6876 return False;
6878 if(!smb_io_unistr2("", &q_u->keyname, True, ps, depth))
6879 return False;
6881 return True;
6884 /*******************************************************************
6885 * write a structure.
6886 ********************************************************************/
6888 BOOL spoolss_io_r_deleteprinterkey(const char *desc, SPOOL_R_DELETEPRINTERKEY *r_u, prs_struct *ps, int depth)
6890 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterkey");
6891 depth++;
6893 if(!prs_align(ps))
6894 return False;
6896 if(!prs_werror("status", ps, depth, &r_u->status))
6897 return False;
6899 return True;
6903 /*******************************************************************
6904 * read a structure.
6905 ********************************************************************/
6907 BOOL spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6909 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdataex");
6910 depth++;
6912 if(!prs_align(ps))
6913 return False;
6914 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6915 return False;
6917 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6918 return False;
6920 if(!prs_align(ps))
6921 return False;
6923 if(!prs_uint32("size", ps, depth, &q_u->size))
6924 return False;
6926 return True;
6929 /*******************************************************************
6930 ********************************************************************/
6932 static BOOL spoolss_io_printer_enum_values_ctr(const char *desc, prs_struct *ps,
6933 PRINTER_ENUM_VALUES_CTR *ctr, int depth)
6935 int i;
6936 uint32 valuename_offset,
6937 data_offset,
6938 current_offset;
6939 const uint32 basic_unit = 20; /* size of static portion of enum_values */
6941 prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr");
6942 depth++;
6945 * offset data begins at 20 bytes per structure * size_of_array.
6946 * Don't forget the uint32 at the beginning
6947 * */
6949 current_offset = basic_unit * ctr->size_of_array;
6951 /* first loop to write basic enum_value information */
6953 if (UNMARSHALLING(ps)) {
6954 ctr->values = PRS_ALLOC_MEM(ps, PRINTER_ENUM_VALUES, ctr->size_of_array);
6955 if (!ctr->values)
6956 return False;
6959 for (i=0; i<ctr->size_of_array; i++) {
6960 valuename_offset = current_offset;
6961 if (!prs_uint32("valuename_offset", ps, depth, &valuename_offset))
6962 return False;
6964 if (!prs_uint32("value_len", ps, depth, &ctr->values[i].value_len))
6965 return False;
6967 if (!prs_uint32("type", ps, depth, &ctr->values[i].type))
6968 return False;
6970 data_offset = ctr->values[i].value_len + valuename_offset;
6972 if (!prs_uint32("data_offset", ps, depth, &data_offset))
6973 return False;
6975 if (!prs_uint32("data_len", ps, depth, &ctr->values[i].data_len))
6976 return False;
6978 current_offset = data_offset + ctr->values[i].data_len - basic_unit;
6979 /* account for 2 byte alignment */
6980 current_offset += (current_offset % 2);
6984 * loop #2 for writing the dynamically size objects; pay
6985 * attention to 2-byte alignment here....
6988 for (i=0; i<ctr->size_of_array; i++) {
6990 if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
6991 return False;
6993 if ( ctr->values[i].data_len ) {
6994 if ( UNMARSHALLING(ps) ) {
6995 ctr->values[i].data = PRS_ALLOC_MEM(ps, uint8, ctr->values[i].data_len);
6996 if (!ctr->values[i].data)
6997 return False;
6999 if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len))
7000 return False;
7003 if ( !prs_align_uint16(ps) )
7004 return False;
7007 return True;
7010 /*******************************************************************
7011 * write a structure.
7012 ********************************************************************/
7014 BOOL spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth)
7016 uint32 data_offset, end_offset;
7017 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdataex");
7018 depth++;
7020 if(!prs_align(ps))
7021 return False;
7023 if (!prs_uint32("size", ps, depth, &r_u->ctr.size))
7024 return False;
7026 data_offset = prs_offset(ps);
7028 if (!prs_set_offset(ps, data_offset + r_u->ctr.size))
7029 return False;
7031 if(!prs_align(ps))
7032 return False;
7034 if(!prs_uint32("needed", ps, depth, &r_u->needed))
7035 return False;
7037 if(!prs_uint32("returned", ps, depth, &r_u->returned))
7038 return False;
7040 if(!prs_werror("status", ps, depth, &r_u->status))
7041 return False;
7043 r_u->ctr.size_of_array = r_u->returned;
7045 end_offset = prs_offset(ps);
7047 if (!prs_set_offset(ps, data_offset))
7048 return False;
7050 if (r_u->ctr.size)
7051 if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth ))
7052 return False;
7054 if (!prs_set_offset(ps, end_offset))
7055 return False;
7056 return True;
7059 /*******************************************************************
7060 * write a structure.
7061 ********************************************************************/
7064 uint32 GetPrintProcessorDirectory(
7065 [in] unistr2 *name,
7066 [in] unistr2 *environment,
7067 [in] uint32 level,
7068 [in,out] RPC_BUFFER buffer,
7069 [in] uint32 offered,
7070 [out] uint32 needed,
7071 [out] uint32 returned
7076 BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, RPC_BUFFER *buffer, uint32 offered)
7078 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
7080 init_unistr2(&q_u->name, name, UNI_STR_TERMINATE);
7081 init_unistr2(&q_u->environment, environment, UNI_STR_TERMINATE);
7083 q_u->level = level;
7085 q_u->buffer = buffer;
7086 q_u->offered = offered;
7088 return True;
7091 BOOL spoolss_io_q_getprintprocessordirectory(const char *desc, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, prs_struct *ps, int depth)
7093 uint32 ptr;
7095 prs_debug(ps, depth, desc, "spoolss_io_q_getprintprocessordirectory");
7096 depth++;
7098 if(!prs_align(ps))
7099 return False;
7101 if (!prs_uint32("ptr", ps, depth, &ptr))
7102 return False;
7104 if (ptr) {
7105 if(!smb_io_unistr2("name", &q_u->name, True, ps, depth))
7106 return False;
7109 if (!prs_align(ps))
7110 return False;
7112 if (!prs_uint32("ptr", ps, depth, &ptr))
7113 return False;
7115 if (ptr) {
7116 if(!smb_io_unistr2("environment", &q_u->environment, True,
7117 ps, depth))
7118 return False;
7121 if (!prs_align(ps))
7122 return False;
7124 if(!prs_uint32("level", ps, depth, &q_u->level))
7125 return False;
7127 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
7128 return False;
7130 if(!prs_align(ps))
7131 return False;
7133 if(!prs_uint32("offered", ps, depth, &q_u->offered))
7134 return False;
7136 return True;
7139 /*******************************************************************
7140 * write a structure.
7141 ********************************************************************/
7143 BOOL spoolss_io_r_getprintprocessordirectory(const char *desc, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u, prs_struct *ps, int depth)
7145 prs_debug(ps, depth, desc, "spoolss_io_r_getprintprocessordirectory");
7146 depth++;
7148 if(!prs_align(ps))
7149 return False;
7151 if(!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
7152 return False;
7154 if(!prs_align(ps))
7155 return False;
7157 if(!prs_uint32("needed", ps, depth, &r_u->needed))
7158 return False;
7160 if(!prs_werror("status", ps, depth, &r_u->status))
7161 return False;
7163 return True;
7166 BOOL smb_io_printprocessordirectory_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth)
7168 prs_struct *ps=&buffer->prs;
7170 prs_debug(ps, depth, desc, "smb_io_printprocessordirectory_1");
7171 depth++;
7173 buffer->struct_start=prs_offset(ps);
7175 if (!smb_io_unistr(desc, &info->name, ps, depth))
7176 return False;
7178 return True;
7181 /*******************************************************************
7182 * init a structure.
7183 ********************************************************************/
7185 BOOL make_spoolss_q_addform(SPOOL_Q_ADDFORM *q_u, POLICY_HND *handle,
7186 int level, FORM *form)
7188 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7189 q_u->level = level;
7190 q_u->level2 = level;
7191 memcpy(&q_u->form, form, sizeof(FORM));
7193 return True;
7196 /*******************************************************************
7197 * init a structure.
7198 ********************************************************************/
7200 BOOL make_spoolss_q_setform(SPOOL_Q_SETFORM *q_u, POLICY_HND *handle,
7201 int level, const char *form_name, FORM *form)
7203 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7204 q_u->level = level;
7205 q_u->level2 = level;
7206 memcpy(&q_u->form, form, sizeof(FORM));
7207 init_unistr2(&q_u->name, form_name, UNI_STR_TERMINATE);
7209 return True;
7212 /*******************************************************************
7213 * init a structure.
7214 ********************************************************************/
7216 BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle,
7217 const char *form)
7219 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7220 init_unistr2(&q_u->name, form, UNI_STR_TERMINATE);
7221 return True;
7224 /*******************************************************************
7225 * init a structure.
7226 ********************************************************************/
7228 BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle,
7229 const char *formname, uint32 level,
7230 RPC_BUFFER *buffer, uint32 offered)
7232 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7233 q_u->level = level;
7234 init_unistr2(&q_u->formname, formname, UNI_STR_TERMINATE);
7235 q_u->buffer=buffer;
7236 q_u->offered=offered;
7238 return True;
7241 /*******************************************************************
7242 * init a structure.
7243 ********************************************************************/
7245 BOOL make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
7246 uint32 level, RPC_BUFFER *buffer,
7247 uint32 offered)
7249 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7250 q_u->level = level;
7251 q_u->buffer=buffer;
7252 q_u->offered=offered;
7254 return True;
7257 /*******************************************************************
7258 * init a structure.
7259 ********************************************************************/
7261 BOOL make_spoolss_q_setjob(SPOOL_Q_SETJOB *q_u, POLICY_HND *handle,
7262 uint32 jobid, uint32 level, uint32 command)
7264 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7265 q_u->jobid = jobid;
7266 q_u->level = level;
7268 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7269 the server side code has it marked as unused. */
7271 q_u->command = command;
7273 return True;
7276 /*******************************************************************
7277 * init a structure.
7278 ********************************************************************/
7280 BOOL make_spoolss_q_getjob(SPOOL_Q_GETJOB *q_u, POLICY_HND *handle,
7281 uint32 jobid, uint32 level, RPC_BUFFER *buffer,
7282 uint32 offered)
7284 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7285 q_u->jobid = jobid;
7286 q_u->level = level;
7287 q_u->buffer = buffer;
7288 q_u->offered = offered;
7290 return True;
7293 /*******************************************************************
7294 * init a structure.
7295 ********************************************************************/
7297 BOOL make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u,
7298 POLICY_HND *handle)
7300 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7302 return True;
7305 /*******************************************************************
7306 * init a structure.
7307 ********************************************************************/
7309 BOOL make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u,
7310 POLICY_HND *handle)
7312 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7314 return True;
7317 /*******************************************************************
7318 * init a structure.
7319 ********************************************************************/
7321 BOOL make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER *q_u,
7322 POLICY_HND *handle, uint32 level,
7323 char *docname, char *outputfile,
7324 char *datatype)
7326 DOC_INFO_CONTAINER *ctr = &q_u->doc_info_container;
7328 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7330 ctr->level = level;
7332 switch (level) {
7333 case 1:
7334 ctr->docinfo.switch_value = level;
7336 ctr->docinfo.doc_info_1.p_docname = docname ? 1 : 0;
7337 ctr->docinfo.doc_info_1.p_outputfile = outputfile ? 1 : 0;
7338 ctr->docinfo.doc_info_1.p_datatype = datatype ? 1 : 0;
7340 init_unistr2(&ctr->docinfo.doc_info_1.docname, docname, UNI_STR_TERMINATE);
7341 init_unistr2(&ctr->docinfo.doc_info_1.outputfile, outputfile, UNI_STR_TERMINATE);
7342 init_unistr2(&ctr->docinfo.doc_info_1.datatype, datatype, UNI_STR_TERMINATE);
7344 break;
7345 case 2:
7346 /* DOC_INFO_2 is only used by Windows 9x and since it
7347 doesn't do printing over RPC we don't have to worry
7348 about it. */
7349 default:
7350 DEBUG(3, ("unsupported info level %d\n", level));
7351 return False;
7354 return True;
7357 /*******************************************************************
7358 * init a structure.
7359 ********************************************************************/
7361 BOOL make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u,
7362 POLICY_HND *handle)
7364 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7366 return True;
7369 /*******************************************************************
7370 * init a structure.
7371 ********************************************************************/
7373 BOOL make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER *q_u,
7374 POLICY_HND *handle, uint32 data_size,
7375 char *data)
7377 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7378 q_u->buffer_size = q_u->buffer_size2 = data_size;
7379 q_u->buffer = (unsigned char *)data;
7380 return True;
7383 /*******************************************************************
7384 * init a structure.
7385 ********************************************************************/
7387 BOOL make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA *q_u,
7388 POLICY_HND *handle, char *valuename)
7390 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7391 init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
7393 return True;
7396 /*******************************************************************
7397 * init a structure.
7398 ********************************************************************/
7400 BOOL make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX *q_u,
7401 POLICY_HND *handle, char *key,
7402 char *value)
7404 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7405 init_unistr2(&q_u->valuename, value, UNI_STR_TERMINATE);
7406 init_unistr2(&q_u->keyname, key, UNI_STR_TERMINATE);
7408 return True;
7411 /*******************************************************************
7412 * init a structure.
7413 ********************************************************************/
7415 BOOL make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, POLICY_HND *handle,
7416 uint32 flags, uint32 options, const char *localmachine,
7417 uint32 printerlocal, SPOOL_NOTIFY_OPTION *option)
7419 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7421 q_u->flags = flags;
7422 q_u->options = options;
7424 q_u->localmachine_ptr = 1;
7426 init_unistr2(&q_u->localmachine, localmachine, UNI_STR_TERMINATE);
7428 q_u->printerlocal = printerlocal;
7430 if (option)
7431 q_u->option_ptr = 1;
7433 q_u->option = option;
7435 return True;
7439 /*******************************************************************
7440 ********************************************************************/
7442 BOOL spoolss_io_q_xcvdataport(const char *desc, SPOOL_Q_XCVDATAPORT *q_u, prs_struct *ps, int depth)
7444 prs_debug(ps, depth, desc, "spoolss_io_q_xcvdataport");
7445 depth++;
7447 if(!prs_align(ps))
7448 return False;
7450 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
7451 return False;
7453 if(!smb_io_unistr2("", &q_u->dataname, True, ps, depth))
7454 return False;
7456 if (!prs_align(ps))
7457 return False;
7459 if(!prs_rpcbuffer("", ps, depth, &q_u->indata))
7460 return False;
7462 if (!prs_align(ps))
7463 return False;
7465 if (!prs_uint32("indata_len", ps, depth, &q_u->indata_len))
7466 return False;
7467 if (!prs_uint32("offered", ps, depth, &q_u->offered))
7468 return False;
7469 if (!prs_uint32("unknown", ps, depth, &q_u->unknown))
7470 return False;
7472 return True;
7475 /*******************************************************************
7476 ********************************************************************/
7478 BOOL spoolss_io_r_xcvdataport(const char *desc, SPOOL_R_XCVDATAPORT *r_u, prs_struct *ps, int depth)
7480 prs_debug(ps, depth, desc, "spoolss_io_r_xcvdataport");
7481 depth++;
7483 if(!prs_align(ps))
7484 return False;
7485 if(!prs_rpcbuffer("", ps, depth, &r_u->outdata))
7486 return False;
7488 if (!prs_align(ps))
7489 return False;
7491 if (!prs_uint32("needed", ps, depth, &r_u->needed))
7492 return False;
7493 if (!prs_uint32("unknown", ps, depth, &r_u->unknown))
7494 return False;
7496 if(!prs_werror("status", ps, depth, &r_u->status))
7497 return False;
7499 return True;
7502 /*******************************************************************
7503 ********************************************************************/
7505 BOOL make_monitorui_buf( RPC_BUFFER *buf, const char *dllname )
7507 UNISTR string;
7509 if ( !buf )
7510 return False;
7512 init_unistr( &string, dllname );
7514 if ( !prs_unistr( "ui_dll", &buf->prs, 0, &string ) )
7515 return False;
7517 return True;
7520 /*******************************************************************
7521 ********************************************************************/
7523 #define PORT_DATA_1_PAD 540
7525 static BOOL smb_io_port_data_1( const char *desc, RPC_BUFFER *buf, int depth, SPOOL_PORT_DATA_1 *p1 )
7527 prs_struct *ps = &buf->prs;
7528 uint8 padding[PORT_DATA_1_PAD];
7530 prs_debug(ps, depth, desc, "smb_io_port_data_1");
7531 depth++;
7533 if(!prs_align(ps))
7534 return False;
7536 if( !prs_uint16s(True, "portname", ps, depth, p1->portname, MAX_PORTNAME))
7537 return False;
7539 if (!prs_uint32("version", ps, depth, &p1->version))
7540 return False;
7541 if (!prs_uint32("protocol", ps, depth, &p1->protocol))
7542 return False;
7543 if (!prs_uint32("size", ps, depth, &p1->size))
7544 return False;
7545 if (!prs_uint32("reserved", ps, depth, &p1->reserved))
7546 return False;
7548 if( !prs_uint16s(True, "hostaddress", ps, depth, p1->hostaddress, MAX_NETWORK_NAME))
7549 return False;
7550 if( !prs_uint16s(True, "snmpcommunity", ps, depth, p1->snmpcommunity, MAX_SNMP_COMM_NAME))
7551 return False;
7553 if (!prs_uint32("dblspool", ps, depth, &p1->dblspool))
7554 return False;
7556 if( !prs_uint16s(True, "queue", ps, depth, p1->queue, MAX_QUEUE_NAME))
7557 return False;
7558 if( !prs_uint16s(True, "ipaddress", ps, depth, p1->ipaddress, MAX_IPADDR_STRING))
7559 return False;
7561 if( !prs_uint8s(False, "", ps, depth, padding, PORT_DATA_1_PAD))
7562 return False;
7564 if (!prs_uint32("port", ps, depth, &p1->port))
7565 return False;
7566 if (!prs_uint32("snmpenabled", ps, depth, &p1->snmpenabled))
7567 return False;
7568 if (!prs_uint32("snmpdevindex", ps, depth, &p1->snmpdevindex))
7569 return False;
7571 return True;
7574 /*******************************************************************
7575 ********************************************************************/
7577 BOOL convert_port_data_1( NT_PORT_DATA_1 *port1, RPC_BUFFER *buf )
7579 SPOOL_PORT_DATA_1 spdata_1;
7581 ZERO_STRUCT( spdata_1 );
7583 if ( !smb_io_port_data_1( "port_data_1", buf, 0, &spdata_1 ) )
7584 return False;
7586 rpcstr_pull(port1->name, spdata_1.portname, sizeof(port1->name), -1, 0);
7587 rpcstr_pull(port1->queue, spdata_1.queue, sizeof(port1->queue), -1, 0);
7588 rpcstr_pull(port1->hostaddr, spdata_1.hostaddress, sizeof(port1->hostaddr), -1, 0);
7590 port1->port = spdata_1.port;
7592 switch ( spdata_1.protocol ) {
7593 case 1:
7594 port1->protocol = PORT_PROTOCOL_DIRECT;
7595 break;
7596 case 2:
7597 port1->protocol = PORT_PROTOCOL_LPR;
7598 break;
7599 default:
7600 DEBUG(3,("convert_port_data_1: unknown protocol [%d]!\n",
7601 spdata_1.protocol));
7602 return False;
7605 return True;