r19028: Implement getprinterinfo level 6 (only the status) and get rid of snum in the
[Samba.git] / source / rpc_parse / parse_spoolss.c
blob1001ba21907ecd51d68a68fd80725726e8fddf04
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_6 structure.
2456 ********************************************************************/
2458 BOOL smb_io_printer_info_6(const char *desc, RPC_BUFFER *buffer,
2459 PRINTER_INFO_6 *info, int depth)
2461 prs_struct *ps=&buffer->prs;
2463 prs_debug(ps, depth, desc, "smb_io_printer_info_6");
2464 depth++;
2466 if (!prs_uint32("status", ps, depth, &info->status))
2467 return False;
2469 return True;
2472 /*******************************************************************
2473 Parse a PRINTER_INFO_7 structure.
2474 ********************************************************************/
2476 BOOL smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth)
2478 prs_struct *ps=&buffer->prs;
2480 prs_debug(ps, depth, desc, "smb_io_printer_info_7");
2481 depth++;
2483 buffer->struct_start=prs_offset(ps);
2485 if (!smb_io_relstr("guid", buffer, depth, &info->guid))
2486 return False;
2487 if (!prs_uint32("action", ps, depth, &info->action))
2488 return False;
2489 return True;
2492 /*******************************************************************
2493 Parse a PORT_INFO_1 structure.
2494 ********************************************************************/
2496 BOOL smb_io_port_info_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2498 prs_struct *ps=&buffer->prs;
2500 prs_debug(ps, depth, desc, "smb_io_port_info_1");
2501 depth++;
2503 buffer->struct_start=prs_offset(ps);
2505 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2506 return False;
2508 return True;
2511 /*******************************************************************
2512 Parse a PORT_INFO_2 structure.
2513 ********************************************************************/
2515 BOOL smb_io_port_info_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2517 prs_struct *ps=&buffer->prs;
2519 prs_debug(ps, depth, desc, "smb_io_port_info_2");
2520 depth++;
2522 buffer->struct_start=prs_offset(ps);
2524 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2525 return False;
2526 if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2527 return False;
2528 if (!smb_io_relstr("description", buffer, depth, &info->description))
2529 return False;
2530 if (!prs_uint32("port_type", ps, depth, &info->port_type))
2531 return False;
2532 if (!prs_uint32("reserved", ps, depth, &info->reserved))
2533 return False;
2535 return True;
2538 /*******************************************************************
2539 Parse a DRIVER_INFO_1 structure.
2540 ********************************************************************/
2542 BOOL smb_io_printer_driver_info_1(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
2544 prs_struct *ps=&buffer->prs;
2546 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
2547 depth++;
2549 buffer->struct_start=prs_offset(ps);
2551 if (!smb_io_relstr("name", buffer, depth, &info->name))
2552 return False;
2554 return True;
2557 /*******************************************************************
2558 Parse a DRIVER_INFO_2 structure.
2559 ********************************************************************/
2561 BOOL smb_io_printer_driver_info_2(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
2563 prs_struct *ps=&buffer->prs;
2565 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
2566 depth++;
2568 buffer->struct_start=prs_offset(ps);
2570 if (!prs_uint32("version", ps, depth, &info->version))
2571 return False;
2572 if (!smb_io_relstr("name", buffer, depth, &info->name))
2573 return False;
2574 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2575 return False;
2576 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2577 return False;
2578 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2579 return False;
2580 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2581 return False;
2583 return True;
2586 /*******************************************************************
2587 Parse a DRIVER_INFO_3 structure.
2588 ********************************************************************/
2590 BOOL smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
2592 prs_struct *ps=&buffer->prs;
2594 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
2595 depth++;
2597 buffer->struct_start=prs_offset(ps);
2599 if (!prs_uint32("version", ps, depth, &info->version))
2600 return False;
2601 if (!smb_io_relstr("name", buffer, depth, &info->name))
2602 return False;
2603 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2604 return False;
2605 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2606 return False;
2607 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2608 return False;
2609 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2610 return False;
2611 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2612 return False;
2614 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2615 return False;
2617 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2618 return False;
2619 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2620 return False;
2622 return True;
2625 /*******************************************************************
2626 Parse a DRIVER_INFO_6 structure.
2627 ********************************************************************/
2629 BOOL smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
2631 prs_struct *ps=&buffer->prs;
2633 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
2634 depth++;
2636 buffer->struct_start=prs_offset(ps);
2638 if (!prs_uint32("version", ps, depth, &info->version))
2639 return False;
2640 if (!smb_io_relstr("name", buffer, depth, &info->name))
2641 return False;
2642 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2643 return False;
2644 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2645 return False;
2646 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2647 return False;
2648 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2649 return False;
2650 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2651 return False;
2653 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2654 return False;
2656 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2657 return False;
2658 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2659 return False;
2661 if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
2662 return False;
2664 if (!prs_uint64("date", ps, depth, &info->driver_date))
2665 return False;
2667 if (!prs_uint32("padding", ps, depth, &info->padding))
2668 return False;
2670 if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
2671 return False;
2673 if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
2674 return False;
2676 if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
2677 return False;
2678 if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
2679 return False;
2680 if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
2681 return False;
2682 if (!smb_io_relstr("provider", buffer, depth, &info->provider))
2683 return False;
2685 return True;
2688 /*******************************************************************
2689 Parse a JOB_INFO_1 structure.
2690 ********************************************************************/
2692 BOOL smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, int depth)
2694 prs_struct *ps=&buffer->prs;
2696 prs_debug(ps, depth, desc, "smb_io_job_info_1");
2697 depth++;
2699 buffer->struct_start=prs_offset(ps);
2701 if (!prs_uint32("jobid", ps, depth, &info->jobid))
2702 return False;
2703 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2704 return False;
2705 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2706 return False;
2707 if (!smb_io_relstr("username", buffer, depth, &info->username))
2708 return False;
2709 if (!smb_io_relstr("document", buffer, depth, &info->document))
2710 return False;
2711 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2712 return False;
2713 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2714 return False;
2715 if (!prs_uint32("status", ps, depth, &info->status))
2716 return False;
2717 if (!prs_uint32("priority", ps, depth, &info->priority))
2718 return False;
2719 if (!prs_uint32("position", ps, depth, &info->position))
2720 return False;
2721 if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
2722 return False;
2723 if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
2724 return False;
2725 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
2726 return False;
2728 return True;
2731 /*******************************************************************
2732 Parse a JOB_INFO_2 structure.
2733 ********************************************************************/
2735 BOOL smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth)
2737 uint32 pipo=0;
2738 prs_struct *ps=&buffer->prs;
2740 prs_debug(ps, depth, desc, "smb_io_job_info_2");
2741 depth++;
2743 buffer->struct_start=prs_offset(ps);
2745 if (!prs_uint32("jobid",ps, depth, &info->jobid))
2746 return False;
2747 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2748 return False;
2749 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2750 return False;
2751 if (!smb_io_relstr("username", buffer, depth, &info->username))
2752 return False;
2753 if (!smb_io_relstr("document", buffer, depth, &info->document))
2754 return False;
2755 if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
2756 return False;
2757 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2758 return False;
2760 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2761 return False;
2762 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2763 return False;
2764 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2765 return False;
2766 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2767 return False;
2768 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2769 return False;
2771 /* SEC_DESC sec_desc;*/
2772 if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
2773 return False;
2775 if (!prs_uint32("status",ps, depth, &info->status))
2776 return False;
2777 if (!prs_uint32("priority",ps, depth, &info->priority))
2778 return False;
2779 if (!prs_uint32("position",ps, depth, &info->position))
2780 return False;
2781 if (!prs_uint32("starttime",ps, depth, &info->starttime))
2782 return False;
2783 if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
2784 return False;
2785 if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
2786 return False;
2787 if (!prs_uint32("size",ps, depth, &info->size))
2788 return False;
2789 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
2790 return False;
2791 if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
2792 return False;
2793 if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
2794 return False;
2796 return True;
2799 /*******************************************************************
2800 ********************************************************************/
2802 BOOL smb_io_form_1(const char *desc, RPC_BUFFER *buffer, FORM_1 *info, int depth)
2804 prs_struct *ps=&buffer->prs;
2806 prs_debug(ps, depth, desc, "smb_io_form_1");
2807 depth++;
2809 buffer->struct_start=prs_offset(ps);
2811 if (!prs_uint32("flag", ps, depth, &info->flag))
2812 return False;
2814 if (!smb_io_relstr("name", buffer, depth, &info->name))
2815 return False;
2817 if (!prs_uint32("width", ps, depth, &info->width))
2818 return False;
2819 if (!prs_uint32("length", ps, depth, &info->length))
2820 return False;
2821 if (!prs_uint32("left", ps, depth, &info->left))
2822 return False;
2823 if (!prs_uint32("top", ps, depth, &info->top))
2824 return False;
2825 if (!prs_uint32("right", ps, depth, &info->right))
2826 return False;
2827 if (!prs_uint32("bottom", ps, depth, &info->bottom))
2828 return False;
2830 return True;
2835 /*******************************************************************
2836 Parse a DRIVER_DIRECTORY_1 structure.
2837 ********************************************************************/
2839 BOOL smb_io_driverdir_1(const char *desc, RPC_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
2841 prs_struct *ps=&buffer->prs;
2843 prs_debug(ps, depth, desc, "smb_io_driverdir_1");
2844 depth++;
2846 buffer->struct_start=prs_offset(ps);
2848 if (!smb_io_unistr(desc, &info->name, ps, depth))
2849 return False;
2851 return True;
2854 /*******************************************************************
2855 Parse a PORT_INFO_1 structure.
2856 ********************************************************************/
2858 BOOL smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2860 prs_struct *ps=&buffer->prs;
2862 prs_debug(ps, depth, desc, "smb_io_port_1");
2863 depth++;
2865 buffer->struct_start=prs_offset(ps);
2867 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2868 return False;
2870 return True;
2873 /*******************************************************************
2874 Parse a PORT_INFO_2 structure.
2875 ********************************************************************/
2877 BOOL smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2879 prs_struct *ps=&buffer->prs;
2881 prs_debug(ps, depth, desc, "smb_io_port_2");
2882 depth++;
2884 buffer->struct_start=prs_offset(ps);
2886 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2887 return False;
2888 if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2889 return False;
2890 if(!smb_io_relstr("description", buffer, depth, &info->description))
2891 return False;
2892 if(!prs_uint32("port_type", ps, depth, &info->port_type))
2893 return False;
2894 if(!prs_uint32("reserved", ps, depth, &info->reserved))
2895 return False;
2897 return True;
2900 /*******************************************************************
2901 ********************************************************************/
2903 BOOL smb_io_printprocessor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
2905 prs_struct *ps=&buffer->prs;
2907 prs_debug(ps, depth, desc, "smb_io_printprocessor_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_printprocdatatype_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth)
2923 prs_struct *ps=&buffer->prs;
2925 prs_debug(ps, depth, desc, "smb_io_printprocdatatype_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_1(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
2941 prs_struct *ps=&buffer->prs;
2943 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1");
2944 depth++;
2946 buffer->struct_start=prs_offset(ps);
2948 if (!smb_io_relstr("name", buffer, depth, &info->name))
2949 return False;
2951 return True;
2954 /*******************************************************************
2955 ********************************************************************/
2957 BOOL smb_io_printmonitor_info_2(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
2959 prs_struct *ps=&buffer->prs;
2961 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
2962 depth++;
2964 buffer->struct_start=prs_offset(ps);
2966 if (!smb_io_relstr("name", buffer, depth, &info->name))
2967 return False;
2968 if (!smb_io_relstr("environment", buffer, depth, &info->environment))
2969 return False;
2970 if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
2971 return False;
2973 return True;
2976 /*******************************************************************
2977 return the size required by a struct in the stream
2978 ********************************************************************/
2980 uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
2982 int size=0;
2984 size+=size_of_relative_string( &info->printername );
2985 size+=size_of_relative_string( &info->servername );
2987 size+=size_of_uint32( &info->cjobs);
2988 size+=size_of_uint32( &info->total_jobs);
2989 size+=size_of_uint32( &info->total_bytes);
2991 size+=size_of_uint16( &info->year);
2992 size+=size_of_uint16( &info->month);
2993 size+=size_of_uint16( &info->dayofweek);
2994 size+=size_of_uint16( &info->day);
2995 size+=size_of_uint16( &info->hour);
2996 size+=size_of_uint16( &info->minute);
2997 size+=size_of_uint16( &info->second);
2998 size+=size_of_uint16( &info->milliseconds);
3000 size+=size_of_uint32( &info->global_counter);
3001 size+=size_of_uint32( &info->total_pages);
3003 size+=size_of_uint16( &info->major_version);
3004 size+=size_of_uint16( &info->build_version);
3006 size+=size_of_uint32( &info->unknown7);
3007 size+=size_of_uint32( &info->unknown8);
3008 size+=size_of_uint32( &info->unknown9);
3009 size+=size_of_uint32( &info->session_counter);
3010 size+=size_of_uint32( &info->unknown11);
3011 size+=size_of_uint32( &info->printer_errors);
3012 size+=size_of_uint32( &info->unknown13);
3013 size+=size_of_uint32( &info->unknown14);
3014 size+=size_of_uint32( &info->unknown15);
3015 size+=size_of_uint32( &info->unknown16);
3016 size+=size_of_uint32( &info->change_id);
3017 size+=size_of_uint32( &info->unknown18);
3018 size+=size_of_uint32( &info->status);
3019 size+=size_of_uint32( &info->unknown20);
3020 size+=size_of_uint32( &info->c_setprinter);
3022 size+=size_of_uint16( &info->unknown22);
3023 size+=size_of_uint16( &info->unknown23);
3024 size+=size_of_uint16( &info->unknown24);
3025 size+=size_of_uint16( &info->unknown25);
3026 size+=size_of_uint16( &info->unknown26);
3027 size+=size_of_uint16( &info->unknown27);
3028 size+=size_of_uint16( &info->unknown28);
3029 size+=size_of_uint16( &info->unknown29);
3031 return size;
3034 /*******************************************************************
3035 return the size required by a struct in the stream
3036 ********************************************************************/
3038 uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
3040 int size=0;
3042 size+=size_of_uint32( &info->flags );
3043 size+=size_of_relative_string( &info->description );
3044 size+=size_of_relative_string( &info->name );
3045 size+=size_of_relative_string( &info->comment );
3047 return size;
3050 /*******************************************************************
3051 return the size required by a struct in the stream
3052 ********************************************************************/
3054 uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
3056 uint32 size=0;
3058 size += 4;
3060 size += sec_desc_size( info->secdesc );
3062 size+=size_of_device_mode( info->devmode );
3064 size+=size_of_relative_string( &info->servername );
3065 size+=size_of_relative_string( &info->printername );
3066 size+=size_of_relative_string( &info->sharename );
3067 size+=size_of_relative_string( &info->portname );
3068 size+=size_of_relative_string( &info->drivername );
3069 size+=size_of_relative_string( &info->comment );
3070 size+=size_of_relative_string( &info->location );
3072 size+=size_of_relative_string( &info->sepfile );
3073 size+=size_of_relative_string( &info->printprocessor );
3074 size+=size_of_relative_string( &info->datatype );
3075 size+=size_of_relative_string( &info->parameters );
3077 size+=size_of_uint32( &info->attributes );
3078 size+=size_of_uint32( &info->priority );
3079 size+=size_of_uint32( &info->defaultpriority );
3080 size+=size_of_uint32( &info->starttime );
3081 size+=size_of_uint32( &info->untiltime );
3082 size+=size_of_uint32( &info->status );
3083 size+=size_of_uint32( &info->cjobs );
3084 size+=size_of_uint32( &info->averageppm );
3087 * add any adjustments for alignment. This is
3088 * not optimal since we could be calling this
3089 * function from a loop (e.g. enumprinters), but
3090 * it is easier to maintain the calculation here and
3091 * not place the burden on the caller to remember. --jerry
3093 if ((size % 4) != 0)
3094 size += 4 - (size % 4);
3096 return size;
3099 /*******************************************************************
3100 return the size required by a struct in the stream
3101 ********************************************************************/
3103 uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
3105 uint32 size=0;
3107 size+=size_of_relative_string( &info->printername );
3108 size+=size_of_relative_string( &info->servername );
3110 size+=size_of_uint32( &info->attributes );
3111 return size;
3114 /*******************************************************************
3115 return the size required by a struct in the stream
3116 ********************************************************************/
3118 uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
3120 uint32 size=0;
3122 size+=size_of_relative_string( &info->printername );
3123 size+=size_of_relative_string( &info->portname );
3125 size+=size_of_uint32( &info->attributes );
3126 size+=size_of_uint32( &info->device_not_selected_timeout );
3127 size+=size_of_uint32( &info->transmission_retry_timeout );
3128 return size;
3131 /*******************************************************************
3132 return the size required by a struct in the stream
3133 ********************************************************************/
3135 uint32 spoolss_size_printer_info_6(PRINTER_INFO_6 *info)
3137 return sizeof(uint32);
3140 /*******************************************************************
3141 return the size required by a struct in the stream
3142 ********************************************************************/
3144 uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
3146 /* The 4 is for the self relative pointer.. */
3147 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3148 return 4 + (uint32)sec_desc_size( info->secdesc );
3151 /*******************************************************************
3152 return the size required by a struct in the stream
3153 ********************************************************************/
3155 uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info)
3157 uint32 size=0;
3159 size+=size_of_relative_string( &info->guid );
3160 size+=size_of_uint32( &info->action );
3161 return size;
3164 /*******************************************************************
3165 return the size required by a struct in the stream
3166 ********************************************************************/
3168 uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
3170 int size=0;
3171 size+=size_of_relative_string( &info->name );
3173 return size;
3176 /*******************************************************************
3177 return the size required by a struct in the stream
3178 ********************************************************************/
3180 uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
3182 int size=0;
3183 size+=size_of_uint32( &info->version );
3184 size+=size_of_relative_string( &info->name );
3185 size+=size_of_relative_string( &info->architecture );
3186 size+=size_of_relative_string( &info->driverpath );
3187 size+=size_of_relative_string( &info->datafile );
3188 size+=size_of_relative_string( &info->configfile );
3190 return size;
3193 /*******************************************************************
3194 return the size required by a string array.
3195 ********************************************************************/
3197 uint32 spoolss_size_string_array(uint16 *string)
3199 uint32 i = 0;
3201 if (string) {
3202 for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
3204 i=i+2; /* to count all chars including the leading zero */
3205 i=2*i; /* because we need the value in bytes */
3206 i=i+4; /* the offset pointer size */
3208 return i;
3211 /*******************************************************************
3212 return the size required by a struct in the stream
3213 ********************************************************************/
3215 uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
3217 int size=0;
3219 size+=size_of_uint32( &info->version );
3220 size+=size_of_relative_string( &info->name );
3221 size+=size_of_relative_string( &info->architecture );
3222 size+=size_of_relative_string( &info->driverpath );
3223 size+=size_of_relative_string( &info->datafile );
3224 size+=size_of_relative_string( &info->configfile );
3225 size+=size_of_relative_string( &info->helpfile );
3226 size+=size_of_relative_string( &info->monitorname );
3227 size+=size_of_relative_string( &info->defaultdatatype );
3229 size+=spoolss_size_string_array(info->dependentfiles);
3231 return size;
3234 /*******************************************************************
3235 return the size required by a struct in the stream
3236 ********************************************************************/
3238 uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
3240 uint32 size=0;
3242 size+=size_of_uint32( &info->version );
3243 size+=size_of_relative_string( &info->name );
3244 size+=size_of_relative_string( &info->architecture );
3245 size+=size_of_relative_string( &info->driverpath );
3246 size+=size_of_relative_string( &info->datafile );
3247 size+=size_of_relative_string( &info->configfile );
3248 size+=size_of_relative_string( &info->helpfile );
3250 size+=spoolss_size_string_array(info->dependentfiles);
3252 size+=size_of_relative_string( &info->monitorname );
3253 size+=size_of_relative_string( &info->defaultdatatype );
3255 size+=spoolss_size_string_array(info->previousdrivernames);
3257 size+=size_of_nttime(&info->driver_date);
3258 size+=size_of_uint32( &info->padding );
3259 size+=size_of_uint32( &info->driver_version_low );
3260 size+=size_of_uint32( &info->driver_version_high );
3261 size+=size_of_relative_string( &info->mfgname );
3262 size+=size_of_relative_string( &info->oem_url );
3263 size+=size_of_relative_string( &info->hardware_id );
3264 size+=size_of_relative_string( &info->provider );
3266 return size;
3269 /*******************************************************************
3270 return the size required by a struct in the stream
3271 ********************************************************************/
3273 uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
3275 int size=0;
3276 size+=size_of_uint32( &info->jobid );
3277 size+=size_of_relative_string( &info->printername );
3278 size+=size_of_relative_string( &info->machinename );
3279 size+=size_of_relative_string( &info->username );
3280 size+=size_of_relative_string( &info->document );
3281 size+=size_of_relative_string( &info->datatype );
3282 size+=size_of_relative_string( &info->text_status );
3283 size+=size_of_uint32( &info->status );
3284 size+=size_of_uint32( &info->priority );
3285 size+=size_of_uint32( &info->position );
3286 size+=size_of_uint32( &info->totalpages );
3287 size+=size_of_uint32( &info->pagesprinted );
3288 size+=size_of_systemtime( &info->submitted );
3290 return size;
3293 /*******************************************************************
3294 return the size required by a struct in the stream
3295 ********************************************************************/
3297 uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
3299 int size=0;
3301 size+=4; /* size of sec desc ptr */
3303 size+=size_of_uint32( &info->jobid );
3304 size+=size_of_relative_string( &info->printername );
3305 size+=size_of_relative_string( &info->machinename );
3306 size+=size_of_relative_string( &info->username );
3307 size+=size_of_relative_string( &info->document );
3308 size+=size_of_relative_string( &info->notifyname );
3309 size+=size_of_relative_string( &info->datatype );
3310 size+=size_of_relative_string( &info->printprocessor );
3311 size+=size_of_relative_string( &info->parameters );
3312 size+=size_of_relative_string( &info->drivername );
3313 size+=size_of_device_mode( info->devmode );
3314 size+=size_of_relative_string( &info->text_status );
3315 /* SEC_DESC sec_desc;*/
3316 size+=size_of_uint32( &info->status );
3317 size+=size_of_uint32( &info->priority );
3318 size+=size_of_uint32( &info->position );
3319 size+=size_of_uint32( &info->starttime );
3320 size+=size_of_uint32( &info->untiltime );
3321 size+=size_of_uint32( &info->totalpages );
3322 size+=size_of_uint32( &info->size );
3323 size+=size_of_systemtime( &info->submitted );
3324 size+=size_of_uint32( &info->timeelapsed );
3325 size+=size_of_uint32( &info->pagesprinted );
3327 return size;
3330 /*******************************************************************
3331 return the size required by a struct in the stream
3332 ********************************************************************/
3334 uint32 spoolss_size_form_1(FORM_1 *info)
3336 int size=0;
3338 size+=size_of_uint32( &info->flag );
3339 size+=size_of_relative_string( &info->name );
3340 size+=size_of_uint32( &info->width );
3341 size+=size_of_uint32( &info->length );
3342 size+=size_of_uint32( &info->left );
3343 size+=size_of_uint32( &info->top );
3344 size+=size_of_uint32( &info->right );
3345 size+=size_of_uint32( &info->bottom );
3347 return size;
3350 /*******************************************************************
3351 return the size required by a struct in the stream
3352 ********************************************************************/
3354 uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
3356 int size=0;
3358 size+=size_of_relative_string( &info->port_name );
3360 return size;
3363 /*******************************************************************
3364 return the size required by a struct in the stream
3365 ********************************************************************/
3367 uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info)
3369 int size=0;
3371 size=str_len_uni(&info->name); /* the string length */
3372 size=size+1; /* add the leading zero */
3373 size=size*2; /* convert in char */
3375 return size;
3378 /*******************************************************************
3379 return the size required by a struct in the stream
3380 ********************************************************************/
3382 uint32 spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1 *info)
3384 int size=0;
3386 size=str_len_uni(&info->name); /* the string length */
3387 size=size+1; /* add the leading zero */
3388 size=size*2; /* convert in char */
3390 return size;
3393 /*******************************************************************
3394 return the size required by a struct in the stream
3395 ********************************************************************/
3397 uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
3399 int size=0;
3401 size+=size_of_relative_string( &info->port_name );
3402 size+=size_of_relative_string( &info->monitor_name );
3403 size+=size_of_relative_string( &info->description );
3405 size+=size_of_uint32( &info->port_type );
3406 size+=size_of_uint32( &info->reserved );
3408 return size;
3411 /*******************************************************************
3412 return the size required by a struct in the stream
3413 ********************************************************************/
3415 uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
3417 int size=0;
3418 size+=size_of_relative_string( &info->name );
3420 return size;
3423 /*******************************************************************
3424 return the size required by a struct in the stream
3425 ********************************************************************/
3427 uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info)
3429 int size=0;
3430 size+=size_of_relative_string( &info->name );
3432 return size;
3435 /*******************************************************************
3436 return the size required by a struct in the stream
3437 ********************************************************************/
3438 uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
3440 uint32 size = 0;
3442 if (!p)
3443 return 0;
3445 /* uint32(offset) + uint32(length) + length) */
3446 size += (size_of_uint32(&p->value_len)*2) + p->value_len;
3447 size += (size_of_uint32(&p->data_len)*2) + p->data_len + (p->data_len%2) ;
3449 size += size_of_uint32(&p->type);
3451 return size;
3454 /*******************************************************************
3455 return the size required by a struct in the stream
3456 ********************************************************************/
3458 uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
3460 int size=0;
3461 size+=size_of_relative_string( &info->name );
3463 return size;
3466 /*******************************************************************
3467 return the size required by a struct in the stream
3468 ********************************************************************/
3470 uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
3472 int size=0;
3473 size+=size_of_relative_string( &info->name);
3474 size+=size_of_relative_string( &info->environment);
3475 size+=size_of_relative_string( &info->dll_name);
3477 return size;
3480 /*******************************************************************
3481 * init a structure.
3482 ********************************************************************/
3484 BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
3485 const POLICY_HND *hnd,
3486 const fstring architecture,
3487 uint32 level, uint32 clientmajor, uint32 clientminor,
3488 RPC_BUFFER *buffer, uint32 offered)
3490 if (q_u == NULL)
3491 return False;
3493 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3495 init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture);
3497 q_u->level=level;
3498 q_u->clientmajorversion=clientmajor;
3499 q_u->clientminorversion=clientminor;
3501 q_u->buffer=buffer;
3502 q_u->offered=offered;
3504 return True;
3507 /*******************************************************************
3508 * read a structure.
3509 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3510 ********************************************************************/
3512 BOOL spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
3514 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
3515 depth++;
3517 if(!prs_align(ps))
3518 return False;
3520 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3521 return False;
3522 if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr))
3523 return False;
3524 if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth))
3525 return False;
3527 if(!prs_align(ps))
3528 return False;
3529 if(!prs_uint32("level", ps, depth, &q_u->level))
3530 return False;
3532 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3533 return False;
3535 if(!prs_align(ps))
3536 return False;
3538 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3539 return False;
3541 if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion))
3542 return False;
3543 if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion))
3544 return False;
3546 return True;
3549 /*******************************************************************
3550 * read a structure.
3551 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3552 ********************************************************************/
3554 BOOL spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
3556 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
3557 depth++;
3559 if (!prs_align(ps))
3560 return False;
3562 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3563 return False;
3565 if (!prs_align(ps))
3566 return False;
3567 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3568 return False;
3569 if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion))
3570 return False;
3571 if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
3572 return False;
3573 if (!prs_werror("status", ps, depth, &r_u->status))
3574 return False;
3576 return True;
3579 /*******************************************************************
3580 * init a structure.
3581 ********************************************************************/
3583 BOOL make_spoolss_q_enumprinters(
3584 SPOOL_Q_ENUMPRINTERS *q_u,
3585 uint32 flags,
3586 char *servername,
3587 uint32 level,
3588 RPC_BUFFER *buffer,
3589 uint32 offered
3592 q_u->flags=flags;
3594 q_u->servername_ptr = (servername != NULL) ? 1 : 0;
3595 init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
3597 q_u->level=level;
3598 q_u->buffer=buffer;
3599 q_u->offered=offered;
3601 return True;
3604 /*******************************************************************
3605 * init a structure.
3606 ********************************************************************/
3608 BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u,
3609 fstring servername, uint32 level,
3610 RPC_BUFFER *buffer, uint32 offered)
3612 q_u->name_ptr = (servername != NULL) ? 1 : 0;
3613 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
3615 q_u->level=level;
3616 q_u->buffer=buffer;
3617 q_u->offered=offered;
3619 return True;
3622 /*******************************************************************
3623 * read a structure.
3624 * called from spoolss_enumprinters (srv_spoolss.c)
3625 ********************************************************************/
3627 BOOL spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
3629 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
3630 depth++;
3632 if (!prs_align(ps))
3633 return False;
3635 if (!prs_uint32("flags", ps, depth, &q_u->flags))
3636 return False;
3637 if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
3638 return False;
3640 if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
3641 return False;
3643 if (!prs_align(ps))
3644 return False;
3645 if (!prs_uint32("level", ps, depth, &q_u->level))
3646 return False;
3648 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3649 return False;
3651 if (!prs_align(ps))
3652 return False;
3653 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3654 return False;
3656 return True;
3659 /*******************************************************************
3660 Parse a SPOOL_R_ENUMPRINTERS structure.
3661 ********************************************************************/
3663 BOOL spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
3665 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
3666 depth++;
3668 if (!prs_align(ps))
3669 return False;
3671 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3672 return False;
3674 if (!prs_align(ps))
3675 return False;
3677 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3678 return False;
3680 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3681 return False;
3683 if (!prs_werror("status", ps, depth, &r_u->status))
3684 return False;
3686 return True;
3689 /*******************************************************************
3690 * write a structure.
3691 * called from spoolss_r_enum_printers (srv_spoolss.c)
3693 ********************************************************************/
3695 BOOL spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
3697 prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
3698 depth++;
3700 if (!prs_align(ps))
3701 return False;
3703 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3704 return False;
3706 if (!prs_align(ps))
3707 return False;
3709 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3710 return False;
3712 if (!prs_werror("status", ps, depth, &r_u->status))
3713 return False;
3715 return True;
3718 /*******************************************************************
3719 * read a structure.
3720 * called from spoolss_getprinter (srv_spoolss.c)
3721 ********************************************************************/
3723 BOOL spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
3725 prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
3726 depth++;
3728 if (!prs_align(ps))
3729 return False;
3731 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3732 return False;
3733 if (!prs_uint32("level", ps, depth, &q_u->level))
3734 return False;
3736 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3737 return False;
3739 if (!prs_align(ps))
3740 return False;
3741 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3742 return False;
3744 return True;
3747 /*******************************************************************
3748 * init a structure.
3749 ********************************************************************/
3751 BOOL make_spoolss_q_getprinter(
3752 TALLOC_CTX *mem_ctx,
3753 SPOOL_Q_GETPRINTER *q_u,
3754 const POLICY_HND *hnd,
3755 uint32 level,
3756 RPC_BUFFER *buffer,
3757 uint32 offered
3760 if (q_u == NULL)
3762 return False;
3764 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3766 q_u->level=level;
3767 q_u->buffer=buffer;
3768 q_u->offered=offered;
3770 return True;
3773 /*******************************************************************
3774 * init a structure.
3775 ********************************************************************/
3776 BOOL make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
3777 const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
3778 uint32 command)
3780 SEC_DESC *secdesc;
3781 DEVICEMODE *devmode;
3783 if (!q_u || !info)
3784 return False;
3786 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3788 q_u->level = level;
3789 q_u->info.level = level;
3790 q_u->info.info_ptr = 1; /* Info is != NULL, see above */
3791 switch (level) {
3793 /* There's no such thing as a setprinter level 1 */
3795 case 2:
3796 secdesc = info->printers_2->secdesc;
3797 devmode = info->printers_2->devmode;
3799 make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2);
3800 #if 1 /* JERRY TEST */
3801 q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
3802 if (!q_u->secdesc_ctr)
3803 return False;
3804 q_u->secdesc_ctr->sd = secdesc;
3805 q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3807 q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
3808 q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0;
3809 q_u->devmode_ctr.devmode = devmode;
3810 #else
3811 q_u->secdesc_ctr = NULL;
3813 q_u->devmode_ctr.devmode_ptr = 0;
3814 q_u->devmode_ctr.size = 0;
3815 q_u->devmode_ctr.devmode = NULL;
3816 #endif
3817 break;
3818 case 3:
3819 secdesc = info->printers_3->secdesc;
3821 make_spoolss_printer_info_3 (mem_ctx, &q_u->info.info_3, info->printers_3);
3823 q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
3824 if (!q_u->secdesc_ctr)
3825 return False;
3826 q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3827 q_u->secdesc_ctr->sd = secdesc;
3829 break;
3830 case 7:
3831 make_spoolss_printer_info_7 (mem_ctx, &q_u->info.info_7, info->printers_7);
3832 break;
3834 default:
3835 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
3836 break;
3840 q_u->command = command;
3842 return True;
3846 /*******************************************************************
3847 ********************************************************************/
3849 BOOL spoolss_io_r_setprinter(const char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
3851 prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
3852 depth++;
3854 if(!prs_align(ps))
3855 return False;
3857 if(!prs_werror("status", ps, depth, &r_u->status))
3858 return False;
3860 return True;
3863 /*******************************************************************
3864 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3865 ********************************************************************/
3867 BOOL spoolss_io_q_setprinter(const char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
3869 uint32 ptr_sec_desc = 0;
3871 prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
3872 depth++;
3874 if(!prs_align(ps))
3875 return False;
3877 if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
3878 return False;
3879 if(!prs_uint32("level", ps, depth, &q_u->level))
3880 return False;
3882 /* check for supported levels and structures we know about */
3884 switch ( q_u->level ) {
3885 case 0:
3886 case 2:
3887 case 3:
3888 case 7:
3889 /* supported levels */
3890 break;
3891 default:
3892 DEBUG(0,("spoolss_io_q_setprinter: unsupported printer info level [%d]\n",
3893 q_u->level));
3894 return True;
3898 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
3899 return False;
3901 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
3902 return False;
3904 if(!prs_align(ps))
3905 return False;
3907 switch (q_u->level)
3909 case 2:
3911 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
3912 break;
3914 case 3:
3916 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
3917 break;
3920 if (ptr_sec_desc)
3922 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
3923 return False;
3924 } else {
3925 uint32 dummy = 0;
3927 /* Parse a NULL security descriptor. This should really
3928 happen inside the sec_io_desc_buf() function. */
3930 prs_debug(ps, depth, "", "sec_io_desc_buf");
3931 if (!prs_uint32("size", ps, depth + 1, &dummy))
3932 return False;
3933 if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return
3934 False;
3937 if(!prs_uint32("command", ps, depth, &q_u->command))
3938 return False;
3940 return True;
3943 /*******************************************************************
3944 ********************************************************************/
3946 BOOL spoolss_io_r_fcpn(const char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
3948 prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
3949 depth++;
3951 if(!prs_align(ps))
3952 return False;
3954 if(!prs_werror("status", ps, depth, &r_u->status))
3955 return False;
3957 return True;
3960 /*******************************************************************
3961 ********************************************************************/
3963 BOOL spoolss_io_q_fcpn(const char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
3966 prs_debug(ps, depth, desc, "spoolss_io_q_fcpn");
3967 depth++;
3969 if(!prs_align(ps))
3970 return False;
3972 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3973 return False;
3975 return True;
3979 /*******************************************************************
3980 ********************************************************************/
3982 BOOL spoolss_io_r_addjob(const char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
3984 prs_debug(ps, depth, desc, "");
3985 depth++;
3987 if(!prs_align(ps))
3988 return False;
3990 if(!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3991 return False;
3993 if(!prs_align(ps))
3994 return False;
3996 if(!prs_uint32("needed", ps, depth, &r_u->needed))
3997 return False;
3999 if(!prs_werror("status", ps, depth, &r_u->status))
4000 return False;
4002 return True;
4005 /*******************************************************************
4006 ********************************************************************/
4008 BOOL spoolss_io_q_addjob(const char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
4010 prs_debug(ps, depth, desc, "");
4011 depth++;
4013 if(!prs_align(ps))
4014 return False;
4016 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
4017 return False;
4018 if(!prs_uint32("level", ps, depth, &q_u->level))
4019 return False;
4021 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4022 return False;
4024 if(!prs_align(ps))
4025 return False;
4027 if(!prs_uint32("offered", ps, depth, &q_u->offered))
4028 return False;
4030 return True;
4033 /*******************************************************************
4034 ********************************************************************/
4036 BOOL spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
4038 prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
4039 depth++;
4041 if (!prs_align(ps))
4042 return False;
4044 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4045 return False;
4047 if (!prs_align(ps))
4048 return False;
4050 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4051 return False;
4053 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4054 return False;
4056 if (!prs_werror("status", ps, depth, &r_u->status))
4057 return False;
4059 return True;
4062 /*******************************************************************
4063 ********************************************************************/
4065 BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
4066 uint32 firstjob,
4067 uint32 numofjobs,
4068 uint32 level,
4069 RPC_BUFFER *buffer,
4070 uint32 offered)
4072 if (q_u == NULL)
4074 return False;
4076 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
4077 q_u->firstjob = firstjob;
4078 q_u->numofjobs = numofjobs;
4079 q_u->level = level;
4080 q_u->buffer= buffer;
4081 q_u->offered = offered;
4082 return True;
4085 /*******************************************************************
4086 ********************************************************************/
4088 BOOL spoolss_io_q_enumjobs(const char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
4090 prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
4091 depth++;
4093 if (!prs_align(ps))
4094 return False;
4096 if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth))
4097 return False;
4099 if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
4100 return False;
4101 if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
4102 return False;
4103 if (!prs_uint32("level", ps, depth, &q_u->level))
4104 return False;
4106 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4107 return False;
4109 if(!prs_align(ps))
4110 return False;
4112 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4113 return False;
4115 return True;
4118 /*******************************************************************
4119 ********************************************************************/
4121 BOOL spoolss_io_r_schedulejob(const char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth)
4123 prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob");
4124 depth++;
4126 if(!prs_align(ps))
4127 return False;
4129 if(!prs_werror("status", ps, depth, &r_u->status))
4130 return False;
4132 return True;
4135 /*******************************************************************
4136 ********************************************************************/
4138 BOOL spoolss_io_q_schedulejob(const char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth)
4140 prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob");
4141 depth++;
4143 if(!prs_align(ps))
4144 return False;
4146 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4147 return False;
4148 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4149 return False;
4151 return True;
4154 /*******************************************************************
4155 ********************************************************************/
4157 BOOL spoolss_io_r_setjob(const char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth)
4159 prs_debug(ps, depth, desc, "spoolss_io_r_setjob");
4160 depth++;
4162 if(!prs_align(ps))
4163 return False;
4165 if(!prs_werror("status", ps, depth, &r_u->status))
4166 return False;
4168 return True;
4171 /*******************************************************************
4172 ********************************************************************/
4174 BOOL spoolss_io_q_setjob(const char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth)
4176 prs_debug(ps, depth, desc, "spoolss_io_q_setjob");
4177 depth++;
4179 if(!prs_align(ps))
4180 return False;
4182 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4183 return False;
4184 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4185 return False;
4187 * level is usually 0. If (level!=0) then I'm in trouble !
4188 * I will try to generate setjob command with level!=0, one day.
4190 if(!prs_uint32("level", ps, depth, &q_u->level))
4191 return False;
4192 if(!prs_uint32("command", ps, depth, &q_u->command))
4193 return False;
4195 return True;
4198 /*******************************************************************
4199 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4200 ********************************************************************/
4202 BOOL spoolss_io_r_enumprinterdrivers(const char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
4204 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
4205 depth++;
4207 if (!prs_align(ps))
4208 return False;
4210 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4211 return False;
4213 if (!prs_align(ps))
4214 return False;
4216 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4217 return False;
4219 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4220 return False;
4222 if (!prs_werror("status", ps, depth, &r_u->status))
4223 return False;
4225 return True;
4228 /*******************************************************************
4229 * init a structure.
4230 ********************************************************************/
4232 BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
4233 const char *name,
4234 const char *environment,
4235 uint32 level,
4236 RPC_BUFFER *buffer, uint32 offered)
4238 init_buf_unistr2(&q_u->name, &q_u->name_ptr, name);
4239 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment);
4241 q_u->level=level;
4242 q_u->buffer=buffer;
4243 q_u->offered=offered;
4245 return True;
4248 /*******************************************************************
4249 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4250 ********************************************************************/
4252 BOOL spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
4255 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
4256 depth++;
4258 if (!prs_align(ps))
4259 return False;
4261 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
4262 return False;
4263 if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
4264 return False;
4266 if (!prs_align(ps))
4267 return False;
4268 if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
4269 return False;
4270 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
4271 return False;
4273 if (!prs_align(ps))
4274 return False;
4275 if (!prs_uint32("level", ps, depth, &q_u->level))
4276 return False;
4278 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4279 return False;
4281 if (!prs_align(ps))
4282 return False;
4284 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4285 return False;
4287 return True;
4290 /*******************************************************************
4291 ********************************************************************/
4293 BOOL spoolss_io_q_enumforms(const char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
4296 prs_debug(ps, depth, desc, "spoolss_io_q_enumforms");
4297 depth++;
4299 if (!prs_align(ps))
4300 return False;
4301 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4302 return False;
4303 if (!prs_uint32("level", ps, depth, &q_u->level))
4304 return False;
4306 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4307 return False;
4309 if (!prs_align(ps))
4310 return False;
4311 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4312 return False;
4314 return True;
4317 /*******************************************************************
4318 ********************************************************************/
4320 BOOL spoolss_io_r_enumforms(const char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
4322 prs_debug(ps, depth, desc, "spoolss_io_r_enumforms");
4323 depth++;
4325 if (!prs_align(ps))
4326 return False;
4328 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4329 return False;
4331 if (!prs_align(ps))
4332 return False;
4334 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4335 return False;
4337 if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
4338 return False;
4340 if (!prs_werror("status", ps, depth, &r_u->status))
4341 return False;
4343 return True;
4346 /*******************************************************************
4347 ********************************************************************/
4349 BOOL spoolss_io_q_getform(const char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
4352 prs_debug(ps, depth, desc, "spoolss_io_q_getform");
4353 depth++;
4355 if (!prs_align(ps))
4356 return False;
4357 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4358 return False;
4359 if (!smb_io_unistr2("", &q_u->formname,True,ps,depth))
4360 return False;
4362 if (!prs_align(ps))
4363 return False;
4365 if (!prs_uint32("level", ps, depth, &q_u->level))
4366 return False;
4368 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4369 return False;
4371 if (!prs_align(ps))
4372 return False;
4373 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4374 return False;
4376 return True;
4379 /*******************************************************************
4380 ********************************************************************/
4382 BOOL spoolss_io_r_getform(const char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
4384 prs_debug(ps, depth, desc, "spoolss_io_r_getform");
4385 depth++;
4387 if (!prs_align(ps))
4388 return False;
4390 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4391 return False;
4393 if (!prs_align(ps))
4394 return False;
4396 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4397 return False;
4399 if (!prs_werror("status", ps, depth, &r_u->status))
4400 return False;
4402 return True;
4405 /*******************************************************************
4406 Parse a SPOOL_R_ENUMPORTS structure.
4407 ********************************************************************/
4409 BOOL spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
4411 prs_debug(ps, depth, desc, "spoolss_io_r_enumports");
4412 depth++;
4414 if (!prs_align(ps))
4415 return False;
4417 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4418 return False;
4420 if (!prs_align(ps))
4421 return False;
4423 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4424 return False;
4426 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4427 return False;
4429 if (!prs_werror("status", ps, depth, &r_u->status))
4430 return False;
4432 return True;
4435 /*******************************************************************
4436 ********************************************************************/
4438 BOOL spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
4440 prs_debug(ps, depth, desc, "");
4441 depth++;
4443 if (!prs_align(ps))
4444 return False;
4446 if (!prs_uint32("", ps, depth, &q_u->name_ptr))
4447 return False;
4448 if (!smb_io_unistr2("", &q_u->name,True,ps,depth))
4449 return False;
4451 if (!prs_align(ps))
4452 return False;
4453 if (!prs_uint32("level", ps, depth, &q_u->level))
4454 return False;
4456 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
4457 return False;
4459 if (!prs_align(ps))
4460 return False;
4461 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4462 return False;
4464 return True;
4467 /*******************************************************************
4468 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4469 ********************************************************************/
4471 BOOL spool_io_printer_info_level_1(const char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
4473 prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
4474 depth++;
4476 if(!prs_align(ps))
4477 return False;
4479 if(!prs_uint32("flags", ps, depth, &il->flags))
4480 return False;
4481 if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr))
4482 return False;
4483 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4484 return False;
4485 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4486 return False;
4488 if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth))
4489 return False;
4490 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4491 return False;
4492 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4493 return False;
4495 return True;
4498 /*******************************************************************
4499 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4500 ********************************************************************/
4502 BOOL spool_io_printer_info_level_3(const char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
4504 prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
4505 depth++;
4507 if(!prs_align(ps))
4508 return False;
4510 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4511 return False;
4513 return True;
4516 /*******************************************************************
4517 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4518 ********************************************************************/
4520 BOOL spool_io_printer_info_level_2(const char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
4522 prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
4523 depth++;
4525 if(!prs_align(ps))
4526 return False;
4528 if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr))
4529 return False;
4530 if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr))
4531 return False;
4532 if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr))
4533 return False;
4534 if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
4535 return False;
4537 if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
4538 return False;
4539 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4540 return False;
4541 if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr))
4542 return False;
4543 if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr))
4544 return False;
4545 if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr))
4546 return False;
4547 if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr))
4548 return False;
4549 if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr))
4550 return False;
4551 if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr))
4552 return False;
4553 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4554 return False;
4556 if(!prs_uint32("attributes", ps, depth, &il->attributes))
4557 return False;
4558 if(!prs_uint32("priority", ps, depth, &il->priority))
4559 return False;
4560 if(!prs_uint32("default_priority", ps, depth, &il->default_priority))
4561 return False;
4562 if(!prs_uint32("starttime", ps, depth, &il->starttime))
4563 return False;
4564 if(!prs_uint32("untiltime", ps, depth, &il->untiltime))
4565 return False;
4566 if(!prs_uint32("status", ps, depth, &il->status))
4567 return False;
4568 if(!prs_uint32("cjobs", ps, depth, &il->cjobs))
4569 return False;
4570 if(!prs_uint32("averageppm", ps, depth, &il->averageppm))
4571 return False;
4573 if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth))
4574 return False;
4575 if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth))
4576 return False;
4577 if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth))
4578 return False;
4579 if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth))
4580 return False;
4581 if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth))
4582 return False;
4583 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4584 return False;
4585 if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth))
4586 return False;
4587 if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth))
4588 return False;
4589 if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth))
4590 return False;
4591 if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth))
4592 return False;
4593 if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth))
4594 return False;
4596 return True;
4599 BOOL spool_io_printer_info_level_7(const char *desc, SPOOL_PRINTER_INFO_LEVEL_7 *il, prs_struct *ps, int depth)
4601 prs_debug(ps, depth, desc, "spool_io_printer_info_level_7");
4602 depth++;
4604 if(!prs_align(ps))
4605 return False;
4607 if(!prs_uint32("guid_ptr", ps, depth, &il->guid_ptr))
4608 return False;
4609 if(!prs_uint32("action", ps, depth, &il->action))
4610 return False;
4612 if(!smb_io_unistr2("servername", &il->guid, il->guid_ptr, ps, depth))
4613 return False;
4614 return True;
4617 /*******************************************************************
4618 ********************************************************************/
4620 BOOL spool_io_printer_info_level(const char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
4622 prs_debug(ps, depth, desc, "spool_io_printer_info_level");
4623 depth++;
4625 if(!prs_align(ps))
4626 return False;
4627 if(!prs_uint32("level", ps, depth, &il->level))
4628 return False;
4629 if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr))
4630 return False;
4632 /* if no struct inside just return */
4633 if (il->info_ptr==0) {
4634 if (UNMARSHALLING(ps)) {
4635 il->info_1=NULL;
4636 il->info_2=NULL;
4638 return True;
4641 switch (il->level) {
4643 * level 0 is used by setprinter when managing the queue
4644 * (hold, stop, start a queue)
4646 case 0:
4647 break;
4648 /* DOCUMENT ME!!! What is level 1 used for? */
4649 case 1:
4651 if (UNMARSHALLING(ps)) {
4652 if ((il->info_1=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_1,1)) == NULL)
4653 return False;
4655 if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
4656 return False;
4657 break;
4660 * level 2 is used by addprinter
4661 * and by setprinter when updating printer's info
4663 case 2:
4664 if (UNMARSHALLING(ps)) {
4665 if ((il->info_2=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_2,1)) == NULL)
4666 return False;
4668 if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
4669 return False;
4670 break;
4671 /* DOCUMENT ME!!! What is level 3 used for? */
4672 case 3:
4674 if (UNMARSHALLING(ps)) {
4675 if ((il->info_3=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_3,1)) == NULL)
4676 return False;
4678 if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
4679 return False;
4680 break;
4682 case 7:
4683 if (UNMARSHALLING(ps))
4684 if ((il->info_7=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_7,1)) == NULL)
4685 return False;
4686 if (!spool_io_printer_info_level_7("", il->info_7, ps, depth))
4687 return False;
4688 break;
4691 return True;
4694 /*******************************************************************
4695 ********************************************************************/
4697 BOOL spoolss_io_q_addprinterex(const char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
4699 uint32 ptr_sec_desc = 0;
4701 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
4702 depth++;
4704 if(!prs_align(ps))
4705 return False;
4707 if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->server_name))
4708 return False;
4709 if (!prs_io_unistr2("servername", ps, depth, q_u->server_name))
4710 return False;
4712 if(!prs_align(ps))
4713 return False;
4715 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4716 return False;
4718 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
4719 return False;
4721 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
4722 return False;
4724 if(!prs_align(ps))
4725 return False;
4727 switch (q_u->level) {
4728 case 2:
4729 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
4730 break;
4731 case 3:
4732 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
4733 break;
4735 if (ptr_sec_desc) {
4736 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
4737 return False;
4738 } else {
4739 uint32 dummy;
4741 /* Parse a NULL security descriptor. This should really
4742 happen inside the sec_io_desc_buf() function. */
4744 prs_debug(ps, depth, "", "sec_io_desc_buf");
4745 if (!prs_uint32("size", ps, depth + 1, &dummy))
4746 return False;
4747 if (!prs_uint32("ptr", ps, depth + 1, &dummy))
4748 return False;
4751 if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
4752 return False;
4753 if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
4754 return False;
4756 return True;
4759 /*******************************************************************
4760 ********************************************************************/
4762 BOOL spoolss_io_r_addprinterex(const char *desc, SPOOL_R_ADDPRINTEREX *r_u,
4763 prs_struct *ps, int depth)
4765 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
4766 depth++;
4768 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
4769 return False;
4771 if(!prs_werror("status", ps, depth, &r_u->status))
4772 return False;
4774 return True;
4777 /*******************************************************************
4778 ********************************************************************/
4780 BOOL spool_io_printer_driver_info_level_3(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
4781 prs_struct *ps, int depth)
4783 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il;
4785 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3");
4786 depth++;
4788 /* reading */
4789 if (UNMARSHALLING(ps)) {
4790 il=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_DRIVER_INFO_LEVEL_3,1);
4791 if(il == NULL)
4792 return False;
4793 *q_u=il;
4795 else {
4796 il=*q_u;
4799 if(!prs_align(ps))
4800 return False;
4802 if(!prs_uint32("cversion", ps, depth, &il->cversion))
4803 return False;
4804 if(!prs_uint32("name", ps, depth, &il->name_ptr))
4805 return False;
4806 if(!prs_uint32("environment", ps, depth, &il->environment_ptr))
4807 return False;
4808 if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr))
4809 return False;
4810 if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr))
4811 return False;
4812 if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr))
4813 return False;
4814 if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr))
4815 return False;
4816 if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr))
4817 return False;
4818 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4819 return False;
4820 if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize))
4821 return False;
4822 if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr))
4823 return False;
4825 if(!prs_align(ps))
4826 return False;
4828 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4829 return False;
4830 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4831 return False;
4832 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4833 return False;
4834 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4835 return False;
4836 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4837 return False;
4838 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4839 return False;
4840 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4841 return False;
4842 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4843 return False;
4845 if(!prs_align(ps))
4846 return False;
4848 if (il->dependentfiles_ptr)
4849 smb_io_buffer5("", &il->dependentfiles, ps, depth);
4851 return True;
4854 /*******************************************************************
4855 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4856 ********************************************************************/
4858 BOOL spool_io_printer_driver_info_level_6(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
4859 prs_struct *ps, int depth)
4861 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il;
4863 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6");
4864 depth++;
4866 /* reading */
4867 if (UNMARSHALLING(ps)) {
4868 il=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_DRIVER_INFO_LEVEL_6,1);
4869 if(il == NULL)
4870 return False;
4871 *q_u=il;
4873 else {
4874 il=*q_u;
4877 if(!prs_align(ps))
4878 return False;
4881 * I know this seems weird, but I have no other explanation.
4882 * This is observed behavior on both NT4 and 2K servers.
4883 * --jerry
4886 if (!prs_align_uint64(ps))
4887 return False;
4889 /* parse the main elements the packet */
4891 if(!prs_uint32("cversion ", ps, depth, &il->version))
4892 return False;
4893 if(!prs_uint32("name ", ps, depth, &il->name_ptr))
4894 return False;
4895 if(!prs_uint32("environment ", ps, depth, &il->environment_ptr))
4896 return False;
4897 if(!prs_uint32("driverpath ", ps, depth, &il->driverpath_ptr))
4898 return False;
4899 if(!prs_uint32("datafile ", ps, depth, &il->datafile_ptr))
4900 return False;
4901 if(!prs_uint32("configfile ", ps, depth, &il->configfile_ptr))
4902 return False;
4903 if(!prs_uint32("helpfile ", ps, depth, &il->helpfile_ptr))
4904 return False;
4905 if(!prs_uint32("monitorname ", ps, depth, &il->monitorname_ptr))
4906 return False;
4907 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4908 return False;
4909 if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_len))
4910 return False;
4911 if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_ptr))
4912 return False;
4913 if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_len))
4914 return False;
4915 if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_ptr))
4916 return False;
4917 if(!smb_io_time("driverdate ", &il->driverdate, ps, depth))
4918 return False;
4919 if(!prs_uint32("dummy4 ", ps, depth, &il->dummy4))
4920 return False;
4921 if(!prs_uint64("driverversion ", ps, depth, &il->driverversion))
4922 return False;
4923 if(!prs_uint32("mfgname ", ps, depth, &il->mfgname_ptr))
4924 return False;
4925 if(!prs_uint32("oemurl ", ps, depth, &il->oemurl_ptr))
4926 return False;
4927 if(!prs_uint32("hardwareid ", ps, depth, &il->hardwareid_ptr))
4928 return False;
4929 if(!prs_uint32("provider ", ps, depth, &il->provider_ptr))
4930 return False;
4932 /* parse the structures in the packet */
4934 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4935 return False;
4936 if(!prs_align(ps))
4937 return False;
4939 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4940 return False;
4941 if(!prs_align(ps))
4942 return False;
4944 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4945 return False;
4946 if(!prs_align(ps))
4947 return False;
4949 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4950 return False;
4951 if(!prs_align(ps))
4952 return False;
4954 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4955 return False;
4956 if(!prs_align(ps))
4957 return False;
4959 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4960 return False;
4961 if(!prs_align(ps))
4962 return False;
4964 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4965 return False;
4966 if(!prs_align(ps))
4967 return False;
4969 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4970 return False;
4971 if(!prs_align(ps))
4972 return False;
4973 if (il->dependentfiles_ptr) {
4974 if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth))
4975 return False;
4976 if(!prs_align(ps))
4977 return False;
4979 if (il->previousnames_ptr) {
4980 if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth))
4981 return False;
4982 if(!prs_align(ps))
4983 return False;
4985 if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth))
4986 return False;
4987 if(!prs_align(ps))
4988 return False;
4989 if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth))
4990 return False;
4991 if(!prs_align(ps))
4992 return False;
4993 if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth))
4994 return False;
4995 if(!prs_align(ps))
4996 return False;
4997 if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth))
4998 return False;
5000 return True;
5003 /*******************************************************************
5004 convert a buffer of UNICODE strings null terminated
5005 the buffer is terminated by a NULL
5007 convert to an dos codepage array (null terminated)
5009 dynamically allocate memory
5011 ********************************************************************/
5013 static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
5015 fstring f;
5016 int n = 0;
5017 char *src;
5019 if (buf5==NULL)
5020 return False;
5022 src = (char *)buf5->buffer;
5023 *ar = SMB_MALLOC_ARRAY(fstring, 1);
5024 if (!*ar) {
5025 return False;
5028 while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
5029 rpcstr_pull(f, src, sizeof(f)-1, -1, STR_TERMINATE);
5030 src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
5031 *ar = SMB_REALLOC_ARRAY(*ar, fstring, n+2);
5032 if (!*ar) {
5033 return False;
5035 fstrcpy((*ar)[n], f);
5036 n++;
5039 fstrcpy((*ar)[n], "");
5041 return True;
5044 /*******************************************************************
5045 read a UNICODE array with null terminated strings
5046 and null terminated array
5047 and size of array at beginning
5048 ********************************************************************/
5050 BOOL smb_io_unibuffer(const char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
5052 if (buffer==NULL) return False;
5054 buffer->offset=0;
5055 buffer->uni_str_len=buffer->uni_max_len;
5057 if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
5058 return False;
5060 if(!prs_unistr2(True, "buffer ", ps, depth, buffer))
5061 return False;
5063 return True;
5066 /*******************************************************************
5067 ********************************************************************/
5069 BOOL spool_io_printer_driver_info_level(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
5071 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
5072 depth++;
5074 if(!prs_align(ps))
5075 return False;
5076 if(!prs_uint32("level", ps, depth, &il->level))
5077 return False;
5078 if(!prs_uint32("ptr", ps, depth, &il->ptr))
5079 return False;
5081 if (il->ptr==0)
5082 return True;
5084 switch (il->level) {
5085 case 3:
5086 if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth))
5087 return False;
5088 break;
5089 case 6:
5090 if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth))
5091 return False;
5092 break;
5093 default:
5094 return False;
5097 return True;
5100 /*******************************************************************
5101 init a SPOOL_Q_ADDPRINTERDRIVER struct
5102 ******************************************************************/
5104 BOOL make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
5105 SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name,
5106 uint32 level, PRINTER_DRIVER_CTR *info)
5108 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5110 if (!srv_name || !info) {
5111 return False;
5114 q_u->server_name_ptr = 1; /* srv_name is != NULL, see above */
5115 init_unistr2(&q_u->server_name, srv_name, UNI_STR_TERMINATE);
5117 q_u->level = level;
5119 q_u->info.level = level;
5120 q_u->info.ptr = 1; /* Info is != NULL, see above */
5121 switch (level)
5123 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5124 case 3 :
5125 make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3);
5126 break;
5128 default:
5129 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level));
5130 break;
5133 return True;
5136 BOOL make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
5137 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
5138 DRIVER_INFO_3 *info3)
5140 uint32 len = 0;
5141 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf;
5143 if (!(inf=TALLOC_ZERO_P(mem_ctx, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)))
5144 return False;
5146 inf->cversion = info3->version;
5147 inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
5148 inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
5149 inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
5150 inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
5151 inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
5152 inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
5153 inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
5154 inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
5156 init_unistr2_from_unistr(&inf->name, &info3->name);
5157 init_unistr2_from_unistr(&inf->environment, &info3->architecture);
5158 init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
5159 init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
5160 init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
5161 init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
5162 init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
5163 init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
5165 if (info3->dependentfiles) {
5166 BOOL done = False;
5167 BOOL null_char = False;
5168 uint16 *ptr = info3->dependentfiles;
5170 while (!done) {
5171 switch (*ptr) {
5172 case 0:
5173 /* the null_char BOOL is used to help locate
5174 two '\0's back to back */
5175 if (null_char) {
5176 done = True;
5177 } else {
5178 null_char = True;
5180 break;
5182 default:
5183 null_char = False;
5184 break;
5186 len++;
5187 ptr++;
5191 inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0;
5192 inf->dependentfilessize = (info3->dependentfiles != NULL) ? len : 0;
5193 if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles)) {
5194 SAFE_FREE(inf);
5195 return False;
5198 *spool_drv_info = inf;
5200 return True;
5203 /*******************************************************************
5204 make a BUFFER5 struct from a uint16*
5205 ******************************************************************/
5207 BOOL make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src)
5210 buf5->buf_len = len;
5211 if (src) {
5212 if((buf5->buffer=(uint16*)TALLOC_MEMDUP(mem_ctx, src, sizeof(uint16)*len)) == NULL) {
5213 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5214 return False;
5216 } else {
5217 buf5->buffer=NULL;
5220 return True;
5223 /*******************************************************************
5224 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5225 ********************************************************************/
5227 BOOL spoolss_io_q_addprinterdriver(const char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5229 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
5230 depth++;
5232 if(!prs_align(ps))
5233 return False;
5235 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
5236 return False;
5237 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
5238 return False;
5240 if(!prs_align(ps))
5241 return False;
5242 if(!prs_uint32("info_level", ps, depth, &q_u->level))
5243 return False;
5245 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
5246 return False;
5248 return True;
5251 /*******************************************************************
5252 ********************************************************************/
5254 BOOL spoolss_io_r_addprinterdriver(const char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5256 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
5257 depth++;
5259 if(!prs_werror("status", ps, depth, &q_u->status))
5260 return False;
5262 return True;
5265 /*******************************************************************
5266 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5267 ********************************************************************/
5269 BOOL spoolss_io_q_addprinterdriverex(const char *desc, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, prs_struct *ps, int depth)
5271 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriverex");
5272 depth++;
5274 if(!prs_align(ps))
5275 return False;
5277 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
5278 return False;
5279 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
5280 return False;
5282 if(!prs_align(ps))
5283 return False;
5284 if(!prs_uint32("info_level", ps, depth, &q_u->level))
5285 return False;
5287 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
5288 return False;
5290 if(!prs_align(ps))
5291 return False;
5292 if(!prs_uint32("copy flags", ps, depth, &q_u->copy_flags))
5293 return False;
5295 return True;
5298 /*******************************************************************
5299 ********************************************************************/
5301 BOOL spoolss_io_r_addprinterdriverex(const char *desc, SPOOL_R_ADDPRINTERDRIVEREX *q_u, prs_struct *ps, int depth)
5303 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriverex");
5304 depth++;
5306 if(!prs_werror("status", ps, depth, &q_u->status))
5307 return False;
5309 return True;
5312 /*******************************************************************
5313 ********************************************************************/
5315 BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
5316 NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc)
5318 NT_PRINTER_DRIVER_INFO_LEVEL_3 *d;
5320 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5322 if (*asc==NULL)
5324 *asc=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_3);
5325 if(*asc == NULL)
5326 return False;
5327 ZERO_STRUCTP(*asc);
5330 d=*asc;
5332 d->cversion=uni->cversion;
5334 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5335 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5336 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5337 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5338 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5339 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5340 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5341 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5343 DEBUGADD(8,( "version: %d\n", d->cversion));
5344 DEBUGADD(8,( "name: %s\n", d->name));
5345 DEBUGADD(8,( "environment: %s\n", d->environment));
5346 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5347 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5348 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5349 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5350 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5351 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5353 if (uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5354 return True;
5356 SAFE_FREE(*asc);
5357 return False;
5360 /*******************************************************************
5361 ********************************************************************/
5362 BOOL uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *uni,
5363 NT_PRINTER_DRIVER_INFO_LEVEL_6 **asc)
5365 NT_PRINTER_DRIVER_INFO_LEVEL_6 *d;
5367 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5369 if (*asc==NULL)
5371 *asc=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_6);
5372 if(*asc == NULL)
5373 return False;
5374 ZERO_STRUCTP(*asc);
5377 d=*asc;
5379 d->version=uni->version;
5381 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5382 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5383 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5384 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5385 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5386 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5387 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5388 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5390 DEBUGADD(8,( "version: %d\n", d->version));
5391 DEBUGADD(8,( "name: %s\n", d->name));
5392 DEBUGADD(8,( "environment: %s\n", d->environment));
5393 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5394 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5395 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5396 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5397 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5398 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5400 if (!uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5401 goto error;
5402 if (!uniarray_2_dosarray(&uni->previousnames, &d->previousnames ))
5403 goto error;
5405 return True;
5407 error:
5408 SAFE_FREE(*asc);
5409 return False;
5412 BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
5413 NT_PRINTER_INFO_LEVEL_2 *d)
5415 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5417 d->attributes=uni->attributes;
5418 d->priority=uni->priority;
5419 d->default_priority=uni->default_priority;
5420 d->starttime=uni->starttime;
5421 d->untiltime=uni->untiltime;
5422 d->status=uni->status;
5423 d->cjobs=uni->cjobs;
5425 unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1);
5426 unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1);
5427 unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
5428 unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
5429 unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
5430 unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
5431 unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
5432 unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
5433 unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
5434 unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype)-1);
5435 unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters)-1);
5437 return True;
5440 /*******************************************************************
5441 * init a structure.
5442 ********************************************************************/
5444 BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u,
5445 fstring servername, fstring env_name, uint32 level,
5446 RPC_BUFFER *buffer, uint32 offered)
5448 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
5449 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name);
5451 q_u->level=level;
5452 q_u->buffer=buffer;
5453 q_u->offered=offered;
5455 return True;
5458 /*******************************************************************
5459 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5460 ********************************************************************/
5462 BOOL spoolss_io_q_getprinterdriverdir(const char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth)
5464 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir");
5465 depth++;
5467 if(!prs_align(ps))
5468 return False;
5469 if(!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5470 return False;
5471 if(!smb_io_unistr2("", &q_u->name, q_u->name_ptr, ps, depth))
5472 return False;
5474 if(!prs_align(ps))
5475 return False;
5477 if(!prs_uint32("", ps, depth, &q_u->environment_ptr))
5478 return False;
5479 if(!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5480 return False;
5482 if(!prs_align(ps))
5483 return False;
5485 if(!prs_uint32("level", ps, depth, &q_u->level))
5486 return False;
5488 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
5489 return False;
5491 if(!prs_align(ps))
5492 return False;
5494 if(!prs_uint32("offered", ps, depth, &q_u->offered))
5495 return False;
5497 return True;
5500 /*******************************************************************
5501 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5502 ********************************************************************/
5504 BOOL spoolss_io_r_getprinterdriverdir(const char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth)
5506 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir");
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_werror("status", ps, depth, &r_u->status))
5522 return False;
5524 return True;
5527 /*******************************************************************
5528 ********************************************************************/
5530 BOOL spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
5532 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
5533 depth++;
5535 if (!prs_align(ps))
5536 return False;
5538 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
5539 return False;
5541 if (!prs_align(ps))
5542 return False;
5544 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5545 return False;
5547 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5548 return False;
5550 if (!prs_werror("status", ps, depth, &r_u->status))
5551 return False;
5553 return True;
5556 /*******************************************************************
5557 ********************************************************************/
5559 BOOL spoolss_io_q_enumprintprocessors(const char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth)
5561 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
5562 depth++;
5564 if (!prs_align(ps))
5565 return False;
5567 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5568 return False;
5569 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5570 return False;
5572 if (!prs_align(ps))
5573 return False;
5575 if (!prs_uint32("", ps, depth, &q_u->environment_ptr))
5576 return False;
5577 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5578 return False;
5580 if (!prs_align(ps))
5581 return False;
5583 if (!prs_uint32("level", ps, depth, &q_u->level))
5584 return False;
5586 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
5587 return False;
5589 if (!prs_align(ps))
5590 return False;
5592 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5593 return False;
5595 return True;
5598 /*******************************************************************
5599 ********************************************************************/
5601 BOOL spoolss_io_q_addprintprocessor(const char *desc, SPOOL_Q_ADDPRINTPROCESSOR *q_u, prs_struct *ps, int depth)
5603 prs_debug(ps, depth, desc, "spoolss_io_q_addprintprocessor");
5604 depth++;
5606 if (!prs_align(ps))
5607 return False;
5609 if (!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
5610 return False;
5611 if (!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
5612 return False;
5614 if (!prs_align(ps))
5615 return False;
5616 if (!smb_io_unistr2("environment", &q_u->environment, True, ps, depth))
5617 return False;
5619 if (!prs_align(ps))
5620 return False;
5621 if (!smb_io_unistr2("path", &q_u->path, True, ps, depth))
5622 return False;
5624 if (!prs_align(ps))
5625 return False;
5626 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5627 return False;
5629 return True;
5632 /*******************************************************************
5633 ********************************************************************/
5635 BOOL spoolss_io_r_addprintprocessor(const char *desc, SPOOL_R_ADDPRINTPROCESSOR *r_u, prs_struct *ps, int depth)
5637 prs_debug(ps, depth, desc, "spoolss_io_r_addprintproicessor");
5638 depth++;
5640 if (!prs_align(ps))
5641 return False;
5643 if (!prs_werror("status", ps, depth, &r_u->status))
5644 return False;
5646 return True;
5649 /*******************************************************************
5650 ********************************************************************/
5652 BOOL spoolss_io_r_enumprintprocdatatypes(const char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth)
5654 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes");
5655 depth++;
5657 if (!prs_align(ps))
5658 return False;
5660 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
5661 return False;
5663 if (!prs_align(ps))
5664 return False;
5666 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5667 return False;
5669 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5670 return False;
5672 if (!prs_werror("status", ps, depth, &r_u->status))
5673 return False;
5675 return True;
5678 /*******************************************************************
5679 ********************************************************************/
5681 BOOL spoolss_io_q_enumprintprocdatatypes(const char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth)
5683 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes");
5684 depth++;
5686 if (!prs_align(ps))
5687 return False;
5689 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5690 return False;
5691 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5692 return False;
5694 if (!prs_align(ps))
5695 return False;
5697 if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr))
5698 return False;
5699 if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth))
5700 return False;
5702 if (!prs_align(ps))
5703 return False;
5705 if (!prs_uint32("level", ps, depth, &q_u->level))
5706 return False;
5708 if(!prs_rpcbuffer_p("buffer", ps, depth, &q_u->buffer))
5709 return False;
5711 if (!prs_align(ps))
5712 return False;
5714 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5715 return False;
5717 return True;
5720 /*******************************************************************
5721 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5722 ********************************************************************/
5724 BOOL spoolss_io_q_enumprintmonitors(const char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
5726 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
5727 depth++;
5729 if (!prs_align(ps))
5730 return False;
5732 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5733 return False;
5734 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5735 return False;
5737 if (!prs_align(ps))
5738 return False;
5740 if (!prs_uint32("level", ps, depth, &q_u->level))
5741 return False;
5743 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
5744 return False;
5746 if (!prs_align(ps))
5747 return False;
5749 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5750 return False;
5752 return True;
5755 /*******************************************************************
5756 ********************************************************************/
5758 BOOL spoolss_io_r_enumprintmonitors(const char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
5760 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
5761 depth++;
5763 if (!prs_align(ps))
5764 return False;
5766 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
5767 return False;
5769 if (!prs_align(ps))
5770 return False;
5772 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5773 return False;
5775 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5776 return False;
5778 if (!prs_werror("status", ps, depth, &r_u->status))
5779 return False;
5781 return True;
5784 /*******************************************************************
5785 ********************************************************************/
5787 BOOL spoolss_io_r_enumprinterdata(const char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth)
5789 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata");
5790 depth++;
5792 if(!prs_align(ps))
5793 return False;
5794 if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize))
5795 return False;
5797 if (UNMARSHALLING(ps) && r_u->valuesize) {
5798 r_u->value = PRS_ALLOC_MEM(ps, uint16, r_u->valuesize);
5799 if (!r_u->value) {
5800 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
5801 return False;
5805 if(!prs_uint16uni(False, "value", ps, depth, r_u->value, r_u->valuesize ))
5806 return False;
5808 if(!prs_align(ps))
5809 return False;
5811 if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize))
5812 return False;
5814 if(!prs_uint32("type", ps, depth, &r_u->type))
5815 return False;
5817 if(!prs_uint32("datasize", ps, depth, &r_u->datasize))
5818 return False;
5820 if (UNMARSHALLING(ps) && r_u->datasize) {
5821 r_u->data = PRS_ALLOC_MEM(ps, uint8, r_u->datasize);
5822 if (!r_u->data) {
5823 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
5824 return False;
5828 if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize))
5829 return False;
5830 if(!prs_align(ps))
5831 return False;
5833 if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize))
5834 return False;
5835 if(!prs_werror("status", ps, depth, &r_u->status))
5836 return False;
5838 return True;
5841 /*******************************************************************
5842 ********************************************************************/
5844 BOOL spoolss_io_q_enumprinterdata(const char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth)
5846 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata");
5847 depth++;
5849 if(!prs_align(ps))
5850 return False;
5851 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5852 return False;
5853 if(!prs_uint32("index", ps, depth, &q_u->index))
5854 return False;
5855 if(!prs_uint32("valuesize", ps, depth, &q_u->valuesize))
5856 return False;
5857 if(!prs_uint32("datasize", ps, depth, &q_u->datasize))
5858 return False;
5860 return True;
5863 /*******************************************************************
5864 ********************************************************************/
5866 BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
5867 const POLICY_HND *hnd,
5868 uint32 idx, uint32 valuelen, uint32 datalen)
5870 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5871 q_u->index=idx;
5872 q_u->valuesize=valuelen;
5873 q_u->datasize=datalen;
5875 return True;
5878 /*******************************************************************
5879 ********************************************************************/
5881 BOOL make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
5882 const POLICY_HND *hnd, const char *key,
5883 uint32 size)
5885 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5886 init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
5887 q_u->size = size;
5889 return True;
5892 /*******************************************************************
5893 ********************************************************************/
5894 BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND *hnd,
5895 char* value, uint32 data_type, char* data, uint32 data_size)
5897 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5898 q_u->type = data_type;
5899 init_unistr2(&q_u->value, value, UNI_STR_TERMINATE);
5901 q_u->max_len = q_u->real_len = data_size;
5902 q_u->data = (unsigned char *)data;
5904 return True;
5907 /*******************************************************************
5908 ********************************************************************/
5909 BOOL make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX *q_u, const POLICY_HND *hnd,
5910 char *key, char* value, uint32 data_type, char* data,
5911 uint32 data_size)
5913 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5914 q_u->type = data_type;
5915 init_unistr2(&q_u->value, value, UNI_STR_TERMINATE);
5916 init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
5918 q_u->max_len = q_u->real_len = data_size;
5919 q_u->data = (unsigned char *)data;
5921 return True;
5924 /*******************************************************************
5925 ********************************************************************/
5927 BOOL spoolss_io_q_setprinterdata(const char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
5929 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
5930 depth++;
5932 if(!prs_align(ps))
5933 return False;
5934 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5935 return False;
5936 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
5937 return False;
5939 if(!prs_align(ps))
5940 return False;
5942 if(!prs_uint32("type", ps, depth, &q_u->type))
5943 return False;
5945 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
5946 return False;
5948 switch (q_u->type)
5950 case REG_SZ:
5951 case REG_BINARY:
5952 case REG_DWORD:
5953 case REG_MULTI_SZ:
5954 if (q_u->max_len) {
5955 if (UNMARSHALLING(ps))
5956 q_u->data=PRS_ALLOC_MEM(ps, uint8, q_u->max_len);
5957 if(q_u->data == NULL)
5958 return False;
5959 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
5960 return False;
5962 if(!prs_align(ps))
5963 return False;
5964 break;
5967 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
5968 return False;
5970 return True;
5973 /*******************************************************************
5974 ********************************************************************/
5976 BOOL spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
5978 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
5979 depth++;
5981 if(!prs_align(ps))
5982 return False;
5983 if(!prs_werror("status", ps, depth, &r_u->status))
5984 return False;
5986 return True;
5989 /*******************************************************************
5990 ********************************************************************/
5991 BOOL spoolss_io_q_resetprinter(const char *desc, SPOOL_Q_RESETPRINTER *q_u, prs_struct *ps, int depth)
5993 prs_debug(ps, depth, desc, "spoolss_io_q_resetprinter");
5994 depth++;
5996 if (!prs_align(ps))
5997 return False;
5998 if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5999 return False;
6001 if (!prs_uint32("datatype_ptr", ps, depth, &q_u->datatype_ptr))
6002 return False;
6004 if (q_u->datatype_ptr) {
6005 if (!smb_io_unistr2("datatype", &q_u->datatype, q_u->datatype_ptr?True:False, ps, depth))
6006 return False;
6009 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
6010 return False;
6012 return True;
6016 /*******************************************************************
6017 ********************************************************************/
6018 BOOL spoolss_io_r_resetprinter(const char *desc, SPOOL_R_RESETPRINTER *r_u, prs_struct *ps, int depth)
6020 prs_debug(ps, depth, desc, "spoolss_io_r_resetprinter");
6021 depth++;
6023 if(!prs_align(ps))
6024 return False;
6025 if(!prs_werror("status", ps, depth, &r_u->status))
6026 return False;
6028 return True;
6031 /*******************************************************************
6032 ********************************************************************/
6034 static BOOL spoolss_io_addform(const char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth)
6036 prs_debug(ps, depth, desc, "spoolss_io_addform");
6037 depth++;
6038 if(!prs_align(ps))
6039 return False;
6041 if (ptr!=0)
6043 if(!prs_uint32("flags", ps, depth, &f->flags))
6044 return False;
6045 if(!prs_uint32("name_ptr", ps, depth, &f->name_ptr))
6046 return False;
6047 if(!prs_uint32("size_x", ps, depth, &f->size_x))
6048 return False;
6049 if(!prs_uint32("size_y", ps, depth, &f->size_y))
6050 return False;
6051 if(!prs_uint32("left", ps, depth, &f->left))
6052 return False;
6053 if(!prs_uint32("top", ps, depth, &f->top))
6054 return False;
6055 if(!prs_uint32("right", ps, depth, &f->right))
6056 return False;
6057 if(!prs_uint32("bottom", ps, depth, &f->bottom))
6058 return False;
6060 if(!smb_io_unistr2("", &f->name, f->name_ptr, ps, depth))
6061 return False;
6064 return True;
6067 /*******************************************************************
6068 ********************************************************************/
6070 BOOL spoolss_io_q_deleteform(const char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth)
6072 prs_debug(ps, depth, desc, "spoolss_io_q_deleteform");
6073 depth++;
6075 if(!prs_align(ps))
6076 return False;
6077 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6078 return False;
6079 if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth))
6080 return False;
6082 return True;
6085 /*******************************************************************
6086 ********************************************************************/
6088 BOOL spoolss_io_r_deleteform(const char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth)
6090 prs_debug(ps, depth, desc, "spoolss_io_r_deleteform");
6091 depth++;
6093 if(!prs_align(ps))
6094 return False;
6095 if(!prs_werror("status", ps, depth, &r_u->status))
6096 return False;
6098 return True;
6101 /*******************************************************************
6102 ********************************************************************/
6104 BOOL spoolss_io_q_addform(const char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth)
6106 uint32 useless_ptr=1;
6107 prs_debug(ps, depth, desc, "spoolss_io_q_addform");
6108 depth++;
6110 if(!prs_align(ps))
6111 return False;
6112 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6113 return False;
6114 if(!prs_uint32("level", ps, depth, &q_u->level))
6115 return False;
6116 if(!prs_uint32("level2", ps, depth, &q_u->level2))
6117 return False;
6119 if (q_u->level==1)
6121 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
6122 return False;
6123 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
6124 return False;
6127 return True;
6130 /*******************************************************************
6131 ********************************************************************/
6133 BOOL spoolss_io_r_addform(const char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth)
6135 prs_debug(ps, depth, desc, "spoolss_io_r_addform");
6136 depth++;
6138 if(!prs_align(ps))
6139 return False;
6140 if(!prs_werror("status", ps, depth, &r_u->status))
6141 return False;
6143 return True;
6146 /*******************************************************************
6147 ********************************************************************/
6149 BOOL spoolss_io_q_setform(const char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth)
6151 uint32 useless_ptr=1;
6152 prs_debug(ps, depth, desc, "spoolss_io_q_setform");
6153 depth++;
6155 if(!prs_align(ps))
6156 return False;
6157 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6158 return False;
6159 if(!smb_io_unistr2("", &q_u->name, True, ps, depth))
6160 return False;
6162 if(!prs_align(ps))
6163 return False;
6165 if(!prs_uint32("level", ps, depth, &q_u->level))
6166 return False;
6167 if(!prs_uint32("level2", ps, depth, &q_u->level2))
6168 return False;
6170 if (q_u->level==1)
6172 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
6173 return False;
6174 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
6175 return False;
6178 return True;
6181 /*******************************************************************
6182 ********************************************************************/
6184 BOOL spoolss_io_r_setform(const char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth)
6186 prs_debug(ps, depth, desc, "spoolss_io_r_setform");
6187 depth++;
6189 if(!prs_align(ps))
6190 return False;
6191 if(!prs_werror("status", ps, depth, &r_u->status))
6192 return False;
6194 return True;
6197 /*******************************************************************
6198 Parse a SPOOL_R_GETJOB structure.
6199 ********************************************************************/
6201 BOOL spoolss_io_r_getjob(const char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
6203 prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
6204 depth++;
6206 if (!prs_align(ps))
6207 return False;
6209 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
6210 return False;
6212 if (!prs_align(ps))
6213 return False;
6215 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6216 return False;
6218 if (!prs_werror("status", ps, depth, &r_u->status))
6219 return False;
6221 return True;
6224 /*******************************************************************
6225 Parse a SPOOL_Q_GETJOB structure.
6226 ********************************************************************/
6228 BOOL spoolss_io_q_getjob(const char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
6230 prs_debug(ps, depth, desc, "");
6231 depth++;
6233 if(!prs_align(ps))
6234 return False;
6236 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6237 return False;
6238 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
6239 return False;
6240 if(!prs_uint32("level", ps, depth, &q_u->level))
6241 return False;
6243 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
6244 return False;
6246 if(!prs_align(ps))
6247 return False;
6249 if(!prs_uint32("offered", ps, depth, &q_u->offered))
6250 return False;
6252 return True;
6255 void free_devmode(DEVICEMODE *devmode)
6257 if (devmode!=NULL) {
6258 SAFE_FREE(devmode->dev_private);
6259 SAFE_FREE(devmode);
6263 void free_printer_info_1(PRINTER_INFO_1 *printer)
6265 SAFE_FREE(printer);
6268 void free_printer_info_2(PRINTER_INFO_2 *printer)
6270 if (printer!=NULL) {
6271 free_devmode(printer->devmode);
6272 printer->devmode = NULL;
6273 SAFE_FREE(printer);
6277 void free_printer_info_3(PRINTER_INFO_3 *printer)
6279 SAFE_FREE(printer);
6282 void free_printer_info_4(PRINTER_INFO_4 *printer)
6284 SAFE_FREE(printer);
6287 void free_printer_info_5(PRINTER_INFO_5 *printer)
6289 SAFE_FREE(printer);
6292 void free_printer_info_6(PRINTER_INFO_6 *printer)
6294 SAFE_FREE(printer);
6297 void free_printer_info_7(PRINTER_INFO_7 *printer)
6299 SAFE_FREE(printer);
6302 void free_job_info_2(JOB_INFO_2 *job)
6304 if (job!=NULL)
6305 free_devmode(job->devmode);
6308 /*******************************************************************
6309 * init a structure.
6310 ********************************************************************/
6312 BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
6313 const fstring string, uint32 printer, uint32 type)
6315 if (q_u == NULL)
6316 return False;
6318 init_unistr2(&q_u->string, string, UNI_STR_TERMINATE);
6320 q_u->printer=printer;
6321 q_u->type=type;
6323 q_u->unknown0=0x0;
6324 q_u->unknown1=0x0;
6326 return True;
6329 /*******************************************************************
6330 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6331 ********************************************************************/
6333 BOOL spoolss_io_q_replyopenprinter(const char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
6335 prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
6336 depth++;
6338 if(!prs_align(ps))
6339 return False;
6341 if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
6342 return False;
6344 if(!prs_align(ps))
6345 return False;
6347 if(!prs_uint32("printer", ps, depth, &q_u->printer))
6348 return False;
6349 if(!prs_uint32("type", ps, depth, &q_u->type))
6350 return False;
6352 if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6353 return False;
6354 if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6355 return False;
6357 return True;
6360 /*******************************************************************
6361 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6362 ********************************************************************/
6364 BOOL spoolss_io_r_replyopenprinter(const char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
6366 prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
6367 depth++;
6369 if (!prs_align(ps))
6370 return False;
6372 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6373 return False;
6375 if (!prs_werror("status", ps, depth, &r_u->status))
6376 return False;
6378 return True;
6381 /*******************************************************************
6382 * init a structure.
6383 ********************************************************************/
6384 BOOL make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER *q_u, POLICY_HND *hnd,
6385 uint32 condition, uint32 change_id)
6388 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6390 q_u->condition = condition;
6391 q_u->change_id = change_id;
6393 /* magic values */
6394 q_u->unknown1 = 0x1;
6395 memset(q_u->unknown2, 0x0, 5);
6396 q_u->unknown2[0] = 0x1;
6398 return True;
6401 /*******************************************************************
6402 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6403 ********************************************************************/
6404 BOOL spoolss_io_q_routerreplyprinter (const char *desc, SPOOL_Q_ROUTERREPLYPRINTER *q_u, prs_struct *ps, int depth)
6407 prs_debug(ps, depth, desc, "spoolss_io_q_routerreplyprinter");
6408 depth++;
6410 if (!prs_align(ps))
6411 return False;
6413 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6414 return False;
6416 if (!prs_uint32("condition", ps, depth, &q_u->condition))
6417 return False;
6419 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6420 return False;
6422 if (!prs_uint32("change_id", ps, depth, &q_u->change_id))
6423 return False;
6425 if (!prs_uint8s(False, "dev_private", ps, depth, q_u->unknown2, 5))
6426 return False;
6428 return True;
6431 /*******************************************************************
6432 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6433 ********************************************************************/
6434 BOOL spoolss_io_r_routerreplyprinter (const char *desc, SPOOL_R_ROUTERREPLYPRINTER *r_u, prs_struct *ps, int depth)
6436 prs_debug(ps, depth, desc, "spoolss_io_r_routerreplyprinter");
6437 depth++;
6439 if (!prs_align(ps))
6440 return False;
6442 if (!prs_werror("status", ps, depth, &r_u->status))
6443 return False;
6445 return True;
6448 /*******************************************************************
6449 * init a structure.
6450 ********************************************************************/
6452 BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd)
6454 if (q_u == NULL)
6455 return False;
6457 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6459 return True;
6462 /*******************************************************************
6463 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6464 ********************************************************************/
6466 BOOL spoolss_io_q_replycloseprinter(const char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth)
6468 prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
6469 depth++;
6471 if(!prs_align(ps))
6472 return False;
6474 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6475 return False;
6477 return True;
6480 /*******************************************************************
6481 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6482 ********************************************************************/
6484 BOOL spoolss_io_r_replycloseprinter(const char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth)
6486 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
6487 depth++;
6489 if (!prs_align(ps))
6490 return False;
6492 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6493 return False;
6495 if (!prs_werror("status", ps, depth, &r_u->status))
6496 return False;
6498 return True;
6501 #if 0 /* JERRY - not currently used but could be :-) */
6503 /*******************************************************************
6504 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6505 ******************************************************************/
6506 static BOOL copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA *dst,
6507 SPOOL_NOTIFY_INFO_DATA *src, int n)
6509 int i;
6511 memcpy(dst, src, sizeof(SPOOL_NOTIFY_INFO_DATA)*n);
6513 for (i=0; i<n; i++) {
6514 int len;
6515 uint16 *s = NULL;
6517 if (src->size != POINTER)
6518 continue;
6519 len = src->notify_data.data.length;
6520 s = SMB_MALLOC_ARRAY(uint16, len);
6521 if (s == NULL) {
6522 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6523 return False;
6526 memcpy(s, src->notify_data.data.string, len*2);
6527 dst->notify_data.data.string = s;
6530 return True;
6533 /*******************************************************************
6534 Deep copy a SPOOL_NOTIFY_INFO structure
6535 ******************************************************************/
6536 static BOOL copy_spool_notify_info(SPOOL_NOTIFY_INFO *dst, SPOOL_NOTIFY_INFO *src)
6538 if (!dst) {
6539 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6540 return False;
6543 dst->version = src->version;
6544 dst->flags = src->flags;
6545 dst->count = src->count;
6547 if (dst->count)
6549 dst->data = SMB_MALLOC_ARRAY(SPOOL_NOTIFY_INFO_DATA, dst->count);
6551 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6552 dst->count));
6554 if (dst->data == NULL) {
6555 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6556 dst->count));
6557 return False;
6560 return (copy_spool_notify_info_data(dst->data, src->data, src->count));
6563 return True;
6565 #endif /* JERRY */
6567 /*******************************************************************
6568 * init a structure.
6569 ********************************************************************/
6571 BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
6572 uint32 change_low, uint32 change_high,
6573 SPOOL_NOTIFY_INFO *info)
6575 if (q_u == NULL)
6576 return False;
6578 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6580 q_u->change_low=change_low;
6581 q_u->change_high=change_high;
6583 q_u->unknown0=0x0;
6584 q_u->unknown1=0x0;
6586 q_u->info_ptr=0x0FF0ADDE;
6588 q_u->info.version=2;
6590 if (info->count) {
6591 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6592 info->count));
6593 q_u->info.version = info->version;
6594 q_u->info.flags = info->flags;
6595 q_u->info.count = info->count;
6596 /* pointer field - be careful! */
6597 q_u->info.data = info->data;
6599 else {
6600 q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
6601 q_u->info.count=0;
6604 return True;
6607 /*******************************************************************
6608 Parse a SPOOL_Q_REPLY_RRPCN structure.
6609 ********************************************************************/
6611 BOOL spoolss_io_q_reply_rrpcn(const char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
6613 prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
6614 depth++;
6616 if(!prs_align(ps))
6617 return False;
6619 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6620 return False;
6622 if (!prs_uint32("change_low", ps, depth, &q_u->change_low))
6623 return False;
6625 if (!prs_uint32("change_high", ps, depth, &q_u->change_high))
6626 return False;
6628 if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6629 return False;
6631 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6632 return False;
6634 if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr))
6635 return False;
6637 if(q_u->info_ptr!=0)
6638 if(!smb_io_notify_info(desc, &q_u->info, ps, depth))
6639 return False;
6641 return True;
6644 /*******************************************************************
6645 Parse a SPOOL_R_REPLY_RRPCN structure.
6646 ********************************************************************/
6648 BOOL spoolss_io_r_reply_rrpcn(const char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth)
6650 prs_debug(ps, depth, desc, "spoolss_io_r_reply_rrpcn");
6651 depth++;
6653 if (!prs_align(ps))
6654 return False;
6656 if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0))
6657 return False;
6659 if (!prs_werror("status", ps, depth, &r_u->status))
6660 return False;
6662 return True;
6665 /*******************************************************************
6666 * read a structure.
6667 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6668 ********************************************************************/
6670 BOOL spoolss_io_q_getprinterdataex(const char *desc, SPOOL_Q_GETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6672 if (q_u == NULL)
6673 return False;
6675 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdataex");
6676 depth++;
6678 if (!prs_align(ps))
6679 return False;
6680 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6681 return False;
6682 if (!prs_align(ps))
6683 return False;
6684 if (!smb_io_unistr2("keyname", &q_u->keyname,True,ps,depth))
6685 return False;
6686 if (!prs_align(ps))
6687 return False;
6688 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
6689 return False;
6690 if (!prs_align(ps))
6691 return False;
6692 if (!prs_uint32("size", ps, depth, &q_u->size))
6693 return False;
6695 return True;
6698 /*******************************************************************
6699 * write a structure.
6700 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6701 ********************************************************************/
6703 BOOL spoolss_io_r_getprinterdataex(const char *desc, SPOOL_R_GETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6705 if (r_u == NULL)
6706 return False;
6708 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdataex");
6709 depth++;
6711 if (!prs_align(ps))
6712 return False;
6713 if (!prs_uint32("type", ps, depth, &r_u->type))
6714 return False;
6715 if (!prs_uint32("size", ps, depth, &r_u->size))
6716 return False;
6718 if (UNMARSHALLING(ps) && r_u->size) {
6719 r_u->data = PRS_ALLOC_MEM(ps, unsigned char, r_u->size);
6720 if(!r_u->data)
6721 return False;
6724 if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
6725 return False;
6727 if (!prs_align(ps))
6728 return False;
6730 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6731 return False;
6732 if (!prs_werror("status", ps, depth, &r_u->status))
6733 return False;
6735 return True;
6738 /*******************************************************************
6739 * read a structure.
6740 ********************************************************************/
6742 BOOL spoolss_io_q_setprinterdataex(const char *desc, SPOOL_Q_SETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6744 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdataex");
6745 depth++;
6747 if(!prs_align(ps))
6748 return False;
6749 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6750 return False;
6751 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6752 return False;
6754 if(!prs_align(ps))
6755 return False;
6757 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
6758 return False;
6760 if(!prs_align(ps))
6761 return False;
6763 if(!prs_uint32("type", ps, depth, &q_u->type))
6764 return False;
6766 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
6767 return False;
6769 switch (q_u->type)
6771 case 0x1:
6772 case 0x3:
6773 case 0x4:
6774 case 0x7:
6775 if (q_u->max_len) {
6776 if (UNMARSHALLING(ps))
6777 q_u->data=PRS_ALLOC_MEM(ps, uint8, q_u->max_len);
6778 if(q_u->data == NULL)
6779 return False;
6780 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
6781 return False;
6783 if(!prs_align(ps))
6784 return False;
6785 break;
6788 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
6789 return False;
6791 return True;
6794 /*******************************************************************
6795 * write a structure.
6796 ********************************************************************/
6798 BOOL spoolss_io_r_setprinterdataex(const char *desc, SPOOL_R_SETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6800 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdataex");
6801 depth++;
6803 if(!prs_align(ps))
6804 return False;
6805 if(!prs_werror("status", ps, depth, &r_u->status))
6806 return False;
6808 return True;
6811 /*******************************************************************
6812 * read a structure.
6813 ********************************************************************/
6814 BOOL make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u,
6815 POLICY_HND *hnd, const char *key,
6816 uint32 size)
6818 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
6820 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6821 init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
6822 q_u->size = size;
6824 return True;
6827 /*******************************************************************
6828 * read a structure.
6829 ********************************************************************/
6831 BOOL spoolss_io_q_enumprinterkey(const char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth)
6833 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterkey");
6834 depth++;
6836 if(!prs_align(ps))
6837 return False;
6838 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6839 return False;
6841 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6842 return False;
6844 if(!prs_align(ps))
6845 return False;
6847 if(!prs_uint32("size", ps, depth, &q_u->size))
6848 return False;
6850 return True;
6853 /*******************************************************************
6854 * write a structure.
6855 ********************************************************************/
6857 BOOL spoolss_io_r_enumprinterkey(const char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth)
6859 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterkey");
6860 depth++;
6862 if(!prs_align(ps))
6863 return False;
6865 if (!smb_io_buffer5("", &r_u->keys, ps, depth))
6866 return False;
6868 if(!prs_align(ps))
6869 return False;
6871 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6872 return False;
6874 if(!prs_werror("status", ps, depth, &r_u->status))
6875 return False;
6877 return True;
6880 /*******************************************************************
6881 * read a structure.
6882 ********************************************************************/
6884 BOOL make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY *q_u,
6885 POLICY_HND *hnd, char *keyname)
6887 DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
6889 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6890 init_unistr2(&q_u->keyname, keyname, UNI_STR_TERMINATE);
6892 return True;
6895 /*******************************************************************
6896 * read a structure.
6897 ********************************************************************/
6899 BOOL spoolss_io_q_deleteprinterkey(const char *desc, SPOOL_Q_DELETEPRINTERKEY *q_u, prs_struct *ps, int depth)
6901 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterkey");
6902 depth++;
6904 if(!prs_align(ps))
6905 return False;
6906 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6907 return False;
6909 if(!smb_io_unistr2("", &q_u->keyname, True, ps, depth))
6910 return False;
6912 return True;
6915 /*******************************************************************
6916 * write a structure.
6917 ********************************************************************/
6919 BOOL spoolss_io_r_deleteprinterkey(const char *desc, SPOOL_R_DELETEPRINTERKEY *r_u, prs_struct *ps, int depth)
6921 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterkey");
6922 depth++;
6924 if(!prs_align(ps))
6925 return False;
6927 if(!prs_werror("status", ps, depth, &r_u->status))
6928 return False;
6930 return True;
6934 /*******************************************************************
6935 * read a structure.
6936 ********************************************************************/
6938 BOOL spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6940 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdataex");
6941 depth++;
6943 if(!prs_align(ps))
6944 return False;
6945 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6946 return False;
6948 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6949 return False;
6951 if(!prs_align(ps))
6952 return False;
6954 if(!prs_uint32("size", ps, depth, &q_u->size))
6955 return False;
6957 return True;
6960 /*******************************************************************
6961 ********************************************************************/
6963 static BOOL spoolss_io_printer_enum_values_ctr(const char *desc, prs_struct *ps,
6964 PRINTER_ENUM_VALUES_CTR *ctr, int depth)
6966 int i;
6967 uint32 valuename_offset,
6968 data_offset,
6969 current_offset;
6970 const uint32 basic_unit = 20; /* size of static portion of enum_values */
6972 prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr");
6973 depth++;
6976 * offset data begins at 20 bytes per structure * size_of_array.
6977 * Don't forget the uint32 at the beginning
6978 * */
6980 current_offset = basic_unit * ctr->size_of_array;
6982 /* first loop to write basic enum_value information */
6984 if (UNMARSHALLING(ps)) {
6985 ctr->values = PRS_ALLOC_MEM(ps, PRINTER_ENUM_VALUES, ctr->size_of_array);
6986 if (!ctr->values)
6987 return False;
6990 for (i=0; i<ctr->size_of_array; i++) {
6991 valuename_offset = current_offset;
6992 if (!prs_uint32("valuename_offset", ps, depth, &valuename_offset))
6993 return False;
6995 if (!prs_uint32("value_len", ps, depth, &ctr->values[i].value_len))
6996 return False;
6998 if (!prs_uint32("type", ps, depth, &ctr->values[i].type))
6999 return False;
7001 data_offset = ctr->values[i].value_len + valuename_offset;
7003 if (!prs_uint32("data_offset", ps, depth, &data_offset))
7004 return False;
7006 if (!prs_uint32("data_len", ps, depth, &ctr->values[i].data_len))
7007 return False;
7009 current_offset = data_offset + ctr->values[i].data_len - basic_unit;
7010 /* account for 2 byte alignment */
7011 current_offset += (current_offset % 2);
7015 * loop #2 for writing the dynamically size objects; pay
7016 * attention to 2-byte alignment here....
7019 for (i=0; i<ctr->size_of_array; i++) {
7021 if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
7022 return False;
7024 if ( ctr->values[i].data_len ) {
7025 if ( UNMARSHALLING(ps) ) {
7026 ctr->values[i].data = PRS_ALLOC_MEM(ps, uint8, ctr->values[i].data_len);
7027 if (!ctr->values[i].data)
7028 return False;
7030 if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len))
7031 return False;
7034 if ( !prs_align_uint16(ps) )
7035 return False;
7038 return True;
7041 /*******************************************************************
7042 * write a structure.
7043 ********************************************************************/
7045 BOOL spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth)
7047 uint32 data_offset, end_offset;
7048 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdataex");
7049 depth++;
7051 if(!prs_align(ps))
7052 return False;
7054 if (!prs_uint32("size", ps, depth, &r_u->ctr.size))
7055 return False;
7057 data_offset = prs_offset(ps);
7059 if (!prs_set_offset(ps, data_offset + r_u->ctr.size))
7060 return False;
7062 if(!prs_align(ps))
7063 return False;
7065 if(!prs_uint32("needed", ps, depth, &r_u->needed))
7066 return False;
7068 if(!prs_uint32("returned", ps, depth, &r_u->returned))
7069 return False;
7071 if(!prs_werror("status", ps, depth, &r_u->status))
7072 return False;
7074 r_u->ctr.size_of_array = r_u->returned;
7076 end_offset = prs_offset(ps);
7078 if (!prs_set_offset(ps, data_offset))
7079 return False;
7081 if (r_u->ctr.size)
7082 if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth ))
7083 return False;
7085 if (!prs_set_offset(ps, end_offset))
7086 return False;
7087 return True;
7090 /*******************************************************************
7091 * write a structure.
7092 ********************************************************************/
7095 uint32 GetPrintProcessorDirectory(
7096 [in] unistr2 *name,
7097 [in] unistr2 *environment,
7098 [in] uint32 level,
7099 [in,out] RPC_BUFFER buffer,
7100 [in] uint32 offered,
7101 [out] uint32 needed,
7102 [out] uint32 returned
7107 BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, RPC_BUFFER *buffer, uint32 offered)
7109 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
7111 init_unistr2(&q_u->name, name, UNI_STR_TERMINATE);
7112 init_unistr2(&q_u->environment, environment, UNI_STR_TERMINATE);
7114 q_u->level = level;
7116 q_u->buffer = buffer;
7117 q_u->offered = offered;
7119 return True;
7122 BOOL spoolss_io_q_getprintprocessordirectory(const char *desc, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, prs_struct *ps, int depth)
7124 uint32 ptr;
7126 prs_debug(ps, depth, desc, "spoolss_io_q_getprintprocessordirectory");
7127 depth++;
7129 if(!prs_align(ps))
7130 return False;
7132 if (!prs_uint32("ptr", ps, depth, &ptr))
7133 return False;
7135 if (ptr) {
7136 if(!smb_io_unistr2("name", &q_u->name, True, ps, depth))
7137 return False;
7140 if (!prs_align(ps))
7141 return False;
7143 if (!prs_uint32("ptr", ps, depth, &ptr))
7144 return False;
7146 if (ptr) {
7147 if(!smb_io_unistr2("environment", &q_u->environment, True,
7148 ps, depth))
7149 return False;
7152 if (!prs_align(ps))
7153 return False;
7155 if(!prs_uint32("level", ps, depth, &q_u->level))
7156 return False;
7158 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
7159 return False;
7161 if(!prs_align(ps))
7162 return False;
7164 if(!prs_uint32("offered", ps, depth, &q_u->offered))
7165 return False;
7167 return True;
7170 /*******************************************************************
7171 * write a structure.
7172 ********************************************************************/
7174 BOOL spoolss_io_r_getprintprocessordirectory(const char *desc, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u, prs_struct *ps, int depth)
7176 prs_debug(ps, depth, desc, "spoolss_io_r_getprintprocessordirectory");
7177 depth++;
7179 if(!prs_align(ps))
7180 return False;
7182 if(!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
7183 return False;
7185 if(!prs_align(ps))
7186 return False;
7188 if(!prs_uint32("needed", ps, depth, &r_u->needed))
7189 return False;
7191 if(!prs_werror("status", ps, depth, &r_u->status))
7192 return False;
7194 return True;
7197 BOOL smb_io_printprocessordirectory_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth)
7199 prs_struct *ps=&buffer->prs;
7201 prs_debug(ps, depth, desc, "smb_io_printprocessordirectory_1");
7202 depth++;
7204 buffer->struct_start=prs_offset(ps);
7206 if (!smb_io_unistr(desc, &info->name, ps, depth))
7207 return False;
7209 return True;
7212 /*******************************************************************
7213 * init a structure.
7214 ********************************************************************/
7216 BOOL make_spoolss_q_addform(SPOOL_Q_ADDFORM *q_u, POLICY_HND *handle,
7217 int level, FORM *form)
7219 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7220 q_u->level = level;
7221 q_u->level2 = level;
7222 memcpy(&q_u->form, form, sizeof(FORM));
7224 return True;
7227 /*******************************************************************
7228 * init a structure.
7229 ********************************************************************/
7231 BOOL make_spoolss_q_setform(SPOOL_Q_SETFORM *q_u, POLICY_HND *handle,
7232 int level, const char *form_name, FORM *form)
7234 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7235 q_u->level = level;
7236 q_u->level2 = level;
7237 memcpy(&q_u->form, form, sizeof(FORM));
7238 init_unistr2(&q_u->name, form_name, UNI_STR_TERMINATE);
7240 return True;
7243 /*******************************************************************
7244 * init a structure.
7245 ********************************************************************/
7247 BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle,
7248 const char *form)
7250 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7251 init_unistr2(&q_u->name, form, UNI_STR_TERMINATE);
7252 return True;
7255 /*******************************************************************
7256 * init a structure.
7257 ********************************************************************/
7259 BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle,
7260 const char *formname, uint32 level,
7261 RPC_BUFFER *buffer, uint32 offered)
7263 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7264 q_u->level = level;
7265 init_unistr2(&q_u->formname, formname, UNI_STR_TERMINATE);
7266 q_u->buffer=buffer;
7267 q_u->offered=offered;
7269 return True;
7272 /*******************************************************************
7273 * init a structure.
7274 ********************************************************************/
7276 BOOL make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
7277 uint32 level, RPC_BUFFER *buffer,
7278 uint32 offered)
7280 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7281 q_u->level = level;
7282 q_u->buffer=buffer;
7283 q_u->offered=offered;
7285 return True;
7288 /*******************************************************************
7289 * init a structure.
7290 ********************************************************************/
7292 BOOL make_spoolss_q_setjob(SPOOL_Q_SETJOB *q_u, POLICY_HND *handle,
7293 uint32 jobid, uint32 level, uint32 command)
7295 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7296 q_u->jobid = jobid;
7297 q_u->level = level;
7299 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7300 the server side code has it marked as unused. */
7302 q_u->command = command;
7304 return True;
7307 /*******************************************************************
7308 * init a structure.
7309 ********************************************************************/
7311 BOOL make_spoolss_q_getjob(SPOOL_Q_GETJOB *q_u, POLICY_HND *handle,
7312 uint32 jobid, uint32 level, RPC_BUFFER *buffer,
7313 uint32 offered)
7315 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7316 q_u->jobid = jobid;
7317 q_u->level = level;
7318 q_u->buffer = buffer;
7319 q_u->offered = offered;
7321 return True;
7324 /*******************************************************************
7325 * init a structure.
7326 ********************************************************************/
7328 BOOL make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u,
7329 POLICY_HND *handle)
7331 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7333 return True;
7336 /*******************************************************************
7337 * init a structure.
7338 ********************************************************************/
7340 BOOL make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u,
7341 POLICY_HND *handle)
7343 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7345 return True;
7348 /*******************************************************************
7349 * init a structure.
7350 ********************************************************************/
7352 BOOL make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER *q_u,
7353 POLICY_HND *handle, uint32 level,
7354 char *docname, char *outputfile,
7355 char *datatype)
7357 DOC_INFO_CONTAINER *ctr = &q_u->doc_info_container;
7359 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7361 ctr->level = level;
7363 switch (level) {
7364 case 1:
7365 ctr->docinfo.switch_value = level;
7367 ctr->docinfo.doc_info_1.p_docname = docname ? 1 : 0;
7368 ctr->docinfo.doc_info_1.p_outputfile = outputfile ? 1 : 0;
7369 ctr->docinfo.doc_info_1.p_datatype = datatype ? 1 : 0;
7371 init_unistr2(&ctr->docinfo.doc_info_1.docname, docname, UNI_STR_TERMINATE);
7372 init_unistr2(&ctr->docinfo.doc_info_1.outputfile, outputfile, UNI_STR_TERMINATE);
7373 init_unistr2(&ctr->docinfo.doc_info_1.datatype, datatype, UNI_STR_TERMINATE);
7375 break;
7376 case 2:
7377 /* DOC_INFO_2 is only used by Windows 9x and since it
7378 doesn't do printing over RPC we don't have to worry
7379 about it. */
7380 default:
7381 DEBUG(3, ("unsupported info level %d\n", level));
7382 return False;
7385 return True;
7388 /*******************************************************************
7389 * init a structure.
7390 ********************************************************************/
7392 BOOL make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u,
7393 POLICY_HND *handle)
7395 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7397 return True;
7400 /*******************************************************************
7401 * init a structure.
7402 ********************************************************************/
7404 BOOL make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER *q_u,
7405 POLICY_HND *handle, uint32 data_size,
7406 char *data)
7408 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7409 q_u->buffer_size = q_u->buffer_size2 = data_size;
7410 q_u->buffer = (unsigned char *)data;
7411 return True;
7414 /*******************************************************************
7415 * init a structure.
7416 ********************************************************************/
7418 BOOL make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA *q_u,
7419 POLICY_HND *handle, char *valuename)
7421 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7422 init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
7424 return True;
7427 /*******************************************************************
7428 * init a structure.
7429 ********************************************************************/
7431 BOOL make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX *q_u,
7432 POLICY_HND *handle, char *key,
7433 char *value)
7435 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7436 init_unistr2(&q_u->valuename, value, UNI_STR_TERMINATE);
7437 init_unistr2(&q_u->keyname, key, UNI_STR_TERMINATE);
7439 return True;
7442 /*******************************************************************
7443 * init a structure.
7444 ********************************************************************/
7446 BOOL make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, POLICY_HND *handle,
7447 uint32 flags, uint32 options, const char *localmachine,
7448 uint32 printerlocal, SPOOL_NOTIFY_OPTION *option)
7450 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7452 q_u->flags = flags;
7453 q_u->options = options;
7455 q_u->localmachine_ptr = 1;
7457 init_unistr2(&q_u->localmachine, localmachine, UNI_STR_TERMINATE);
7459 q_u->printerlocal = printerlocal;
7461 if (option)
7462 q_u->option_ptr = 1;
7464 q_u->option = option;
7466 return True;
7470 /*******************************************************************
7471 ********************************************************************/
7473 BOOL spoolss_io_q_xcvdataport(const char *desc, SPOOL_Q_XCVDATAPORT *q_u, prs_struct *ps, int depth)
7475 prs_debug(ps, depth, desc, "spoolss_io_q_xcvdataport");
7476 depth++;
7478 if(!prs_align(ps))
7479 return False;
7481 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
7482 return False;
7484 if(!smb_io_unistr2("", &q_u->dataname, True, ps, depth))
7485 return False;
7487 if (!prs_align(ps))
7488 return False;
7490 if(!prs_rpcbuffer("", ps, depth, &q_u->indata))
7491 return False;
7493 if (!prs_align(ps))
7494 return False;
7496 if (!prs_uint32("indata_len", ps, depth, &q_u->indata_len))
7497 return False;
7498 if (!prs_uint32("offered", ps, depth, &q_u->offered))
7499 return False;
7500 if (!prs_uint32("unknown", ps, depth, &q_u->unknown))
7501 return False;
7503 return True;
7506 /*******************************************************************
7507 ********************************************************************/
7509 BOOL spoolss_io_r_xcvdataport(const char *desc, SPOOL_R_XCVDATAPORT *r_u, prs_struct *ps, int depth)
7511 prs_debug(ps, depth, desc, "spoolss_io_r_xcvdataport");
7512 depth++;
7514 if(!prs_align(ps))
7515 return False;
7516 if(!prs_rpcbuffer("", ps, depth, &r_u->outdata))
7517 return False;
7519 if (!prs_align(ps))
7520 return False;
7522 if (!prs_uint32("needed", ps, depth, &r_u->needed))
7523 return False;
7524 if (!prs_uint32("unknown", ps, depth, &r_u->unknown))
7525 return False;
7527 if(!prs_werror("status", ps, depth, &r_u->status))
7528 return False;
7530 return True;
7533 /*******************************************************************
7534 ********************************************************************/
7536 BOOL make_monitorui_buf( RPC_BUFFER *buf, const char *dllname )
7538 UNISTR string;
7540 if ( !buf )
7541 return False;
7543 init_unistr( &string, dllname );
7545 if ( !prs_unistr( "ui_dll", &buf->prs, 0, &string ) )
7546 return False;
7548 return True;
7551 /*******************************************************************
7552 ********************************************************************/
7554 #define PORT_DATA_1_PAD 540
7556 static BOOL smb_io_port_data_1( const char *desc, RPC_BUFFER *buf, int depth, SPOOL_PORT_DATA_1 *p1 )
7558 prs_struct *ps = &buf->prs;
7559 uint8 padding[PORT_DATA_1_PAD];
7561 prs_debug(ps, depth, desc, "smb_io_port_data_1");
7562 depth++;
7564 if(!prs_align(ps))
7565 return False;
7567 if( !prs_uint16s(True, "portname", ps, depth, p1->portname, MAX_PORTNAME))
7568 return False;
7570 if (!prs_uint32("version", ps, depth, &p1->version))
7571 return False;
7572 if (!prs_uint32("protocol", ps, depth, &p1->protocol))
7573 return False;
7574 if (!prs_uint32("size", ps, depth, &p1->size))
7575 return False;
7576 if (!prs_uint32("reserved", ps, depth, &p1->reserved))
7577 return False;
7579 if( !prs_uint16s(True, "hostaddress", ps, depth, p1->hostaddress, MAX_NETWORK_NAME))
7580 return False;
7581 if( !prs_uint16s(True, "snmpcommunity", ps, depth, p1->snmpcommunity, MAX_SNMP_COMM_NAME))
7582 return False;
7584 if (!prs_uint32("dblspool", ps, depth, &p1->dblspool))
7585 return False;
7587 if( !prs_uint16s(True, "queue", ps, depth, p1->queue, MAX_QUEUE_NAME))
7588 return False;
7589 if( !prs_uint16s(True, "ipaddress", ps, depth, p1->ipaddress, MAX_IPADDR_STRING))
7590 return False;
7592 if( !prs_uint8s(False, "", ps, depth, padding, PORT_DATA_1_PAD))
7593 return False;
7595 if (!prs_uint32("port", ps, depth, &p1->port))
7596 return False;
7597 if (!prs_uint32("snmpenabled", ps, depth, &p1->snmpenabled))
7598 return False;
7599 if (!prs_uint32("snmpdevindex", ps, depth, &p1->snmpdevindex))
7600 return False;
7602 return True;
7605 /*******************************************************************
7606 ********************************************************************/
7608 BOOL convert_port_data_1( NT_PORT_DATA_1 *port1, RPC_BUFFER *buf )
7610 SPOOL_PORT_DATA_1 spdata_1;
7612 ZERO_STRUCT( spdata_1 );
7614 if ( !smb_io_port_data_1( "port_data_1", buf, 0, &spdata_1 ) )
7615 return False;
7617 rpcstr_pull(port1->name, spdata_1.portname, sizeof(port1->name), -1, 0);
7618 rpcstr_pull(port1->queue, spdata_1.queue, sizeof(port1->queue), -1, 0);
7619 rpcstr_pull(port1->hostaddr, spdata_1.hostaddress, sizeof(port1->hostaddr), -1, 0);
7621 port1->port = spdata_1.port;
7623 switch ( spdata_1.protocol ) {
7624 case 1:
7625 port1->protocol = PORT_PROTOCOL_DIRECT;
7626 break;
7627 case 2:
7628 port1->protocol = PORT_PROTOCOL_LPR;
7629 break;
7630 default:
7631 DEBUG(3,("convert_port_data_1: unknown protocol [%d]!\n",
7632 spdata_1.protocol));
7633 return False;
7636 return True;