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.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /*******************************************************************
28 return the length of a UNISTR string.
29 ********************************************************************/
31 static uint32 str_len_uni(UNISTR *source)
38 while (source->buffer[i])
44 /*******************************************************************
45 This should be moved in a more generic lib.
46 ********************************************************************/
48 static BOOL spoolss_io_system_time(char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime)
50 if(!prs_uint16("year", ps, depth, &systime->year))
52 if(!prs_uint16("month", ps, depth, &systime->month))
54 if(!prs_uint16("dayofweek", ps, depth, &systime->dayofweek))
56 if(!prs_uint16("day", ps, depth, &systime->day))
58 if(!prs_uint16("hour", ps, depth, &systime->hour))
60 if(!prs_uint16("minute", ps, depth, &systime->minute))
62 if(!prs_uint16("second", ps, depth, &systime->second))
64 if(!prs_uint16("milliseconds", ps, depth, &systime->milliseconds))
70 /*******************************************************************
71 ********************************************************************/
73 BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime)
75 systime->year=unixtime->tm_year+1900;
76 systime->month=unixtime->tm_mon+1;
77 systime->dayofweek=unixtime->tm_wday;
78 systime->day=unixtime->tm_mday;
79 systime->hour=unixtime->tm_hour;
80 systime->minute=unixtime->tm_min;
81 systime->second=unixtime->tm_sec;
82 systime->milliseconds=0;
87 /*******************************************************************
88 reads or writes an DOC_INFO structure.
89 ********************************************************************/
91 static BOOL smb_io_doc_info_1(char *desc, DOC_INFO_1 *info_1, prs_struct *ps, int depth)
93 if (info_1 == NULL) return False;
95 prs_debug(ps, depth, desc, "smb_io_doc_info_1");
101 if(!prs_uint32("p_docname", ps, depth, &info_1->p_docname))
103 if(!prs_uint32("p_outputfile", ps, depth, &info_1->p_outputfile))
105 if(!prs_uint32("p_datatype", ps, depth, &info_1->p_datatype))
108 if(!smb_io_unistr2("", &info_1->docname, info_1->p_docname, ps, depth))
110 if(!smb_io_unistr2("", &info_1->outputfile, info_1->p_outputfile, ps, depth))
112 if(!smb_io_unistr2("", &info_1->datatype, info_1->p_datatype, ps, depth))
118 /*******************************************************************
119 reads or writes an DOC_INFO structure.
120 ********************************************************************/
122 static BOOL smb_io_doc_info(char *desc, DOC_INFO *info, prs_struct *ps, int depth)
124 uint32 useless_ptr=0;
126 if (info == NULL) return False;
128 prs_debug(ps, depth, desc, "smb_io_doc_info");
134 if(!prs_uint32("switch_value", ps, depth, &info->switch_value))
137 if(!prs_uint32("doc_info_X ptr", ps, depth, &useless_ptr))
140 switch (info->switch_value)
143 if(!smb_io_doc_info_1("",&info->doc_info_1, ps, depth))
148 this is just a placeholder
150 MSDN July 1998 says doc_info_2 is only on
151 Windows 95, and as Win95 doesn't do RPC to print
152 this case is nearly impossible
154 Maybe one day with Windows for dishwasher 2037 ...
157 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
160 DEBUG(0,("Something is obviously wrong somewhere !\n"));
167 /*******************************************************************
168 reads or writes an DOC_INFO_CONTAINER structure.
169 ********************************************************************/
171 static BOOL smb_io_doc_info_container(char *desc, DOC_INFO_CONTAINER *cont, prs_struct *ps, int depth)
173 if (cont == NULL) return False;
175 prs_debug(ps, depth, desc, "smb_io_doc_info_container");
181 if(!prs_uint32("level", ps, depth, &cont->level))
184 if(!smb_io_doc_info("",&cont->docinfo, ps, depth))
190 /*******************************************************************
191 reads or writes an NOTIFY OPTION TYPE structure.
192 ********************************************************************/
194 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
195 structure. The _TYPE structure is really the deferred referrants (i.e
196 the notify fields array) of the _TYPE structure. -tpot */
198 static BOOL smb_io_notify_option_type(char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
200 prs_debug(ps, depth, desc, "smb_io_notify_option_type");
206 if(!prs_uint16("type", ps, depth, &type->type))
208 if(!prs_uint16("reserved0", ps, depth, &type->reserved0))
210 if(!prs_uint32("reserved1", ps, depth, &type->reserved1))
212 if(!prs_uint32("reserved2", ps, depth, &type->reserved2))
214 if(!prs_uint32("count", ps, depth, &type->count))
216 if(!prs_uint32("fields_ptr", ps, depth, &type->fields_ptr))
222 /*******************************************************************
223 reads or writes an NOTIFY OPTION TYPE DATA.
224 ********************************************************************/
226 static BOOL smb_io_notify_option_type_data(char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
230 prs_debug(ps, depth, desc, "smb_io_notify_option_type_data");
233 /* if there are no fields just return */
234 if (type->fields_ptr==0)
240 if(!prs_uint32("count2", ps, depth, &type->count2))
243 if (type->count2 != type->count)
244 DEBUG(4,("What a mess, count was %x now is %x !\n", type->count, type->count2));
246 /* parse the option type data */
247 for(i=0;i<type->count2;i++)
248 if(!prs_uint16("fields",ps,depth,&type->fields[i]))
253 /*******************************************************************
254 reads or writes an NOTIFY OPTION structure.
255 ********************************************************************/
257 static BOOL smb_io_notify_option_type_ctr(char *desc, SPOOL_NOTIFY_OPTION_TYPE_CTR *ctr , prs_struct *ps, int depth)
261 prs_debug(ps, depth, desc, "smb_io_notify_option_type_ctr");
264 if(!prs_uint32("count", ps, depth, &ctr->count))
268 if (UNMARSHALLING(ps))
269 if((ctr->type=(SPOOL_NOTIFY_OPTION_TYPE *)prs_alloc_mem(ps,ctr->count*sizeof(SPOOL_NOTIFY_OPTION_TYPE))) == NULL)
272 /* the option type struct */
273 for(i=0;i<ctr->count;i++)
274 if(!smb_io_notify_option_type("", &ctr->type[i] , ps, depth))
277 /* the type associated with the option type struct */
278 for(i=0;i<ctr->count;i++)
279 if(!smb_io_notify_option_type_data("", &ctr->type[i] , ps, depth))
285 /*******************************************************************
286 reads or writes an NOTIFY OPTION structure.
287 ********************************************************************/
289 static BOOL smb_io_notify_option(char *desc, SPOOL_NOTIFY_OPTION *option, prs_struct *ps, int depth)
291 prs_debug(ps, depth, desc, "smb_io_notify_option");
294 if(!prs_uint32("version", ps, depth, &option->version))
296 if(!prs_uint32("flags", ps, depth, &option->flags))
298 if(!prs_uint32("count", ps, depth, &option->count))
300 if(!prs_uint32("option_type_ptr", ps, depth, &option->option_type_ptr))
303 /* marshalling or unmarshalling, that would work */
304 if (option->option_type_ptr!=0) {
305 if(!smb_io_notify_option_type_ctr("", &option->ctr ,ps, depth))
309 option->ctr.type=NULL;
316 /*******************************************************************
317 reads or writes an NOTIFY INFO DATA structure.
318 ********************************************************************/
320 static BOOL smb_io_notify_info_data(char *desc,SPOOL_NOTIFY_INFO_DATA *data, prs_struct *ps, int depth)
322 uint32 useless_ptr=0xADDE0FF0;
324 uint32 how_many_words;
328 prs_debug(ps, depth, desc, "smb_io_notify_info_data");
331 how_many_words=data->size;
332 if (how_many_words==POINTER) {
333 how_many_words=TWO_VALUE;
336 isvalue=data->enc_type;
340 if(!prs_uint16("type", ps, depth, &data->type))
342 if(!prs_uint16("field", ps, depth, &data->field))
346 if(!prs_uint32("how many words", ps, depth, &how_many_words))
348 if(!prs_uint32("id", ps, depth, &data->id))
350 if(!prs_uint32("how many words", ps, depth, &how_many_words))
357 if(!prs_uint32("value[0]", ps, depth, &data->notify_data.value[0]))
359 if(!prs_uint32("value[1]", ps, depth, &data->notify_data.value[1]))
364 /* length in ascii including \0 */
365 x=2*(data->notify_data.data.length+1);
366 if(!prs_uint32("string length", ps, depth, &x ))
368 if(!prs_uint32("pointer", ps, depth, &useless_ptr))
376 /*******************************************************************
377 reads or writes an NOTIFY INFO DATA structure.
378 ********************************************************************/
380 BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data,
381 prs_struct *ps, int depth)
386 prs_debug(ps, depth, desc, "smb_io_notify_info_data_strings");
392 isvalue=data->enc_type;
394 if (isvalue==False) {
395 /* length of string in unicode include \0 */
396 x=data->notify_data.data.length+1;
397 if(!prs_uint32("string length", ps, depth, &x ))
399 if (MARSHALLING(ps)) {
400 /* These are already in little endian format. Don't byte swap. */
403 /* No memory allocated for this string
404 therefore following the data.string
405 pointer is a bad idea. Use a pointer to
406 the uint32 length union member to
407 provide a source for a unicode NULL */
409 if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2))
412 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
417 /* Tallocate memory for string */
419 data->notify_data.data.string = (uint16 *)prs_alloc_mem(ps, x * 2);
420 if (!data->notify_data.data.string)
423 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
429 /* Win2k does not seem to put this parse align here */
438 /*******************************************************************
439 reads or writes an NOTIFY INFO structure.
440 ********************************************************************/
442 static BOOL smb_io_notify_info(char *desc, SPOOL_NOTIFY_INFO *info, prs_struct *ps, int depth)
446 prs_debug(ps, depth, desc, "smb_io_notify_info");
452 if(!prs_uint32("count", ps, depth, &info->count))
454 if(!prs_uint32("version", ps, depth, &info->version))
456 if(!prs_uint32("flags", ps, depth, &info->flags))
458 if(!prs_uint32("count", ps, depth, &info->count))
461 for (i=0;i<info->count;i++) {
462 if(!smb_io_notify_info_data(desc, &info->data[i], ps, depth))
466 /* now do the strings at the end of the stream */
467 for (i=0;i<info->count;i++) {
468 if(!smb_io_notify_info_data_strings(desc, &info->data[i], ps, depth))
475 /*******************************************************************
476 ********************************************************************/
478 static BOOL spool_io_user_level_1(char *desc, SPOOL_USER_1 *q_u, prs_struct *ps, int depth)
480 prs_debug(ps, depth, desc, "");
484 if (UNMARSHALLING(ps))
489 if (!prs_uint32("size", ps, depth, &q_u->size))
491 if (!prs_uint32("client_name_ptr", ps, depth, &q_u->client_name_ptr))
493 if (!prs_uint32("user_name_ptr", ps, depth, &q_u->user_name_ptr))
495 if (!prs_uint32("build", ps, depth, &q_u->build))
497 if (!prs_uint32("major", ps, depth, &q_u->major))
499 if (!prs_uint32("minor", ps, depth, &q_u->minor))
501 if (!prs_uint32("processor", ps, depth, &q_u->processor))
504 if (!smb_io_unistr2("", &q_u->client_name, q_u->client_name_ptr, ps, depth))
508 if (!smb_io_unistr2("", &q_u->user_name, q_u->user_name_ptr, ps, depth))
514 /*******************************************************************
515 ********************************************************************/
517 static BOOL spool_io_user_level(char *desc, SPOOL_USER_CTR *q_u, prs_struct *ps, int depth)
522 prs_debug(ps, depth, desc, "spool_io_user_level");
527 if (!prs_uint32("level", ps, depth, &q_u->level))
529 if (!prs_uint32("ptr", ps, depth, &q_u->ptr))
532 switch (q_u->level) {
534 if (!spool_io_user_level_1("", &q_u->user1, ps, depth))
544 /*******************************************************************
545 * read or write a DEVICEMODE struct.
546 * on reading allocate memory for the private member
547 ********************************************************************/
549 BOOL spoolss_io_devmode(char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode)
551 prs_debug(ps, depth, desc, "spoolss_io_devmode");
554 if (UNMARSHALLING(ps)) {
555 devmode->devicename.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) );
556 if (devmode->devicename.buffer == NULL)
560 if (!prs_uint16uni(True,"devicename", ps, depth, devmode->devicename.buffer, 32))
562 if (!prs_uint16("specversion", ps, depth, &devmode->specversion))
564 if (!prs_uint16("driverversion", ps, depth, &devmode->driverversion))
566 if (!prs_uint16("size", ps, depth, &devmode->size))
568 if (!prs_uint16("driverextra", ps, depth, &devmode->driverextra))
570 if (!prs_uint32("fields", ps, depth, &devmode->fields))
572 if (!prs_uint16("orientation", ps, depth, &devmode->orientation))
574 if (!prs_uint16("papersize", ps, depth, &devmode->papersize))
576 if (!prs_uint16("paperlength", ps, depth, &devmode->paperlength))
578 if (!prs_uint16("paperwidth", ps, depth, &devmode->paperwidth))
580 if (!prs_uint16("scale", ps, depth, &devmode->scale))
582 if (!prs_uint16("copies", ps, depth, &devmode->copies))
584 if (!prs_uint16("defaultsource", ps, depth, &devmode->defaultsource))
586 if (!prs_uint16("printquality", ps, depth, &devmode->printquality))
588 if (!prs_uint16("color", ps, depth, &devmode->color))
590 if (!prs_uint16("duplex", ps, depth, &devmode->duplex))
592 if (!prs_uint16("yresolution", ps, depth, &devmode->yresolution))
594 if (!prs_uint16("ttoption", ps, depth, &devmode->ttoption))
596 if (!prs_uint16("collate", ps, depth, &devmode->collate))
599 if (UNMARSHALLING(ps)) {
600 devmode->formname.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) );
601 if (devmode->formname.buffer == NULL)
605 if (!prs_uint16uni(True, "formname", ps, depth, devmode->formname.buffer, 32))
607 if (!prs_uint16("logpixels", ps, depth, &devmode->logpixels))
609 if (!prs_uint32("bitsperpel", ps, depth, &devmode->bitsperpel))
611 if (!prs_uint32("pelswidth", ps, depth, &devmode->pelswidth))
613 if (!prs_uint32("pelsheight", ps, depth, &devmode->pelsheight))
615 if (!prs_uint32("displayflags", ps, depth, &devmode->displayflags))
617 if (!prs_uint32("displayfrequency", ps, depth, &devmode->displayfrequency))
621 * Conditional parsing. Assume that the DeviceMode has been
622 * zero'd by the caller.
624 switch(devmode->specversion) {
626 /* Used by spooler when issuing OpenPrinter() calls. NT 3.5x? */
630 /* See the comments on the DEVMODE in the msdn GDI documentation */
631 /* (WINVER >= 0x0400) */
634 if (!prs_uint32("icmmethod", ps, depth, &devmode->icmmethod))
636 if (!prs_uint32("icmintent", ps, depth, &devmode->icmintent))
638 if (!prs_uint32("mediatype", ps, depth, &devmode->mediatype))
640 if (!prs_uint32("dithertype", ps, depth, &devmode->dithertype))
642 if (!prs_uint32("reserved1", ps, depth, &devmode->reserved1))
644 if (!prs_uint32("reserved2", ps, depth, &devmode->reserved2))
647 /* (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400) */
648 if (devmode->specversion == 0x401) {
649 if (!prs_uint32("panningwidth", ps, depth, &devmode->panningwidth))
651 if (!prs_uint32("panningheight", ps, depth, &devmode->panningheight))
656 /* log an error if we see something else */
658 DEBUG(0,("spoolss_io_devmode: Unknown specversion [0x%x]!\n", devmode->specversion));
659 DEBUG(0,("spoolss_io_devmode: Please report to samba-technical@samba.org\n"));
663 if (devmode->driverextra!=0) {
664 if (UNMARSHALLING(ps)) {
665 devmode->private=(uint8 *)prs_alloc_mem(ps, devmode->driverextra*sizeof(uint8));
666 if(devmode->private == NULL)
668 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode->driverextra));
671 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode->driverextra));
672 if (!prs_uint8s(False, "private", ps, depth,
673 devmode->private, devmode->driverextra))
680 /*******************************************************************
681 Read or write a DEVICEMODE container
682 ********************************************************************/
684 static BOOL spoolss_io_devmode_cont(char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth)
689 prs_debug(ps, depth, desc, "spoolss_io_devmode_cont");
695 if (!prs_uint32("size", ps, depth, &dm_c->size))
698 if (!prs_uint32("devmode_ptr", ps, depth, &dm_c->devmode_ptr))
701 if (dm_c->size==0 || dm_c->devmode_ptr==0) {
702 if (UNMARSHALLING(ps))
703 /* if while reading there is no DEVMODE ... */
708 /* so we have a DEVICEMODE to follow */
709 if (UNMARSHALLING(ps)) {
710 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
711 dm_c->devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE));
712 if(dm_c->devmode == NULL)
716 /* this is bad code, shouldn't be there */
717 if (!prs_uint32("size", ps, depth, &dm_c->size))
720 if (!spoolss_io_devmode(desc, ps, depth, dm_c->devmode))
726 /*******************************************************************
727 ********************************************************************/
729 static BOOL spoolss_io_printer_default(char *desc, PRINTER_DEFAULT *pd, prs_struct *ps, int depth)
734 prs_debug(ps, depth, desc, "spoolss_io_printer_default");
737 if (!prs_uint32("datatype_ptr", ps, depth, &pd->datatype_ptr))
740 if (!smb_io_unistr2("datatype", &pd->datatype, pd->datatype_ptr, ps,depth))
746 if (!spoolss_io_devmode_cont("", &pd->devmode_cont, ps, depth))
752 if (!prs_uint32("access_required", ps, depth, &pd->access_required))
758 /*******************************************************************
760 ********************************************************************/
762 BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
763 const fstring printername,
764 const fstring datatype,
765 uint32 access_required,
766 const fstring clientname,
767 const fstring user_name)
769 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
770 q_u->printername_ptr = (printername!=NULL)?1:0;
771 init_unistr2(&q_u->printername, printername, strlen(printername)+1);
773 q_u->printer_default.datatype_ptr = 0;
775 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
776 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
778 q_u->printer_default.devmode_cont.size=0;
779 q_u->printer_default.devmode_cont.devmode_ptr=0;
780 q_u->printer_default.devmode_cont.devmode=NULL;
781 q_u->printer_default.access_required=access_required;
783 q_u->user_ctr.level=1;
785 q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+10;
786 q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
787 q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
788 q_u->user_ctr.user1.build=1381;
789 q_u->user_ctr.user1.major=2;
790 q_u->user_ctr.user1.minor=0;
791 q_u->user_ctr.user1.processor=0;
792 init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
793 init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
798 /*******************************************************************
800 ********************************************************************/
802 BOOL make_spoolss_q_addprinterex(
804 SPOOL_Q_ADDPRINTEREX *q_u,
805 const char *srv_name,
806 const char* clientname,
807 const char* user_name,
809 PRINTER_INFO_CTR *ctr)
811 DEBUG(5,("make_spoolss_q_addprinterex\n"));
813 if (!ctr) return False;
817 q_u->server_name_ptr = (srv_name!=NULL)?1:0;
818 init_unistr2(&q_u->server_name, srv_name, strlen(srv_name));
822 q_u->info.level = level;
823 q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0;
826 /* init q_u->info.info2 from *info */
827 if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) {
828 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
838 q_u->user_ctr.level=1;
840 q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
841 q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
842 q_u->user_ctr.user1.build=1381;
843 q_u->user_ctr.user1.major=2;
844 q_u->user_ctr.user1.minor=0;
845 q_u->user_ctr.user1.processor=0;
846 init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
847 init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
848 q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len +
849 q_u->user_ctr.user1.client_name.uni_str_len + 2;
854 /*******************************************************************
855 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
856 *******************************************************************/
858 BOOL make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
859 PRINTER_INFO_2 *info)
862 SPOOL_PRINTER_INFO_LEVEL_2 *inf;
864 /* allocate the necessary memory */
865 if (!(inf=(SPOOL_PRINTER_INFO_LEVEL_2*)talloc(mem_ctx, sizeof(SPOOL_PRINTER_INFO_LEVEL_2)))) {
866 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
870 inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
871 inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
872 inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
873 inf->portname_ptr = (info->portname.buffer!=NULL)?1:0;
874 inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0;
875 inf->comment_ptr = (info->comment.buffer!=NULL)?1:0;
876 inf->location_ptr = (info->location.buffer!=NULL)?1:0;
877 inf->devmode_ptr = (info->devmode!=NULL)?1:0;
878 inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0;
879 inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0;
880 inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0;
881 inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0;
882 inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
883 inf->attributes = info->attributes;
884 inf->priority = info->priority;
885 inf->default_priority = info->defaultpriority;
886 inf->starttime = info->starttime;
887 inf->untiltime = info->untiltime;
888 inf->cjobs = info->cjobs;
889 inf->averageppm = info->averageppm;
890 init_unistr2_from_unistr(&inf->servername, &info->servername);
891 init_unistr2_from_unistr(&inf->printername, &info->printername);
892 init_unistr2_from_unistr(&inf->sharename, &info->sharename);
893 init_unistr2_from_unistr(&inf->portname, &info->portname);
894 init_unistr2_from_unistr(&inf->drivername, &info->drivername);
895 init_unistr2_from_unistr(&inf->comment, &info->comment);
896 init_unistr2_from_unistr(&inf->location, &info->location);
897 init_unistr2_from_unistr(&inf->sepfile, &info->sepfile);
898 init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor);
899 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
900 init_unistr2_from_unistr(&inf->parameters, &info->parameters);
901 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
908 /*******************************************************************
910 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
911 ********************************************************************/
913 BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth)
918 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer");
924 if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr))
926 if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth))
932 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
938 /*******************************************************************
940 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
941 * called from spoolss_open_printer_ex (cli_spoolss.c)
942 ********************************************************************/
944 BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth)
946 if (r_u == NULL) return False;
948 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer");
954 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
957 if (!prs_werror("status code", ps, depth, &(r_u->status)))
964 /*******************************************************************
966 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
967 ********************************************************************/
969 BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
974 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
980 if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr))
982 if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth))
988 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
991 if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
993 if (!spool_io_user_level("", &q_u->user_ctr, ps, depth))
999 /*******************************************************************
1000 * write a structure.
1001 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1002 * called from spoolss_open_printer_ex (cli_spoolss.c)
1003 ********************************************************************/
1005 BOOL spoolss_io_r_open_printer_ex(char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth)
1007 if (r_u == NULL) return False;
1009 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex");
1015 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
1018 if (!prs_werror("status code", ps, depth, &(r_u->status)))
1024 /*******************************************************************
1026 ********************************************************************/
1027 BOOL make_spoolss_q_deleteprinterdriver(
1028 TALLOC_CTX *mem_ctx,
1029 SPOOL_Q_DELETEPRINTERDRIVER *q_u,
1035 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1037 q_u->server_ptr = (server!=NULL)?1:0;
1039 /* these must be NULL terminated or else NT4 will
1040 complain about invalid parameters --jerry */
1041 init_unistr2(&q_u->server, server, strlen(server)+1);
1042 init_unistr2(&q_u->arch, arch, strlen(arch)+1);
1043 init_unistr2(&q_u->driver, driver, strlen(driver)+1);
1050 /*******************************************************************
1052 ********************************************************************/
1054 BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
1055 const POLICY_HND *handle,
1056 UNISTR2 *valuename, uint32 size)
1058 if (q_u == NULL) return False;
1060 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1062 q_u->handle = *handle;
1063 copy_unistr2(&q_u->valuename, valuename);
1069 /*******************************************************************
1071 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1072 ********************************************************************/
1074 BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth)
1079 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata");
1084 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1088 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1092 if (!prs_uint32("size", ps, depth, &q_u->size))
1098 /*******************************************************************
1100 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1101 ********************************************************************/
1103 BOOL spoolss_io_q_deleteprinterdata(char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth)
1108 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata");
1113 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1117 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1123 /*******************************************************************
1124 * write a structure.
1125 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1126 ********************************************************************/
1128 BOOL spoolss_io_r_deleteprinterdata(char *desc, SPOOL_R_DELETEPRINTERDATA *r_u, prs_struct *ps, int depth)
1130 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdata");
1132 if(!prs_werror("status", ps, depth, &r_u->status))
1138 /*******************************************************************
1139 * write a structure.
1140 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1141 ********************************************************************/
1143 BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth)
1148 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata");
1153 if (!prs_uint32("type", ps, depth, &r_u->type))
1155 if (!prs_uint32("size", ps, depth, &r_u->size))
1158 if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
1164 if (!prs_uint32("needed", ps, depth, &r_u->needed))
1166 if (!prs_werror("status", ps, depth, &r_u->status))
1172 /*******************************************************************
1174 ********************************************************************/
1176 BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
1178 if (q_u == NULL) return False;
1180 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1182 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
1187 /*******************************************************************
1189 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1190 * called from spoolss_abortprinter (cli_spoolss.c)
1191 ********************************************************************/
1193 BOOL spoolss_io_q_abortprinter(char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth)
1195 if (q_u == NULL) return False;
1197 prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter");
1203 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1209 /*******************************************************************
1210 * write a structure.
1211 * called from spoolss_r_abortprinter (srv_spoolss.c)
1212 ********************************************************************/
1214 BOOL spoolss_io_r_abortprinter(char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth)
1216 prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter");
1218 if(!prs_werror("status", ps, depth, &r_u->status))
1224 /*******************************************************************
1226 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1227 * called from spoolss_deleteprinter (cli_spoolss.c)
1228 ********************************************************************/
1230 BOOL spoolss_io_q_deleteprinter(char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
1232 if (q_u == NULL) return False;
1234 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
1240 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1246 /*******************************************************************
1247 * write a structure.
1248 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1249 * called from spoolss_deleteprinter (cli_spoolss.c)
1250 ********************************************************************/
1252 BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
1254 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
1260 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1262 if (!prs_werror("status", ps, depth, &r_u->status))
1269 /*******************************************************************
1271 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1272 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1273 ********************************************************************/
1275 BOOL spoolss_io_q_deleteprinterdriver(char *desc, SPOOL_Q_DELETEPRINTERDRIVER *q_u, prs_struct *ps, int depth)
1277 if (q_u == NULL) return False;
1279 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriver");
1285 if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
1287 if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
1289 if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth))
1291 if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth))
1299 /*******************************************************************
1300 * write a structure.
1301 ********************************************************************/
1302 BOOL spoolss_io_r_deleteprinterdriver(char *desc, SPOOL_R_DELETEPRINTERDRIVER *r_u, prs_struct *ps, int depth)
1304 if (r_u == NULL) return False;
1306 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriver");
1312 if (!prs_werror("status", ps, depth, &r_u->status))
1320 /*******************************************************************
1322 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1323 * called from spoolss_closeprinter (cli_spoolss.c)
1324 ********************************************************************/
1326 BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
1328 if (q_u == NULL) return False;
1330 prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
1336 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1342 /*******************************************************************
1343 * write a structure.
1344 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1345 * called from spoolss_closeprinter (cli_spoolss.c)
1346 ********************************************************************/
1348 BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth)
1350 prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter");
1356 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1358 if (!prs_werror("status", ps, depth, &r_u->status))
1364 /*******************************************************************
1366 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1367 ********************************************************************/
1369 BOOL spoolss_io_q_startdocprinter(char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth)
1371 if (q_u == NULL) return False;
1373 prs_debug(ps, depth, desc, "spoolss_io_q_startdocprinter");
1379 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1382 if(!smb_io_doc_info_container("",&q_u->doc_info_container, ps, depth))
1388 /*******************************************************************
1389 * write a structure.
1390 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1391 ********************************************************************/
1393 BOOL spoolss_io_r_startdocprinter(char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth)
1395 prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter");
1397 if(!prs_uint32("jobid", ps, depth, &r_u->jobid))
1399 if(!prs_werror("status", ps, depth, &r_u->status))
1405 /*******************************************************************
1407 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1408 ********************************************************************/
1410 BOOL spoolss_io_q_enddocprinter(char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth)
1412 if (q_u == NULL) return False;
1414 prs_debug(ps, depth, desc, "spoolss_io_q_enddocprinter");
1420 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1426 /*******************************************************************
1427 * write a structure.
1428 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1429 ********************************************************************/
1431 BOOL spoolss_io_r_enddocprinter(char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth)
1433 prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter");
1435 if(!prs_werror("status", ps, depth, &r_u->status))
1441 /*******************************************************************
1443 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1444 ********************************************************************/
1446 BOOL spoolss_io_q_startpageprinter(char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth)
1448 if (q_u == NULL) return False;
1450 prs_debug(ps, depth, desc, "spoolss_io_q_startpageprinter");
1456 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1462 /*******************************************************************
1463 * write a structure.
1464 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1465 ********************************************************************/
1467 BOOL spoolss_io_r_startpageprinter(char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth)
1469 prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter");
1471 if(!prs_werror("status", ps, depth, &r_u->status))
1477 /*******************************************************************
1479 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1480 ********************************************************************/
1482 BOOL spoolss_io_q_endpageprinter(char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth)
1484 if (q_u == NULL) return False;
1486 prs_debug(ps, depth, desc, "spoolss_io_q_endpageprinter");
1492 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1498 /*******************************************************************
1499 * write a structure.
1500 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1501 ********************************************************************/
1503 BOOL spoolss_io_r_endpageprinter(char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth)
1505 prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter");
1507 if(!prs_werror("status", ps, depth, &r_u->status))
1513 /*******************************************************************
1515 * called from spoolss_q_writeprinter (srv_spoolss.c)
1516 ********************************************************************/
1518 BOOL spoolss_io_q_writeprinter(char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth)
1520 if (q_u == NULL) return False;
1522 prs_debug(ps, depth, desc, "spoolss_io_q_writeprinter");
1528 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1530 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1533 if (q_u->buffer_size!=0)
1535 if (UNMARSHALLING(ps))
1536 q_u->buffer=(uint8 *)prs_alloc_mem(ps,q_u->buffer_size*sizeof(uint8));
1537 if(q_u->buffer == NULL)
1539 if(!prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size))
1544 if(!prs_uint32("buffer_size2", ps, depth, &q_u->buffer_size2))
1550 /*******************************************************************
1551 * write a structure.
1552 * called from spoolss_r_writeprinter (srv_spoolss.c)
1553 ********************************************************************/
1555 BOOL spoolss_io_r_writeprinter(char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth)
1557 prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter");
1559 if(!prs_uint32("buffer_written", ps, depth, &r_u->buffer_written))
1561 if(!prs_werror("status", ps, depth, &r_u->status))
1567 /*******************************************************************
1569 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1570 ********************************************************************/
1572 BOOL spoolss_io_q_rffpcnex(char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, int depth)
1574 prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex");
1580 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
1582 if(!prs_uint32("flags", ps, depth, &q_u->flags))
1584 if(!prs_uint32("options", ps, depth, &q_u->options))
1586 if(!prs_uint32("localmachine_ptr", ps, depth, &q_u->localmachine_ptr))
1588 if(!smb_io_unistr2("localmachine", &q_u->localmachine, q_u->localmachine_ptr, ps, depth))
1594 if(!prs_uint32("printerlocal", ps, depth, &q_u->printerlocal))
1597 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1600 if (q_u->option_ptr!=0) {
1602 if (UNMARSHALLING(ps))
1603 if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
1606 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1613 /*******************************************************************
1614 * write a structure.
1615 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1616 ********************************************************************/
1618 BOOL spoolss_io_r_rffpcnex(char *desc, SPOOL_R_RFFPCNEX *r_u, prs_struct *ps, int depth)
1620 prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex");
1623 if(!prs_werror("status", ps, depth, &r_u->status))
1629 /*******************************************************************
1631 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1632 ********************************************************************/
1634 BOOL spoolss_io_q_rfnpcnex(char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, int depth)
1636 prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex");
1642 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1645 if(!prs_uint32("change", ps, depth, &q_u->change))
1648 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1651 if (q_u->option_ptr!=0) {
1653 if (UNMARSHALLING(ps))
1654 if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
1657 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1664 /*******************************************************************
1665 * write a structure.
1666 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1667 ********************************************************************/
1669 BOOL spoolss_io_r_rfnpcnex(char *desc, SPOOL_R_RFNPCNEX *r_u, prs_struct *ps, int depth)
1671 prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex");
1677 if (!prs_uint32("info_ptr", ps, depth, &r_u->info_ptr))
1680 if(!smb_io_notify_info("notify info", &r_u->info ,ps,depth))
1685 if(!prs_werror("status", ps, depth, &r_u->status))
1691 /*******************************************************************
1692 * return the length of a uint16 (obvious, but the code is clean)
1693 ********************************************************************/
1695 static uint32 size_of_uint16(uint16 *value)
1697 return (sizeof(*value));
1700 /*******************************************************************
1701 * return the length of a uint32 (obvious, but the code is clean)
1702 ********************************************************************/
1704 static uint32 size_of_uint32(uint32 *value)
1706 return (sizeof(*value));
1709 /*******************************************************************
1710 * return the length of a NTTIME (obvious, but the code is clean)
1711 ********************************************************************/
1713 static uint32 size_of_nttime(NTTIME *value)
1715 return (sizeof(*value));
1718 /*******************************************************************
1719 * return the length of a UNICODE string in number of char, includes:
1720 * - the leading zero
1721 * - the relative pointer size
1722 ********************************************************************/
1724 static uint32 size_of_relative_string(UNISTR *string)
1728 size=str_len_uni(string); /* the string length */
1729 size=size+1; /* add the leading zero */
1730 size=size*2; /* convert in char */
1731 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1732 size += ((4 - (size & 3)) & 3);
1733 size=size+4; /* add the size of the ptr */
1738 /*******************************************************************
1739 * return the length of a uint32 (obvious, but the code is clean)
1740 ********************************************************************/
1742 static uint32 size_of_device_mode(DEVICEMODE *devmode)
1747 return (4+devmode->size+devmode->driverextra);
1750 /*******************************************************************
1751 * return the length of a uint32 (obvious, but the code is clean)
1752 ********************************************************************/
1754 static uint32 size_of_systemtime(SYSTEMTIME *systime)
1759 return (sizeof(SYSTEMTIME) +4);
1762 /*******************************************************************
1763 * write a UNICODE string.
1764 * used by all the RPC structs passing a buffer
1765 ********************************************************************/
1767 static BOOL spoolss_smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
1772 prs_debug(ps, depth, desc, "spoolss_smb_io_unistr");
1775 /* there should be no align here as it can mess up
1776 parsing a NEW_BUFFER->prs */
1782 if (!prs_unistr("unistr", ps, depth, uni))
1788 /*******************************************************************
1789 * write a UNICODE string and its relative pointer.
1790 * used by all the RPC structs passing a buffer
1792 * As I'm a nice guy, I'm forcing myself to explain this code.
1793 * MS did a good job in the overall spoolss code except in some
1794 * functions where they are passing the API buffer directly in the
1795 * RPC request/reply. That's to maintain compatiility at the API level.
1796 * They could have done it the good way the first time.
1798 * So what happen is: the strings are written at the buffer's end,
1799 * in the reverse order of the original structure. Some pointers to
1800 * the strings are also in the buffer. Those are relative to the
1803 * If you don't understand or want to change that function,
1804 * first get in touch with me: jfm@samba.org
1806 ********************************************************************/
1808 static BOOL smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR *string)
1810 prs_struct *ps=&buffer->prs;
1812 if (MARSHALLING(ps)) {
1813 uint32 struct_offset = prs_offset(ps);
1814 uint32 relative_offset;
1816 buffer->string_at_end -= (size_of_relative_string(string) - 4);
1817 if(!prs_set_offset(ps, buffer->string_at_end))
1821 buffer->string_at_end = prs_offset(ps);
1823 /* write the string */
1824 if (!smb_io_unistr(desc, string, ps, depth))
1827 if(!prs_set_offset(ps, struct_offset))
1830 relative_offset=buffer->string_at_end - buffer->struct_start;
1831 /* write its offset */
1832 if (!prs_uint32("offset", ps, depth, &relative_offset))
1838 /* read the offset */
1839 if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end)))
1842 old_offset = prs_offset(ps);
1843 if(!prs_set_offset(ps, buffer->string_at_end+buffer->struct_start))
1846 /* read the string */
1847 if (!spoolss_smb_io_unistr(desc, string, ps, depth))
1850 if(!prs_set_offset(ps, old_offset))
1856 /*******************************************************************
1857 * write a array of UNICODE strings and its relative pointer.
1858 * used by 2 RPC structs
1859 ********************************************************************/
1861 static BOOL smb_io_relarraystr(char *desc, NEW_BUFFER *buffer, int depth, uint16 **string)
1865 prs_struct *ps=&buffer->prs;
1867 if (MARSHALLING(ps)) {
1868 uint32 struct_offset = prs_offset(ps);
1869 uint32 relative_offset;
1876 /* first write the last 0 */
1877 buffer->string_at_end -= 2;
1878 if(!prs_set_offset(ps, buffer->string_at_end))
1881 if(!prs_uint16("leading zero", ps, depth, &zero))
1884 while (p && (*p!=0)) {
1888 /* Yes this should be malloc not talloc. Don't change. */
1890 chaine.buffer = malloc((q-p+1)*sizeof(uint16));
1891 if (chaine.buffer == NULL)
1894 memcpy(chaine.buffer, p, (q-p+1)*sizeof(uint16));
1896 buffer->string_at_end -= (q-p+1)*sizeof(uint16);
1898 if(!prs_set_offset(ps, buffer->string_at_end)) {
1899 SAFE_FREE(chaine.buffer);
1903 /* write the string */
1904 if (!spoolss_smb_io_unistr(desc, &chaine, ps, depth)) {
1905 SAFE_FREE(chaine.buffer);
1911 SAFE_FREE(chaine.buffer);
1914 if(!prs_set_offset(ps, struct_offset))
1917 relative_offset=buffer->string_at_end - buffer->struct_start;
1918 /* write its offset */
1919 if (!prs_uint32("offset", ps, depth, &relative_offset))
1927 uint16 *chaine2=NULL;
1930 size_t realloc_size = 0;
1934 /* read the offset */
1935 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
1938 old_offset = prs_offset(ps);
1939 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
1943 if (!spoolss_smb_io_unistr(desc, &chaine, ps, depth))
1946 l_chaine=str_len_uni(&chaine);
1948 /* we're going to add two more bytes here in case this
1949 is the last string in the array and we need to add
1950 an extra NULL for termination */
1955 realloc_size = (l_chaine2+l_chaine+2)*sizeof(uint16);
1957 /* Yes this should be realloc - it's freed below. JRA */
1959 if((tc2=(uint16 *)Realloc(chaine2, realloc_size)) == NULL) {
1964 memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16));
1965 l_chaine2+=l_chaine+1;
1968 } while(l_chaine!=0);
1970 /* the end should be bould NULL terminated so add
1971 the second one here */
1974 chaine2[l_chaine2] = '\0';
1975 *string=(uint16 *)talloc_memdup(prs_get_mem_context(ps),chaine2,realloc_size);
1979 if(!prs_set_offset(ps, old_offset))
1985 /*******************************************************************
1986 Parse a DEVMODE structure and its relative pointer.
1987 ********************************************************************/
1989 static BOOL smb_io_relsecdesc(char *desc, NEW_BUFFER *buffer, int depth, SEC_DESC **secdesc)
1991 prs_struct *ps= &buffer->prs;
1993 prs_debug(ps, depth, desc, "smb_io_relsecdesc");
1996 if (MARSHALLING(ps)) {
1997 uint32 struct_offset = prs_offset(ps);
1998 uint32 relative_offset;
2001 relative_offset = 0;
2002 if (!prs_uint32("offset", ps, depth, &relative_offset))
2007 if (*secdesc != NULL) {
2008 buffer->string_at_end -= sec_desc_size(*secdesc);
2010 if(!prs_set_offset(ps, buffer->string_at_end))
2012 /* write the secdesc */
2013 if (!sec_io_desc(desc, secdesc, ps, depth))
2016 if(!prs_set_offset(ps, struct_offset))
2020 relative_offset=buffer->string_at_end - buffer->struct_start;
2021 /* write its offset */
2023 if (!prs_uint32("offset", ps, depth, &relative_offset))
2028 /* read the offset */
2029 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
2032 old_offset = prs_offset(ps);
2033 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
2037 if (!sec_io_desc(desc, secdesc, ps, depth))
2040 if(!prs_set_offset(ps, old_offset))
2046 /*******************************************************************
2047 Parse a DEVMODE structure and its relative pointer.
2048 ********************************************************************/
2050 static BOOL smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode)
2052 prs_struct *ps=&buffer->prs;
2054 prs_debug(ps, depth, desc, "smb_io_reldevmode");
2057 if (MARSHALLING(ps)) {
2058 uint32 struct_offset = prs_offset(ps);
2059 uint32 relative_offset;
2061 if (*devmode == NULL) {
2063 if (!prs_uint32("offset", ps, depth, &relative_offset))
2065 DEBUG(8, ("boing, the devmode was NULL\n"));
2070 buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra);
2072 if(!prs_set_offset(ps, buffer->string_at_end))
2075 /* write the DEVMODE */
2076 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2079 if(!prs_set_offset(ps, struct_offset))
2082 relative_offset=buffer->string_at_end - buffer->struct_start;
2083 /* write its offset */
2084 if (!prs_uint32("offset", ps, depth, &relative_offset))
2090 /* read the offset */
2091 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
2094 old_offset = prs_offset(ps);
2095 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
2098 /* read the string */
2099 if((*devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE))) == NULL)
2101 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2104 if(!prs_set_offset(ps, old_offset))
2110 /*******************************************************************
2111 Parse a PRINTER_INFO_0 structure.
2112 ********************************************************************/
2114 BOOL smb_io_printer_info_0(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
2116 prs_struct *ps=&buffer->prs;
2118 prs_debug(ps, depth, desc, "smb_io_printer_info_0");
2121 buffer->struct_start=prs_offset(ps);
2123 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2125 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2128 if(!prs_uint32("cjobs", ps, depth, &info->cjobs))
2130 if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs))
2132 if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes))
2135 if(!prs_uint16("year", ps, depth, &info->year))
2137 if(!prs_uint16("month", ps, depth, &info->month))
2139 if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek))
2141 if(!prs_uint16("day", ps, depth, &info->day))
2143 if(!prs_uint16("hour", ps, depth, &info->hour))
2145 if(!prs_uint16("minute", ps, depth, &info->minute))
2147 if(!prs_uint16("second", ps, depth, &info->second))
2149 if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds))
2152 if(!prs_uint32("global_counter", ps, depth, &info->global_counter))
2154 if(!prs_uint32("total_pages", ps, depth, &info->total_pages))
2157 if(!prs_uint16("major_version", ps, depth, &info->major_version))
2159 if(!prs_uint16("build_version", ps, depth, &info->build_version))
2161 if(!prs_uint32("unknown7", ps, depth, &info->unknown7))
2163 if(!prs_uint32("unknown8", ps, depth, &info->unknown8))
2165 if(!prs_uint32("unknown9", ps, depth, &info->unknown9))
2167 if(!prs_uint32("session_counter", ps, depth, &info->session_counter))
2169 if(!prs_uint32("unknown11", ps, depth, &info->unknown11))
2171 if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors))
2173 if(!prs_uint32("unknown13", ps, depth, &info->unknown13))
2175 if(!prs_uint32("unknown14", ps, depth, &info->unknown14))
2177 if(!prs_uint32("unknown15", ps, depth, &info->unknown15))
2179 if(!prs_uint32("unknown16", ps, depth, &info->unknown16))
2181 if(!prs_uint32("change_id", ps, depth, &info->change_id))
2183 if(!prs_uint32("unknown18", ps, depth, &info->unknown18))
2185 if(!prs_uint32("status" , ps, depth, &info->status))
2187 if(!prs_uint32("unknown20", ps, depth, &info->unknown20))
2189 if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter))
2191 if(!prs_uint16("unknown22", ps, depth, &info->unknown22))
2193 if(!prs_uint16("unknown23", ps, depth, &info->unknown23))
2195 if(!prs_uint16("unknown24", ps, depth, &info->unknown24))
2197 if(!prs_uint16("unknown25", ps, depth, &info->unknown25))
2199 if(!prs_uint16("unknown26", ps, depth, &info->unknown26))
2201 if(!prs_uint16("unknown27", ps, depth, &info->unknown27))
2203 if(!prs_uint16("unknown28", ps, depth, &info->unknown28))
2205 if(!prs_uint16("unknown29", ps, depth, &info->unknown29))
2211 /*******************************************************************
2212 Parse a PRINTER_INFO_1 structure.
2213 ********************************************************************/
2215 BOOL smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
2217 prs_struct *ps=&buffer->prs;
2219 prs_debug(ps, depth, desc, "smb_io_printer_info_1");
2222 buffer->struct_start=prs_offset(ps);
2224 if (!prs_uint32("flags", ps, depth, &info->flags))
2226 if (!smb_io_relstr("description", buffer, depth, &info->description))
2228 if (!smb_io_relstr("name", buffer, depth, &info->name))
2230 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2236 /*******************************************************************
2237 Parse a PRINTER_INFO_2 structure.
2238 ********************************************************************/
2240 BOOL smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
2242 prs_struct *ps=&buffer->prs;
2244 prs_debug(ps, depth, desc, "smb_io_printer_info_2");
2247 buffer->struct_start=prs_offset(ps);
2249 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2251 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2253 if (!smb_io_relstr("sharename", buffer, depth, &info->sharename))
2255 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2257 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2259 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2261 if (!smb_io_relstr("location", buffer, depth, &info->location))
2264 /* NT parses the DEVMODE at the end of the struct */
2265 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2268 if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
2270 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2272 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2274 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2277 if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
2280 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2282 if (!prs_uint32("priority", ps, depth, &info->priority))
2284 if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority))
2286 if (!prs_uint32("starttime", ps, depth, &info->starttime))
2288 if (!prs_uint32("untiltime", ps, depth, &info->untiltime))
2290 if (!prs_uint32("status", ps, depth, &info->status))
2292 if (!prs_uint32("jobs", ps, depth, &info->cjobs))
2294 if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
2298 if (!prs_uint32_post("secdesc_ptr", ps, depth, NULL, sec_offset, info->secdesc ? prs_offset(ps)-buffer->struct_start : 0 ))
2301 if (!sec_io_desc("secdesc", &info->secdesc, ps, depth))
2307 /*******************************************************************
2308 Parse a PRINTER_INFO_3 structure.
2309 ********************************************************************/
2311 BOOL smb_io_printer_info_3(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
2313 prs_struct *ps=&buffer->prs;
2315 prs_debug(ps, depth, desc, "smb_io_printer_info_3");
2318 buffer->struct_start=prs_offset(ps);
2320 if (!prs_uint32("flags", ps, depth, &info->flags))
2322 if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth))
2328 /*******************************************************************
2329 Parse a PRINTER_INFO_4 structure.
2330 ********************************************************************/
2332 BOOL smb_io_printer_info_4(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_4 *info, int depth)
2334 prs_struct *ps=&buffer->prs;
2336 prs_debug(ps, depth, desc, "smb_io_printer_info_4");
2339 buffer->struct_start=prs_offset(ps);
2341 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2343 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2345 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2350 /*******************************************************************
2351 Parse a PRINTER_INFO_5 structure.
2352 ********************************************************************/
2354 BOOL smb_io_printer_info_5(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_5 *info, int depth)
2356 prs_struct *ps=&buffer->prs;
2358 prs_debug(ps, depth, desc, "smb_io_printer_info_5");
2361 buffer->struct_start=prs_offset(ps);
2363 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2365 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2367 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2369 if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout))
2371 if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout))
2376 /*******************************************************************
2377 Parse a PORT_INFO_1 structure.
2378 ********************************************************************/
2380 BOOL smb_io_port_info_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2382 prs_struct *ps=&buffer->prs;
2384 prs_debug(ps, depth, desc, "smb_io_port_info_1");
2387 buffer->struct_start=prs_offset(ps);
2389 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2395 /*******************************************************************
2396 Parse a PORT_INFO_2 structure.
2397 ********************************************************************/
2399 BOOL smb_io_port_info_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2401 prs_struct *ps=&buffer->prs;
2403 prs_debug(ps, depth, desc, "smb_io_port_info_2");
2406 buffer->struct_start=prs_offset(ps);
2408 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2410 if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2412 if (!smb_io_relstr("description", buffer, depth, &info->description))
2414 if (!prs_uint32("port_type", ps, depth, &info->port_type))
2416 if (!prs_uint32("reserved", ps, depth, &info->reserved))
2422 /*******************************************************************
2423 Parse a DRIVER_INFO_1 structure.
2424 ********************************************************************/
2426 BOOL smb_io_printer_driver_info_1(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
2428 prs_struct *ps=&buffer->prs;
2430 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
2433 buffer->struct_start=prs_offset(ps);
2435 if (!smb_io_relstr("name", buffer, depth, &info->name))
2441 /*******************************************************************
2442 Parse a DRIVER_INFO_2 structure.
2443 ********************************************************************/
2445 BOOL smb_io_printer_driver_info_2(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
2447 prs_struct *ps=&buffer->prs;
2449 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
2452 buffer->struct_start=prs_offset(ps);
2454 if (!prs_uint32("version", ps, depth, &info->version))
2456 if (!smb_io_relstr("name", buffer, depth, &info->name))
2458 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2460 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2462 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2464 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2470 /*******************************************************************
2471 Parse a DRIVER_INFO_3 structure.
2472 ********************************************************************/
2474 BOOL smb_io_printer_driver_info_3(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
2476 prs_struct *ps=&buffer->prs;
2478 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
2481 buffer->struct_start=prs_offset(ps);
2483 if (!prs_uint32("version", ps, depth, &info->version))
2485 if (!smb_io_relstr("name", buffer, depth, &info->name))
2487 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2489 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2491 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2493 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2495 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2498 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2501 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2503 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2509 /*******************************************************************
2510 Parse a DRIVER_INFO_6 structure.
2511 ********************************************************************/
2513 BOOL smb_io_printer_driver_info_6(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
2515 prs_struct *ps=&buffer->prs;
2517 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
2520 buffer->struct_start=prs_offset(ps);
2522 if (!prs_uint32("version", ps, depth, &info->version))
2524 if (!smb_io_relstr("name", buffer, depth, &info->name))
2526 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2528 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2530 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2532 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2534 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2537 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2540 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2542 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2545 if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
2548 if (!prs_uint32("date.low", ps, depth, &info->driver_date.low))
2550 if (!prs_uint32("date.high", ps, depth, &info->driver_date.high))
2553 if (!prs_uint32("padding", ps, depth, &info->padding))
2556 if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
2559 if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
2562 if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
2564 if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
2566 if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
2568 if (!smb_io_relstr("provider", buffer, depth, &info->provider))
2574 /*******************************************************************
2575 Parse a JOB_INFO_1 structure.
2576 ********************************************************************/
2578 BOOL smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth)
2580 prs_struct *ps=&buffer->prs;
2582 prs_debug(ps, depth, desc, "smb_io_job_info_1");
2585 buffer->struct_start=prs_offset(ps);
2587 if (!prs_uint32("jobid", ps, depth, &info->jobid))
2589 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2591 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2593 if (!smb_io_relstr("username", buffer, depth, &info->username))
2595 if (!smb_io_relstr("document", buffer, depth, &info->document))
2597 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2599 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2601 if (!prs_uint32("status", ps, depth, &info->status))
2603 if (!prs_uint32("priority", ps, depth, &info->priority))
2605 if (!prs_uint32("position", ps, depth, &info->position))
2607 if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
2609 if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
2611 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
2617 /*******************************************************************
2618 Parse a JOB_INFO_2 structure.
2619 ********************************************************************/
2621 BOOL smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth)
2624 prs_struct *ps=&buffer->prs;
2626 prs_debug(ps, depth, desc, "smb_io_job_info_2");
2629 buffer->struct_start=prs_offset(ps);
2631 if (!prs_uint32("jobid",ps, depth, &info->jobid))
2633 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2635 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2637 if (!smb_io_relstr("username", buffer, depth, &info->username))
2639 if (!smb_io_relstr("document", buffer, depth, &info->document))
2641 if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
2643 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2646 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2648 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2650 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2652 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2654 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2657 /* SEC_DESC sec_desc;*/
2658 if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
2661 if (!prs_uint32("status",ps, depth, &info->status))
2663 if (!prs_uint32("priority",ps, depth, &info->priority))
2665 if (!prs_uint32("position",ps, depth, &info->position))
2667 if (!prs_uint32("starttime",ps, depth, &info->starttime))
2669 if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
2671 if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
2673 if (!prs_uint32("size",ps, depth, &info->size))
2675 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
2677 if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
2679 if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
2685 /*******************************************************************
2686 ********************************************************************/
2688 BOOL smb_io_form_1(char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth)
2690 prs_struct *ps=&buffer->prs;
2692 prs_debug(ps, depth, desc, "smb_io_form_1");
2695 buffer->struct_start=prs_offset(ps);
2697 if (!prs_uint32("flag", ps, depth, &info->flag))
2700 if (!smb_io_relstr("name", buffer, depth, &info->name))
2703 if (!prs_uint32("width", ps, depth, &info->width))
2705 if (!prs_uint32("length", ps, depth, &info->length))
2707 if (!prs_uint32("left", ps, depth, &info->left))
2709 if (!prs_uint32("top", ps, depth, &info->top))
2711 if (!prs_uint32("right", ps, depth, &info->right))
2713 if (!prs_uint32("bottom", ps, depth, &info->bottom))
2719 /*******************************************************************
2720 Read/write a BUFFER struct.
2721 ********************************************************************/
2723 static BOOL spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUFFER **pp_buffer)
2725 NEW_BUFFER *buffer = *pp_buffer;
2727 prs_debug(ps, depth, desc, "spoolss_io_buffer");
2730 if (UNMARSHALLING(ps))
2731 buffer = *pp_buffer = (NEW_BUFFER *)prs_alloc_mem(ps, sizeof(NEW_BUFFER));
2736 if (!prs_uint32("ptr", ps, depth, &buffer->ptr))
2740 if (UNMARSHALLING(ps)) {
2742 buffer->string_at_end=0;
2744 if (buffer->ptr==0) {
2746 * JRA. I'm not sure if the data in here is in big-endian format if
2747 * the client is big-endian. Leave as default (little endian) for now.
2750 if (!prs_init(&buffer->prs, 0, prs_get_mem_context(ps), UNMARSHALL))
2755 if (!prs_uint32("size", ps, depth, &buffer->size))
2759 * JRA. I'm not sure if the data in here is in big-endian format if
2760 * the client is big-endian. Leave as default (little endian) for now.
2763 if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL))
2766 if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size))
2769 if (!prs_set_offset(&buffer->prs, 0))
2772 if (!prs_set_offset(ps, buffer->size+prs_offset(ps)))
2775 buffer->string_at_end=buffer->size;
2783 if (buffer->ptr==0) {
2784 /* We have finished with the data in buffer->prs - free it. */
2785 prs_mem_free(&buffer->prs);
2789 if (!prs_uint32("size", ps, depth, &buffer->size))
2792 if (!prs_append_some_prs_data(ps, &buffer->prs, 0, buffer->size))
2798 /* We have finished with the data in buffer->prs - free it. */
2799 prs_mem_free(&buffer->prs);
2805 /*******************************************************************
2806 move a BUFFER from the query to the reply.
2807 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2808 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2809 Clears the memory to zero also.
2810 ********************************************************************/
2812 void spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest)
2814 prs_switch_type(&src->prs, MARSHALL);
2815 if(!prs_set_offset(&src->prs, 0))
2817 prs_force_dynamic(&src->prs);
2818 prs_mem_clear(&src->prs);
2822 /*******************************************************************
2823 Get the size of a BUFFER struct.
2824 ********************************************************************/
2826 uint32 new_get_buffer_size(NEW_BUFFER *buffer)
2828 return (buffer->size);
2831 /*******************************************************************
2832 Parse a DRIVER_DIRECTORY_1 structure.
2833 ********************************************************************/
2835 BOOL smb_io_driverdir_1(char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
2837 prs_struct *ps=&buffer->prs;
2839 prs_debug(ps, depth, desc, "smb_io_driverdir_1");
2842 buffer->struct_start=prs_offset(ps);
2844 if (!smb_io_unistr(desc, &info->name, ps, depth))
2850 /*******************************************************************
2851 Parse a PORT_INFO_1 structure.
2852 ********************************************************************/
2854 BOOL smb_io_port_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2856 prs_struct *ps=&buffer->prs;
2858 prs_debug(ps, depth, desc, "smb_io_port_1");
2861 buffer->struct_start=prs_offset(ps);
2863 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2869 /*******************************************************************
2870 Parse a PORT_INFO_2 structure.
2871 ********************************************************************/
2873 BOOL smb_io_port_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2875 prs_struct *ps=&buffer->prs;
2877 prs_debug(ps, depth, desc, "smb_io_port_2");
2880 buffer->struct_start=prs_offset(ps);
2882 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2884 if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2886 if(!smb_io_relstr("description", buffer, depth, &info->description))
2888 if(!prs_uint32("port_type", ps, depth, &info->port_type))
2890 if(!prs_uint32("reserved", ps, depth, &info->reserved))
2896 /*******************************************************************
2897 ********************************************************************/
2899 BOOL smb_io_printprocessor_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
2901 prs_struct *ps=&buffer->prs;
2903 prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1");
2906 buffer->struct_start=prs_offset(ps);
2908 if (smb_io_relstr("name", buffer, depth, &info->name))
2914 /*******************************************************************
2915 ********************************************************************/
2917 BOOL smb_io_printprocdatatype_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth)
2919 prs_struct *ps=&buffer->prs;
2921 prs_debug(ps, depth, desc, "smb_io_printprocdatatype_info_1");
2924 buffer->struct_start=prs_offset(ps);
2926 if (smb_io_relstr("name", buffer, depth, &info->name))
2932 /*******************************************************************
2933 ********************************************************************/
2935 BOOL smb_io_printmonitor_info_1(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
2937 prs_struct *ps=&buffer->prs;
2939 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1");
2942 buffer->struct_start=prs_offset(ps);
2944 if (!smb_io_relstr("name", buffer, depth, &info->name))
2950 /*******************************************************************
2951 ********************************************************************/
2953 BOOL smb_io_printmonitor_info_2(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
2955 prs_struct *ps=&buffer->prs;
2957 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
2960 buffer->struct_start=prs_offset(ps);
2962 if (!smb_io_relstr("name", buffer, depth, &info->name))
2964 if (!smb_io_relstr("environment", buffer, depth, &info->environment))
2966 if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
2972 /*******************************************************************
2973 return the size required by a struct in the stream
2974 ********************************************************************/
2976 uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
2980 size+=size_of_relative_string( &info->printername );
2981 size+=size_of_relative_string( &info->servername );
2983 size+=size_of_uint32( &info->cjobs);
2984 size+=size_of_uint32( &info->total_jobs);
2985 size+=size_of_uint32( &info->total_bytes);
2987 size+=size_of_uint16( &info->year);
2988 size+=size_of_uint16( &info->month);
2989 size+=size_of_uint16( &info->dayofweek);
2990 size+=size_of_uint16( &info->day);
2991 size+=size_of_uint16( &info->hour);
2992 size+=size_of_uint16( &info->minute);
2993 size+=size_of_uint16( &info->second);
2994 size+=size_of_uint16( &info->milliseconds);
2996 size+=size_of_uint32( &info->global_counter);
2997 size+=size_of_uint32( &info->total_pages);
2999 size+=size_of_uint16( &info->major_version);
3000 size+=size_of_uint16( &info->build_version);
3002 size+=size_of_uint32( &info->unknown7);
3003 size+=size_of_uint32( &info->unknown8);
3004 size+=size_of_uint32( &info->unknown9);
3005 size+=size_of_uint32( &info->session_counter);
3006 size+=size_of_uint32( &info->unknown11);
3007 size+=size_of_uint32( &info->printer_errors);
3008 size+=size_of_uint32( &info->unknown13);
3009 size+=size_of_uint32( &info->unknown14);
3010 size+=size_of_uint32( &info->unknown15);
3011 size+=size_of_uint32( &info->unknown16);
3012 size+=size_of_uint32( &info->change_id);
3013 size+=size_of_uint32( &info->unknown18);
3014 size+=size_of_uint32( &info->status);
3015 size+=size_of_uint32( &info->unknown20);
3016 size+=size_of_uint32( &info->c_setprinter);
3018 size+=size_of_uint16( &info->unknown22);
3019 size+=size_of_uint16( &info->unknown23);
3020 size+=size_of_uint16( &info->unknown24);
3021 size+=size_of_uint16( &info->unknown25);
3022 size+=size_of_uint16( &info->unknown26);
3023 size+=size_of_uint16( &info->unknown27);
3024 size+=size_of_uint16( &info->unknown28);
3025 size+=size_of_uint16( &info->unknown29);
3030 /*******************************************************************
3031 return the size required by a struct in the stream
3032 ********************************************************************/
3034 uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
3038 size+=size_of_uint32( &info->flags );
3039 size+=size_of_relative_string( &info->description );
3040 size+=size_of_relative_string( &info->name );
3041 size+=size_of_relative_string( &info->comment );
3046 /*******************************************************************
3047 return the size required by a struct in the stream
3048 ********************************************************************/
3050 uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
3055 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3056 size += sec_desc_size( info->secdesc );
3058 size+=size_of_device_mode( info->devmode );
3060 size+=size_of_relative_string( &info->servername );
3061 size+=size_of_relative_string( &info->printername );
3062 size+=size_of_relative_string( &info->sharename );
3063 size+=size_of_relative_string( &info->portname );
3064 size+=size_of_relative_string( &info->drivername );
3065 size+=size_of_relative_string( &info->comment );
3066 size+=size_of_relative_string( &info->location );
3068 size+=size_of_relative_string( &info->sepfile );
3069 size+=size_of_relative_string( &info->printprocessor );
3070 size+=size_of_relative_string( &info->datatype );
3071 size+=size_of_relative_string( &info->parameters );
3073 size+=size_of_uint32( &info->attributes );
3074 size+=size_of_uint32( &info->priority );
3075 size+=size_of_uint32( &info->defaultpriority );
3076 size+=size_of_uint32( &info->starttime );
3077 size+=size_of_uint32( &info->untiltime );
3078 size+=size_of_uint32( &info->status );
3079 size+=size_of_uint32( &info->cjobs );
3080 size+=size_of_uint32( &info->averageppm );
3084 /*******************************************************************
3085 return the size required by a struct in the stream
3086 ********************************************************************/
3088 uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
3092 size+=size_of_relative_string( &info->printername );
3093 size+=size_of_relative_string( &info->servername );
3095 size+=size_of_uint32( &info->attributes );
3099 /*******************************************************************
3100 return the size required by a struct in the stream
3101 ********************************************************************/
3103 uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
3107 size+=size_of_relative_string( &info->printername );
3108 size+=size_of_relative_string( &info->portname );
3110 size+=size_of_uint32( &info->attributes );
3111 size+=size_of_uint32( &info->device_not_selected_timeout );
3112 size+=size_of_uint32( &info->transmission_retry_timeout );
3117 /*******************************************************************
3118 return the size required by a struct in the stream
3119 ********************************************************************/
3121 uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
3123 /* The 4 is for the self relative pointer.. */
3124 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3125 return 4 + (uint32)sec_desc_size( info->secdesc );
3128 /*******************************************************************
3129 return the size required by a struct in the stream
3130 ********************************************************************/
3132 uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
3135 size+=size_of_relative_string( &info->name );
3140 /*******************************************************************
3141 return the size required by a struct in the stream
3142 ********************************************************************/
3144 uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
3147 size+=size_of_uint32( &info->version );
3148 size+=size_of_relative_string( &info->name );
3149 size+=size_of_relative_string( &info->architecture );
3150 size+=size_of_relative_string( &info->driverpath );
3151 size+=size_of_relative_string( &info->datafile );
3152 size+=size_of_relative_string( &info->configfile );
3157 /*******************************************************************
3158 return the size required by a string array.
3159 ********************************************************************/
3161 uint32 spoolss_size_string_array(uint16 *string)
3166 for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
3168 i=i+2; /* to count all chars including the leading zero */
3169 i=2*i; /* because we need the value in bytes */
3170 i=i+4; /* the offset pointer size */
3175 /*******************************************************************
3176 return the size required by a struct in the stream
3177 ********************************************************************/
3179 uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
3183 size+=size_of_uint32( &info->version );
3184 size+=size_of_relative_string( &info->name );
3185 size+=size_of_relative_string( &info->architecture );
3186 size+=size_of_relative_string( &info->driverpath );
3187 size+=size_of_relative_string( &info->datafile );
3188 size+=size_of_relative_string( &info->configfile );
3189 size+=size_of_relative_string( &info->helpfile );
3190 size+=size_of_relative_string( &info->monitorname );
3191 size+=size_of_relative_string( &info->defaultdatatype );
3193 size+=spoolss_size_string_array(info->dependentfiles);
3198 /*******************************************************************
3199 return the size required by a struct in the stream
3200 ********************************************************************/
3202 uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
3206 size+=size_of_uint32( &info->version );
3207 size+=size_of_relative_string( &info->name );
3208 size+=size_of_relative_string( &info->architecture );
3209 size+=size_of_relative_string( &info->driverpath );
3210 size+=size_of_relative_string( &info->datafile );
3211 size+=size_of_relative_string( &info->configfile );
3212 size+=size_of_relative_string( &info->helpfile );
3214 size+=spoolss_size_string_array(info->dependentfiles);
3216 size+=size_of_relative_string( &info->monitorname );
3217 size+=size_of_relative_string( &info->defaultdatatype );
3219 size+=spoolss_size_string_array(info->previousdrivernames);
3221 size+=size_of_nttime(&info->driver_date);
3222 size+=size_of_uint32( &info->padding );
3223 size+=size_of_uint32( &info->driver_version_low );
3224 size+=size_of_uint32( &info->driver_version_high );
3225 size+=size_of_relative_string( &info->mfgname );
3226 size+=size_of_relative_string( &info->oem_url );
3227 size+=size_of_relative_string( &info->hardware_id );
3228 size+=size_of_relative_string( &info->provider );
3233 /*******************************************************************
3234 return the size required by a struct in the stream
3235 ********************************************************************/
3237 uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
3240 size+=size_of_uint32( &info->jobid );
3241 size+=size_of_relative_string( &info->printername );
3242 size+=size_of_relative_string( &info->machinename );
3243 size+=size_of_relative_string( &info->username );
3244 size+=size_of_relative_string( &info->document );
3245 size+=size_of_relative_string( &info->datatype );
3246 size+=size_of_relative_string( &info->text_status );
3247 size+=size_of_uint32( &info->status );
3248 size+=size_of_uint32( &info->priority );
3249 size+=size_of_uint32( &info->position );
3250 size+=size_of_uint32( &info->totalpages );
3251 size+=size_of_uint32( &info->pagesprinted );
3252 size+=size_of_systemtime( &info->submitted );
3257 /*******************************************************************
3258 return the size required by a struct in the stream
3259 ********************************************************************/
3261 uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
3265 size+=4; /* size of sec desc ptr */
3267 size+=size_of_uint32( &info->jobid );
3268 size+=size_of_relative_string( &info->printername );
3269 size+=size_of_relative_string( &info->machinename );
3270 size+=size_of_relative_string( &info->username );
3271 size+=size_of_relative_string( &info->document );
3272 size+=size_of_relative_string( &info->notifyname );
3273 size+=size_of_relative_string( &info->datatype );
3274 size+=size_of_relative_string( &info->printprocessor );
3275 size+=size_of_relative_string( &info->parameters );
3276 size+=size_of_relative_string( &info->drivername );
3277 size+=size_of_device_mode( info->devmode );
3278 size+=size_of_relative_string( &info->text_status );
3279 /* SEC_DESC sec_desc;*/
3280 size+=size_of_uint32( &info->status );
3281 size+=size_of_uint32( &info->priority );
3282 size+=size_of_uint32( &info->position );
3283 size+=size_of_uint32( &info->starttime );
3284 size+=size_of_uint32( &info->untiltime );
3285 size+=size_of_uint32( &info->totalpages );
3286 size+=size_of_uint32( &info->size );
3287 size+=size_of_systemtime( &info->submitted );
3288 size+=size_of_uint32( &info->timeelapsed );
3289 size+=size_of_uint32( &info->pagesprinted );
3294 /*******************************************************************
3295 return the size required by a struct in the stream
3296 ********************************************************************/
3298 uint32 spoolss_size_form_1(FORM_1 *info)
3302 size+=size_of_uint32( &info->flag );
3303 size+=size_of_relative_string( &info->name );
3304 size+=size_of_uint32( &info->width );
3305 size+=size_of_uint32( &info->length );
3306 size+=size_of_uint32( &info->left );
3307 size+=size_of_uint32( &info->top );
3308 size+=size_of_uint32( &info->right );
3309 size+=size_of_uint32( &info->bottom );
3314 /*******************************************************************
3315 return the size required by a struct in the stream
3316 ********************************************************************/
3318 uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
3322 size+=size_of_relative_string( &info->port_name );
3327 /*******************************************************************
3328 return the size required by a struct in the stream
3329 ********************************************************************/
3331 uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info)
3335 size=str_len_uni(&info->name); /* the string length */
3336 size=size+1; /* add the leading zero */
3337 size=size*2; /* convert in char */
3342 /*******************************************************************
3343 return the size required by a struct in the stream
3344 ********************************************************************/
3346 uint32 spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1 *info)
3350 size=str_len_uni(&info->name); /* the string length */
3351 size=size+1; /* add the leading zero */
3352 size=size*2; /* convert in char */
3357 /*******************************************************************
3358 return the size required by a struct in the stream
3359 ********************************************************************/
3361 uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
3365 size+=size_of_relative_string( &info->port_name );
3366 size+=size_of_relative_string( &info->monitor_name );
3367 size+=size_of_relative_string( &info->description );
3369 size+=size_of_uint32( &info->port_type );
3370 size+=size_of_uint32( &info->reserved );
3375 /*******************************************************************
3376 return the size required by a struct in the stream
3377 ********************************************************************/
3379 uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
3382 size+=size_of_relative_string( &info->name );
3387 /*******************************************************************
3388 return the size required by a struct in the stream
3389 ********************************************************************/
3391 uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info)
3394 size+=size_of_relative_string( &info->name );
3399 /*******************************************************************
3400 return the size required by a struct in the stream
3401 ********************************************************************/
3402 uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
3409 /* uint32(offset) + uint32(length) + length) */
3410 size += (size_of_uint32(&p->value_len)*2) + p->value_len;
3411 size += (size_of_uint32(&p->data_len)*2) + p->data_len;
3413 size += size_of_uint32(&p->type);
3418 /*******************************************************************
3419 return the size required by a struct in the stream
3420 ********************************************************************/
3422 uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
3425 size+=size_of_relative_string( &info->name );
3430 /*******************************************************************
3431 return the size required by a struct in the stream
3432 ********************************************************************/
3434 uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
3437 size+=size_of_relative_string( &info->name);
3438 size+=size_of_relative_string( &info->environment);
3439 size+=size_of_relative_string( &info->dll_name);
3444 /*******************************************************************
3446 ********************************************************************/
3448 BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
3449 const POLICY_HND *hnd,
3450 const fstring architecture,
3451 uint32 level, uint32 clientmajor, uint32 clientminor,
3452 NEW_BUFFER *buffer, uint32 offered)
3457 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3459 init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture);
3462 q_u->clientmajorversion=clientmajor;
3463 q_u->clientminorversion=clientminor;
3466 q_u->offered=offered;
3471 /*******************************************************************
3473 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3474 ********************************************************************/
3476 BOOL spoolss_io_q_getprinterdriver2(char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
3478 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
3484 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3486 if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr))
3488 if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth))
3493 if(!prs_uint32("level", ps, depth, &q_u->level))
3496 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3502 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3505 if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion))
3507 if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion))
3513 /*******************************************************************
3515 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3516 ********************************************************************/
3518 BOOL spoolss_io_r_getprinterdriver2(char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
3520 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
3526 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3531 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3533 if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion))
3535 if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
3537 if (!prs_werror("status", ps, depth, &r_u->status))
3543 /*******************************************************************
3545 ********************************************************************/
3547 BOOL make_spoolss_q_enumprinters(
3548 SPOOL_Q_ENUMPRINTERS *q_u,
3558 q_u->servername_ptr = (servername != NULL) ? 1 : 0;
3559 init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
3563 q_u->offered=offered;
3568 /*******************************************************************
3570 ********************************************************************/
3572 BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u,
3573 fstring servername, uint32 level,
3574 NEW_BUFFER *buffer, uint32 offered)
3576 q_u->name_ptr = (servername != NULL) ? 1 : 0;
3577 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
3581 q_u->offered=offered;
3586 /*******************************************************************
3588 * called from spoolss_enumprinters (srv_spoolss.c)
3589 ********************************************************************/
3591 BOOL spoolss_io_q_enumprinters(char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
3593 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
3599 if (!prs_uint32("flags", ps, depth, &q_u->flags))
3601 if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
3604 if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
3609 if (!prs_uint32("level", ps, depth, &q_u->level))
3612 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3617 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3623 /*******************************************************************
3624 Parse a SPOOL_R_ENUMPRINTERS structure.
3625 ********************************************************************/
3627 BOOL spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
3629 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
3635 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3641 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3644 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3647 if (!prs_werror("status", ps, depth, &r_u->status))
3653 /*******************************************************************
3654 * write a structure.
3655 * called from spoolss_r_enum_printers (srv_spoolss.c)
3657 ********************************************************************/
3659 BOOL spoolss_io_r_getprinter(char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
3661 prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
3667 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3673 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3676 if (!prs_werror("status", ps, depth, &r_u->status))
3682 /*******************************************************************
3684 * called from spoolss_getprinter (srv_spoolss.c)
3685 ********************************************************************/
3687 BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
3689 prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
3695 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3697 if (!prs_uint32("level", ps, depth, &q_u->level))
3700 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3705 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3711 /*******************************************************************
3713 ********************************************************************/
3715 BOOL make_spoolss_q_getprinter(
3716 TALLOC_CTX *mem_ctx,
3717 SPOOL_Q_GETPRINTER *q_u,
3718 const POLICY_HND *hnd,
3728 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3732 q_u->offered=offered;
3737 /*******************************************************************
3739 ********************************************************************/
3740 BOOL make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
3741 const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
3745 DEVICEMODE *devmode;
3750 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3753 q_u->info.level = level;
3754 q_u->info.info_ptr = (info != NULL) ? 1 : 0;
3757 /* There's no such thing as a setprinter level 1 */
3760 secdesc = info->printers_2->secdesc;
3761 devmode = info->printers_2->devmode;
3763 make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2);
3764 #if 1 /* JERRY TEST */
3765 q_u->secdesc_ctr = (SEC_DESC_BUF*)malloc(sizeof(SEC_DESC_BUF));
3766 if (!q_u->secdesc_ctr)
3768 q_u->secdesc_ctr->ptr = (secdesc != NULL) ? 1: 0;
3769 q_u->secdesc_ctr->max_len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3770 q_u->secdesc_ctr->len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3771 q_u->secdesc_ctr->sec = secdesc;
3773 q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
3774 q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0;
3775 q_u->devmode_ctr.devmode = devmode;
3777 q_u->secdesc_ctr = NULL;
3779 q_u->devmode_ctr.devmode_ptr = 0;
3780 q_u->devmode_ctr.size = 0;
3781 q_u->devmode_ctr.devmode = NULL;
3785 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
3790 q_u->command = command;
3796 /*******************************************************************
3797 ********************************************************************/
3799 BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
3801 prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
3807 if(!prs_werror("status", ps, depth, &r_u->status))
3813 /*******************************************************************
3814 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3815 ********************************************************************/
3817 BOOL spoolss_io_q_setprinter(char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
3819 uint32 ptr_sec_desc = 0;
3821 prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
3827 if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
3829 if(!prs_uint32("level", ps, depth, &q_u->level))
3832 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
3835 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
3845 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
3850 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
3856 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
3861 /* Parse a NULL security descriptor. This should really
3862 happen inside the sec_io_desc_buf() function. */
3864 prs_debug(ps, depth, "", "sec_io_desc_buf");
3865 if (!prs_uint32("size", ps, depth + 1, &dummy))
3867 if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return
3871 if(!prs_uint32("command", ps, depth, &q_u->command))
3877 /*******************************************************************
3878 ********************************************************************/
3880 BOOL spoolss_io_r_fcpn(char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
3882 prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
3888 if(!prs_werror("status", ps, depth, &r_u->status))
3894 /*******************************************************************
3895 ********************************************************************/
3897 BOOL spoolss_io_q_fcpn(char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
3900 prs_debug(ps, depth, desc, "spoolss_io_q_fcpn");
3906 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3913 /*******************************************************************
3914 ********************************************************************/
3916 BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
3918 prs_debug(ps, depth, desc, "");
3924 if(!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3930 if(!prs_uint32("needed", ps, depth, &r_u->needed))
3933 if(!prs_werror("status", ps, depth, &r_u->status))
3939 /*******************************************************************
3940 ********************************************************************/
3942 BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
3944 prs_debug(ps, depth, desc, "");
3950 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3952 if(!prs_uint32("level", ps, depth, &q_u->level))
3955 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3961 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3967 /*******************************************************************
3968 ********************************************************************/
3970 BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
3972 prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
3978 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3984 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3987 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3990 if (!prs_werror("status", ps, depth, &r_u->status))
3996 /*******************************************************************
3997 ********************************************************************/
3999 BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
4010 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
4011 q_u->firstjob = firstjob;
4012 q_u->numofjobs = numofjobs;
4014 q_u->buffer= buffer;
4015 q_u->offered = offered;
4019 /*******************************************************************
4020 ********************************************************************/
4022 BOOL spoolss_io_q_enumjobs(char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
4024 prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
4030 if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth))
4033 if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
4035 if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
4037 if (!prs_uint32("level", ps, depth, &q_u->level))
4040 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4046 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4052 /*******************************************************************
4053 ********************************************************************/
4055 BOOL spoolss_io_r_schedulejob(char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth)
4057 prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob");
4063 if(!prs_werror("status", ps, depth, &r_u->status))
4069 /*******************************************************************
4070 ********************************************************************/
4072 BOOL spoolss_io_q_schedulejob(char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth)
4074 prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob");
4080 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4082 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4088 /*******************************************************************
4089 ********************************************************************/
4091 BOOL spoolss_io_r_setjob(char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth)
4093 prs_debug(ps, depth, desc, "spoolss_io_r_setjob");
4099 if(!prs_werror("status", ps, depth, &r_u->status))
4105 /*******************************************************************
4106 ********************************************************************/
4108 BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth)
4110 prs_debug(ps, depth, desc, "spoolss_io_q_setjob");
4116 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4118 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4121 * level is usually 0. If (level!=0) then I'm in trouble !
4122 * I will try to generate setjob command with level!=0, one day.
4124 if(!prs_uint32("level", ps, depth, &q_u->level))
4126 if(!prs_uint32("command", ps, depth, &q_u->command))
4132 /*******************************************************************
4133 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4134 ********************************************************************/
4136 BOOL spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
4138 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
4144 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4150 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4153 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4156 if (!prs_werror("status", ps, depth, &r_u->status))
4162 /*******************************************************************
4164 ********************************************************************/
4166 BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
4168 const char *environment,
4170 NEW_BUFFER *buffer, uint32 offered)
4172 init_buf_unistr2(&q_u->name, &q_u->name_ptr, name);
4173 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment);
4177 q_u->offered=offered;
4182 /*******************************************************************
4183 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4184 ********************************************************************/
4186 BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
4189 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
4195 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
4197 if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
4202 if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
4204 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
4209 if (!prs_uint32("level", ps, depth, &q_u->level))
4212 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4218 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4224 /*******************************************************************
4225 ********************************************************************/
4227 BOOL spoolss_io_q_enumforms(char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
4230 prs_debug(ps, depth, desc, "spoolss_io_q_enumforms");
4235 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4237 if (!prs_uint32("level", ps, depth, &q_u->level))
4240 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4245 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4251 /*******************************************************************
4252 ********************************************************************/
4254 BOOL spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
4256 prs_debug(ps, depth, desc, "spoolss_io_r_enumforms");
4262 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4268 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4271 if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
4274 if (!prs_werror("status", ps, depth, &r_u->status))
4280 /*******************************************************************
4281 ********************************************************************/
4283 BOOL spoolss_io_q_getform(char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
4286 prs_debug(ps, depth, desc, "spoolss_io_q_getform");
4291 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4293 if (!smb_io_unistr2("", &q_u->formname,True,ps,depth))
4299 if (!prs_uint32("level", ps, depth, &q_u->level))
4302 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4307 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4313 /*******************************************************************
4314 ********************************************************************/
4316 BOOL spoolss_io_r_getform(char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
4318 prs_debug(ps, depth, desc, "spoolss_io_r_getform");
4324 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4330 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4333 if (!prs_werror("status", ps, depth, &r_u->status))
4339 /*******************************************************************
4340 Parse a SPOOL_R_ENUMPORTS structure.
4341 ********************************************************************/
4343 BOOL spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
4345 prs_debug(ps, depth, desc, "spoolss_io_r_enumports");
4351 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4357 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4360 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4363 if (!prs_werror("status", ps, depth, &r_u->status))
4369 /*******************************************************************
4370 ********************************************************************/
4372 BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
4374 prs_debug(ps, depth, desc, "");
4380 if (!prs_uint32("", ps, depth, &q_u->name_ptr))
4382 if (!smb_io_unistr2("", &q_u->name,True,ps,depth))
4387 if (!prs_uint32("level", ps, depth, &q_u->level))
4390 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4395 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4401 /*******************************************************************
4402 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4403 ********************************************************************/
4405 BOOL spool_io_printer_info_level_1(char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
4407 prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
4413 if(!prs_uint32("flags", ps, depth, &il->flags))
4415 if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr))
4417 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4419 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4422 if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth))
4424 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4426 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4432 /*******************************************************************
4433 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4434 ********************************************************************/
4436 BOOL spool_io_printer_info_level_3(char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
4438 prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
4444 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4450 /*******************************************************************
4451 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4452 ********************************************************************/
4454 BOOL spool_io_printer_info_level_2(char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
4456 prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
4462 if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr))
4464 if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr))
4466 if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr))
4468 if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
4471 if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
4473 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4475 if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr))
4477 if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr))
4479 if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr))
4481 if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr))
4483 if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr))
4485 if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr))
4487 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4490 if(!prs_uint32("attributes", ps, depth, &il->attributes))
4492 if(!prs_uint32("priority", ps, depth, &il->priority))
4494 if(!prs_uint32("default_priority", ps, depth, &il->default_priority))
4496 if(!prs_uint32("starttime", ps, depth, &il->starttime))
4498 if(!prs_uint32("untiltime", ps, depth, &il->untiltime))
4500 if(!prs_uint32("status", ps, depth, &il->status))
4502 if(!prs_uint32("cjobs", ps, depth, &il->cjobs))
4504 if(!prs_uint32("averageppm", ps, depth, &il->averageppm))
4507 if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth))
4509 if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth))
4511 if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth))
4513 if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth))
4515 if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth))
4517 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4519 if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth))
4521 if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth))
4523 if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth))
4525 if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth))
4527 if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth))
4533 /*******************************************************************
4534 ********************************************************************/
4536 BOOL spool_io_printer_info_level(char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
4538 prs_debug(ps, depth, desc, "spool_io_printer_info_level");
4543 if(!prs_uint32("level", ps, depth, &il->level))
4545 if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr))
4548 /* if no struct inside just return */
4549 if (il->info_ptr==0) {
4550 if (UNMARSHALLING(ps)) {
4557 switch (il->level) {
4559 * level 0 is used by setprinter when managing the queue
4560 * (hold, stop, start a queue)
4564 /* DOCUMENT ME!!! What is level 1 used for? */
4567 if (UNMARSHALLING(ps)) {
4568 if ((il->info_1=(SPOOL_PRINTER_INFO_LEVEL_1 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_1))) == NULL)
4571 if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
4576 * level 2 is used by addprinter
4577 * and by setprinter when updating printer's info
4580 if (UNMARSHALLING(ps)) {
4581 if ((il->info_2=(SPOOL_PRINTER_INFO_LEVEL_2 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_2))) == NULL)
4584 if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
4587 /* DOCUMENT ME!!! What is level 3 used for? */
4590 if (UNMARSHALLING(ps)) {
4591 if ((il->info_3=(SPOOL_PRINTER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_3))) == NULL)
4594 if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
4603 /*******************************************************************
4604 ********************************************************************/
4606 BOOL spoolss_io_q_addprinterex(char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
4608 uint32 ptr_sec_desc = 0;
4610 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
4615 if(!prs_uint32("", ps, depth, &q_u->server_name_ptr))
4617 if(!smb_io_unistr2("", &q_u->server_name, q_u->server_name_ptr, ps, depth))
4623 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4626 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
4629 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
4635 switch (q_u->level) {
4637 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
4640 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
4644 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
4649 /* Parse a NULL security descriptor. This should really
4650 happen inside the sec_io_desc_buf() function. */
4652 prs_debug(ps, depth, "", "sec_io_desc_buf");
4653 if (!prs_uint32("size", ps, depth + 1, &dummy))
4655 if (!prs_uint32("ptr", ps, depth + 1, &dummy))
4659 if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
4661 if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
4667 /*******************************************************************
4668 ********************************************************************/
4670 BOOL spoolss_io_r_addprinterex(char *desc, SPOOL_R_ADDPRINTEREX *r_u,
4671 prs_struct *ps, int depth)
4673 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
4676 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
4679 if(!prs_werror("status", ps, depth, &r_u->status))
4685 /*******************************************************************
4686 ********************************************************************/
4688 BOOL spool_io_printer_driver_info_level_3(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
4689 prs_struct *ps, int depth)
4691 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il;
4693 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3");
4697 if (UNMARSHALLING(ps)) {
4698 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4710 if(!prs_uint32("cversion", ps, depth, &il->cversion))
4712 if(!prs_uint32("name", ps, depth, &il->name_ptr))
4714 if(!prs_uint32("environment", ps, depth, &il->environment_ptr))
4716 if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr))
4718 if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr))
4720 if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr))
4722 if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr))
4724 if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr))
4726 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4728 if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize))
4730 if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr))
4736 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4738 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4740 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4742 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4744 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4746 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4748 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4750 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4756 if (il->dependentfiles_ptr)
4757 smb_io_buffer5("", &il->dependentfiles, ps, depth);
4762 /*******************************************************************
4763 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4764 ********************************************************************/
4766 BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
4767 prs_struct *ps, int depth)
4769 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il;
4771 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6");
4775 if (UNMARSHALLING(ps)) {
4776 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6));
4789 /* parse the main elements the packet */
4791 if(!prs_uint32("version", ps, depth, &il->version))
4794 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4797 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4798 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4799 * from W2K CDROM (which uses unidriver). JohnR 010205
4801 if (!il->name_ptr) {
4802 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4803 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4807 if(!prs_uint32("environment_ptr", ps, depth, &il->environment_ptr))
4809 if(!prs_uint32("driverpath_ptr", ps, depth, &il->driverpath_ptr))
4811 if(!prs_uint32("datafile_ptr", ps, depth, &il->datafile_ptr))
4813 if(!prs_uint32("configfile_ptr", ps, depth, &il->configfile_ptr))
4815 if(!prs_uint32("helpfile_ptr", ps, depth, &il->helpfile_ptr))
4817 if(!prs_uint32("monitorname_ptr", ps, depth, &il->monitorname_ptr))
4819 if(!prs_uint32("defaultdatatype_ptr", ps, depth, &il->defaultdatatype_ptr))
4821 if(!prs_uint32("dependentfiles_len", ps, depth, &il->dependentfiles_len))
4823 if(!prs_uint32("dependentfiles_ptr", ps, depth, &il->dependentfiles_ptr))
4825 if(!prs_uint32("previousnames_len", ps, depth, &il->previousnames_len))
4827 if(!prs_uint32("previousnames_ptr", ps, depth, &il->previousnames_ptr))
4829 if(!smb_io_time("driverdate", &il->driverdate, ps, depth))
4831 if(!prs_uint32("dummy4", ps, depth, &il->dummy4))
4833 if(!prs_uint64("driverversion", ps, depth, &il->driverversion))
4835 if(!prs_uint32("mfgname_ptr", ps, depth, &il->mfgname_ptr))
4837 if(!prs_uint32("oemurl_ptr", ps, depth, &il->oemurl_ptr))
4839 if(!prs_uint32("hardwareid_ptr", ps, depth, &il->hardwareid_ptr))
4841 if(!prs_uint32("provider_ptr", ps, depth, &il->provider_ptr))
4844 /* parse the structures in the packet */
4846 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4851 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4856 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4861 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4866 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4871 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4876 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4881 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4885 if (il->dependentfiles_ptr) {
4886 if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth))
4891 if (il->previousnames_ptr) {
4892 if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth))
4897 if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth))
4901 if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth))
4905 if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth))
4909 if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth))
4915 /*******************************************************************
4916 convert a buffer of UNICODE strings null terminated
4917 the buffer is terminated by a NULL
4919 convert to an dos codepage array (null terminated)
4921 dynamically allocate memory
4923 ********************************************************************/
4924 static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
4933 src = (char *)buf5->buffer;
4936 while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
4937 rpcstr_pull(f, src, sizeof(f)-1, -1, 0);
4938 src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
4939 tar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2));
4944 fstrcpy((*ar)[n], f);
4947 fstrcpy((*ar)[n], "");
4955 /*******************************************************************
4956 read a UNICODE array with null terminated strings
4957 and null terminated array
4958 and size of array at beginning
4959 ********************************************************************/
4961 BOOL smb_io_unibuffer(char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
4963 if (buffer==NULL) return False;
4966 buffer->uni_str_len=buffer->uni_max_len;
4968 if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
4971 if(!prs_unistr2(True, "buffer ", ps, depth, buffer))
4977 /*******************************************************************
4978 ********************************************************************/
4980 BOOL spool_io_printer_driver_info_level(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
4982 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
4987 if(!prs_uint32("level", ps, depth, &il->level))
4989 if(!prs_uint32("ptr", ps, depth, &il->ptr))
4995 switch (il->level) {
4997 if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth))
5001 if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth))
5011 /*******************************************************************
5012 init a SPOOL_Q_ADDPRINTERDRIVER struct
5013 ******************************************************************/
5015 BOOL make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
5016 SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name,
5017 uint32 level, PRINTER_DRIVER_CTR *info)
5019 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5021 q_u->server_name_ptr = (srv_name!=NULL)?1:0;
5022 init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)+1);
5026 q_u->info.level = level;
5027 q_u->info.ptr = (info!=NULL)?1:0;
5030 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5032 make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3);
5035 /* info level 6 is supported by WinME and Win2k */
5037 /* WRITEME!! will add later --jerry */
5041 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level));
5048 BOOL make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
5049 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
5050 DRIVER_INFO_3 *info3)
5053 uint16 *ptr = info3->dependentfiles;
5055 BOOL null_char = False;
5056 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf;
5058 if (!(inf=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3*)talloc_zero(mem_ctx, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3))))
5061 inf->cversion = info3->version;
5062 inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
5063 inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
5064 inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
5065 inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
5066 inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
5067 inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
5068 inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
5069 inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
5071 init_unistr2_from_unistr(&inf->name, &info3->name);
5072 init_unistr2_from_unistr(&inf->environment, &info3->architecture);
5073 init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
5074 init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
5075 init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
5076 init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
5077 init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
5078 init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
5085 /* the null_char BOOL is used to help locate
5086 two '\0's back to back */
5101 inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0;
5102 inf->dependentfilessize = len;
5103 if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles))
5109 *spool_drv_info = inf;
5114 /*******************************************************************
5115 make a BUFFER5 struct from a uint16*
5116 ******************************************************************/
5117 BOOL make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src)
5120 buf5->buf_len = len;
5121 if((buf5->buffer=(uint16*)talloc_memdup(mem_ctx, src, sizeof(uint16)*len)) == NULL)
5123 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5130 /*******************************************************************
5131 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5132 ********************************************************************/
5134 BOOL spoolss_io_q_addprinterdriver(char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5136 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
5142 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
5144 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
5149 if(!prs_uint32("info_level", ps, depth, &q_u->level))
5152 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
5158 /*******************************************************************
5159 ********************************************************************/
5161 BOOL spoolss_io_r_addprinterdriver(char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5163 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
5166 if(!prs_werror("status", ps, depth, &q_u->status))
5172 /*******************************************************************
5173 ********************************************************************/
5175 BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
5176 NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc)
5178 NT_PRINTER_DRIVER_INFO_LEVEL_3 *d;
5180 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5184 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3));
5192 d->cversion=uni->cversion;
5194 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5195 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5196 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5197 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5198 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5199 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5200 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5201 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5203 DEBUGADD(8,( "version: %d\n", d->cversion));
5204 DEBUGADD(8,( "name: %s\n", d->name));
5205 DEBUGADD(8,( "environment: %s\n", d->environment));
5206 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5207 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5208 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5209 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5210 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5211 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5213 if (uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5220 /*******************************************************************
5221 ********************************************************************/
5222 BOOL uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *uni,
5223 NT_PRINTER_DRIVER_INFO_LEVEL_6 **asc)
5225 NT_PRINTER_DRIVER_INFO_LEVEL_6 *d;
5227 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5231 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_6 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6));
5239 d->version=uni->version;
5241 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5242 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5243 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5244 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5245 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5246 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5247 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5248 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5250 DEBUGADD(8,( "version: %d\n", d->version));
5251 DEBUGADD(8,( "name: %s\n", d->name));
5252 DEBUGADD(8,( "environment: %s\n", d->environment));
5253 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5254 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5255 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5256 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5257 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5258 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5260 if (!uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5262 if (!uniarray_2_dosarray(&uni->previousnames, &d->previousnames ))
5272 BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
5273 NT_PRINTER_INFO_LEVEL_2 **asc)
5275 NT_PRINTER_INFO_LEVEL_2 *d;
5278 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5279 time_unix=time(NULL);
5282 DEBUGADD(8,("allocating memory\n"));
5284 *asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2));
5289 /* we allocate memory iff called from
5290 * addprinter(ex) so we can do one time stuff here.
5292 (*asc)->setuptime=time_unix;
5295 DEBUGADD(8,("start converting\n"));
5299 d->attributes=uni->attributes;
5300 d->priority=uni->priority;
5301 d->default_priority=uni->default_priority;
5302 d->starttime=uni->starttime;
5303 d->untiltime=uni->untiltime;
5304 d->status=uni->status;
5305 d->cjobs=uni->cjobs;
5307 unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1);
5308 unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1);
5309 unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
5310 unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
5311 unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
5312 unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
5313 unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
5314 unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
5315 unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
5316 unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype)-1);
5317 unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters)-1);
5322 /*******************************************************************
5324 ********************************************************************/
5326 BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u,
5327 fstring servername, fstring env_name, uint32 level,
5328 NEW_BUFFER *buffer, uint32 offered)
5330 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
5331 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name);
5335 q_u->offered=offered;
5340 /*******************************************************************
5341 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5342 ********************************************************************/
5344 BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth)
5346 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir");
5351 if(!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5353 if(!smb_io_unistr2("", &q_u->name, q_u->name_ptr, ps, depth))
5359 if(!prs_uint32("", ps, depth, &q_u->environment_ptr))
5361 if(!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5367 if(!prs_uint32("level", ps, depth, &q_u->level))
5370 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5376 if(!prs_uint32("offered", ps, depth, &q_u->offered))
5382 /*******************************************************************
5383 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5384 ********************************************************************/
5386 BOOL spoolss_io_r_getprinterdriverdir(char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth)
5388 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir");
5394 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5400 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5403 if (!prs_werror("status", ps, depth, &r_u->status))
5409 /*******************************************************************
5410 ********************************************************************/
5412 BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
5414 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
5420 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5426 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5429 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5432 if (!prs_werror("status", ps, depth, &r_u->status))
5438 /*******************************************************************
5439 ********************************************************************/
5441 BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth)
5443 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
5449 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5451 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5457 if (!prs_uint32("", ps, depth, &q_u->environment_ptr))
5459 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5465 if (!prs_uint32("level", ps, depth, &q_u->level))
5468 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5474 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5480 /*******************************************************************
5481 ********************************************************************/
5483 BOOL spoolss_io_q_addprintprocessor(char *desc, SPOOL_Q_ADDPRINTPROCESSOR *q_u, prs_struct *ps, int depth)
5485 prs_debug(ps, depth, desc, "spoolss_io_q_addprintprocessor");
5491 if (!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
5493 if (!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
5498 if (!smb_io_unistr2("environment", &q_u->environment, True, ps, depth))
5503 if (!smb_io_unistr2("path", &q_u->path, True, ps, depth))
5508 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5514 /*******************************************************************
5515 ********************************************************************/
5517 BOOL spoolss_io_r_addprintprocessor(char *desc, SPOOL_R_ADDPRINTPROCESSOR *r_u, prs_struct *ps, int depth)
5519 prs_debug(ps, depth, desc, "spoolss_io_r_addprintproicessor");
5525 if (!prs_werror("status", ps, depth, &r_u->status))
5531 /*******************************************************************
5532 ********************************************************************/
5534 BOOL spoolss_io_r_enumprintprocdatatypes(char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth)
5536 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes");
5542 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5548 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5551 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5554 if (!prs_werror("status", ps, depth, &r_u->status))
5560 /*******************************************************************
5561 ********************************************************************/
5563 BOOL spoolss_io_q_enumprintprocdatatypes(char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth)
5565 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes");
5571 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5573 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5579 if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr))
5581 if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth))
5587 if (!prs_uint32("level", ps, depth, &q_u->level))
5590 if(!spoolss_io_buffer("buffer", ps, depth, &q_u->buffer))
5596 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5602 /*******************************************************************
5603 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5604 ********************************************************************/
5606 BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
5608 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
5614 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5616 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5622 if (!prs_uint32("level", ps, depth, &q_u->level))
5625 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5631 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5637 /*******************************************************************
5638 ********************************************************************/
5640 BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
5642 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
5648 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5654 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5657 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5660 if (!prs_werror("status", ps, depth, &r_u->status))
5666 /*******************************************************************
5667 ********************************************************************/
5669 BOOL spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth)
5671 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata");
5676 if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize))
5679 if(!prs_uint16uni(False, "value", ps, depth, r_u->value, r_u->valuesize ))
5685 if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize))
5688 if(!prs_uint32("type", ps, depth, &r_u->type))
5691 if(!prs_uint32("datasize", ps, depth, &r_u->datasize))
5693 if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize))
5698 if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize))
5700 if(!prs_werror("status", ps, depth, &r_u->status))
5706 /*******************************************************************
5707 ********************************************************************/
5709 BOOL spoolss_io_q_enumprinterdata(char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth)
5711 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata");
5716 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5718 if(!prs_uint32("index", ps, depth, &q_u->index))
5720 if(!prs_uint32("valuesize", ps, depth, &q_u->valuesize))
5722 if(!prs_uint32("datasize", ps, depth, &q_u->datasize))
5728 /*******************************************************************
5729 ********************************************************************/
5731 BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
5732 const POLICY_HND *hnd,
5733 uint32 idx, uint32 valuelen, uint32 datalen)
5735 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5737 q_u->valuesize=valuelen;
5738 q_u->datasize=datalen;
5743 /*******************************************************************
5744 ********************************************************************/
5745 BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, TALLOC_CTX *ctx, const POLICY_HND *hnd,
5746 char* value, char* data)
5750 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5752 init_unistr2(&q_u->value, value, strlen(value)+1);
5754 init_unistr2(&tmp, data, strlen(data)+1);
5755 q_u->max_len = q_u->real_len = tmp.uni_max_len*2;
5756 q_u->data = talloc(ctx, q_u->real_len);
5757 memcpy(q_u->data, tmp.buffer, q_u->real_len);
5761 /*******************************************************************
5762 ********************************************************************/
5764 BOOL spoolss_io_q_setprinterdata(char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
5766 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
5771 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5773 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
5779 if(!prs_uint32("type", ps, depth, &q_u->type))
5782 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
5792 if (UNMARSHALLING(ps))
5793 q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
5794 if(q_u->data == NULL)
5796 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
5804 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
5810 /*******************************************************************
5811 ********************************************************************/
5813 BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
5815 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
5820 if(!prs_werror("status", ps, depth, &r_u->status))
5826 /*******************************************************************
5827 ********************************************************************/
5828 BOOL spoolss_io_q_resetprinter(char *desc, SPOOL_Q_RESETPRINTER *q_u, prs_struct *ps, int depth)
5830 prs_debug(ps, depth, desc, "spoolss_io_q_resetprinter");
5835 if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5838 if (!prs_uint32("datatype_ptr", ps, depth, &q_u->datatype_ptr))
5841 if (q_u->datatype_ptr) {
5842 if (!smb_io_unistr2("datatype", &q_u->datatype, q_u->datatype_ptr?True:False, ps, depth))
5846 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
5853 /*******************************************************************
5854 ********************************************************************/
5855 BOOL spoolss_io_r_resetprinter(char *desc, SPOOL_R_RESETPRINTER *r_u, prs_struct *ps, int depth)
5857 prs_debug(ps, depth, desc, "spoolss_io_r_resetprinter");
5862 if(!prs_werror("status", ps, depth, &r_u->status))
5868 /*******************************************************************
5869 ********************************************************************/
5870 BOOL convert_specific_param(NT_PRINTER_PARAM **param, const UNISTR2 *value,
5871 uint32 type, const uint8 *data, uint32 len)
5873 DEBUG(5,("converting a specific param struct\n"));
5877 *param=(NT_PRINTER_PARAM *)malloc(sizeof(NT_PRINTER_PARAM));
5880 memset((char *)*param, '\0', sizeof(NT_PRINTER_PARAM));
5881 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5883 unistr2_to_ascii((*param)->value, value, sizeof((*param)->value)-1);
5884 (*param)->type = type;
5886 /* le champ data n'est pas NULL termine */
5887 /* on stocke donc la longueur */
5889 (*param)->data_len=len;
5892 (*param)->data=(uint8 *)malloc(len * sizeof(uint8));
5893 if((*param)->data == NULL)
5895 memcpy((*param)->data, data, len);
5898 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param)->value, (*param)->data_len));
5899 dump_data(10, (char *)(*param)->data, (*param)->data_len);
5904 /*******************************************************************
5905 ********************************************************************/
5907 static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth)
5909 prs_debug(ps, depth, desc, "spoolss_io_addform");
5916 if(!prs_uint32("flags", ps, depth, &f->flags))
5918 if(!prs_uint32("name_ptr", ps, depth, &f->name_ptr))
5920 if(!prs_uint32("size_x", ps, depth, &f->size_x))
5922 if(!prs_uint32("size_y", ps, depth, &f->size_y))
5924 if(!prs_uint32("left", ps, depth, &f->left))
5926 if(!prs_uint32("top", ps, depth, &f->top))
5928 if(!prs_uint32("right", ps, depth, &f->right))
5930 if(!prs_uint32("bottom", ps, depth, &f->bottom))
5933 if(!smb_io_unistr2("", &f->name, f->name_ptr, ps, depth))
5940 /*******************************************************************
5941 ********************************************************************/
5943 BOOL spoolss_io_q_deleteform(char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth)
5945 prs_debug(ps, depth, desc, "spoolss_io_q_deleteform");
5950 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5952 if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth))
5958 /*******************************************************************
5959 ********************************************************************/
5961 BOOL spoolss_io_r_deleteform(char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth)
5963 prs_debug(ps, depth, desc, "spoolss_io_r_deleteform");
5968 if(!prs_werror("status", ps, depth, &r_u->status))
5974 /*******************************************************************
5975 ********************************************************************/
5977 BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth)
5979 uint32 useless_ptr=1;
5980 prs_debug(ps, depth, desc, "spoolss_io_q_addform");
5985 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5987 if(!prs_uint32("level", ps, depth, &q_u->level))
5989 if(!prs_uint32("level2", ps, depth, &q_u->level2))
5994 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
5996 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
6003 /*******************************************************************
6004 ********************************************************************/
6006 BOOL spoolss_io_r_addform(char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth)
6008 prs_debug(ps, depth, desc, "spoolss_io_r_addform");
6013 if(!prs_werror("status", ps, depth, &r_u->status))
6019 /*******************************************************************
6020 ********************************************************************/
6022 BOOL spoolss_io_q_setform(char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth)
6024 uint32 useless_ptr=1;
6025 prs_debug(ps, depth, desc, "spoolss_io_q_setform");
6030 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6032 if(!smb_io_unistr2("", &q_u->name, True, ps, depth))
6038 if(!prs_uint32("level", ps, depth, &q_u->level))
6040 if(!prs_uint32("level2", ps, depth, &q_u->level2))
6045 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
6047 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
6054 /*******************************************************************
6055 ********************************************************************/
6057 BOOL spoolss_io_r_setform(char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth)
6059 prs_debug(ps, depth, desc, "spoolss_io_r_setform");
6064 if(!prs_werror("status", ps, depth, &r_u->status))
6070 /*******************************************************************
6071 Parse a SPOOL_R_GETJOB structure.
6072 ********************************************************************/
6074 BOOL spoolss_io_r_getjob(char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
6076 prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
6082 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
6088 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6091 if (!prs_werror("status", ps, depth, &r_u->status))
6097 /*******************************************************************
6098 Parse a SPOOL_Q_GETJOB structure.
6099 ********************************************************************/
6101 BOOL spoolss_io_q_getjob(char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
6103 prs_debug(ps, depth, desc, "");
6109 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6111 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
6113 if(!prs_uint32("level", ps, depth, &q_u->level))
6116 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
6122 if(!prs_uint32("offered", ps, depth, &q_u->offered))
6128 void free_devmode(DEVICEMODE *devmode)
6130 if (devmode!=NULL) {
6131 SAFE_FREE(devmode->private);
6136 void free_printer_info_1(PRINTER_INFO_1 *printer)
6141 void free_printer_info_2(PRINTER_INFO_2 *printer)
6143 if (printer!=NULL) {
6144 free_devmode(printer->devmode);
6145 printer->devmode = NULL;
6150 void free_printer_info_3(PRINTER_INFO_3 *printer)
6155 void free_printer_info_4(PRINTER_INFO_4 *printer)
6160 void free_printer_info_5(PRINTER_INFO_5 *printer)
6165 void free_job_info_2(JOB_INFO_2 *job)
6168 free_devmode(job->devmode);
6171 /*******************************************************************
6173 ********************************************************************/
6175 BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
6176 const fstring string, uint32 printer, uint32 type)
6181 init_unistr2(&q_u->string, string, strlen(string)+1);
6183 q_u->printer=printer;
6192 /*******************************************************************
6193 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6194 ********************************************************************/
6196 BOOL spoolss_io_q_replyopenprinter(char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
6198 prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
6204 if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
6210 if(!prs_uint32("printer", ps, depth, &q_u->printer))
6212 if(!prs_uint32("type", ps, depth, &q_u->type))
6215 if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6217 if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6223 /*******************************************************************
6224 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6225 ********************************************************************/
6227 BOOL spoolss_io_r_replyopenprinter(char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
6229 prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
6235 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6238 if (!prs_werror("status", ps, depth, &r_u->status))
6244 /*******************************************************************
6246 ********************************************************************/
6247 BOOL make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER *q_u, POLICY_HND *hnd,
6248 uint32 condition, uint32 change_id)
6251 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6253 q_u->condition = condition;
6254 q_u->change_id = change_id;
6257 q_u->unknown1 = 0x1;
6258 memset(q_u->unknown2, 0x0, 5);
6259 q_u->unknown2[0] = 0x1;
6264 /*******************************************************************
6265 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6266 ********************************************************************/
6267 BOOL spoolss_io_q_routerreplyprinter (char *desc, SPOOL_Q_ROUTERREPLYPRINTER *q_u, prs_struct *ps, int depth)
6270 prs_debug(ps, depth, desc, "spoolss_io_q_routerreplyprinter");
6276 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6279 if (!prs_uint32("condition", ps, depth, &q_u->condition))
6282 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6285 if (!prs_uint32("change_id", ps, depth, &q_u->change_id))
6288 if (!prs_uint8s(False, "private", ps, depth, q_u->unknown2, 5))
6294 /*******************************************************************
6295 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6296 ********************************************************************/
6297 BOOL spoolss_io_r_routerreplyprinter (char *desc, SPOOL_R_ROUTERREPLYPRINTER *r_u, prs_struct *ps, int depth)
6299 prs_debug(ps, depth, desc, "spoolss_io_r_routerreplyprinter");
6305 if (!prs_werror("status", ps, depth, &r_u->status))
6311 /*******************************************************************
6313 ********************************************************************/
6315 BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd)
6320 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6325 /*******************************************************************
6326 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6327 ********************************************************************/
6329 BOOL spoolss_io_q_replycloseprinter(char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth)
6331 prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
6337 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6343 /*******************************************************************
6344 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6345 ********************************************************************/
6347 BOOL spoolss_io_r_replycloseprinter(char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth)
6349 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
6355 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6358 if (!prs_werror("status", ps, depth, &r_u->status))
6364 #if 0 /* JERRY - not currently used but could be :-) */
6366 /*******************************************************************
6367 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6368 ******************************************************************/
6369 static BOOL copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA *dst,
6370 SPOOL_NOTIFY_INFO_DATA *src, int n)
6374 memcpy(dst, src, sizeof(SPOOL_NOTIFY_INFO_DATA)*n);
6376 for (i=0; i<n; i++) {
6380 if (src->size != POINTER)
6382 len = src->notify_data.data.length;
6383 s = malloc(sizeof(uint16)*len);
6385 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6389 memcpy(s, src->notify_data.data.string, len*2);
6390 dst->notify_data.data.string = s;
6396 /*******************************************************************
6397 Deep copy a SPOOL_NOTIFY_INFO structure
6398 ******************************************************************/
6399 static BOOL copy_spool_notify_info(SPOOL_NOTIFY_INFO *dst, SPOOL_NOTIFY_INFO *src)
6402 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6406 dst->version = src->version;
6407 dst->flags = src->flags;
6408 dst->count = src->count;
6412 dst->data = malloc(dst->count * sizeof(SPOOL_NOTIFY_INFO_DATA));
6414 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6417 if (dst->data == NULL) {
6418 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6423 return (copy_spool_notify_info_data(dst->data, src->data, src->count));
6430 /*******************************************************************
6432 ********************************************************************/
6434 BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
6435 uint32 change_low, uint32 change_high,
6436 SPOOL_NOTIFY_INFO *info)
6441 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6443 q_u->change_low=change_low;
6444 q_u->change_high=change_high;
6449 q_u->info_ptr=0xaddee11e;
6451 q_u->info.version=2;
6454 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6456 q_u->info.version = info->version;
6457 q_u->info.flags = info->flags;
6458 q_u->info.count = info->count;
6459 /* pointer field - be careful! */
6460 q_u->info.data = info->data;
6463 q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
6470 /*******************************************************************
6471 Parse a SPOOL_Q_REPLY_RRPCN structure.
6472 ********************************************************************/
6474 BOOL spoolss_io_q_reply_rrpcn(char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
6476 prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
6482 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6485 if (!prs_uint32("change_low", ps, depth, &q_u->change_low))
6488 if (!prs_uint32("change_high", ps, depth, &q_u->change_high))
6491 if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6494 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6497 if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr))
6500 if(q_u->info_ptr!=0)
6501 if(!smb_io_notify_info(desc, &q_u->info, ps, depth))
6507 /*******************************************************************
6508 Parse a SPOOL_R_REPLY_RRPCN structure.
6509 ********************************************************************/
6511 BOOL spoolss_io_r_reply_rrpcn(char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth)
6513 prs_debug(ps, depth, desc, "spoolss_io_r_reply_rrpcn");
6519 if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0))
6522 if (!prs_werror("status", ps, depth, &r_u->status))
6528 /*******************************************************************
6530 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6531 ********************************************************************/
6533 BOOL spoolss_io_q_getprinterdataex(char *desc, SPOOL_Q_GETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6538 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdataex");
6543 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6547 if (!smb_io_unistr2("keyname", &q_u->keyname,True,ps,depth))
6551 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
6555 if (!prs_uint32("size", ps, depth, &q_u->size))
6561 /*******************************************************************
6562 * write a structure.
6563 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6564 ********************************************************************/
6566 BOOL spoolss_io_r_getprinterdataex(char *desc, SPOOL_R_GETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6571 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdataex");
6576 if (!prs_uint32("type", ps, depth, &r_u->type))
6578 if (!prs_uint32("size", ps, depth, &r_u->size))
6581 if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
6587 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6589 if (!prs_werror("status", ps, depth, &r_u->status))
6595 /*******************************************************************
6597 ********************************************************************/
6599 BOOL spoolss_io_q_setprinterdataex(char *desc, SPOOL_Q_SETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6601 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdataex");
6606 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6608 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6614 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
6620 if(!prs_uint32("type", ps, depth, &q_u->type))
6623 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
6633 if (UNMARSHALLING(ps))
6634 q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
6635 if(q_u->data == NULL)
6637 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
6645 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
6651 /*******************************************************************
6652 * write a structure.
6653 ********************************************************************/
6655 BOOL spoolss_io_r_setprinterdataex(char *desc, SPOOL_R_SETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6657 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdataex");
6662 if(!prs_werror("status", ps, depth, &r_u->status))
6669 /*******************************************************************
6671 ********************************************************************/
6673 BOOL spoolss_io_q_enumprinterkey(char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth)
6675 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterkey");
6680 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6683 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6689 if(!prs_uint32("size", ps, depth, &q_u->size))
6695 /*******************************************************************
6696 * write a structure.
6697 ********************************************************************/
6699 BOOL spoolss_io_r_enumprinterkey(char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth)
6701 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterkey");
6707 if (!smb_io_buffer5("", &r_u->keys, ps, depth))
6713 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6716 if(!prs_werror("status", ps, depth, &r_u->status))
6723 /*******************************************************************
6725 ********************************************************************/
6727 BOOL spoolss_io_q_enumprinterdataex(char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6729 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdataex");
6734 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6737 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6743 if(!prs_uint32("size", ps, depth, &q_u->size))
6749 /*******************************************************************
6750 ********************************************************************/
6751 static BOOL spoolss_io_printer_enum_values_ctr(char *desc, prs_struct *ps,
6752 PRINTER_ENUM_VALUES_CTR *ctr, int depth)
6755 uint32 valuename_offset,
6758 const uint32 basic_unit = 20; /* size of static portion of enum_values */
6760 prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr");
6763 if (!prs_uint32("size", ps, depth, &ctr->size))
6766 /* offset data begins at 20 bytes per structure * size_of_array.
6767 Don't forget the uint32 at the beginning */
6769 current_offset = basic_unit * ctr->size_of_array;
6771 /* first loop to write basic enum_value information */
6773 for (i=0; i<ctr->size_of_array; i++)
6775 valuename_offset = current_offset;
6776 if (!prs_uint32("valuename_offset", ps, depth, &valuename_offset))
6779 if (!prs_uint32("value_len", ps, depth, &ctr->values[i].value_len))
6782 if (!prs_uint32("type", ps, depth, &ctr->values[i].type))
6785 data_offset = ctr->values[i].value_len + valuename_offset;
6786 if (!prs_uint32("data_offset", ps, depth, &data_offset))
6789 if (!prs_uint32("data_len", ps, depth, &ctr->values[i].data_len))
6792 current_offset = data_offset + ctr->values[i].data_len - basic_unit;
6795 /* loop #2 for writing the dynamically size objects
6796 while viewing conversations between Win2k -> Win2k,
6797 4-byte alignment does not seem to matter here --jerry */
6799 for (i=0; i<ctr->size_of_array; i++)
6802 if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
6805 if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len))
6815 /*******************************************************************
6816 * write a structure.
6817 ********************************************************************/
6819 BOOL spoolss_io_r_enumprinterdataex(char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6821 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdataex");
6827 if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth ))
6833 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6836 if(!prs_uint32("returned", ps, depth, &r_u->returned))
6839 if(!prs_werror("status", ps, depth, &r_u->status))
6846 /*******************************************************************
6847 * write a structure.
6848 ********************************************************************/
6851 uint32 GetPrintProcessorDirectory(
6853 [in] unistr2 *environment,
6855 [in,out] NEW_BUFFER buffer,
6856 [in] uint32 offered,
6857 [out] uint32 needed,
6858 [out] uint32 returned
6863 BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, NEW_BUFFER *buffer, uint32 offered)
6865 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
6867 init_unistr2(&q_u->name, name, strlen(name)+1);
6868 init_unistr2(&q_u->environment, environment, strlen(environment)+1);
6872 q_u->buffer = buffer;
6873 q_u->offered = offered;
6878 BOOL spoolss_io_q_getprintprocessordirectory(char *desc, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, prs_struct *ps, int depth)
6882 prs_debug(ps, depth, desc, "spoolss_io_q_getprintprocessordirectory");
6888 if (!prs_uint32("ptr", ps, depth, &ptr))
6892 if(!smb_io_unistr2("name", &q_u->name, True, ps, depth))
6899 if (!prs_uint32("ptr", ps, depth, &ptr))
6903 if(!smb_io_unistr2("environment", &q_u->environment, True,
6911 if(!prs_uint32("level", ps, depth, &q_u->level))
6914 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
6920 if(!prs_uint32("offered", ps, depth, &q_u->offered))
6926 /*******************************************************************
6927 * write a structure.
6928 ********************************************************************/
6930 BOOL spoolss_io_r_getprintprocessordirectory(char *desc, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u, prs_struct *ps, int depth)
6932 prs_debug(ps, depth, desc, "spoolss_io_r_getprintprocessordirectory");
6938 if(!spoolss_io_buffer("", ps, depth, &r_u->buffer))
6944 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6947 if(!prs_werror("status", ps, depth, &r_u->status))
6953 BOOL smb_io_printprocessordirectory_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth)
6955 prs_struct *ps=&buffer->prs;
6957 prs_debug(ps, depth, desc, "smb_io_printprocessordirectory_1");
6960 buffer->struct_start=prs_offset(ps);
6962 if (!smb_io_unistr(desc, &info->name, ps, depth))
6968 /*******************************************************************
6970 ********************************************************************/
6972 BOOL make_spoolss_q_addform(SPOOL_Q_ADDFORM *q_u, POLICY_HND *handle,
6973 int level, FORM *form)
6975 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
6977 q_u->level2 = level;
6978 memcpy(&q_u->form, form, sizeof(FORM));
6983 /*******************************************************************
6985 ********************************************************************/
6987 BOOL make_spoolss_q_setform(SPOOL_Q_SETFORM *q_u, POLICY_HND *handle,
6988 int level, char *form_name, FORM *form)
6990 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
6992 q_u->level2 = level;
6993 memcpy(&q_u->form, form, sizeof(FORM));
6994 init_unistr2(&q_u->name, form_name, strlen(form_name) + 1);
6999 /*******************************************************************
7001 ********************************************************************/
7003 BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle, char *form)
7005 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7006 init_unistr2(&q_u->name, form, strlen(form) + 1);
7010 /*******************************************************************
7012 ********************************************************************/
7014 BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle,
7015 char *formname, uint32 level, NEW_BUFFER *buffer,
7018 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7020 init_unistr2(&q_u->formname, formname, strlen(formname) + 1);
7022 q_u->offered=offered;
7027 /*******************************************************************
7029 ********************************************************************/
7031 BOOL make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
7032 uint32 level, NEW_BUFFER *buffer,
7035 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7038 q_u->offered=offered;