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 3 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, see <http://www.gnu.org/licenses/>.
27 #define DBGC_CLASS DBGC_RPC_PARSE
30 /*******************************************************************
31 This should be moved in a more generic lib.
32 ********************************************************************/
34 bool spoolss_io_system_time(const char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime)
36 if(!prs_uint16("year", ps, depth, &systime->year))
38 if(!prs_uint16("month", ps, depth, &systime->month))
40 if(!prs_uint16("dayofweek", ps, depth, &systime->dayofweek))
42 if(!prs_uint16("day", ps, depth, &systime->day))
44 if(!prs_uint16("hour", ps, depth, &systime->hour))
46 if(!prs_uint16("minute", ps, depth, &systime->minute))
48 if(!prs_uint16("second", ps, depth, &systime->second))
50 if(!prs_uint16("milliseconds", ps, depth, &systime->milliseconds))
56 /*******************************************************************
57 ********************************************************************/
59 bool make_systemtime(SYSTEMTIME *systime, struct tm *unixtime)
61 systime->year=unixtime->tm_year+1900;
62 systime->month=unixtime->tm_mon+1;
63 systime->dayofweek=unixtime->tm_wday;
64 systime->day=unixtime->tm_mday;
65 systime->hour=unixtime->tm_hour;
66 systime->minute=unixtime->tm_min;
67 systime->second=unixtime->tm_sec;
68 systime->milliseconds=0;
73 /*******************************************************************
74 reads or writes an DOC_INFO structure.
75 ********************************************************************/
77 static bool smb_io_doc_info_1(const char *desc, DOC_INFO_1 *info_1, prs_struct *ps, int depth)
79 if (info_1 == NULL) return False;
81 prs_debug(ps, depth, desc, "smb_io_doc_info_1");
87 if(!prs_uint32("p_docname", ps, depth, &info_1->p_docname))
89 if(!prs_uint32("p_outputfile", ps, depth, &info_1->p_outputfile))
91 if(!prs_uint32("p_datatype", ps, depth, &info_1->p_datatype))
94 if(!smb_io_unistr2("", &info_1->docname, info_1->p_docname, ps, depth))
96 if(!smb_io_unistr2("", &info_1->outputfile, info_1->p_outputfile, ps, depth))
98 if(!smb_io_unistr2("", &info_1->datatype, info_1->p_datatype, ps, depth))
104 /*******************************************************************
105 reads or writes an DOC_INFO structure.
106 ********************************************************************/
108 static bool smb_io_doc_info(const char *desc, DOC_INFO *info, prs_struct *ps, int depth)
110 uint32 useless_ptr=0;
112 if (info == NULL) return False;
114 prs_debug(ps, depth, desc, "smb_io_doc_info");
120 if(!prs_uint32("switch_value", ps, depth, &info->switch_value))
123 if(!prs_uint32("doc_info_X ptr", ps, depth, &useless_ptr))
126 switch (info->switch_value)
129 if(!smb_io_doc_info_1("",&info->doc_info_1, ps, depth))
134 this is just a placeholder
136 MSDN July 1998 says doc_info_2 is only on
137 Windows 95, and as Win95 doesn't do RPC to print
138 this case is nearly impossible
140 Maybe one day with Windows for dishwasher 2037 ...
143 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
146 DEBUG(0,("Something is obviously wrong somewhere !\n"));
153 /*******************************************************************
154 reads or writes an DOC_INFO_CONTAINER structure.
155 ********************************************************************/
157 static bool smb_io_doc_info_container(const char *desc, DOC_INFO_CONTAINER *cont, prs_struct *ps, int depth)
159 if (cont == NULL) return False;
161 prs_debug(ps, depth, desc, "smb_io_doc_info_container");
167 if(!prs_uint32("level", ps, depth, &cont->level))
170 if(!smb_io_doc_info("",&cont->docinfo, ps, depth))
176 /*******************************************************************
177 reads or writes an NOTIFY OPTION TYPE structure.
178 ********************************************************************/
180 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
181 structure. The _TYPE structure is really the deferred referrants (i.e
182 the notify fields array) of the _TYPE structure. -tpot */
184 static bool smb_io_notify_option_type(const char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
186 prs_debug(ps, depth, desc, "smb_io_notify_option_type");
192 if(!prs_uint16("type", ps, depth, &type->type))
194 if(!prs_uint16("reserved0", ps, depth, &type->reserved0))
196 if(!prs_uint32("reserved1", ps, depth, &type->reserved1))
198 if(!prs_uint32("reserved2", ps, depth, &type->reserved2))
200 if(!prs_uint32("count", ps, depth, &type->count))
202 if(!prs_uint32("fields_ptr", ps, depth, &type->fields_ptr))
208 /*******************************************************************
209 reads or writes an NOTIFY OPTION TYPE DATA.
210 ********************************************************************/
212 static bool smb_io_notify_option_type_data(const char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
216 prs_debug(ps, depth, desc, "smb_io_notify_option_type_data");
219 /* if there are no fields just return */
220 if (type->fields_ptr==0)
226 if(!prs_uint32("count2", ps, depth, &type->count2))
229 if (type->count2 != type->count)
230 DEBUG(4,("What a mess, count was %x now is %x !\n", type->count, type->count2));
232 if (type->count2 > MAX_NOTIFY_TYPE_FOR_NOW) {
236 /* parse the option type data */
237 for(i=0;i<type->count2;i++)
238 if(!prs_uint16("fields",ps,depth,&type->fields[i]))
243 /*******************************************************************
244 reads or writes an NOTIFY OPTION structure.
245 ********************************************************************/
247 static bool smb_io_notify_option_type_ctr(const char *desc, SPOOL_NOTIFY_OPTION_TYPE_CTR *ctr , prs_struct *ps, int depth)
251 prs_debug(ps, depth, desc, "smb_io_notify_option_type_ctr");
254 if(!prs_uint32("count", ps, depth, &ctr->count))
258 if (UNMARSHALLING(ps) && ctr->count)
259 if((ctr->type=PRS_ALLOC_MEM(ps,SPOOL_NOTIFY_OPTION_TYPE,ctr->count)) == NULL)
262 /* the option type struct */
263 for(i=0;i<ctr->count;i++)
264 if(!smb_io_notify_option_type("", &ctr->type[i] , ps, depth))
267 /* the type associated with the option type struct */
268 for(i=0;i<ctr->count;i++)
269 if(!smb_io_notify_option_type_data("", &ctr->type[i] , ps, depth))
275 /*******************************************************************
276 reads or writes an NOTIFY OPTION structure.
277 ********************************************************************/
279 static bool smb_io_notify_option(const char *desc, SPOOL_NOTIFY_OPTION *option, prs_struct *ps, int depth)
281 prs_debug(ps, depth, desc, "smb_io_notify_option");
284 if(!prs_uint32("version", ps, depth, &option->version))
286 if(!prs_uint32("flags", ps, depth, &option->flags))
288 if(!prs_uint32("count", ps, depth, &option->count))
290 if(!prs_uint32("option_type_ptr", ps, depth, &option->option_type_ptr))
293 /* marshalling or unmarshalling, that would work */
294 if (option->option_type_ptr!=0) {
295 if(!smb_io_notify_option_type_ctr("", &option->ctr ,ps, depth))
299 option->ctr.type=NULL;
306 /*******************************************************************
307 reads or writes an NOTIFY INFO DATA structure.
308 ********************************************************************/
310 static bool smb_io_notify_info_data(const char *desc,SPOOL_NOTIFY_INFO_DATA *data, prs_struct *ps, int depth)
312 uint32 useless_ptr=0x0FF0ADDE;
314 prs_debug(ps, depth, desc, "smb_io_notify_info_data");
319 if(!prs_uint16("type", ps, depth, &data->type))
321 if(!prs_uint16("field", ps, depth, &data->field))
324 if(!prs_uint32("how many words", ps, depth, &data->size))
326 if(!prs_uint32("id", ps, depth, &data->id))
328 if(!prs_uint32("how many words", ps, depth, &data->size))
331 switch (data->enc_type) {
333 /* One and two value data has two uint32 values */
335 case NOTIFY_ONE_VALUE:
336 case NOTIFY_TWO_VALUE:
338 if(!prs_uint32("value[0]", ps, depth, &data->notify_data.value[0]))
340 if(!prs_uint32("value[1]", ps, depth, &data->notify_data.value[1]))
344 /* Pointers and strings have a string length and a
345 pointer. For a string the length is expressed as
346 the number of uint16 characters plus a trailing
351 if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length ))
353 if(!prs_uint32("pointer", ps, depth, &useless_ptr))
360 if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length))
363 if(!prs_uint32("pointer", ps, depth, &useless_ptr))
369 if( !prs_uint32( "sd size", ps, depth, &data->notify_data.sd.size ) )
371 if( !prs_uint32( "pointer", ps, depth, &useless_ptr ) )
377 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data\n",
385 /*******************************************************************
386 reads or writes an NOTIFY INFO DATA structure.
387 ********************************************************************/
389 bool smb_io_notify_info_data_strings(const char *desc,SPOOL_NOTIFY_INFO_DATA *data,
390 prs_struct *ps, int depth)
392 prs_debug(ps, depth, desc, "smb_io_notify_info_data_strings");
398 switch(data->enc_type) {
400 /* No data for values */
402 case NOTIFY_ONE_VALUE:
403 case NOTIFY_TWO_VALUE:
407 /* Strings start with a length in uint16s */
412 data->notify_data.data.length /= 2;
414 if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length))
417 if (UNMARSHALLING(ps) && data->notify_data.data.length) {
418 data->notify_data.data.string = PRS_ALLOC_MEM(ps, uint16,
419 data->notify_data.data.length);
421 if (!data->notify_data.data.string)
425 if (!prs_uint16uni(True, "string", ps, depth, data->notify_data.data.string,
426 data->notify_data.data.length))
430 data->notify_data.data.length *= 2;
436 if (UNMARSHALLING(ps) && data->notify_data.data.length) {
437 data->notify_data.data.string = PRS_ALLOC_MEM(ps, uint16,
438 data->notify_data.data.length);
440 if (!data->notify_data.data.string)
444 if(!prs_uint8s(True,"buffer",ps,depth,(uint8*)data->notify_data.data.string,data->notify_data.data.length))
450 if( !prs_uint32("secdesc size ", ps, depth, &data->notify_data.sd.size ) )
452 if ( !sec_io_desc( "sec_desc", &data->notify_data.sd.desc, ps, depth ) )
457 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data_strings\n",
463 if (isvalue==False) {
465 /* length of string in unicode include \0 */
466 x=data->notify_data.data.length+1;
468 if (data->field != 16)
469 if(!prs_uint32("string length", ps, depth, &x ))
472 if (MARSHALLING(ps)) {
473 /* These are already in little endian format. Don't byte swap. */
476 /* No memory allocated for this string
477 therefore following the data.string
478 pointer is a bad idea. Use a pointer to
479 the uint32 length union member to
480 provide a source for a unicode NULL */
482 if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2))
486 if (data->field == 16)
489 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
494 /* Tallocate memory for string */
497 data->notify_data.data.string = PRS_ALLOC_MEM(ps, uint16, x * 2);
498 if (!data->notify_data.data.string)
501 data->notify_data.data.string = NULL;
504 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
512 /* Win2k does not seem to put this parse align here */
520 /*******************************************************************
521 reads or writes an NOTIFY INFO structure.
522 ********************************************************************/
524 static bool smb_io_notify_info(const char *desc, SPOOL_NOTIFY_INFO *info, prs_struct *ps, int depth)
528 prs_debug(ps, depth, desc, "smb_io_notify_info");
534 if(!prs_uint32("count", ps, depth, &info->count))
536 if(!prs_uint32("version", ps, depth, &info->version))
538 if(!prs_uint32("flags", ps, depth, &info->flags))
540 if(!prs_uint32("count", ps, depth, &info->count))
543 for (i=0;i<info->count;i++) {
544 if(!smb_io_notify_info_data(desc, &info->data[i], ps, depth))
548 /* now do the strings at the end of the stream */
549 for (i=0;i<info->count;i++) {
550 if(!smb_io_notify_info_data_strings(desc, &info->data[i], ps, depth))
557 /*******************************************************************
558 ********************************************************************/
560 bool spool_io_user_level_1( const char *desc, prs_struct *ps, int depth, SPOOL_USER_1 *q_u )
562 prs_debug(ps, depth, desc, "");
568 if (!prs_uint32("size", ps, depth, &q_u->size))
571 if (!prs_io_unistr2_p("", ps, depth, &q_u->client_name))
573 if (!prs_io_unistr2_p("", ps, depth, &q_u->user_name))
576 if (!prs_uint32("build", ps, depth, &q_u->build))
578 if (!prs_uint32("major", ps, depth, &q_u->major))
580 if (!prs_uint32("minor", ps, depth, &q_u->minor))
582 if (!prs_uint32("processor", ps, depth, &q_u->processor))
585 if (!prs_io_unistr2("", ps, depth, q_u->client_name))
590 if (!prs_io_unistr2("", ps, depth, q_u->user_name))
596 /*******************************************************************
597 ********************************************************************/
599 static bool spool_io_user_level(const char *desc, SPOOL_USER_CTR *q_u, prs_struct *ps, int depth)
604 prs_debug(ps, depth, desc, "spool_io_user_level");
610 if (!prs_uint32("level", ps, depth, &q_u->level))
613 switch ( q_u->level )
616 if ( !prs_pointer( "" , ps, depth, (void*)&q_u->user.user1,
617 sizeof(SPOOL_USER_1), (PRS_POINTER_CAST)spool_io_user_level_1 ))
629 /*******************************************************************
630 * read or write a DEVICEMODE struct.
631 * on reading allocate memory for the private member
632 ********************************************************************/
634 #define DM_NUM_OPTIONAL_FIELDS 8
636 bool spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode)
638 int available_space; /* size of the device mode left to parse */
639 /* only important on unmarshalling */
641 uint16 *unistr_buffer;
644 struct optional_fields {
647 } opt_fields[DM_NUM_OPTIONAL_FIELDS] = {
648 { "icmmethod", NULL },
649 { "icmintent", NULL },
650 { "mediatype", NULL },
651 { "dithertype", NULL },
652 { "reserved1", NULL },
653 { "reserved2", NULL },
654 { "panningwidth", NULL },
655 { "panningheight", NULL }
658 /* assign at run time to keep non-gcc compilers happy */
660 opt_fields[0].field = &devmode->icmmethod;
661 opt_fields[1].field = &devmode->icmintent;
662 opt_fields[2].field = &devmode->mediatype;
663 opt_fields[3].field = &devmode->dithertype;
664 opt_fields[4].field = &devmode->reserved1;
665 opt_fields[5].field = &devmode->reserved2;
666 opt_fields[6].field = &devmode->panningwidth;
667 opt_fields[7].field = &devmode->panningheight;
670 prs_debug(ps, depth, desc, "spoolss_io_devmode");
673 if (UNMARSHALLING(ps)) {
674 devmode->devicename.buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
675 if (devmode->devicename.buffer == NULL)
677 unistr_buffer = devmode->devicename.buffer;
680 /* devicename is a static sized string but the buffer we set is not */
681 unistr_buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
682 memset( unistr_buffer, 0x0, MAXDEVICENAME );
683 for ( j=0; devmode->devicename.buffer[j]; j++ )
684 unistr_buffer[j] = devmode->devicename.buffer[j];
687 if (!prs_uint16uni(True,"devicename", ps, depth, unistr_buffer, MAXDEVICENAME))
690 if (!prs_uint16("specversion", ps, depth, &devmode->specversion))
693 if (!prs_uint16("driverversion", ps, depth, &devmode->driverversion))
695 if (!prs_uint16("size", ps, depth, &devmode->size))
697 if (!prs_uint16("driverextra", ps, depth, &devmode->driverextra))
699 if (!prs_uint32("fields", ps, depth, &devmode->fields))
701 if (!prs_uint16("orientation", ps, depth, &devmode->orientation))
703 if (!prs_uint16("papersize", ps, depth, &devmode->papersize))
705 if (!prs_uint16("paperlength", ps, depth, &devmode->paperlength))
707 if (!prs_uint16("paperwidth", ps, depth, &devmode->paperwidth))
709 if (!prs_uint16("scale", ps, depth, &devmode->scale))
711 if (!prs_uint16("copies", ps, depth, &devmode->copies))
713 if (!prs_uint16("defaultsource", ps, depth, &devmode->defaultsource))
715 if (!prs_uint16("printquality", ps, depth, &devmode->printquality))
717 if (!prs_uint16("color", ps, depth, &devmode->color))
719 if (!prs_uint16("duplex", ps, depth, &devmode->duplex))
721 if (!prs_uint16("yresolution", ps, depth, &devmode->yresolution))
723 if (!prs_uint16("ttoption", ps, depth, &devmode->ttoption))
725 if (!prs_uint16("collate", ps, depth, &devmode->collate))
728 if (UNMARSHALLING(ps)) {
729 devmode->formname.buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
730 if (devmode->formname.buffer == NULL)
732 unistr_buffer = devmode->formname.buffer;
735 /* devicename is a static sized string but the buffer we set is not */
736 unistr_buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
737 memset( unistr_buffer, 0x0, MAXDEVICENAME );
738 for ( j=0; devmode->formname.buffer[j]; j++ )
739 unistr_buffer[j] = devmode->formname.buffer[j];
742 if (!prs_uint16uni(True, "formname", ps, depth, unistr_buffer, MAXDEVICENAME))
744 if (!prs_uint16("logpixels", ps, depth, &devmode->logpixels))
746 if (!prs_uint32("bitsperpel", ps, depth, &devmode->bitsperpel))
748 if (!prs_uint32("pelswidth", ps, depth, &devmode->pelswidth))
750 if (!prs_uint32("pelsheight", ps, depth, &devmode->pelsheight))
752 if (!prs_uint32("displayflags", ps, depth, &devmode->displayflags))
754 if (!prs_uint32("displayfrequency", ps, depth, &devmode->displayfrequency))
757 * every device mode I've ever seen on the wire at least has up
758 * to the displayfrequency field. --jerry (05-09-2002)
761 /* add uint32's + uint16's + two UNICODE strings */
763 available_space = devmode->size - (sizeof(uint32)*6 + sizeof(uint16)*18 + sizeof(uint16)*64);
765 /* Sanity check - we only have uint32's left tp parse */
767 if ( available_space && ((available_space % sizeof(uint32)) != 0) ) {
768 DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n",
769 available_space, devmode->size));
770 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
775 * Conditional parsing. Assume that the DeviceMode has been
776 * zero'd by the caller.
779 while ((available_space > 0) && (i < DM_NUM_OPTIONAL_FIELDS))
781 DEBUG(11, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space));
782 if (!prs_uint32(opt_fields[i].name, ps, depth, opt_fields[i].field))
784 available_space -= sizeof(uint32);
788 /* Sanity Check - we should no available space at this point unless
789 MS changes the device mode structure */
791 if (available_space) {
792 DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n"));
793 DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n",
794 available_space, devmode->size));
795 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
800 if (devmode->driverextra!=0) {
801 if (UNMARSHALLING(ps)) {
802 devmode->dev_private=PRS_ALLOC_MEM(ps, uint8, devmode->driverextra);
803 if(devmode->dev_private == NULL)
805 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for dev_private\n",devmode->driverextra));
808 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of dev_private\n",devmode->driverextra));
809 if (!prs_uint8s(False, "dev_private", ps, depth,
810 devmode->dev_private, devmode->driverextra))
817 /*******************************************************************
818 Read or write a DEVICEMODE container
819 ********************************************************************/
821 static bool spoolss_io_devmode_cont(const char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth)
826 prs_debug(ps, depth, desc, "spoolss_io_devmode_cont");
832 if (!prs_uint32("size", ps, depth, &dm_c->size))
835 if (!prs_uint32("devmode_ptr", ps, depth, &dm_c->devmode_ptr))
838 if (dm_c->size==0 || dm_c->devmode_ptr==0) {
839 if (UNMARSHALLING(ps))
840 /* if while reading there is no DEVMODE ... */
845 /* so we have a DEVICEMODE to follow */
846 if (UNMARSHALLING(ps)) {
847 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
848 dm_c->devmode=PRS_ALLOC_MEM(ps,DEVICEMODE,1);
849 if(dm_c->devmode == NULL)
853 /* this is bad code, shouldn't be there */
854 if (!prs_uint32("size", ps, depth, &dm_c->size))
857 if (!spoolss_io_devmode(desc, ps, depth, dm_c->devmode))
863 /*******************************************************************
864 ********************************************************************/
866 static bool spoolss_io_printer_default(const char *desc, PRINTER_DEFAULT *pd, prs_struct *ps, int depth)
871 prs_debug(ps, depth, desc, "spoolss_io_printer_default");
874 if (!prs_uint32("datatype_ptr", ps, depth, &pd->datatype_ptr))
877 if (!smb_io_unistr2("datatype", &pd->datatype, pd->datatype_ptr, ps,depth))
883 if (!spoolss_io_devmode_cont("", &pd->devmode_cont, ps, depth))
889 if (!prs_uint32("access_required", ps, depth, &pd->access_required))
895 /*******************************************************************
897 ********************************************************************/
899 bool make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
900 const fstring printername,
901 const fstring datatype,
902 uint32 access_required,
903 const fstring clientname,
904 const fstring user_name)
906 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
908 q_u->printername = TALLOC_P( talloc_tos(), UNISTR2 );
909 if (!q_u->printername) {
912 init_unistr2(q_u->printername, printername, UNI_STR_TERMINATE);
914 q_u->printer_default.datatype_ptr = 0;
916 q_u->printer_default.devmode_cont.size=0;
917 q_u->printer_default.devmode_cont.devmode_ptr=0;
918 q_u->printer_default.devmode_cont.devmode=NULL;
919 q_u->printer_default.access_required=access_required;
921 q_u->user_switch = 1;
923 q_u->user_ctr.level = 1;
924 q_u->user_ctr.user.user1 = TALLOC_P( talloc_tos(), SPOOL_USER_1 );
925 if (!q_u->user_ctr.user.user1) {
928 q_u->user_ctr.user.user1->size = strlen(clientname) + strlen(user_name) + 10;
929 q_u->user_ctr.user.user1->build = 1381;
930 q_u->user_ctr.user.user1->major = 2;
931 q_u->user_ctr.user.user1->minor = 0;
932 q_u->user_ctr.user.user1->processor = 0;
934 q_u->user_ctr.user.user1->client_name = TALLOC_P( talloc_tos(), UNISTR2 );
935 if (!q_u->user_ctr.user.user1->client_name) {
938 q_u->user_ctr.user.user1->user_name = TALLOC_P( talloc_tos(), UNISTR2 );
939 if (!q_u->user_ctr.user.user1->user_name) {
943 init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE);
944 init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE);
949 /*******************************************************************
951 ********************************************************************/
953 bool make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u,
954 const char *srv_name, const char* clientname, const char* user_name,
955 uint32 level, PRINTER_INFO_CTR *ctr)
957 DEBUG(5,("make_spoolss_q_addprinterex\n"));
959 if (!ctr || !ctr->printers_2)
964 q_u->server_name = TALLOC_P( mem_ctx, UNISTR2 );
965 if (!q_u->server_name) {
968 init_unistr2(q_u->server_name, srv_name, UNI_FLAGS_NONE);
972 q_u->info.level = level;
973 q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0;
976 /* init q_u->info.info2 from *info */
977 if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) {
978 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
988 q_u->user_ctr.level = 1;
989 q_u->user_ctr.user.user1 = TALLOC_P( talloc_tos(), SPOOL_USER_1 );
990 if (!q_u->user_ctr.user.user1) {
993 q_u->user_ctr.user.user1->build = 1381;
994 q_u->user_ctr.user.user1->major = 2;
995 q_u->user_ctr.user.user1->minor = 0;
996 q_u->user_ctr.user.user1->processor = 0;
998 q_u->user_ctr.user.user1->client_name = TALLOC_P( mem_ctx, UNISTR2 );
999 if (!q_u->user_ctr.user.user1->client_name) {
1002 q_u->user_ctr.user.user1->user_name = TALLOC_P( mem_ctx, UNISTR2 );
1003 if (!q_u->user_ctr.user.user1->user_name) {
1006 init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE);
1007 init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE);
1009 q_u->user_ctr.user.user1->size = q_u->user_ctr.user.user1->user_name->uni_str_len +
1010 q_u->user_ctr.user.user1->client_name->uni_str_len + 2;
1015 /*******************************************************************
1016 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
1017 *******************************************************************/
1019 bool make_spoolss_printer_info_2(TALLOC_CTX *ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
1020 PRINTER_INFO_2 *info)
1023 SPOOL_PRINTER_INFO_LEVEL_2 *inf;
1025 /* allocate the necessary memory */
1026 if (!(inf=TALLOC_P(ctx, SPOOL_PRINTER_INFO_LEVEL_2))) {
1027 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
1031 inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
1032 inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
1033 inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
1034 inf->portname_ptr = (info->portname.buffer!=NULL)?1:0;
1035 inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0;
1036 inf->comment_ptr = (info->comment.buffer!=NULL)?1:0;
1037 inf->location_ptr = (info->location.buffer!=NULL)?1:0;
1038 inf->devmode_ptr = (info->devmode!=NULL)?1:0;
1039 inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0;
1040 inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0;
1041 inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0;
1042 inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0;
1043 inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
1044 inf->attributes = info->attributes;
1045 inf->priority = info->priority;
1046 inf->default_priority = info->defaultpriority;
1047 inf->starttime = info->starttime;
1048 inf->untiltime = info->untiltime;
1049 inf->cjobs = info->cjobs;
1050 inf->averageppm = info->averageppm;
1051 init_unistr2_from_unistr(inf, &inf->servername, &info->servername);
1052 init_unistr2_from_unistr(inf, &inf->printername, &info->printername);
1053 init_unistr2_from_unistr(inf, &inf->sharename, &info->sharename);
1054 init_unistr2_from_unistr(inf, &inf->portname, &info->portname);
1055 init_unistr2_from_unistr(inf, &inf->drivername, &info->drivername);
1056 init_unistr2_from_unistr(inf, &inf->comment, &info->comment);
1057 init_unistr2_from_unistr(inf, &inf->location, &info->location);
1058 init_unistr2_from_unistr(inf, &inf->sepfile, &info->sepfile);
1059 init_unistr2_from_unistr(inf, &inf->printprocessor, &info->printprocessor);
1060 init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
1061 init_unistr2_from_unistr(inf, &inf->parameters, &info->parameters);
1062 init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
1069 /*******************************************************************
1070 create a SPOOL_PRINTER_INFO_3 struct from a PRINTER_INFO_3 struct
1071 *******************************************************************/
1073 bool make_spoolss_printer_info_3(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3 **spool_info3,
1074 PRINTER_INFO_3 *info)
1077 SPOOL_PRINTER_INFO_LEVEL_3 *inf;
1079 /* allocate the necessary memory */
1080 if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3))) {
1081 DEBUG(0,("make_spoolss_printer_info_3: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_3 sruct!\n"));
1085 inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
1092 /*******************************************************************
1093 create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
1094 *******************************************************************/
1096 bool make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7 **spool_info7,
1097 PRINTER_INFO_7 *info)
1100 SPOOL_PRINTER_INFO_LEVEL_7 *inf;
1102 /* allocate the necessary memory */
1103 if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7))) {
1104 DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
1108 inf->guid_ptr = (info->guid.buffer!=NULL)?1:0;
1109 inf->action = info->action;
1110 init_unistr2_from_unistr(inf, &inf->guid, &info->guid);
1118 /*******************************************************************
1120 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1121 ********************************************************************/
1123 bool spoolss_io_q_open_printer(const char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth)
1128 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer");
1134 if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername))
1136 if (!prs_io_unistr2("printername", ps, depth, q_u->printername))
1142 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
1148 /*******************************************************************
1149 * write a structure.
1150 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1151 * called from spoolss_open_printer_ex (cli_spoolss.c)
1152 ********************************************************************/
1154 bool spoolss_io_r_open_printer(const char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth)
1156 if (r_u == NULL) return False;
1158 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer");
1164 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
1167 if (!prs_werror("status code", ps, depth, &(r_u->status)))
1174 /*******************************************************************
1176 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1177 ********************************************************************/
1179 bool spoolss_io_q_open_printer_ex(const char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
1184 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
1190 if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername))
1192 if (!prs_io_unistr2("printername", ps, depth, q_u->printername))
1198 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
1201 if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
1203 if (!spool_io_user_level("", &q_u->user_ctr, ps, depth))
1209 /*******************************************************************
1210 * write a structure.
1211 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1212 * called from spoolss_open_printer_ex (cli_spoolss.c)
1213 ********************************************************************/
1215 bool spoolss_io_r_open_printer_ex(const char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth)
1217 if (r_u == NULL) return False;
1219 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex");
1225 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
1228 if (!prs_werror("status code", ps, depth, &(r_u->status)))
1234 /*******************************************************************
1236 ********************************************************************/
1237 bool make_spoolss_q_deleteprinterdriverex( TALLOC_CTX *mem_ctx,
1238 SPOOL_Q_DELETEPRINTERDRIVEREX *q_u,
1244 DEBUG(5,("make_spoolss_q_deleteprinterdriverex\n"));
1246 q_u->server_ptr = (server!=NULL)?1:0;
1247 q_u->delete_flags = DPD_DELETE_UNUSED_FILES;
1249 /* these must be NULL terminated or else NT4 will
1250 complain about invalid parameters --jerry */
1251 init_unistr2(&q_u->server, server, UNI_STR_TERMINATE);
1252 init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE);
1253 init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE);
1256 q_u->delete_flags |= DPD_DELETE_SPECIFIC_VERSION;
1257 q_u->version = version;
1264 /*******************************************************************
1266 ********************************************************************/
1267 bool make_spoolss_q_deleteprinterdriver(
1268 TALLOC_CTX *mem_ctx,
1269 SPOOL_Q_DELETEPRINTERDRIVER *q_u,
1275 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1277 q_u->server_ptr = (server!=NULL)?1:0;
1279 /* these must be NULL terminated or else NT4 will
1280 complain about invalid parameters --jerry */
1281 init_unistr2(&q_u->server, server, UNI_STR_TERMINATE);
1282 init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE);
1283 init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE);
1288 /*******************************************************************
1290 ********************************************************************/
1292 bool make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
1293 const POLICY_HND *handle,
1294 const char *valuename, uint32 size)
1296 if (q_u == NULL) return False;
1298 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1300 q_u->handle = *handle;
1301 init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
1307 /*******************************************************************
1309 ********************************************************************/
1311 bool make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX *q_u,
1312 const POLICY_HND *handle,
1313 const char *keyname,
1314 const char *valuename, uint32 size)
1316 if (q_u == NULL) return False;
1318 DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
1320 q_u->handle = *handle;
1321 init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
1322 init_unistr2(&q_u->keyname, keyname, UNI_STR_TERMINATE);
1328 /*******************************************************************
1330 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1331 ********************************************************************/
1333 bool spoolss_io_q_getprinterdata(const char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth)
1338 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata");
1343 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1347 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1351 if (!prs_uint32("size", ps, depth, &q_u->size))
1357 /*******************************************************************
1359 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1360 ********************************************************************/
1362 bool spoolss_io_q_deleteprinterdata(const char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth)
1367 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata");
1372 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1376 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1382 /*******************************************************************
1383 * write a structure.
1384 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1385 ********************************************************************/
1387 bool spoolss_io_r_deleteprinterdata(const char *desc, SPOOL_R_DELETEPRINTERDATA *r_u, prs_struct *ps, int depth)
1389 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdata");
1391 if(!prs_werror("status", ps, depth, &r_u->status))
1397 /*******************************************************************
1399 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1400 ********************************************************************/
1402 bool spoolss_io_q_deleteprinterdataex(const char *desc, SPOOL_Q_DELETEPRINTERDATAEX *q_u, prs_struct *ps, int depth)
1407 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdataex");
1412 if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
1415 if (!smb_io_unistr2("keyname ", &q_u->keyname, True, ps, depth))
1417 if (!smb_io_unistr2("valuename", &q_u->valuename, True, ps, depth))
1423 /*******************************************************************
1424 * write a structure.
1425 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1426 ********************************************************************/
1428 bool spoolss_io_r_deleteprinterdataex(const char *desc, SPOOL_R_DELETEPRINTERDATAEX *r_u, prs_struct *ps, int depth)
1430 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdataex");
1433 if(!prs_werror("status", ps, depth, &r_u->status))
1439 /*******************************************************************
1440 * write a structure.
1441 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1442 ********************************************************************/
1444 bool spoolss_io_r_getprinterdata(const char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth)
1449 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata");
1454 if (!prs_uint32("type", ps, depth, &r_u->type))
1456 if (!prs_uint32("size", ps, depth, &r_u->size))
1459 if (UNMARSHALLING(ps) && r_u->size) {
1460 r_u->data = PRS_ALLOC_MEM(ps, unsigned char, r_u->size);
1465 if (!prs_uint8s( False, "data", ps, depth, r_u->data, r_u->size ))
1471 if (!prs_uint32("needed", ps, depth, &r_u->needed))
1473 if (!prs_werror("status", ps, depth, &r_u->status))
1479 /*******************************************************************
1481 ********************************************************************/
1483 bool make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
1485 if (q_u == NULL) return False;
1487 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1489 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
1494 /*******************************************************************
1496 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1497 * called from spoolss_abortprinter (cli_spoolss.c)
1498 ********************************************************************/
1500 bool spoolss_io_q_abortprinter(const char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth)
1502 if (q_u == NULL) return False;
1504 prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter");
1510 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1516 /*******************************************************************
1517 * write a structure.
1518 * called from spoolss_r_abortprinter (srv_spoolss.c)
1519 ********************************************************************/
1521 bool spoolss_io_r_abortprinter(const char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth)
1523 prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter");
1525 if(!prs_werror("status", ps, depth, &r_u->status))
1531 /*******************************************************************
1533 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1534 * called from spoolss_deleteprinter (cli_spoolss.c)
1535 ********************************************************************/
1537 bool spoolss_io_q_deleteprinter(const char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
1539 if (q_u == NULL) return False;
1541 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
1547 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1553 /*******************************************************************
1554 * write a structure.
1555 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1556 * called from spoolss_deleteprinter (cli_spoolss.c)
1557 ********************************************************************/
1559 bool spoolss_io_r_deleteprinter(const char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
1561 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
1567 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1569 if (!prs_werror("status", ps, depth, &r_u->status))
1576 /*******************************************************************
1578 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1579 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1580 ********************************************************************/
1582 bool spoolss_io_q_deleteprinterdriver(const char *desc, SPOOL_Q_DELETEPRINTERDRIVER *q_u, prs_struct *ps, int depth)
1584 if (q_u == NULL) return False;
1586 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriver");
1592 if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
1594 if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
1596 if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth))
1598 if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth))
1606 /*******************************************************************
1607 * write a structure.
1608 ********************************************************************/
1609 bool spoolss_io_r_deleteprinterdriver(const char *desc, SPOOL_R_DELETEPRINTERDRIVER *r_u, prs_struct *ps, int depth)
1611 if (r_u == NULL) return False;
1613 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriver");
1619 if (!prs_werror("status", ps, depth, &r_u->status))
1626 /*******************************************************************
1628 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1629 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1630 ********************************************************************/
1632 bool spoolss_io_q_deleteprinterdriverex(const char *desc, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, prs_struct *ps, int depth)
1634 if (q_u == NULL) return False;
1636 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriverex");
1642 if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
1644 if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
1646 if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth))
1648 if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth))
1654 if(!prs_uint32("delete_flags ", ps, depth, &q_u->delete_flags))
1656 if(!prs_uint32("version ", ps, depth, &q_u->version))
1664 /*******************************************************************
1665 * write a structure.
1666 ********************************************************************/
1667 bool spoolss_io_r_deleteprinterdriverex(const char *desc, SPOOL_R_DELETEPRINTERDRIVEREX *r_u, prs_struct *ps, int depth)
1669 if (r_u == NULL) return False;
1671 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriverex");
1677 if (!prs_werror("status", ps, depth, &r_u->status))
1685 /*******************************************************************
1687 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1688 * called from spoolss_closeprinter (cli_spoolss.c)
1689 ********************************************************************/
1691 bool spoolss_io_q_closeprinter(const char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
1693 if (q_u == NULL) return False;
1695 prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
1701 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1707 /*******************************************************************
1708 * write a structure.
1709 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1710 * called from spoolss_closeprinter (cli_spoolss.c)
1711 ********************************************************************/
1713 bool spoolss_io_r_closeprinter(const char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth)
1715 prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter");
1721 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1723 if (!prs_werror("status", ps, depth, &r_u->status))
1729 /*******************************************************************
1731 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1732 ********************************************************************/
1734 bool spoolss_io_q_startdocprinter(const char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth)
1736 if (q_u == NULL) return False;
1738 prs_debug(ps, depth, desc, "spoolss_io_q_startdocprinter");
1744 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1747 if(!smb_io_doc_info_container("",&q_u->doc_info_container, ps, depth))
1753 /*******************************************************************
1754 * write a structure.
1755 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1756 ********************************************************************/
1758 bool spoolss_io_r_startdocprinter(const char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth)
1760 prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter");
1762 if(!prs_uint32("jobid", ps, depth, &r_u->jobid))
1764 if(!prs_werror("status", ps, depth, &r_u->status))
1770 /*******************************************************************
1772 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1773 ********************************************************************/
1775 bool spoolss_io_q_enddocprinter(const char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth)
1777 if (q_u == NULL) return False;
1779 prs_debug(ps, depth, desc, "spoolss_io_q_enddocprinter");
1785 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1791 /*******************************************************************
1792 * write a structure.
1793 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1794 ********************************************************************/
1796 bool spoolss_io_r_enddocprinter(const char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth)
1798 prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter");
1800 if(!prs_werror("status", ps, depth, &r_u->status))
1806 /*******************************************************************
1808 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1809 ********************************************************************/
1811 bool spoolss_io_q_startpageprinter(const char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth)
1813 if (q_u == NULL) return False;
1815 prs_debug(ps, depth, desc, "spoolss_io_q_startpageprinter");
1821 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1827 /*******************************************************************
1828 * write a structure.
1829 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1830 ********************************************************************/
1832 bool spoolss_io_r_startpageprinter(const char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth)
1834 prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter");
1836 if(!prs_werror("status", ps, depth, &r_u->status))
1842 /*******************************************************************
1844 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1845 ********************************************************************/
1847 bool spoolss_io_q_endpageprinter(const char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth)
1849 if (q_u == NULL) return False;
1851 prs_debug(ps, depth, desc, "spoolss_io_q_endpageprinter");
1857 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1863 /*******************************************************************
1864 * write a structure.
1865 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1866 ********************************************************************/
1868 bool spoolss_io_r_endpageprinter(const char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth)
1870 prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter");
1872 if(!prs_werror("status", ps, depth, &r_u->status))
1878 /*******************************************************************
1880 * called from spoolss_q_writeprinter (srv_spoolss.c)
1881 ********************************************************************/
1883 bool spoolss_io_q_writeprinter(const char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth)
1885 if (q_u == NULL) return False;
1887 prs_debug(ps, depth, desc, "spoolss_io_q_writeprinter");
1893 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1895 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1898 if (q_u->buffer_size!=0)
1900 if (UNMARSHALLING(ps))
1901 q_u->buffer=PRS_ALLOC_MEM(ps, uint8, q_u->buffer_size);
1902 if(q_u->buffer == NULL)
1904 if(!prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size))
1909 if(!prs_uint32("buffer_size2", ps, depth, &q_u->buffer_size2))
1915 /*******************************************************************
1916 * write a structure.
1917 * called from spoolss_r_writeprinter (srv_spoolss.c)
1918 ********************************************************************/
1920 bool spoolss_io_r_writeprinter(const char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth)
1922 prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter");
1924 if(!prs_uint32("buffer_written", ps, depth, &r_u->buffer_written))
1926 if(!prs_werror("status", ps, depth, &r_u->status))
1932 /*******************************************************************
1934 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1935 ********************************************************************/
1937 bool spoolss_io_q_rffpcnex(const char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, int depth)
1939 prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex");
1945 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
1947 if(!prs_uint32("flags", ps, depth, &q_u->flags))
1949 if(!prs_uint32("options", ps, depth, &q_u->options))
1951 if(!prs_uint32("localmachine_ptr", ps, depth, &q_u->localmachine_ptr))
1953 if(!smb_io_unistr2("localmachine", &q_u->localmachine, q_u->localmachine_ptr, ps, depth))
1959 if(!prs_uint32("printerlocal", ps, depth, &q_u->printerlocal))
1962 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1965 if (q_u->option_ptr!=0) {
1967 if (UNMARSHALLING(ps))
1968 if((q_u->option=PRS_ALLOC_MEM(ps,SPOOL_NOTIFY_OPTION,1)) == NULL)
1971 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1978 /*******************************************************************
1979 * write a structure.
1980 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1981 ********************************************************************/
1983 bool spoolss_io_r_rffpcnex(const char *desc, SPOOL_R_RFFPCNEX *r_u, prs_struct *ps, int depth)
1985 prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex");
1988 if(!prs_werror("status", ps, depth, &r_u->status))
1994 /*******************************************************************
1996 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1997 ********************************************************************/
1999 bool spoolss_io_q_rfnpcnex(const char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, int depth)
2001 prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex");
2007 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
2010 if(!prs_uint32("change", ps, depth, &q_u->change))
2013 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
2016 if (q_u->option_ptr!=0) {
2018 if (UNMARSHALLING(ps))
2019 if((q_u->option=PRS_ALLOC_MEM(ps,SPOOL_NOTIFY_OPTION,1)) == NULL)
2022 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
2029 /*******************************************************************
2030 * write a structure.
2031 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
2032 ********************************************************************/
2034 bool spoolss_io_r_rfnpcnex(const char *desc, SPOOL_R_RFNPCNEX *r_u, prs_struct *ps, int depth)
2036 prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex");
2042 if (!prs_uint32("info_ptr", ps, depth, &r_u->info_ptr))
2045 if(!smb_io_notify_info("notify info", &r_u->info ,ps,depth))
2050 if(!prs_werror("status", ps, depth, &r_u->status))
2056 /*******************************************************************
2057 * return the length of a uint16 (obvious, but the code is clean)
2058 ********************************************************************/
2060 static uint32 size_of_uint16(uint16 *value)
2062 return (sizeof(*value));
2065 /*******************************************************************
2066 * return the length of a uint32 (obvious, but the code is clean)
2067 ********************************************************************/
2069 static uint32 size_of_uint32(uint32 *value)
2071 return (sizeof(*value));
2074 /*******************************************************************
2075 * return the length of a NTTIME (obvious, but the code is clean)
2076 ********************************************************************/
2078 static uint32 size_of_nttime(NTTIME *value)
2080 return (sizeof(*value));
2083 /*******************************************************************
2084 * return the length of a uint32 (obvious, but the code is clean)
2085 ********************************************************************/
2087 static uint32 size_of_device_mode(DEVICEMODE *devmode)
2092 return (4+devmode->size+devmode->driverextra);
2095 /*******************************************************************
2096 * return the length of a uint32 (obvious, but the code is clean)
2097 ********************************************************************/
2099 static uint32 size_of_systemtime(SYSTEMTIME *systime)
2104 return (sizeof(SYSTEMTIME) +4);
2107 /*******************************************************************
2108 Parse a DEVMODE structure and its relative pointer.
2109 ********************************************************************/
2111 static bool smb_io_reldevmode(const char *desc, RPC_BUFFER *buffer, int depth, DEVICEMODE **devmode)
2113 prs_struct *ps=&buffer->prs;
2115 prs_debug(ps, depth, desc, "smb_io_reldevmode");
2118 if (MARSHALLING(ps)) {
2119 uint32 struct_offset = prs_offset(ps);
2120 uint32 relative_offset;
2122 if (*devmode == NULL) {
2124 if (!prs_uint32("offset", ps, depth, &relative_offset))
2126 DEBUG(8, ("boing, the devmode was NULL\n"));
2131 buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra);
2133 if(!prs_set_offset(ps, buffer->string_at_end))
2136 /* write the DEVMODE */
2137 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2140 if(!prs_set_offset(ps, struct_offset))
2143 relative_offset=buffer->string_at_end - buffer->struct_start;
2144 /* write its offset */
2145 if (!prs_uint32("offset", ps, depth, &relative_offset))
2151 /* read the offset */
2152 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
2154 if (buffer->string_at_end == 0) {
2159 old_offset = prs_offset(ps);
2160 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
2163 /* read the string */
2164 if((*devmode=PRS_ALLOC_MEM(ps,DEVICEMODE,1)) == NULL)
2166 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2169 if(!prs_set_offset(ps, old_offset))
2175 /*******************************************************************
2176 Parse a PRINTER_INFO_0 structure.
2177 ********************************************************************/
2179 bool smb_io_printer_info_0(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
2181 prs_struct *ps=&buffer->prs;
2183 prs_debug(ps, depth, desc, "smb_io_printer_info_0");
2186 buffer->struct_start=prs_offset(ps);
2188 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2190 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2193 if(!prs_uint32("cjobs", ps, depth, &info->cjobs))
2195 if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs))
2197 if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes))
2200 if(!prs_uint16("year", ps, depth, &info->year))
2202 if(!prs_uint16("month", ps, depth, &info->month))
2204 if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek))
2206 if(!prs_uint16("day", ps, depth, &info->day))
2208 if(!prs_uint16("hour", ps, depth, &info->hour))
2210 if(!prs_uint16("minute", ps, depth, &info->minute))
2212 if(!prs_uint16("second", ps, depth, &info->second))
2214 if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds))
2217 if(!prs_uint32("global_counter", ps, depth, &info->global_counter))
2219 if(!prs_uint32("total_pages", ps, depth, &info->total_pages))
2222 if(!prs_uint16("major_version", ps, depth, &info->major_version))
2224 if(!prs_uint16("build_version", ps, depth, &info->build_version))
2226 if(!prs_uint32("unknown7", ps, depth, &info->unknown7))
2228 if(!prs_uint32("unknown8", ps, depth, &info->unknown8))
2230 if(!prs_uint32("unknown9", ps, depth, &info->unknown9))
2232 if(!prs_uint32("session_counter", ps, depth, &info->session_counter))
2234 if(!prs_uint32("unknown11", ps, depth, &info->unknown11))
2236 if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors))
2238 if(!prs_uint32("unknown13", ps, depth, &info->unknown13))
2240 if(!prs_uint32("unknown14", ps, depth, &info->unknown14))
2242 if(!prs_uint32("unknown15", ps, depth, &info->unknown15))
2244 if(!prs_uint32("unknown16", ps, depth, &info->unknown16))
2246 if(!prs_uint32("change_id", ps, depth, &info->change_id))
2248 if(!prs_uint32("unknown18", ps, depth, &info->unknown18))
2250 if(!prs_uint32("status" , ps, depth, &info->status))
2252 if(!prs_uint32("unknown20", ps, depth, &info->unknown20))
2254 if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter))
2256 if(!prs_uint16("unknown22", ps, depth, &info->unknown22))
2258 if(!prs_uint16("unknown23", ps, depth, &info->unknown23))
2260 if(!prs_uint16("unknown24", ps, depth, &info->unknown24))
2262 if(!prs_uint16("unknown25", ps, depth, &info->unknown25))
2264 if(!prs_uint16("unknown26", ps, depth, &info->unknown26))
2266 if(!prs_uint16("unknown27", ps, depth, &info->unknown27))
2268 if(!prs_uint16("unknown28", ps, depth, &info->unknown28))
2270 if(!prs_uint16("unknown29", ps, depth, &info->unknown29))
2276 /*******************************************************************
2277 Parse a PRINTER_INFO_1 structure.
2278 ********************************************************************/
2280 bool smb_io_printer_info_1(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
2282 prs_struct *ps=&buffer->prs;
2284 prs_debug(ps, depth, desc, "smb_io_printer_info_1");
2287 buffer->struct_start=prs_offset(ps);
2289 if (!prs_uint32("flags", ps, depth, &info->flags))
2291 if (!smb_io_relstr("description", buffer, depth, &info->description))
2293 if (!smb_io_relstr("name", buffer, depth, &info->name))
2295 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2301 /*******************************************************************
2302 Parse a PRINTER_INFO_2 structure.
2303 ********************************************************************/
2305 bool smb_io_printer_info_2(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
2307 prs_struct *ps=&buffer->prs;
2308 uint32 dm_offset, sd_offset, current_offset;
2309 uint32 dummy_value = 0, has_secdesc = 0;
2311 prs_debug(ps, depth, desc, "smb_io_printer_info_2");
2314 buffer->struct_start=prs_offset(ps);
2316 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2318 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2320 if (!smb_io_relstr("sharename", buffer, depth, &info->sharename))
2322 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2324 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2326 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2328 if (!smb_io_relstr("location", buffer, depth, &info->location))
2331 /* save current offset and wind forwared by a uint32 */
2332 dm_offset = prs_offset(ps);
2333 if (!prs_uint32("devmode", ps, depth, &dummy_value))
2336 if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
2338 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2340 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2342 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2345 /* save current offset for the sec_desc */
2346 sd_offset = prs_offset(ps);
2347 if (!prs_uint32("sec_desc", ps, depth, &has_secdesc))
2351 /* save current location so we can pick back up here */
2352 current_offset = prs_offset(ps);
2354 /* parse the devmode */
2355 if (!prs_set_offset(ps, dm_offset))
2357 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2360 /* parse the sec_desc */
2361 if (info->secdesc) {
2362 if (!prs_set_offset(ps, sd_offset))
2364 if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
2368 /* pick up where we left off */
2369 if (!prs_set_offset(ps, current_offset))
2372 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2374 if (!prs_uint32("priority", ps, depth, &info->priority))
2376 if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority))
2378 if (!prs_uint32("starttime", ps, depth, &info->starttime))
2380 if (!prs_uint32("untiltime", ps, depth, &info->untiltime))
2382 if (!prs_uint32("status", ps, depth, &info->status))
2384 if (!prs_uint32("jobs", ps, depth, &info->cjobs))
2386 if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
2392 /*******************************************************************
2393 Parse a PRINTER_INFO_3 structure.
2394 ********************************************************************/
2396 bool smb_io_printer_info_3(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
2399 prs_struct *ps=&buffer->prs;
2401 prs_debug(ps, depth, desc, "smb_io_printer_info_3");
2404 buffer->struct_start=prs_offset(ps);
2406 if (MARSHALLING(ps)) {
2407 /* Ensure the SD is 8 byte aligned in the buffer. */
2408 uint32 start = prs_offset(ps); /* Remember the start position. */
2411 /* Write a dummy value. */
2412 if (!prs_uint32("offset", ps, depth, &off_val))
2416 if (!prs_align_uint64(ps))
2419 /* Remember where we must seek back to write the SD. */
2420 offset = prs_offset(ps);
2422 /* Calculate the real offset for the SD. */
2424 off_val = offset - start;
2426 /* Seek back to where we store the SD offset & store. */
2427 prs_set_offset(ps, start);
2428 if (!prs_uint32("offset", ps, depth, &off_val))
2431 /* Return to after the 8 byte align. */
2432 prs_set_offset(ps, offset);
2435 if (!prs_uint32("offset", ps, depth, &offset))
2437 /* Seek within the buffer. */
2438 if (!prs_set_offset(ps, offset))
2441 if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth))
2447 /*******************************************************************
2448 Parse a PRINTER_INFO_4 structure.
2449 ********************************************************************/
2451 bool smb_io_printer_info_4(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_4 *info, int depth)
2453 prs_struct *ps=&buffer->prs;
2455 prs_debug(ps, depth, desc, "smb_io_printer_info_4");
2458 buffer->struct_start=prs_offset(ps);
2460 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2462 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2464 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2469 /*******************************************************************
2470 Parse a PRINTER_INFO_5 structure.
2471 ********************************************************************/
2473 bool smb_io_printer_info_5(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_5 *info, int depth)
2475 prs_struct *ps=&buffer->prs;
2477 prs_debug(ps, depth, desc, "smb_io_printer_info_5");
2480 buffer->struct_start=prs_offset(ps);
2482 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2484 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2486 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2488 if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout))
2490 if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout))
2495 /*******************************************************************
2496 Parse a PRINTER_INFO_6 structure.
2497 ********************************************************************/
2499 bool smb_io_printer_info_6(const char *desc, RPC_BUFFER *buffer,
2500 PRINTER_INFO_6 *info, int depth)
2502 prs_struct *ps=&buffer->prs;
2504 prs_debug(ps, depth, desc, "smb_io_printer_info_6");
2507 if (!prs_uint32("status", ps, depth, &info->status))
2513 /*******************************************************************
2514 Parse a PRINTER_INFO_7 structure.
2515 ********************************************************************/
2517 bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth)
2519 prs_struct *ps=&buffer->prs;
2521 prs_debug(ps, depth, desc, "smb_io_printer_info_7");
2524 buffer->struct_start=prs_offset(ps);
2526 if (!smb_io_relstr("guid", buffer, depth, &info->guid))
2528 if (!prs_uint32("action", ps, depth, &info->action))
2533 /*******************************************************************
2534 Parse a PORT_INFO_1 structure.
2535 ********************************************************************/
2537 bool smb_io_port_info_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2539 prs_struct *ps=&buffer->prs;
2541 prs_debug(ps, depth, desc, "smb_io_port_info_1");
2544 buffer->struct_start=prs_offset(ps);
2546 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2552 /*******************************************************************
2553 Parse a PORT_INFO_2 structure.
2554 ********************************************************************/
2556 bool smb_io_port_info_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2558 prs_struct *ps=&buffer->prs;
2560 prs_debug(ps, depth, desc, "smb_io_port_info_2");
2563 buffer->struct_start=prs_offset(ps);
2565 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2567 if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2569 if (!smb_io_relstr("description", buffer, depth, &info->description))
2571 if (!prs_uint32("port_type", ps, depth, &info->port_type))
2573 if (!prs_uint32("reserved", ps, depth, &info->reserved))
2579 /*******************************************************************
2580 Parse a DRIVER_INFO_1 structure.
2581 ********************************************************************/
2583 bool smb_io_printer_driver_info_1(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
2585 prs_struct *ps=&buffer->prs;
2587 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
2590 buffer->struct_start=prs_offset(ps);
2592 if (!smb_io_relstr("name", buffer, depth, &info->name))
2598 /*******************************************************************
2599 Parse a DRIVER_INFO_2 structure.
2600 ********************************************************************/
2602 bool smb_io_printer_driver_info_2(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
2604 prs_struct *ps=&buffer->prs;
2606 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
2609 buffer->struct_start=prs_offset(ps);
2611 if (!prs_uint32("version", ps, depth, &info->version))
2613 if (!smb_io_relstr("name", buffer, depth, &info->name))
2615 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2617 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2619 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2621 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2627 /*******************************************************************
2628 Parse a DRIVER_INFO_3 structure.
2629 ********************************************************************/
2631 bool smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
2633 prs_struct *ps=&buffer->prs;
2635 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
2638 buffer->struct_start=prs_offset(ps);
2640 if (!prs_uint32("version", ps, depth, &info->version))
2642 if (!smb_io_relstr("name", buffer, depth, &info->name))
2644 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2646 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2648 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2650 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2652 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2655 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2658 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2660 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2666 /*******************************************************************
2667 Parse a DRIVER_INFO_6 structure.
2668 ********************************************************************/
2670 bool smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
2672 prs_struct *ps=&buffer->prs;
2674 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
2677 buffer->struct_start=prs_offset(ps);
2679 if (!prs_uint32("version", ps, depth, &info->version))
2681 if (!smb_io_relstr("name", buffer, depth, &info->name))
2683 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2685 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2687 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2689 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2691 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2694 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2697 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2699 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2702 if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
2705 if (!prs_uint64("date", ps, depth, &info->driver_date))
2708 if (!prs_uint32("padding", ps, depth, &info->padding))
2711 if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
2714 if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
2717 if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
2719 if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
2721 if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
2723 if (!smb_io_relstr("provider", buffer, depth, &info->provider))
2729 /*******************************************************************
2730 Parse a JOB_INFO_1 structure.
2731 ********************************************************************/
2733 bool smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, int depth)
2735 prs_struct *ps=&buffer->prs;
2737 prs_debug(ps, depth, desc, "smb_io_job_info_1");
2740 buffer->struct_start=prs_offset(ps);
2742 if (!prs_uint32("jobid", ps, depth, &info->jobid))
2744 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2746 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2748 if (!smb_io_relstr("username", buffer, depth, &info->username))
2750 if (!smb_io_relstr("document", buffer, depth, &info->document))
2752 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2754 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2756 if (!prs_uint32("status", ps, depth, &info->status))
2758 if (!prs_uint32("priority", ps, depth, &info->priority))
2760 if (!prs_uint32("position", ps, depth, &info->position))
2762 if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
2764 if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
2766 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
2772 /*******************************************************************
2773 Parse a JOB_INFO_2 structure.
2774 ********************************************************************/
2776 bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth)
2779 prs_struct *ps=&buffer->prs;
2781 prs_debug(ps, depth, desc, "smb_io_job_info_2");
2784 buffer->struct_start=prs_offset(ps);
2786 if (!prs_uint32("jobid",ps, depth, &info->jobid))
2788 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2790 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2792 if (!smb_io_relstr("username", buffer, depth, &info->username))
2794 if (!smb_io_relstr("document", buffer, depth, &info->document))
2796 if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
2798 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2801 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2803 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2805 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2807 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2809 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2812 /* SEC_DESC sec_desc;*/
2813 if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
2816 if (!prs_uint32("status",ps, depth, &info->status))
2818 if (!prs_uint32("priority",ps, depth, &info->priority))
2820 if (!prs_uint32("position",ps, depth, &info->position))
2822 if (!prs_uint32("starttime",ps, depth, &info->starttime))
2824 if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
2826 if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
2828 if (!prs_uint32("size",ps, depth, &info->size))
2830 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
2832 if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
2834 if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
2840 /*******************************************************************
2841 ********************************************************************/
2843 bool smb_io_form_1(const char *desc, RPC_BUFFER *buffer, FORM_1 *info, int depth)
2845 prs_struct *ps=&buffer->prs;
2847 prs_debug(ps, depth, desc, "smb_io_form_1");
2850 buffer->struct_start=prs_offset(ps);
2852 if (!prs_uint32("flag", ps, depth, &info->flag))
2855 if (!smb_io_relstr("name", buffer, depth, &info->name))
2858 if (!prs_uint32("width", ps, depth, &info->width))
2860 if (!prs_uint32("length", ps, depth, &info->length))
2862 if (!prs_uint32("left", ps, depth, &info->left))
2864 if (!prs_uint32("top", ps, depth, &info->top))
2866 if (!prs_uint32("right", ps, depth, &info->right))
2868 if (!prs_uint32("bottom", ps, depth, &info->bottom))
2876 /*******************************************************************
2877 Parse a DRIVER_DIRECTORY_1 structure.
2878 ********************************************************************/
2880 bool smb_io_driverdir_1(const char *desc, RPC_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
2882 prs_struct *ps=&buffer->prs;
2884 prs_debug(ps, depth, desc, "smb_io_driverdir_1");
2887 buffer->struct_start=prs_offset(ps);
2889 if (!smb_io_unistr(desc, &info->name, ps, depth))
2895 /*******************************************************************
2896 Parse a PORT_INFO_1 structure.
2897 ********************************************************************/
2899 bool smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2901 prs_struct *ps=&buffer->prs;
2903 prs_debug(ps, depth, desc, "smb_io_port_1");
2906 buffer->struct_start=prs_offset(ps);
2908 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2914 /*******************************************************************
2915 Parse a PORT_INFO_2 structure.
2916 ********************************************************************/
2918 bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2920 prs_struct *ps=&buffer->prs;
2922 prs_debug(ps, depth, desc, "smb_io_port_2");
2925 buffer->struct_start=prs_offset(ps);
2927 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2929 if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2931 if(!smb_io_relstr("description", buffer, depth, &info->description))
2933 if(!prs_uint32("port_type", ps, depth, &info->port_type))
2935 if(!prs_uint32("reserved", ps, depth, &info->reserved))
2941 /*******************************************************************
2942 ********************************************************************/
2944 bool smb_io_printprocessor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
2946 prs_struct *ps=&buffer->prs;
2948 prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1");
2951 buffer->struct_start=prs_offset(ps);
2953 if (smb_io_relstr("name", buffer, depth, &info->name))
2959 /*******************************************************************
2960 ********************************************************************/
2962 bool smb_io_printprocdatatype_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth)
2964 prs_struct *ps=&buffer->prs;
2966 prs_debug(ps, depth, desc, "smb_io_printprocdatatype_info_1");
2969 buffer->struct_start=prs_offset(ps);
2971 if (smb_io_relstr("name", buffer, depth, &info->name))
2977 /*******************************************************************
2978 ********************************************************************/
2980 bool smb_io_printmonitor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
2982 prs_struct *ps=&buffer->prs;
2984 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1");
2987 buffer->struct_start=prs_offset(ps);
2989 if (!smb_io_relstr("name", buffer, depth, &info->name))
2995 /*******************************************************************
2996 ********************************************************************/
2998 bool smb_io_printmonitor_info_2(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
3000 prs_struct *ps=&buffer->prs;
3002 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
3005 buffer->struct_start=prs_offset(ps);
3007 if (!smb_io_relstr("name", buffer, depth, &info->name))
3009 if (!smb_io_relstr("environment", buffer, depth, &info->environment))
3011 if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
3017 /*******************************************************************
3018 return the size required by a struct in the stream
3019 ********************************************************************/
3021 uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
3025 size+=size_of_relative_string( &info->printername );
3026 size+=size_of_relative_string( &info->servername );
3028 size+=size_of_uint32( &info->cjobs);
3029 size+=size_of_uint32( &info->total_jobs);
3030 size+=size_of_uint32( &info->total_bytes);
3032 size+=size_of_uint16( &info->year);
3033 size+=size_of_uint16( &info->month);
3034 size+=size_of_uint16( &info->dayofweek);
3035 size+=size_of_uint16( &info->day);
3036 size+=size_of_uint16( &info->hour);
3037 size+=size_of_uint16( &info->minute);
3038 size+=size_of_uint16( &info->second);
3039 size+=size_of_uint16( &info->milliseconds);
3041 size+=size_of_uint32( &info->global_counter);
3042 size+=size_of_uint32( &info->total_pages);
3044 size+=size_of_uint16( &info->major_version);
3045 size+=size_of_uint16( &info->build_version);
3047 size+=size_of_uint32( &info->unknown7);
3048 size+=size_of_uint32( &info->unknown8);
3049 size+=size_of_uint32( &info->unknown9);
3050 size+=size_of_uint32( &info->session_counter);
3051 size+=size_of_uint32( &info->unknown11);
3052 size+=size_of_uint32( &info->printer_errors);
3053 size+=size_of_uint32( &info->unknown13);
3054 size+=size_of_uint32( &info->unknown14);
3055 size+=size_of_uint32( &info->unknown15);
3056 size+=size_of_uint32( &info->unknown16);
3057 size+=size_of_uint32( &info->change_id);
3058 size+=size_of_uint32( &info->unknown18);
3059 size+=size_of_uint32( &info->status);
3060 size+=size_of_uint32( &info->unknown20);
3061 size+=size_of_uint32( &info->c_setprinter);
3063 size+=size_of_uint16( &info->unknown22);
3064 size+=size_of_uint16( &info->unknown23);
3065 size+=size_of_uint16( &info->unknown24);
3066 size+=size_of_uint16( &info->unknown25);
3067 size+=size_of_uint16( &info->unknown26);
3068 size+=size_of_uint16( &info->unknown27);
3069 size+=size_of_uint16( &info->unknown28);
3070 size+=size_of_uint16( &info->unknown29);
3075 /*******************************************************************
3076 return the size required by a struct in the stream
3077 ********************************************************************/
3079 uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
3083 size+=size_of_uint32( &info->flags );
3084 size+=size_of_relative_string( &info->description );
3085 size+=size_of_relative_string( &info->name );
3086 size+=size_of_relative_string( &info->comment );
3091 /*******************************************************************
3092 return the size required by a struct in the stream
3093 ********************************************************************/
3095 uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
3101 size += ndr_size_security_descriptor( info->secdesc, 0 );
3103 size+=size_of_device_mode( info->devmode );
3105 size+=size_of_relative_string( &info->servername );
3106 size+=size_of_relative_string( &info->printername );
3107 size+=size_of_relative_string( &info->sharename );
3108 size+=size_of_relative_string( &info->portname );
3109 size+=size_of_relative_string( &info->drivername );
3110 size+=size_of_relative_string( &info->comment );
3111 size+=size_of_relative_string( &info->location );
3113 size+=size_of_relative_string( &info->sepfile );
3114 size+=size_of_relative_string( &info->printprocessor );
3115 size+=size_of_relative_string( &info->datatype );
3116 size+=size_of_relative_string( &info->parameters );
3118 size+=size_of_uint32( &info->attributes );
3119 size+=size_of_uint32( &info->priority );
3120 size+=size_of_uint32( &info->defaultpriority );
3121 size+=size_of_uint32( &info->starttime );
3122 size+=size_of_uint32( &info->untiltime );
3123 size+=size_of_uint32( &info->status );
3124 size+=size_of_uint32( &info->cjobs );
3125 size+=size_of_uint32( &info->averageppm );
3128 * add any adjustments for alignment. This is
3129 * not optimal since we could be calling this
3130 * function from a loop (e.g. enumprinters), but
3131 * it is easier to maintain the calculation here and
3132 * not place the burden on the caller to remember. --jerry
3134 if ((size % 4) != 0)
3135 size += 4 - (size % 4);
3140 /*******************************************************************
3141 return the size required by a struct in the stream
3142 ********************************************************************/
3144 uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
3148 size+=size_of_relative_string( &info->printername );
3149 size+=size_of_relative_string( &info->servername );
3151 size+=size_of_uint32( &info->attributes );
3155 /*******************************************************************
3156 return the size required by a struct in the stream
3157 ********************************************************************/
3159 uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
3163 size+=size_of_relative_string( &info->printername );
3164 size+=size_of_relative_string( &info->portname );
3166 size+=size_of_uint32( &info->attributes );
3167 size+=size_of_uint32( &info->device_not_selected_timeout );
3168 size+=size_of_uint32( &info->transmission_retry_timeout );
3172 /*******************************************************************
3173 return the size required by a struct in the stream
3174 ********************************************************************/
3176 uint32 spoolss_size_printer_info_6(PRINTER_INFO_6 *info)
3178 return sizeof(uint32);
3181 /*******************************************************************
3182 return the size required by a struct in the stream
3183 ********************************************************************/
3185 uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
3187 /* The 8 is for the self relative pointer - 8 byte aligned.. */
3188 return 8 + (uint32)ndr_size_security_descriptor( info->secdesc, 0 );
3191 /*******************************************************************
3192 return the size required by a struct in the stream
3193 ********************************************************************/
3195 uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info)
3199 size+=size_of_relative_string( &info->guid );
3200 size+=size_of_uint32( &info->action );
3204 /*******************************************************************
3205 return the size required by a struct in the stream
3206 ********************************************************************/
3208 uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
3211 size+=size_of_relative_string( &info->name );
3216 /*******************************************************************
3217 return the size required by a struct in the stream
3218 ********************************************************************/
3220 uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
3223 size+=size_of_uint32( &info->version );
3224 size+=size_of_relative_string( &info->name );
3225 size+=size_of_relative_string( &info->architecture );
3226 size+=size_of_relative_string( &info->driverpath );
3227 size+=size_of_relative_string( &info->datafile );
3228 size+=size_of_relative_string( &info->configfile );
3233 /*******************************************************************
3234 return the size required by a string array.
3235 ********************************************************************/
3237 uint32 spoolss_size_string_array(uint16 *string)
3242 for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
3244 i=i+2; /* to count all chars including the leading zero */
3245 i=2*i; /* because we need the value in bytes */
3246 i=i+4; /* the offset pointer size */
3251 /*******************************************************************
3252 return the size required by a struct in the stream
3253 ********************************************************************/
3255 uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
3259 size+=size_of_uint32( &info->version );
3260 size+=size_of_relative_string( &info->name );
3261 size+=size_of_relative_string( &info->architecture );
3262 size+=size_of_relative_string( &info->driverpath );
3263 size+=size_of_relative_string( &info->datafile );
3264 size+=size_of_relative_string( &info->configfile );
3265 size+=size_of_relative_string( &info->helpfile );
3266 size+=size_of_relative_string( &info->monitorname );
3267 size+=size_of_relative_string( &info->defaultdatatype );
3269 size+=spoolss_size_string_array(info->dependentfiles);
3274 /*******************************************************************
3275 return the size required by a struct in the stream
3276 ********************************************************************/
3278 uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
3282 size+=size_of_uint32( &info->version );
3283 size+=size_of_relative_string( &info->name );
3284 size+=size_of_relative_string( &info->architecture );
3285 size+=size_of_relative_string( &info->driverpath );
3286 size+=size_of_relative_string( &info->datafile );
3287 size+=size_of_relative_string( &info->configfile );
3288 size+=size_of_relative_string( &info->helpfile );
3290 size+=spoolss_size_string_array(info->dependentfiles);
3292 size+=size_of_relative_string( &info->monitorname );
3293 size+=size_of_relative_string( &info->defaultdatatype );
3295 size+=spoolss_size_string_array(info->previousdrivernames);
3297 size+=size_of_nttime(&info->driver_date);
3298 size+=size_of_uint32( &info->padding );
3299 size+=size_of_uint32( &info->driver_version_low );
3300 size+=size_of_uint32( &info->driver_version_high );
3301 size+=size_of_relative_string( &info->mfgname );
3302 size+=size_of_relative_string( &info->oem_url );
3303 size+=size_of_relative_string( &info->hardware_id );
3304 size+=size_of_relative_string( &info->provider );
3309 /*******************************************************************
3310 return the size required by a struct in the stream
3311 ********************************************************************/
3313 uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
3316 size+=size_of_uint32( &info->jobid );
3317 size+=size_of_relative_string( &info->printername );
3318 size+=size_of_relative_string( &info->machinename );
3319 size+=size_of_relative_string( &info->username );
3320 size+=size_of_relative_string( &info->document );
3321 size+=size_of_relative_string( &info->datatype );
3322 size+=size_of_relative_string( &info->text_status );
3323 size+=size_of_uint32( &info->status );
3324 size+=size_of_uint32( &info->priority );
3325 size+=size_of_uint32( &info->position );
3326 size+=size_of_uint32( &info->totalpages );
3327 size+=size_of_uint32( &info->pagesprinted );
3328 size+=size_of_systemtime( &info->submitted );
3333 /*******************************************************************
3334 return the size required by a struct in the stream
3335 ********************************************************************/
3337 uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
3341 size+=4; /* size of sec desc ptr */
3343 size+=size_of_uint32( &info->jobid );
3344 size+=size_of_relative_string( &info->printername );
3345 size+=size_of_relative_string( &info->machinename );
3346 size+=size_of_relative_string( &info->username );
3347 size+=size_of_relative_string( &info->document );
3348 size+=size_of_relative_string( &info->notifyname );
3349 size+=size_of_relative_string( &info->datatype );
3350 size+=size_of_relative_string( &info->printprocessor );
3351 size+=size_of_relative_string( &info->parameters );
3352 size+=size_of_relative_string( &info->drivername );
3353 size+=size_of_device_mode( info->devmode );
3354 size+=size_of_relative_string( &info->text_status );
3355 /* SEC_DESC sec_desc;*/
3356 size+=size_of_uint32( &info->status );
3357 size+=size_of_uint32( &info->priority );
3358 size+=size_of_uint32( &info->position );
3359 size+=size_of_uint32( &info->starttime );
3360 size+=size_of_uint32( &info->untiltime );
3361 size+=size_of_uint32( &info->totalpages );
3362 size+=size_of_uint32( &info->size );
3363 size+=size_of_systemtime( &info->submitted );
3364 size+=size_of_uint32( &info->timeelapsed );
3365 size+=size_of_uint32( &info->pagesprinted );
3370 /*******************************************************************
3371 return the size required by a struct in the stream
3372 ********************************************************************/
3374 uint32 spoolss_size_form_1(FORM_1 *info)
3378 size+=size_of_uint32( &info->flag );
3379 size+=size_of_relative_string( &info->name );
3380 size+=size_of_uint32( &info->width );
3381 size+=size_of_uint32( &info->length );
3382 size+=size_of_uint32( &info->left );
3383 size+=size_of_uint32( &info->top );
3384 size+=size_of_uint32( &info->right );
3385 size+=size_of_uint32( &info->bottom );
3390 /*******************************************************************
3391 return the size required by a struct in the stream
3392 ********************************************************************/
3394 uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
3398 size+=size_of_relative_string( &info->port_name );
3403 /*******************************************************************
3404 return the size required by a struct in the stream
3405 ********************************************************************/
3407 uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info)
3411 size=str_len_uni(&info->name); /* the string length */
3412 size=size+1; /* add the leading zero */
3413 size=size*2; /* convert in char */
3418 /*******************************************************************
3419 return the size required by a struct in the stream
3420 ********************************************************************/
3422 uint32 spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1 *info)
3426 size=str_len_uni(&info->name); /* the string length */
3427 size=size+1; /* add the leading zero */
3428 size=size*2; /* convert in char */
3433 /*******************************************************************
3434 return the size required by a struct in the stream
3435 ********************************************************************/
3437 uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
3441 size+=size_of_relative_string( &info->port_name );
3442 size+=size_of_relative_string( &info->monitor_name );
3443 size+=size_of_relative_string( &info->description );
3445 size+=size_of_uint32( &info->port_type );
3446 size+=size_of_uint32( &info->reserved );
3451 /*******************************************************************
3452 return the size required by a struct in the stream
3453 ********************************************************************/
3455 uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
3458 size+=size_of_relative_string( &info->name );
3463 /*******************************************************************
3464 return the size required by a struct in the stream
3465 ********************************************************************/
3467 uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info)
3470 size+=size_of_relative_string( &info->name );
3475 /*******************************************************************
3476 return the size required by a struct in the stream
3477 ********************************************************************/
3478 uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
3485 /* uint32(offset) + uint32(length) + length) */
3486 size += (size_of_uint32(&p->value_len)*2) + p->value_len;
3487 size += (size_of_uint32(&p->data_len)*2) + p->data_len + (p->data_len%2) ;
3489 size += size_of_uint32(&p->type);
3494 /*******************************************************************
3495 return the size required by a struct in the stream
3496 ********************************************************************/
3498 uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
3501 size+=size_of_relative_string( &info->name );
3506 /*******************************************************************
3507 return the size required by a struct in the stream
3508 ********************************************************************/
3510 uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
3513 size+=size_of_relative_string( &info->name);
3514 size+=size_of_relative_string( &info->environment);
3515 size+=size_of_relative_string( &info->dll_name);
3520 /*******************************************************************
3522 ********************************************************************/
3524 bool make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
3525 const POLICY_HND *hnd,
3526 const fstring architecture,
3527 uint32 level, uint32 clientmajor, uint32 clientminor,
3528 RPC_BUFFER *buffer, uint32 offered)
3533 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3535 init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture);
3538 q_u->clientmajorversion=clientmajor;
3539 q_u->clientminorversion=clientminor;
3542 q_u->offered=offered;
3547 /*******************************************************************
3549 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3550 ********************************************************************/
3552 bool spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
3554 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
3560 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3562 if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr))
3564 if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth))
3569 if(!prs_uint32("level", ps, depth, &q_u->level))
3572 if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3578 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3581 if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion))
3583 if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion))
3589 /*******************************************************************
3591 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3592 ********************************************************************/
3594 bool spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
3596 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
3602 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3607 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3609 if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion))
3611 if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
3613 if (!prs_werror("status", ps, depth, &r_u->status))
3619 /*******************************************************************
3621 ********************************************************************/
3623 bool make_spoolss_q_enumprinters(
3624 SPOOL_Q_ENUMPRINTERS *q_u,
3634 q_u->servername_ptr = (servername != NULL) ? 1 : 0;
3635 init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
3639 q_u->offered=offered;
3644 /*******************************************************************
3646 ********************************************************************/
3648 bool make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u,
3649 fstring servername, uint32 level,
3650 RPC_BUFFER *buffer, uint32 offered)
3652 q_u->name_ptr = (servername != NULL) ? 1 : 0;
3653 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
3657 q_u->offered=offered;
3662 /*******************************************************************
3664 * called from spoolss_enumprinters (srv_spoolss.c)
3665 ********************************************************************/
3667 bool spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
3669 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
3675 if (!prs_uint32("flags", ps, depth, &q_u->flags))
3677 if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
3680 if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
3685 if (!prs_uint32("level", ps, depth, &q_u->level))
3688 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3693 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3699 /*******************************************************************
3700 Parse a SPOOL_R_ENUMPRINTERS structure.
3701 ********************************************************************/
3703 bool spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
3705 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
3711 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3717 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3720 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3723 if (!prs_werror("status", ps, depth, &r_u->status))
3729 /*******************************************************************
3730 * write a structure.
3731 * called from spoolss_r_enum_printers (srv_spoolss.c)
3733 ********************************************************************/
3735 bool spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
3737 prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
3743 if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
3749 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3752 if (!prs_werror("status", ps, depth, &r_u->status))
3758 /*******************************************************************
3760 * called from spoolss_getprinter (srv_spoolss.c)
3761 ********************************************************************/
3763 bool spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
3765 prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
3771 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3773 if (!prs_uint32("level", ps, depth, &q_u->level))
3776 if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
3781 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3787 /*******************************************************************
3789 ********************************************************************/
3791 bool make_spoolss_q_getprinter(
3792 TALLOC_CTX *mem_ctx,
3793 SPOOL_Q_GETPRINTER *q_u,
3794 const POLICY_HND *hnd,
3804 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3808 q_u->offered=offered;
3813 /*******************************************************************
3815 ********************************************************************/
3816 bool make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
3817 const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
3821 DEVICEMODE *devmode;
3826 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3829 q_u->info.level = level;
3830 q_u->info.info_ptr = 1; /* Info is != NULL, see above */
3833 /* There's no such thing as a setprinter level 1 */
3836 secdesc = info->printers_2->secdesc;
3837 devmode = info->printers_2->devmode;
3839 make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2);
3840 #if 1 /* JERRY TEST */
3841 q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
3842 if (!q_u->secdesc_ctr)
3844 q_u->secdesc_ctr->sd = secdesc;
3845 q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3847 q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
3848 q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0;
3849 q_u->devmode_ctr.devmode = devmode;
3851 q_u->secdesc_ctr = NULL;
3853 q_u->devmode_ctr.devmode_ptr = 0;
3854 q_u->devmode_ctr.size = 0;
3855 q_u->devmode_ctr.devmode = NULL;
3859 secdesc = info->printers_3->secdesc;
3861 make_spoolss_printer_info_3 (mem_ctx, &q_u->info.info_3, info->printers_3);
3863 q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
3864 if (!q_u->secdesc_ctr)
3866 q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3867 q_u->secdesc_ctr->sd = secdesc;
3871 make_spoolss_printer_info_7 (mem_ctx, &q_u->info.info_7, info->printers_7);
3875 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
3880 q_u->command = command;
3886 /*******************************************************************
3887 ********************************************************************/
3889 bool spoolss_io_r_setprinter(const char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
3891 prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
3897 if(!prs_werror("status", ps, depth, &r_u->status))
3903 /*******************************************************************
3904 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3905 ********************************************************************/
3907 bool spoolss_io_q_setprinter(const char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
3909 uint32 ptr_sec_desc = 0;
3911 prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
3917 if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
3919 if(!prs_uint32("level", ps, depth, &q_u->level))
3922 /* check for supported levels and structures we know about */
3924 switch ( q_u->level ) {
3929 /* supported levels */
3932 DEBUG(0,("spoolss_io_q_setprinter: unsupported printer info level [%d]\n",
3938 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
3941 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
3951 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
3956 /* FIXME ! Our parsing here is wrong I think,
3957 * but for a level3 it makes no sense for
3958 * ptr_sec_desc to be NULL. JRA. Based on
3959 * a Vista sniff from Martin Zielinski <mz@seh.de>.
3961 if (UNMARSHALLING(ps)) {
3964 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
3971 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
3976 /* Parse a NULL security descriptor. This should really
3977 happen inside the sec_io_desc_buf() function. */
3979 prs_debug(ps, depth, "", "sec_io_desc_buf");
3980 if (!prs_uint32("size", ps, depth + 1, &dummy))
3982 if (!prs_uint32("ptr", ps, depth + 1, &dummy))
3986 if(!prs_uint32("command", ps, depth, &q_u->command))
3992 /*******************************************************************
3993 ********************************************************************/
3995 bool spoolss_io_r_fcpn(const char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
3997 prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
4003 if(!prs_werror("status", ps, depth, &r_u->status))
4009 /*******************************************************************
4010 ********************************************************************/
4012 bool spoolss_io_q_fcpn(const char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
4015 prs_debug(ps, depth, desc, "spoolss_io_q_fcpn");
4021 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4028 /*******************************************************************
4029 ********************************************************************/
4031 bool spoolss_io_r_addjob(const char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
4033 prs_debug(ps, depth, desc, "");
4039 if(!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
4045 if(!prs_uint32("needed", ps, depth, &r_u->needed))
4048 if(!prs_werror("status", ps, depth, &r_u->status))
4054 /*******************************************************************
4055 ********************************************************************/
4057 bool spoolss_io_q_addjob(const char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
4059 prs_debug(ps, depth, desc, "");
4065 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
4067 if(!prs_uint32("level", ps, depth, &q_u->level))