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 */
633 if (!prs_uint32("icmmethod", ps, depth, &devmode->icmmethod))
635 if (!prs_uint32("icmintent", ps, depth, &devmode->icmintent))
637 if (!prs_uint32("mediatype", ps, depth, &devmode->mediatype))
639 if (!prs_uint32("dithertype", ps, depth, &devmode->dithertype))
641 if (!prs_uint32("reserved1", ps, depth, &devmode->reserved1))
643 if (!prs_uint32("reserved2", ps, depth, &devmode->reserved2))
645 if (!prs_uint32("panningwidth", ps, depth, &devmode->panningwidth))
647 if (!prs_uint32("panningheight", ps, depth, &devmode->panningheight))
651 /* log an error if we see something else */
653 DEBUG(0,("spoolss_io_devmode: Unknown specversion [0x%x]!\n", devmode->specversion));
654 DEBUG(0,("spoolss_io_devmode: Please report to samba-technical@samba.org\n"));
658 if (devmode->driverextra!=0) {
659 if (UNMARSHALLING(ps)) {
660 devmode->private=(uint8 *)prs_alloc_mem(ps, devmode->driverextra*sizeof(uint8));
661 if(devmode->private == NULL)
663 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode->driverextra));
666 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode->driverextra));
667 if (!prs_uint8s(False, "private", ps, depth,
668 devmode->private, devmode->driverextra))
675 /*******************************************************************
676 Read or write a DEVICEMODE container
677 ********************************************************************/
679 static BOOL spoolss_io_devmode_cont(char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth)
684 prs_debug(ps, depth, desc, "spoolss_io_devmode_cont");
690 if (!prs_uint32("size", ps, depth, &dm_c->size))
693 if (!prs_uint32("devmode_ptr", ps, depth, &dm_c->devmode_ptr))
696 if (dm_c->size==0 || dm_c->devmode_ptr==0) {
697 if (UNMARSHALLING(ps))
698 /* if while reading there is no DEVMODE ... */
703 /* so we have a DEVICEMODE to follow */
704 if (UNMARSHALLING(ps)) {
705 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
706 dm_c->devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE));
707 if(dm_c->devmode == NULL)
711 /* this is bad code, shouldn't be there */
712 if (!prs_uint32("size", ps, depth, &dm_c->size))
715 if (!spoolss_io_devmode(desc, ps, depth, dm_c->devmode))
721 /*******************************************************************
722 ********************************************************************/
724 static BOOL spoolss_io_printer_default(char *desc, PRINTER_DEFAULT *pd, prs_struct *ps, int depth)
729 prs_debug(ps, depth, desc, "spoolss_io_printer_default");
732 if (!prs_uint32("datatype_ptr", ps, depth, &pd->datatype_ptr))
735 if (!smb_io_unistr2("datatype", &pd->datatype, pd->datatype_ptr, ps,depth))
741 if (!spoolss_io_devmode_cont("", &pd->devmode_cont, ps, depth))
747 if (!prs_uint32("access_required", ps, depth, &pd->access_required))
753 /*******************************************************************
755 ********************************************************************/
757 BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
758 const fstring printername,
759 const fstring datatype,
760 uint32 access_required,
761 const fstring clientname,
762 const fstring user_name)
764 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
765 q_u->printername_ptr = (printername!=NULL)?1:0;
766 init_unistr2(&q_u->printername, printername, strlen(printername)+1);
768 q_u->printer_default.datatype_ptr = 0;
770 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
771 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
773 q_u->printer_default.devmode_cont.size=0;
774 q_u->printer_default.devmode_cont.devmode_ptr=0;
775 q_u->printer_default.devmode_cont.devmode=NULL;
776 q_u->printer_default.access_required=access_required;
778 q_u->user_ctr.level=1;
780 q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+10;
781 q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
782 q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
783 q_u->user_ctr.user1.build=1381;
784 q_u->user_ctr.user1.major=2;
785 q_u->user_ctr.user1.minor=0;
786 q_u->user_ctr.user1.processor=0;
787 init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
788 init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
793 /*******************************************************************
795 ********************************************************************/
797 BOOL make_spoolss_q_addprinterex(
799 SPOOL_Q_ADDPRINTEREX *q_u,
800 const char *srv_name,
801 const char* clientname,
802 const char* user_name,
804 PRINTER_INFO_CTR *ctr)
806 DEBUG(5,("make_spoolss_q_addprinterex\n"));
808 if (!ctr) return False;
812 q_u->server_name_ptr = (srv_name!=NULL)?1:0;
813 init_unistr2(&q_u->server_name, srv_name, strlen(srv_name));
817 q_u->info.level = level;
818 q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0;
821 /* init q_u->info.info2 from *info */
822 if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) {
823 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
833 q_u->user_ctr.level=1;
835 q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
836 q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
837 q_u->user_ctr.user1.build=1381;
838 q_u->user_ctr.user1.major=2;
839 q_u->user_ctr.user1.minor=0;
840 q_u->user_ctr.user1.processor=0;
841 init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
842 init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
843 q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len +
844 q_u->user_ctr.user1.client_name.uni_str_len + 2;
849 /*******************************************************************
850 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
851 *******************************************************************/
853 BOOL make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
854 PRINTER_INFO_2 *info)
857 SPOOL_PRINTER_INFO_LEVEL_2 *inf;
859 /* allocate the necessary memory */
860 if (!(inf=(SPOOL_PRINTER_INFO_LEVEL_2*)talloc(mem_ctx, sizeof(SPOOL_PRINTER_INFO_LEVEL_2)))) {
861 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
865 inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
866 inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
867 inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
868 inf->portname_ptr = (info->portname.buffer!=NULL)?1:0;
869 inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0;
870 inf->comment_ptr = (info->comment.buffer!=NULL)?1:0;
871 inf->location_ptr = (info->location.buffer!=NULL)?1:0;
872 inf->devmode_ptr = (info->devmode!=NULL)?1:0;
873 inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0;
874 inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0;
875 inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0;
876 inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0;
877 inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
878 inf->attributes = info->attributes;
879 inf->priority = info->priority;
880 inf->default_priority = info->defaultpriority;
881 inf->starttime = info->starttime;
882 inf->untiltime = info->untiltime;
883 inf->cjobs = info->cjobs;
884 inf->averageppm = info->averageppm;
885 init_unistr2_from_unistr(&inf->servername, &info->servername);
886 init_unistr2_from_unistr(&inf->printername, &info->printername);
887 init_unistr2_from_unistr(&inf->sharename, &info->sharename);
888 init_unistr2_from_unistr(&inf->portname, &info->portname);
889 init_unistr2_from_unistr(&inf->drivername, &info->drivername);
890 init_unistr2_from_unistr(&inf->comment, &info->comment);
891 init_unistr2_from_unistr(&inf->location, &info->location);
892 init_unistr2_from_unistr(&inf->sepfile, &info->sepfile);
893 init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor);
894 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
895 init_unistr2_from_unistr(&inf->parameters, &info->parameters);
896 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
903 /*******************************************************************
905 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
906 ********************************************************************/
908 BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth)
913 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer");
919 if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr))
921 if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth))
927 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
933 /*******************************************************************
935 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
936 * called from spoolss_open_printer_ex (cli_spoolss.c)
937 ********************************************************************/
939 BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth)
941 if (r_u == NULL) return False;
943 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer");
949 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
952 if (!prs_werror("status code", ps, depth, &(r_u->status)))
959 /*******************************************************************
961 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
962 ********************************************************************/
964 BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
969 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
975 if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr))
977 if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth))
983 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
986 if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
988 if (!spool_io_user_level("", &q_u->user_ctr, ps, depth))
994 /*******************************************************************
996 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
997 * called from spoolss_open_printer_ex (cli_spoolss.c)
998 ********************************************************************/
1000 BOOL spoolss_io_r_open_printer_ex(char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth)
1002 if (r_u == NULL) return False;
1004 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex");
1010 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
1013 if (!prs_werror("status code", ps, depth, &(r_u->status)))
1019 /*******************************************************************
1021 ********************************************************************/
1022 BOOL make_spoolss_q_deleteprinterdriver(
1023 TALLOC_CTX *mem_ctx,
1024 SPOOL_Q_DELETEPRINTERDRIVER *q_u,
1030 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1032 q_u->server_ptr = (server!=NULL)?1:0;
1034 /* these must be NULL terminated or else NT4 will
1035 complain about invalid parameters --jerry */
1036 init_unistr2(&q_u->server, server, strlen(server)+1);
1037 init_unistr2(&q_u->arch, arch, strlen(arch)+1);
1038 init_unistr2(&q_u->driver, driver, strlen(driver)+1);
1045 /*******************************************************************
1047 ********************************************************************/
1049 BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
1050 const POLICY_HND *handle,
1051 UNISTR2 *valuename, uint32 size)
1053 if (q_u == NULL) return False;
1055 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1057 q_u->handle = *handle;
1058 copy_unistr2(&q_u->valuename, valuename);
1064 /*******************************************************************
1066 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1067 ********************************************************************/
1069 BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth)
1074 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata");
1079 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1083 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1087 if (!prs_uint32("size", ps, depth, &q_u->size))
1093 /*******************************************************************
1095 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1096 ********************************************************************/
1098 BOOL spoolss_io_q_deleteprinterdata(char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth)
1103 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata");
1108 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1112 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1118 /*******************************************************************
1119 * write a structure.
1120 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1121 ********************************************************************/
1123 BOOL spoolss_io_r_deleteprinterdata(char *desc, SPOOL_R_DELETEPRINTERDATA *r_u, prs_struct *ps, int depth)
1125 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdata");
1127 if(!prs_werror("status", ps, depth, &r_u->status))
1133 /*******************************************************************
1134 * write a structure.
1135 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1136 ********************************************************************/
1138 BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth)
1143 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata");
1148 if (!prs_uint32("type", ps, depth, &r_u->type))
1150 if (!prs_uint32("size", ps, depth, &r_u->size))
1153 if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
1159 if (!prs_uint32("needed", ps, depth, &r_u->needed))
1161 if (!prs_werror("status", ps, depth, &r_u->status))
1167 /*******************************************************************
1169 ********************************************************************/
1171 BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
1173 if (q_u == NULL) return False;
1175 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1177 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
1182 /*******************************************************************
1184 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1185 * called from spoolss_abortprinter (cli_spoolss.c)
1186 ********************************************************************/
1188 BOOL spoolss_io_q_abortprinter(char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth)
1190 if (q_u == NULL) return False;
1192 prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter");
1198 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1204 /*******************************************************************
1205 * write a structure.
1206 * called from spoolss_r_abortprinter (srv_spoolss.c)
1207 ********************************************************************/
1209 BOOL spoolss_io_r_abortprinter(char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth)
1211 prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter");
1213 if(!prs_werror("status", ps, depth, &r_u->status))
1219 /*******************************************************************
1221 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1222 * called from spoolss_deleteprinter (cli_spoolss.c)
1223 ********************************************************************/
1225 BOOL spoolss_io_q_deleteprinter(char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
1227 if (q_u == NULL) return False;
1229 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
1235 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1241 /*******************************************************************
1242 * write a structure.
1243 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1244 * called from spoolss_deleteprinter (cli_spoolss.c)
1245 ********************************************************************/
1247 BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
1249 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
1255 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1257 if (!prs_werror("status", ps, depth, &r_u->status))
1264 /*******************************************************************
1266 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1267 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1268 ********************************************************************/
1270 BOOL spoolss_io_q_deleteprinterdriver(char *desc, SPOOL_Q_DELETEPRINTERDRIVER *q_u, prs_struct *ps, int depth)
1272 if (q_u == NULL) return False;
1274 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriver");
1280 if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
1282 if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
1284 if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth))
1286 if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth))
1294 /*******************************************************************
1295 * write a structure.
1296 ********************************************************************/
1297 BOOL spoolss_io_r_deleteprinterdriver(char *desc, SPOOL_R_DELETEPRINTERDRIVER *r_u, prs_struct *ps, int depth)
1299 if (r_u == NULL) return False;
1301 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriver");
1307 if (!prs_werror("status", ps, depth, &r_u->status))
1315 /*******************************************************************
1317 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1318 * called from spoolss_closeprinter (cli_spoolss.c)
1319 ********************************************************************/
1321 BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
1323 if (q_u == NULL) return False;
1325 prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
1331 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1337 /*******************************************************************
1338 * write a structure.
1339 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1340 * called from spoolss_closeprinter (cli_spoolss.c)
1341 ********************************************************************/
1343 BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth)
1345 prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter");
1351 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1353 if (!prs_werror("status", ps, depth, &r_u->status))
1359 /*******************************************************************
1361 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1362 ********************************************************************/
1364 BOOL spoolss_io_q_startdocprinter(char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth)
1366 if (q_u == NULL) return False;
1368 prs_debug(ps, depth, desc, "spoolss_io_q_startdocprinter");
1374 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1377 if(!smb_io_doc_info_container("",&q_u->doc_info_container, ps, depth))
1383 /*******************************************************************
1384 * write a structure.
1385 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1386 ********************************************************************/
1388 BOOL spoolss_io_r_startdocprinter(char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth)
1390 prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter");
1392 if(!prs_uint32("jobid", ps, depth, &r_u->jobid))
1394 if(!prs_werror("status", ps, depth, &r_u->status))
1400 /*******************************************************************
1402 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1403 ********************************************************************/
1405 BOOL spoolss_io_q_enddocprinter(char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth)
1407 if (q_u == NULL) return False;
1409 prs_debug(ps, depth, desc, "spoolss_io_q_enddocprinter");
1415 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1421 /*******************************************************************
1422 * write a structure.
1423 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1424 ********************************************************************/
1426 BOOL spoolss_io_r_enddocprinter(char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth)
1428 prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter");
1430 if(!prs_werror("status", ps, depth, &r_u->status))
1436 /*******************************************************************
1438 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1439 ********************************************************************/
1441 BOOL spoolss_io_q_startpageprinter(char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth)
1443 if (q_u == NULL) return False;
1445 prs_debug(ps, depth, desc, "spoolss_io_q_startpageprinter");
1451 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1457 /*******************************************************************
1458 * write a structure.
1459 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1460 ********************************************************************/
1462 BOOL spoolss_io_r_startpageprinter(char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth)
1464 prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter");
1466 if(!prs_werror("status", ps, depth, &r_u->status))
1472 /*******************************************************************
1474 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1475 ********************************************************************/
1477 BOOL spoolss_io_q_endpageprinter(char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth)
1479 if (q_u == NULL) return False;
1481 prs_debug(ps, depth, desc, "spoolss_io_q_endpageprinter");
1487 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1493 /*******************************************************************
1494 * write a structure.
1495 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1496 ********************************************************************/
1498 BOOL spoolss_io_r_endpageprinter(char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth)
1500 prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter");
1502 if(!prs_werror("status", ps, depth, &r_u->status))
1508 /*******************************************************************
1510 * called from spoolss_q_writeprinter (srv_spoolss.c)
1511 ********************************************************************/
1513 BOOL spoolss_io_q_writeprinter(char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth)
1515 if (q_u == NULL) return False;
1517 prs_debug(ps, depth, desc, "spoolss_io_q_writeprinter");
1523 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1525 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1528 if (q_u->buffer_size!=0)
1530 if (UNMARSHALLING(ps))
1531 q_u->buffer=(uint8 *)prs_alloc_mem(ps,q_u->buffer_size*sizeof(uint8));
1532 if(q_u->buffer == NULL)
1534 if(!prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size))
1539 if(!prs_uint32("buffer_size2", ps, depth, &q_u->buffer_size2))
1545 /*******************************************************************
1546 * write a structure.
1547 * called from spoolss_r_writeprinter (srv_spoolss.c)
1548 ********************************************************************/
1550 BOOL spoolss_io_r_writeprinter(char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth)
1552 prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter");
1554 if(!prs_uint32("buffer_written", ps, depth, &r_u->buffer_written))
1556 if(!prs_werror("status", ps, depth, &r_u->status))
1562 /*******************************************************************
1564 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1565 ********************************************************************/
1567 BOOL spoolss_io_q_rffpcnex(char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, int depth)
1569 prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex");
1575 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
1577 if(!prs_uint32("flags", ps, depth, &q_u->flags))
1579 if(!prs_uint32("options", ps, depth, &q_u->options))
1581 if(!prs_uint32("localmachine_ptr", ps, depth, &q_u->localmachine_ptr))
1583 if(!smb_io_unistr2("localmachine", &q_u->localmachine, q_u->localmachine_ptr, ps, depth))
1589 if(!prs_uint32("printerlocal", ps, depth, &q_u->printerlocal))
1592 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1595 if (q_u->option_ptr!=0) {
1597 if (UNMARSHALLING(ps))
1598 if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
1601 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1608 /*******************************************************************
1609 * write a structure.
1610 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1611 ********************************************************************/
1613 BOOL spoolss_io_r_rffpcnex(char *desc, SPOOL_R_RFFPCNEX *r_u, prs_struct *ps, int depth)
1615 prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex");
1618 if(!prs_werror("status", ps, depth, &r_u->status))
1624 /*******************************************************************
1626 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1627 ********************************************************************/
1629 BOOL spoolss_io_q_rfnpcnex(char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, int depth)
1631 prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex");
1637 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1640 if(!prs_uint32("change", ps, depth, &q_u->change))
1643 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1646 if (q_u->option_ptr!=0) {
1648 if (UNMARSHALLING(ps))
1649 if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
1652 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1659 /*******************************************************************
1660 * write a structure.
1661 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1662 ********************************************************************/
1664 BOOL spoolss_io_r_rfnpcnex(char *desc, SPOOL_R_RFNPCNEX *r_u, prs_struct *ps, int depth)
1666 prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex");
1672 if (!prs_uint32("info_ptr", ps, depth, &r_u->info_ptr))
1675 if(!smb_io_notify_info("notify info", &r_u->info ,ps,depth))
1680 if(!prs_werror("status", ps, depth, &r_u->status))
1686 /*******************************************************************
1687 * return the length of a uint16 (obvious, but the code is clean)
1688 ********************************************************************/
1690 static uint32 size_of_uint16(uint16 *value)
1692 return (sizeof(*value));
1695 /*******************************************************************
1696 * return the length of a uint32 (obvious, but the code is clean)
1697 ********************************************************************/
1699 static uint32 size_of_uint32(uint32 *value)
1701 return (sizeof(*value));
1704 /*******************************************************************
1705 * return the length of a NTTIME (obvious, but the code is clean)
1706 ********************************************************************/
1708 static uint32 size_of_nttime(NTTIME *value)
1710 return (sizeof(*value));
1713 /*******************************************************************
1714 * return the length of a UNICODE string in number of char, includes:
1715 * - the leading zero
1716 * - the relative pointer size
1717 ********************************************************************/
1719 static uint32 size_of_relative_string(UNISTR *string)
1723 size=str_len_uni(string); /* the string length */
1724 size=size+1; /* add the trailing zero */
1725 size=size*2; /* convert in char */
1726 size=size+4; /* add the size of the ptr */
1730 * Do not include alignment as Win2k does not align relative
1731 * strings within a buffer --jerry
1733 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1734 /* size += ((4 - (size & 3)) & 3); */
1740 /*******************************************************************
1741 * return the length of a uint32 (obvious, but the code is clean)
1742 ********************************************************************/
1744 static uint32 size_of_device_mode(DEVICEMODE *devmode)
1749 return (4+devmode->size+devmode->driverextra);
1752 /*******************************************************************
1753 * return the length of a uint32 (obvious, but the code is clean)
1754 ********************************************************************/
1756 static uint32 size_of_systemtime(SYSTEMTIME *systime)
1761 return (sizeof(SYSTEMTIME) +4);
1764 /*******************************************************************
1765 * write a UNICODE string and its relative pointer.
1766 * used by all the RPC structs passing a buffer
1768 * As I'm a nice guy, I'm forcing myself to explain this code.
1769 * MS did a good job in the overall spoolss code except in some
1770 * functions where they are passing the API buffer directly in the
1771 * RPC request/reply. That's to maintain compatiility at the API level.
1772 * They could have done it the good way the first time.
1774 * So what happen is: the strings are written at the buffer's end,
1775 * in the reverse order of the original structure. Some pointers to
1776 * the strings are also in the buffer. Those are relative to the
1779 * If you don't understand or want to change that function,
1780 * first get in touch with me: jfm@samba.org
1782 ********************************************************************/
1784 static BOOL smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR *string)
1786 prs_struct *ps=&buffer->prs;
1788 if (MARSHALLING(ps)) {
1789 uint32 struct_offset = prs_offset(ps);
1790 uint32 relative_offset;
1792 buffer->string_at_end -= (size_of_relative_string(string) - 4);
1793 if(!prs_set_offset(ps, buffer->string_at_end))
1797 * Win2k does not align strings in a buffer
1798 * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry
1803 buffer->string_at_end = prs_offset(ps);
1805 /* write the string */
1806 if (!smb_io_unistr(desc, string, ps, depth))
1809 if(!prs_set_offset(ps, struct_offset))
1812 relative_offset=buffer->string_at_end - buffer->struct_start;
1813 /* write its offset */
1814 if (!prs_uint32("offset", ps, depth, &relative_offset))
1820 /* read the offset */
1821 if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end)))
1824 old_offset = prs_offset(ps);
1825 if(!prs_set_offset(ps, buffer->string_at_end+buffer->struct_start))
1828 /* read the string */
1829 if (!smb_io_unistr(desc, string, ps, depth))
1832 if(!prs_set_offset(ps, old_offset))
1838 /*******************************************************************
1839 * write a array of UNICODE strings and its relative pointer.
1840 * used by 2 RPC structs
1841 ********************************************************************/
1843 static BOOL smb_io_relarraystr(char *desc, NEW_BUFFER *buffer, int depth, uint16 **string)
1847 prs_struct *ps=&buffer->prs;
1849 if (MARSHALLING(ps)) {
1850 uint32 struct_offset = prs_offset(ps);
1851 uint32 relative_offset;
1858 /* first write the last 0 */
1859 buffer->string_at_end -= 2;
1860 if(!prs_set_offset(ps, buffer->string_at_end))
1863 if(!prs_uint16("leading zero", ps, depth, &zero))
1866 while (p && (*p!=0)) {
1870 /* Yes this should be malloc not talloc. Don't change. */
1872 chaine.buffer = malloc((q-p+1)*sizeof(uint16));
1873 if (chaine.buffer == NULL)
1876 memcpy(chaine.buffer, p, (q-p+1)*sizeof(uint16));
1878 buffer->string_at_end -= (q-p+1)*sizeof(uint16);
1880 if(!prs_set_offset(ps, buffer->string_at_end)) {
1881 SAFE_FREE(chaine.buffer);
1885 /* write the string */
1886 if (!smb_io_unistr(desc, &chaine, ps, depth)) {
1887 SAFE_FREE(chaine.buffer);
1893 SAFE_FREE(chaine.buffer);
1896 if(!prs_set_offset(ps, struct_offset))
1899 relative_offset=buffer->string_at_end - buffer->struct_start;
1900 /* write its offset */
1901 if (!prs_uint32("offset", ps, depth, &relative_offset))
1909 uint16 *chaine2=NULL;
1912 size_t realloc_size = 0;
1916 /* read the offset */
1917 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
1920 old_offset = prs_offset(ps);
1921 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
1925 if (!smb_io_unistr(desc, &chaine, ps, depth))
1928 l_chaine=str_len_uni(&chaine);
1930 /* we're going to add two more bytes here in case this
1931 is the last string in the array and we need to add
1932 an extra NULL for termination */
1937 realloc_size = (l_chaine2+l_chaine+2)*sizeof(uint16);
1939 /* Yes this should be realloc - it's freed below. JRA */
1941 if((tc2=(uint16 *)Realloc(chaine2, realloc_size)) == NULL) {
1946 memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16));
1947 l_chaine2+=l_chaine+1;
1950 } while(l_chaine!=0);
1952 /* the end should be bould NULL terminated so add
1953 the second one here */
1956 chaine2[l_chaine2] = '\0';
1957 *string=(uint16 *)talloc_memdup(prs_get_mem_context(ps),chaine2,realloc_size);
1961 if(!prs_set_offset(ps, old_offset))
1967 /*******************************************************************
1968 Parse a DEVMODE structure and its relative pointer.
1969 ********************************************************************/
1971 static BOOL smb_io_relsecdesc(char *desc, NEW_BUFFER *buffer, int depth, SEC_DESC **secdesc)
1973 prs_struct *ps= &buffer->prs;
1975 prs_debug(ps, depth, desc, "smb_io_relsecdesc");
1978 if (MARSHALLING(ps)) {
1979 uint32 struct_offset = prs_offset(ps);
1980 uint32 relative_offset;
1983 relative_offset = 0;
1984 if (!prs_uint32("offset", ps, depth, &relative_offset))
1989 if (*secdesc != NULL) {
1990 buffer->string_at_end -= sec_desc_size(*secdesc);
1992 if(!prs_set_offset(ps, buffer->string_at_end))
1994 /* write the secdesc */
1995 if (!sec_io_desc(desc, secdesc, ps, depth))
1998 if(!prs_set_offset(ps, struct_offset))
2002 relative_offset=buffer->string_at_end - buffer->struct_start;
2003 /* write its offset */
2005 if (!prs_uint32("offset", ps, depth, &relative_offset))
2010 /* read the offset */
2011 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
2014 old_offset = prs_offset(ps);
2015 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
2019 if (!sec_io_desc(desc, secdesc, ps, depth))
2022 if(!prs_set_offset(ps, old_offset))
2028 /*******************************************************************
2029 Parse a DEVMODE structure and its relative pointer.
2030 ********************************************************************/
2032 static BOOL smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode)
2034 prs_struct *ps=&buffer->prs;
2036 prs_debug(ps, depth, desc, "smb_io_reldevmode");
2039 if (MARSHALLING(ps)) {
2040 uint32 struct_offset = prs_offset(ps);
2041 uint32 relative_offset;
2043 if (*devmode == NULL) {
2045 if (!prs_uint32("offset", ps, depth, &relative_offset))
2047 DEBUG(8, ("boing, the devmode was NULL\n"));
2052 buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra);
2054 if(!prs_set_offset(ps, buffer->string_at_end))
2057 /* write the DEVMODE */
2058 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2061 if(!prs_set_offset(ps, struct_offset))
2064 relative_offset=buffer->string_at_end - buffer->struct_start;
2065 /* write its offset */
2066 if (!prs_uint32("offset", ps, depth, &relative_offset))
2072 /* read the offset */
2073 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
2076 old_offset = prs_offset(ps);
2077 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
2080 /* read the string */
2081 if((*devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE))) == NULL)
2083 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
2086 if(!prs_set_offset(ps, old_offset))
2092 /*******************************************************************
2093 Parse a PRINTER_INFO_0 structure.
2094 ********************************************************************/
2096 BOOL smb_io_printer_info_0(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
2098 prs_struct *ps=&buffer->prs;
2100 prs_debug(ps, depth, desc, "smb_io_printer_info_0");
2103 buffer->struct_start=prs_offset(ps);
2105 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2107 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2110 if(!prs_uint32("cjobs", ps, depth, &info->cjobs))
2112 if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs))
2114 if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes))
2117 if(!prs_uint16("year", ps, depth, &info->year))
2119 if(!prs_uint16("month", ps, depth, &info->month))
2121 if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek))
2123 if(!prs_uint16("day", ps, depth, &info->day))
2125 if(!prs_uint16("hour", ps, depth, &info->hour))
2127 if(!prs_uint16("minute", ps, depth, &info->minute))
2129 if(!prs_uint16("second", ps, depth, &info->second))
2131 if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds))
2134 if(!prs_uint32("global_counter", ps, depth, &info->global_counter))
2136 if(!prs_uint32("total_pages", ps, depth, &info->total_pages))
2139 if(!prs_uint16("major_version", ps, depth, &info->major_version))
2141 if(!prs_uint16("build_version", ps, depth, &info->build_version))
2143 if(!prs_uint32("unknown7", ps, depth, &info->unknown7))
2145 if(!prs_uint32("unknown8", ps, depth, &info->unknown8))
2147 if(!prs_uint32("unknown9", ps, depth, &info->unknown9))
2149 if(!prs_uint32("session_counter", ps, depth, &info->session_counter))
2151 if(!prs_uint32("unknown11", ps, depth, &info->unknown11))
2153 if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors))
2155 if(!prs_uint32("unknown13", ps, depth, &info->unknown13))
2157 if(!prs_uint32("unknown14", ps, depth, &info->unknown14))
2159 if(!prs_uint32("unknown15", ps, depth, &info->unknown15))
2161 if(!prs_uint32("unknown16", ps, depth, &info->unknown16))
2163 if(!prs_uint32("change_id", ps, depth, &info->change_id))
2165 if(!prs_uint32("unknown18", ps, depth, &info->unknown18))
2167 if(!prs_uint32("status" , ps, depth, &info->status))
2169 if(!prs_uint32("unknown20", ps, depth, &info->unknown20))
2171 if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter))
2173 if(!prs_uint16("unknown22", ps, depth, &info->unknown22))
2175 if(!prs_uint16("unknown23", ps, depth, &info->unknown23))
2177 if(!prs_uint16("unknown24", ps, depth, &info->unknown24))
2179 if(!prs_uint16("unknown25", ps, depth, &info->unknown25))
2181 if(!prs_uint16("unknown26", ps, depth, &info->unknown26))
2183 if(!prs_uint16("unknown27", ps, depth, &info->unknown27))
2185 if(!prs_uint16("unknown28", ps, depth, &info->unknown28))
2187 if(!prs_uint16("unknown29", ps, depth, &info->unknown29))
2193 /*******************************************************************
2194 Parse a PRINTER_INFO_1 structure.
2195 ********************************************************************/
2197 BOOL smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
2199 prs_struct *ps=&buffer->prs;
2201 prs_debug(ps, depth, desc, "smb_io_printer_info_1");
2204 buffer->struct_start=prs_offset(ps);
2206 if (!prs_uint32("flags", ps, depth, &info->flags))
2208 if (!smb_io_relstr("description", buffer, depth, &info->description))
2210 if (!smb_io_relstr("name", buffer, depth, &info->name))
2212 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2218 /*******************************************************************
2219 Parse a PRINTER_INFO_2 structure.
2220 ********************************************************************/
2222 BOOL smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
2224 prs_struct *ps=&buffer->prs;
2226 prs_debug(ps, depth, desc, "smb_io_printer_info_2");
2229 buffer->struct_start=prs_offset(ps);
2231 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2233 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2235 if (!smb_io_relstr("sharename", buffer, depth, &info->sharename))
2237 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2239 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2241 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2243 if (!smb_io_relstr("location", buffer, depth, &info->location))
2246 /* NT parses the DEVMODE at the end of the struct */
2247 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2250 if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
2252 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2254 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2256 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2259 if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
2262 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2264 if (!prs_uint32("priority", ps, depth, &info->priority))
2266 if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority))
2268 if (!prs_uint32("starttime", ps, depth, &info->starttime))
2270 if (!prs_uint32("untiltime", ps, depth, &info->untiltime))
2272 if (!prs_uint32("status", ps, depth, &info->status))
2274 if (!prs_uint32("jobs", ps, depth, &info->cjobs))
2276 if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
2280 if (!prs_uint32_post("secdesc_ptr", ps, depth, NULL, sec_offset, info->secdesc ? prs_offset(ps)-buffer->struct_start : 0 ))
2283 if (!sec_io_desc("secdesc", &info->secdesc, ps, depth))
2289 /*******************************************************************
2290 Parse a PRINTER_INFO_3 structure.
2291 ********************************************************************/
2293 BOOL smb_io_printer_info_3(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
2295 prs_struct *ps=&buffer->prs;
2297 prs_debug(ps, depth, desc, "smb_io_printer_info_3");
2300 buffer->struct_start=prs_offset(ps);
2302 if (!prs_uint32("flags", ps, depth, &info->flags))
2304 if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth))
2310 /*******************************************************************
2311 Parse a PRINTER_INFO_4 structure.
2312 ********************************************************************/
2314 BOOL smb_io_printer_info_4(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_4 *info, int depth)
2316 prs_struct *ps=&buffer->prs;
2318 prs_debug(ps, depth, desc, "smb_io_printer_info_4");
2321 buffer->struct_start=prs_offset(ps);
2323 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2325 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2327 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2332 /*******************************************************************
2333 Parse a PRINTER_INFO_5 structure.
2334 ********************************************************************/
2336 BOOL smb_io_printer_info_5(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_5 *info, int depth)
2338 prs_struct *ps=&buffer->prs;
2340 prs_debug(ps, depth, desc, "smb_io_printer_info_5");
2343 buffer->struct_start=prs_offset(ps);
2345 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2347 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2349 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2351 if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout))
2353 if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout))
2358 /*******************************************************************
2359 Parse a PORT_INFO_1 structure.
2360 ********************************************************************/
2362 BOOL smb_io_port_info_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2364 prs_struct *ps=&buffer->prs;
2366 prs_debug(ps, depth, desc, "smb_io_port_info_1");
2369 buffer->struct_start=prs_offset(ps);
2371 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2377 /*******************************************************************
2378 Parse a PORT_INFO_2 structure.
2379 ********************************************************************/
2381 BOOL smb_io_port_info_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2383 prs_struct *ps=&buffer->prs;
2385 prs_debug(ps, depth, desc, "smb_io_port_info_2");
2388 buffer->struct_start=prs_offset(ps);
2390 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2392 if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2394 if (!smb_io_relstr("description", buffer, depth, &info->description))
2396 if (!prs_uint32("port_type", ps, depth, &info->port_type))
2398 if (!prs_uint32("reserved", ps, depth, &info->reserved))
2404 /*******************************************************************
2405 Parse a DRIVER_INFO_1 structure.
2406 ********************************************************************/
2408 BOOL smb_io_printer_driver_info_1(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
2410 prs_struct *ps=&buffer->prs;
2412 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
2415 buffer->struct_start=prs_offset(ps);
2417 if (!smb_io_relstr("name", buffer, depth, &info->name))
2423 /*******************************************************************
2424 Parse a DRIVER_INFO_2 structure.
2425 ********************************************************************/
2427 BOOL smb_io_printer_driver_info_2(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
2429 prs_struct *ps=&buffer->prs;
2431 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
2434 buffer->struct_start=prs_offset(ps);
2436 if (!prs_uint32("version", ps, depth, &info->version))
2438 if (!smb_io_relstr("name", buffer, depth, &info->name))
2440 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2442 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2444 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2446 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2452 /*******************************************************************
2453 Parse a DRIVER_INFO_3 structure.
2454 ********************************************************************/
2456 BOOL smb_io_printer_driver_info_3(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
2458 prs_struct *ps=&buffer->prs;
2460 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
2463 buffer->struct_start=prs_offset(ps);
2465 if (!prs_uint32("version", ps, depth, &info->version))
2467 if (!smb_io_relstr("name", buffer, depth, &info->name))
2469 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2471 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2473 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2475 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2477 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2480 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2483 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2485 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2491 /*******************************************************************
2492 Parse a DRIVER_INFO_6 structure.
2493 ********************************************************************/
2495 BOOL smb_io_printer_driver_info_6(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
2497 prs_struct *ps=&buffer->prs;
2499 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
2502 buffer->struct_start=prs_offset(ps);
2504 if (!prs_uint32("version", ps, depth, &info->version))
2506 if (!smb_io_relstr("name", buffer, depth, &info->name))
2508 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2510 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2512 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2514 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2516 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2519 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2522 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2524 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2527 if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
2530 if (!prs_uint32("date.low", ps, depth, &info->driver_date.low))
2532 if (!prs_uint32("date.high", ps, depth, &info->driver_date.high))
2535 if (!prs_uint32("padding", ps, depth, &info->padding))
2538 if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
2541 if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
2544 if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
2546 if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
2548 if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
2550 if (!smb_io_relstr("provider", buffer, depth, &info->provider))
2556 /*******************************************************************
2557 Parse a JOB_INFO_1 structure.
2558 ********************************************************************/
2560 BOOL smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth)
2562 prs_struct *ps=&buffer->prs;
2564 prs_debug(ps, depth, desc, "smb_io_job_info_1");
2567 buffer->struct_start=prs_offset(ps);
2569 if (!prs_uint32("jobid", ps, depth, &info->jobid))
2571 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2573 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2575 if (!smb_io_relstr("username", buffer, depth, &info->username))
2577 if (!smb_io_relstr("document", buffer, depth, &info->document))
2579 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2581 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2583 if (!prs_uint32("status", ps, depth, &info->status))
2585 if (!prs_uint32("priority", ps, depth, &info->priority))
2587 if (!prs_uint32("position", ps, depth, &info->position))
2589 if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
2591 if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
2593 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
2599 /*******************************************************************
2600 Parse a JOB_INFO_2 structure.
2601 ********************************************************************/
2603 BOOL smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth)
2606 prs_struct *ps=&buffer->prs;
2608 prs_debug(ps, depth, desc, "smb_io_job_info_2");
2611 buffer->struct_start=prs_offset(ps);
2613 if (!prs_uint32("jobid",ps, depth, &info->jobid))
2615 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2617 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2619 if (!smb_io_relstr("username", buffer, depth, &info->username))
2621 if (!smb_io_relstr("document", buffer, depth, &info->document))
2623 if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
2625 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2628 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2630 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2632 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2634 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2636 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2639 /* SEC_DESC sec_desc;*/
2640 if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
2643 if (!prs_uint32("status",ps, depth, &info->status))
2645 if (!prs_uint32("priority",ps, depth, &info->priority))
2647 if (!prs_uint32("position",ps, depth, &info->position))
2649 if (!prs_uint32("starttime",ps, depth, &info->starttime))
2651 if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
2653 if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
2655 if (!prs_uint32("size",ps, depth, &info->size))
2657 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
2659 if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
2661 if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
2667 /*******************************************************************
2668 ********************************************************************/
2670 BOOL smb_io_form_1(char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth)
2672 prs_struct *ps=&buffer->prs;
2674 prs_debug(ps, depth, desc, "smb_io_form_1");
2677 buffer->struct_start=prs_offset(ps);
2679 if (!prs_uint32("flag", ps, depth, &info->flag))
2682 if (!smb_io_relstr("name", buffer, depth, &info->name))
2685 if (!prs_uint32("width", ps, depth, &info->width))
2687 if (!prs_uint32("length", ps, depth, &info->length))
2689 if (!prs_uint32("left", ps, depth, &info->left))
2691 if (!prs_uint32("top", ps, depth, &info->top))
2693 if (!prs_uint32("right", ps, depth, &info->right))
2695 if (!prs_uint32("bottom", ps, depth, &info->bottom))
2701 /*******************************************************************
2702 Read/write a BUFFER struct.
2703 ********************************************************************/
2705 static BOOL spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUFFER **pp_buffer)
2707 NEW_BUFFER *buffer = *pp_buffer;
2709 prs_debug(ps, depth, desc, "spoolss_io_buffer");
2712 if (UNMARSHALLING(ps))
2713 buffer = *pp_buffer = (NEW_BUFFER *)prs_alloc_mem(ps, sizeof(NEW_BUFFER));
2718 if (!prs_uint32("ptr", ps, depth, &buffer->ptr))
2722 if (UNMARSHALLING(ps)) {
2724 buffer->string_at_end=0;
2726 if (buffer->ptr==0) {
2728 * JRA. I'm not sure if the data in here is in big-endian format if
2729 * the client is big-endian. Leave as default (little endian) for now.
2732 if (!prs_init(&buffer->prs, 0, prs_get_mem_context(ps), UNMARSHALL))
2737 if (!prs_uint32("size", ps, depth, &buffer->size))
2741 * JRA. I'm not sure if the data in here is in big-endian format if
2742 * the client is big-endian. Leave as default (little endian) for now.
2745 if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL))
2748 if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size))
2751 if (!prs_set_offset(&buffer->prs, 0))
2754 if (!prs_set_offset(ps, buffer->size+prs_offset(ps)))
2757 buffer->string_at_end=buffer->size;
2765 if (buffer->ptr==0) {
2766 /* We have finished with the data in buffer->prs - free it. */
2767 prs_mem_free(&buffer->prs);
2771 if (!prs_uint32("size", ps, depth, &buffer->size))
2774 if (!prs_append_some_prs_data(ps, &buffer->prs, 0, buffer->size))
2780 /* We have finished with the data in buffer->prs - free it. */
2781 prs_mem_free(&buffer->prs);
2787 /*******************************************************************
2788 move a BUFFER from the query to the reply.
2789 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2790 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2791 Clears the memory to zero also.
2792 ********************************************************************/
2794 void spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest)
2796 prs_switch_type(&src->prs, MARSHALL);
2797 if(!prs_set_offset(&src->prs, 0))
2799 prs_force_dynamic(&src->prs);
2800 prs_mem_clear(&src->prs);
2804 /*******************************************************************
2805 Get the size of a BUFFER struct.
2806 ********************************************************************/
2808 uint32 new_get_buffer_size(NEW_BUFFER *buffer)
2810 return (buffer->size);
2813 /*******************************************************************
2814 Parse a DRIVER_DIRECTORY_1 structure.
2815 ********************************************************************/
2817 BOOL smb_io_driverdir_1(char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
2819 prs_struct *ps=&buffer->prs;
2821 prs_debug(ps, depth, desc, "smb_io_driverdir_1");
2824 buffer->struct_start=prs_offset(ps);
2826 if (!smb_io_unistr(desc, &info->name, ps, depth))
2832 /*******************************************************************
2833 Parse a PORT_INFO_1 structure.
2834 ********************************************************************/
2836 BOOL smb_io_port_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2838 prs_struct *ps=&buffer->prs;
2840 prs_debug(ps, depth, desc, "smb_io_port_1");
2843 buffer->struct_start=prs_offset(ps);
2845 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2851 /*******************************************************************
2852 Parse a PORT_INFO_2 structure.
2853 ********************************************************************/
2855 BOOL smb_io_port_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2857 prs_struct *ps=&buffer->prs;
2859 prs_debug(ps, depth, desc, "smb_io_port_2");
2862 buffer->struct_start=prs_offset(ps);
2864 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2866 if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2868 if(!smb_io_relstr("description", buffer, depth, &info->description))
2870 if(!prs_uint32("port_type", ps, depth, &info->port_type))
2872 if(!prs_uint32("reserved", ps, depth, &info->reserved))
2878 /*******************************************************************
2879 ********************************************************************/
2881 BOOL smb_io_printprocessor_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
2883 prs_struct *ps=&buffer->prs;
2885 prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1");
2888 buffer->struct_start=prs_offset(ps);
2890 if (smb_io_relstr("name", buffer, depth, &info->name))
2896 /*******************************************************************
2897 ********************************************************************/
2899 BOOL smb_io_printprocdatatype_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth)
2901 prs_struct *ps=&buffer->prs;
2903 prs_debug(ps, depth, desc, "smb_io_printprocdatatype_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_printmonitor_info_1(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
2919 prs_struct *ps=&buffer->prs;
2921 prs_debug(ps, depth, desc, "smb_io_printmonitor_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_2(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
2937 prs_struct *ps=&buffer->prs;
2939 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
2942 buffer->struct_start=prs_offset(ps);
2944 if (!smb_io_relstr("name", buffer, depth, &info->name))
2946 if (!smb_io_relstr("environment", buffer, depth, &info->environment))
2948 if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
2954 /*******************************************************************
2955 return the size required by a struct in the stream
2956 ********************************************************************/
2958 uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
2962 size+=size_of_relative_string( &info->printername );
2963 size+=size_of_relative_string( &info->servername );
2965 size+=size_of_uint32( &info->cjobs);
2966 size+=size_of_uint32( &info->total_jobs);
2967 size+=size_of_uint32( &info->total_bytes);
2969 size+=size_of_uint16( &info->year);
2970 size+=size_of_uint16( &info->month);
2971 size+=size_of_uint16( &info->dayofweek);
2972 size+=size_of_uint16( &info->day);
2973 size+=size_of_uint16( &info->hour);
2974 size+=size_of_uint16( &info->minute);
2975 size+=size_of_uint16( &info->second);
2976 size+=size_of_uint16( &info->milliseconds);
2978 size+=size_of_uint32( &info->global_counter);
2979 size+=size_of_uint32( &info->total_pages);
2981 size+=size_of_uint16( &info->major_version);
2982 size+=size_of_uint16( &info->build_version);
2984 size+=size_of_uint32( &info->unknown7);
2985 size+=size_of_uint32( &info->unknown8);
2986 size+=size_of_uint32( &info->unknown9);
2987 size+=size_of_uint32( &info->session_counter);
2988 size+=size_of_uint32( &info->unknown11);
2989 size+=size_of_uint32( &info->printer_errors);
2990 size+=size_of_uint32( &info->unknown13);
2991 size+=size_of_uint32( &info->unknown14);
2992 size+=size_of_uint32( &info->unknown15);
2993 size+=size_of_uint32( &info->unknown16);
2994 size+=size_of_uint32( &info->change_id);
2995 size+=size_of_uint32( &info->unknown18);
2996 size+=size_of_uint32( &info->status);
2997 size+=size_of_uint32( &info->unknown20);
2998 size+=size_of_uint32( &info->c_setprinter);
3000 size+=size_of_uint16( &info->unknown22);
3001 size+=size_of_uint16( &info->unknown23);
3002 size+=size_of_uint16( &info->unknown24);
3003 size+=size_of_uint16( &info->unknown25);
3004 size+=size_of_uint16( &info->unknown26);
3005 size+=size_of_uint16( &info->unknown27);
3006 size+=size_of_uint16( &info->unknown28);
3007 size+=size_of_uint16( &info->unknown29);
3012 /*******************************************************************
3013 return the size required by a struct in the stream
3014 ********************************************************************/
3016 uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
3020 size+=size_of_uint32( &info->flags );
3021 size+=size_of_relative_string( &info->description );
3022 size+=size_of_relative_string( &info->name );
3023 size+=size_of_relative_string( &info->comment );
3028 /*******************************************************************
3029 return the size required by a struct in the stream
3030 ********************************************************************/
3032 uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
3037 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3038 size += sec_desc_size( info->secdesc );
3040 size+=size_of_device_mode( info->devmode );
3042 size+=size_of_relative_string( &info->servername );
3043 size+=size_of_relative_string( &info->printername );
3044 size+=size_of_relative_string( &info->sharename );
3045 size+=size_of_relative_string( &info->portname );
3046 size+=size_of_relative_string( &info->drivername );
3047 size+=size_of_relative_string( &info->comment );
3048 size+=size_of_relative_string( &info->location );
3050 size+=size_of_relative_string( &info->sepfile );
3051 size+=size_of_relative_string( &info->printprocessor );
3052 size+=size_of_relative_string( &info->datatype );
3053 size+=size_of_relative_string( &info->parameters );
3055 size+=size_of_uint32( &info->attributes );
3056 size+=size_of_uint32( &info->priority );
3057 size+=size_of_uint32( &info->defaultpriority );
3058 size+=size_of_uint32( &info->starttime );
3059 size+=size_of_uint32( &info->untiltime );
3060 size+=size_of_uint32( &info->status );
3061 size+=size_of_uint32( &info->cjobs );
3062 size+=size_of_uint32( &info->averageppm );
3066 /*******************************************************************
3067 return the size required by a struct in the stream
3068 ********************************************************************/
3070 uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
3074 size+=size_of_relative_string( &info->printername );
3075 size+=size_of_relative_string( &info->servername );
3077 size+=size_of_uint32( &info->attributes );
3081 /*******************************************************************
3082 return the size required by a struct in the stream
3083 ********************************************************************/
3085 uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
3089 size+=size_of_relative_string( &info->printername );
3090 size+=size_of_relative_string( &info->portname );
3092 size+=size_of_uint32( &info->attributes );
3093 size+=size_of_uint32( &info->device_not_selected_timeout );
3094 size+=size_of_uint32( &info->transmission_retry_timeout );
3099 /*******************************************************************
3100 return the size required by a struct in the stream
3101 ********************************************************************/
3103 uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
3105 /* The 4 is for the self relative pointer.. */
3106 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3107 return 4 + (uint32)sec_desc_size( info->secdesc );
3110 /*******************************************************************
3111 return the size required by a struct in the stream
3112 ********************************************************************/
3114 uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
3117 size+=size_of_relative_string( &info->name );
3122 /*******************************************************************
3123 return the size required by a struct in the stream
3124 ********************************************************************/
3126 uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
3129 size+=size_of_uint32( &info->version );
3130 size+=size_of_relative_string( &info->name );
3131 size+=size_of_relative_string( &info->architecture );
3132 size+=size_of_relative_string( &info->driverpath );
3133 size+=size_of_relative_string( &info->datafile );
3134 size+=size_of_relative_string( &info->configfile );
3139 /*******************************************************************
3140 return the size required by a string array.
3141 ********************************************************************/
3143 uint32 spoolss_size_string_array(uint16 *string)
3148 for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
3150 i=i+2; /* to count all chars including the leading zero */
3151 i=2*i; /* because we need the value in bytes */
3152 i=i+4; /* the offset pointer size */
3157 /*******************************************************************
3158 return the size required by a struct in the stream
3159 ********************************************************************/
3161 uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
3165 size+=size_of_uint32( &info->version );
3166 size+=size_of_relative_string( &info->name );
3167 size+=size_of_relative_string( &info->architecture );
3168 size+=size_of_relative_string( &info->driverpath );
3169 size+=size_of_relative_string( &info->datafile );
3170 size+=size_of_relative_string( &info->configfile );
3171 size+=size_of_relative_string( &info->helpfile );
3172 size+=size_of_relative_string( &info->monitorname );
3173 size+=size_of_relative_string( &info->defaultdatatype );
3175 size+=spoolss_size_string_array(info->dependentfiles);
3180 /*******************************************************************
3181 return the size required by a struct in the stream
3182 ********************************************************************/
3184 uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
3188 size+=size_of_uint32( &info->version );
3189 size+=size_of_relative_string( &info->name );
3190 size+=size_of_relative_string( &info->architecture );
3191 size+=size_of_relative_string( &info->driverpath );
3192 size+=size_of_relative_string( &info->datafile );
3193 size+=size_of_relative_string( &info->configfile );
3194 size+=size_of_relative_string( &info->helpfile );
3196 size+=spoolss_size_string_array(info->dependentfiles);
3198 size+=size_of_relative_string( &info->monitorname );
3199 size+=size_of_relative_string( &info->defaultdatatype );
3201 size+=spoolss_size_string_array(info->previousdrivernames);
3203 size+=size_of_nttime(&info->driver_date);
3204 size+=size_of_uint32( &info->padding );
3205 size+=size_of_uint32( &info->driver_version_low );
3206 size+=size_of_uint32( &info->driver_version_high );
3207 size+=size_of_relative_string( &info->mfgname );
3208 size+=size_of_relative_string( &info->oem_url );
3209 size+=size_of_relative_string( &info->hardware_id );
3210 size+=size_of_relative_string( &info->provider );
3215 /*******************************************************************
3216 return the size required by a struct in the stream
3217 ********************************************************************/
3219 uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
3222 size+=size_of_uint32( &info->jobid );
3223 size+=size_of_relative_string( &info->printername );
3224 size+=size_of_relative_string( &info->machinename );
3225 size+=size_of_relative_string( &info->username );
3226 size+=size_of_relative_string( &info->document );
3227 size+=size_of_relative_string( &info->datatype );
3228 size+=size_of_relative_string( &info->text_status );
3229 size+=size_of_uint32( &info->status );
3230 size+=size_of_uint32( &info->priority );
3231 size+=size_of_uint32( &info->position );
3232 size+=size_of_uint32( &info->totalpages );
3233 size+=size_of_uint32( &info->pagesprinted );
3234 size+=size_of_systemtime( &info->submitted );
3239 /*******************************************************************
3240 return the size required by a struct in the stream
3241 ********************************************************************/
3243 uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
3247 size+=4; /* size of sec desc ptr */
3249 size+=size_of_uint32( &info->jobid );
3250 size+=size_of_relative_string( &info->printername );
3251 size+=size_of_relative_string( &info->machinename );
3252 size+=size_of_relative_string( &info->username );
3253 size+=size_of_relative_string( &info->document );
3254 size+=size_of_relative_string( &info->notifyname );
3255 size+=size_of_relative_string( &info->datatype );
3256 size+=size_of_relative_string( &info->printprocessor );
3257 size+=size_of_relative_string( &info->parameters );
3258 size+=size_of_relative_string( &info->drivername );
3259 size+=size_of_device_mode( info->devmode );
3260 size+=size_of_relative_string( &info->text_status );
3261 /* SEC_DESC sec_desc;*/
3262 size+=size_of_uint32( &info->status );
3263 size+=size_of_uint32( &info->priority );
3264 size+=size_of_uint32( &info->position );
3265 size+=size_of_uint32( &info->starttime );
3266 size+=size_of_uint32( &info->untiltime );
3267 size+=size_of_uint32( &info->totalpages );
3268 size+=size_of_uint32( &info->size );
3269 size+=size_of_systemtime( &info->submitted );
3270 size+=size_of_uint32( &info->timeelapsed );
3271 size+=size_of_uint32( &info->pagesprinted );
3276 /*******************************************************************
3277 return the size required by a struct in the stream
3278 ********************************************************************/
3280 uint32 spoolss_size_form_1(FORM_1 *info)
3284 size+=size_of_uint32( &info->flag );
3285 size+=size_of_relative_string( &info->name );
3286 size+=size_of_uint32( &info->width );
3287 size+=size_of_uint32( &info->length );
3288 size+=size_of_uint32( &info->left );
3289 size+=size_of_uint32( &info->top );
3290 size+=size_of_uint32( &info->right );
3291 size+=size_of_uint32( &info->bottom );
3296 /*******************************************************************
3297 return the size required by a struct in the stream
3298 ********************************************************************/
3300 uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
3304 size+=size_of_relative_string( &info->port_name );
3309 /*******************************************************************
3310 return the size required by a struct in the stream
3311 ********************************************************************/
3313 uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info)
3317 size=str_len_uni(&info->name); /* the string length */
3318 size=size+1; /* add the leading zero */
3319 size=size*2; /* convert in char */
3324 /*******************************************************************
3325 return the size required by a struct in the stream
3326 ********************************************************************/
3328 uint32 spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1 *info)
3332 size=str_len_uni(&info->name); /* the string length */
3333 size=size+1; /* add the leading zero */
3334 size=size*2; /* convert in char */
3339 /*******************************************************************
3340 return the size required by a struct in the stream
3341 ********************************************************************/
3343 uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
3347 size+=size_of_relative_string( &info->port_name );
3348 size+=size_of_relative_string( &info->monitor_name );
3349 size+=size_of_relative_string( &info->description );
3351 size+=size_of_uint32( &info->port_type );
3352 size+=size_of_uint32( &info->reserved );
3357 /*******************************************************************
3358 return the size required by a struct in the stream
3359 ********************************************************************/
3361 uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
3364 size+=size_of_relative_string( &info->name );
3369 /*******************************************************************
3370 return the size required by a struct in the stream
3371 ********************************************************************/
3373 uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info)
3376 size+=size_of_relative_string( &info->name );
3381 /*******************************************************************
3382 return the size required by a struct in the stream
3383 ********************************************************************/
3384 uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
3391 /* uint32(offset) + uint32(length) + length) */
3392 size += (size_of_uint32(&p->value_len)*2) + p->value_len;
3393 size += (size_of_uint32(&p->data_len)*2) + p->data_len;
3395 size += size_of_uint32(&p->type);
3400 /*******************************************************************
3401 return the size required by a struct in the stream
3402 ********************************************************************/
3404 uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
3407 size+=size_of_relative_string( &info->name );
3412 /*******************************************************************
3413 return the size required by a struct in the stream
3414 ********************************************************************/
3416 uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
3419 size+=size_of_relative_string( &info->name);
3420 size+=size_of_relative_string( &info->environment);
3421 size+=size_of_relative_string( &info->dll_name);
3426 /*******************************************************************
3428 ********************************************************************/
3430 BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
3431 const POLICY_HND *hnd,
3432 const fstring architecture,
3433 uint32 level, uint32 clientmajor, uint32 clientminor,
3434 NEW_BUFFER *buffer, uint32 offered)
3439 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3441 init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture);
3444 q_u->clientmajorversion=clientmajor;
3445 q_u->clientminorversion=clientminor;
3448 q_u->offered=offered;
3453 /*******************************************************************
3455 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3456 ********************************************************************/
3458 BOOL spoolss_io_q_getprinterdriver2(char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
3460 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
3466 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3468 if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr))
3470 if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth))
3475 if(!prs_uint32("level", ps, depth, &q_u->level))
3478 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3484 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3487 if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion))
3489 if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion))
3495 /*******************************************************************
3497 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3498 ********************************************************************/
3500 BOOL spoolss_io_r_getprinterdriver2(char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
3502 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
3508 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3513 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3515 if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion))
3517 if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
3519 if (!prs_werror("status", ps, depth, &r_u->status))
3525 /*******************************************************************
3527 ********************************************************************/
3529 BOOL make_spoolss_q_enumprinters(
3530 SPOOL_Q_ENUMPRINTERS *q_u,
3540 q_u->servername_ptr = (servername != NULL) ? 1 : 0;
3541 init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
3545 q_u->offered=offered;
3550 /*******************************************************************
3552 ********************************************************************/
3554 BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u,
3555 fstring servername, uint32 level,
3556 NEW_BUFFER *buffer, uint32 offered)
3558 q_u->name_ptr = (servername != NULL) ? 1 : 0;
3559 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
3563 q_u->offered=offered;
3568 /*******************************************************************
3570 * called from spoolss_enumprinters (srv_spoolss.c)
3571 ********************************************************************/
3573 BOOL spoolss_io_q_enumprinters(char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
3575 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
3581 if (!prs_uint32("flags", ps, depth, &q_u->flags))
3583 if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
3586 if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
3591 if (!prs_uint32("level", ps, depth, &q_u->level))
3594 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3599 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3605 /*******************************************************************
3606 Parse a SPOOL_R_ENUMPRINTERS structure.
3607 ********************************************************************/
3609 BOOL spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
3611 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
3617 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3623 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3626 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3629 if (!prs_werror("status", ps, depth, &r_u->status))
3635 /*******************************************************************
3636 * write a structure.
3637 * called from spoolss_r_enum_printers (srv_spoolss.c)
3639 ********************************************************************/
3641 BOOL spoolss_io_r_getprinter(char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
3643 prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
3649 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3655 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3658 if (!prs_werror("status", ps, depth, &r_u->status))
3664 /*******************************************************************
3666 * called from spoolss_getprinter (srv_spoolss.c)
3667 ********************************************************************/
3669 BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
3671 prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
3677 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3679 if (!prs_uint32("level", ps, depth, &q_u->level))
3682 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3687 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3693 /*******************************************************************
3695 ********************************************************************/
3697 BOOL make_spoolss_q_getprinter(
3698 TALLOC_CTX *mem_ctx,
3699 SPOOL_Q_GETPRINTER *q_u,
3700 const POLICY_HND *hnd,
3710 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3714 q_u->offered=offered;
3719 /*******************************************************************
3721 ********************************************************************/
3722 BOOL make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
3723 const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
3727 DEVICEMODE *devmode;
3732 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3735 q_u->info.level = level;
3736 q_u->info.info_ptr = (info != NULL) ? 1 : 0;
3739 /* There's no such thing as a setprinter level 1 */
3742 secdesc = info->printers_2->secdesc;
3743 devmode = info->printers_2->devmode;
3745 make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2);
3746 #if 1 /* JERRY TEST */
3747 q_u->secdesc_ctr = (SEC_DESC_BUF*)malloc(sizeof(SEC_DESC_BUF));
3748 if (!q_u->secdesc_ctr)
3750 q_u->secdesc_ctr->ptr = (secdesc != NULL) ? 1: 0;
3751 q_u->secdesc_ctr->max_len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3752 q_u->secdesc_ctr->len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3753 q_u->secdesc_ctr->sec = secdesc;
3755 q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
3756 q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0;
3757 q_u->devmode_ctr.devmode = devmode;
3759 q_u->secdesc_ctr = NULL;
3761 q_u->devmode_ctr.devmode_ptr = 0;
3762 q_u->devmode_ctr.size = 0;
3763 q_u->devmode_ctr.devmode = NULL;
3767 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
3772 q_u->command = command;
3778 /*******************************************************************
3779 ********************************************************************/
3781 BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
3783 prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
3789 if(!prs_werror("status", ps, depth, &r_u->status))
3795 /*******************************************************************
3796 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3797 ********************************************************************/
3799 BOOL spoolss_io_q_setprinter(char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
3801 uint32 ptr_sec_desc = 0;
3803 prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
3809 if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
3811 if(!prs_uint32("level", ps, depth, &q_u->level))
3814 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
3817 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
3827 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
3832 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
3838 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
3843 /* Parse a NULL security descriptor. This should really
3844 happen inside the sec_io_desc_buf() function. */
3846 prs_debug(ps, depth, "", "sec_io_desc_buf");
3847 if (!prs_uint32("size", ps, depth + 1, &dummy))
3849 if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return
3853 if(!prs_uint32("command", ps, depth, &q_u->command))
3859 /*******************************************************************
3860 ********************************************************************/
3862 BOOL spoolss_io_r_fcpn(char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
3864 prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
3870 if(!prs_werror("status", ps, depth, &r_u->status))
3876 /*******************************************************************
3877 ********************************************************************/
3879 BOOL spoolss_io_q_fcpn(char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
3882 prs_debug(ps, depth, desc, "spoolss_io_q_fcpn");
3888 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3895 /*******************************************************************
3896 ********************************************************************/
3898 BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
3900 prs_debug(ps, depth, desc, "");
3906 if(!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3912 if(!prs_uint32("needed", ps, depth, &r_u->needed))
3915 if(!prs_werror("status", ps, depth, &r_u->status))
3921 /*******************************************************************
3922 ********************************************************************/
3924 BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
3926 prs_debug(ps, depth, desc, "");
3932 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3934 if(!prs_uint32("level", ps, depth, &q_u->level))
3937 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3943 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3949 /*******************************************************************
3950 ********************************************************************/
3952 BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
3954 prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
3960 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3966 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3969 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3972 if (!prs_werror("status", ps, depth, &r_u->status))
3978 /*******************************************************************
3979 ********************************************************************/
3981 BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
3992 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3993 q_u->firstjob = firstjob;
3994 q_u->numofjobs = numofjobs;
3996 q_u->buffer= buffer;
3997 q_u->offered = offered;
4001 /*******************************************************************
4002 ********************************************************************/
4004 BOOL spoolss_io_q_enumjobs(char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
4006 prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
4012 if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth))
4015 if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
4017 if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
4019 if (!prs_uint32("level", ps, depth, &q_u->level))
4022 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4028 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4034 /*******************************************************************
4035 ********************************************************************/
4037 BOOL spoolss_io_r_schedulejob(char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth)
4039 prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob");
4045 if(!prs_werror("status", ps, depth, &r_u->status))
4051 /*******************************************************************
4052 ********************************************************************/
4054 BOOL spoolss_io_q_schedulejob(char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth)
4056 prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob");
4062 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4064 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4070 /*******************************************************************
4071 ********************************************************************/
4073 BOOL spoolss_io_r_setjob(char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth)
4075 prs_debug(ps, depth, desc, "spoolss_io_r_setjob");
4081 if(!prs_werror("status", ps, depth, &r_u->status))
4087 /*******************************************************************
4088 ********************************************************************/
4090 BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth)
4092 prs_debug(ps, depth, desc, "spoolss_io_q_setjob");
4098 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4100 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
4103 * level is usually 0. If (level!=0) then I'm in trouble !
4104 * I will try to generate setjob command with level!=0, one day.
4106 if(!prs_uint32("level", ps, depth, &q_u->level))
4108 if(!prs_uint32("command", ps, depth, &q_u->command))
4114 /*******************************************************************
4115 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4116 ********************************************************************/
4118 BOOL spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
4120 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
4126 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4132 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4135 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4138 if (!prs_werror("status", ps, depth, &r_u->status))
4144 /*******************************************************************
4146 ********************************************************************/
4148 BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
4150 const char *environment,
4152 NEW_BUFFER *buffer, uint32 offered)
4154 init_buf_unistr2(&q_u->name, &q_u->name_ptr, name);
4155 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment);
4159 q_u->offered=offered;
4164 /*******************************************************************
4165 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4166 ********************************************************************/
4168 BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
4171 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
4177 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
4179 if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
4184 if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
4186 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
4191 if (!prs_uint32("level", ps, depth, &q_u->level))
4194 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4200 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4206 /*******************************************************************
4207 ********************************************************************/
4209 BOOL spoolss_io_q_enumforms(char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
4212 prs_debug(ps, depth, desc, "spoolss_io_q_enumforms");
4217 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4219 if (!prs_uint32("level", ps, depth, &q_u->level))
4222 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4227 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4233 /*******************************************************************
4234 ********************************************************************/
4236 BOOL spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
4238 prs_debug(ps, depth, desc, "spoolss_io_r_enumforms");
4244 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4250 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4253 if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
4256 if (!prs_werror("status", ps, depth, &r_u->status))
4262 /*******************************************************************
4263 ********************************************************************/
4265 BOOL spoolss_io_q_getform(char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
4268 prs_debug(ps, depth, desc, "spoolss_io_q_getform");
4273 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
4275 if (!smb_io_unistr2("", &q_u->formname,True,ps,depth))
4281 if (!prs_uint32("level", ps, depth, &q_u->level))
4284 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4289 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4295 /*******************************************************************
4296 ********************************************************************/
4298 BOOL spoolss_io_r_getform(char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
4300 prs_debug(ps, depth, desc, "spoolss_io_r_getform");
4306 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4312 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4315 if (!prs_werror("status", ps, depth, &r_u->status))
4321 /*******************************************************************
4322 Parse a SPOOL_R_ENUMPORTS structure.
4323 ********************************************************************/
4325 BOOL spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
4327 prs_debug(ps, depth, desc, "spoolss_io_r_enumports");
4333 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4339 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4342 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4345 if (!prs_werror("status", ps, depth, &r_u->status))
4351 /*******************************************************************
4352 ********************************************************************/
4354 BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
4356 prs_debug(ps, depth, desc, "");
4362 if (!prs_uint32("", ps, depth, &q_u->name_ptr))
4364 if (!smb_io_unistr2("", &q_u->name,True,ps,depth))
4369 if (!prs_uint32("level", ps, depth, &q_u->level))
4372 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4377 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4383 /*******************************************************************
4384 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4385 ********************************************************************/
4387 BOOL spool_io_printer_info_level_1(char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
4389 prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
4395 if(!prs_uint32("flags", ps, depth, &il->flags))
4397 if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr))
4399 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4401 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4404 if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth))
4406 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4408 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4414 /*******************************************************************
4415 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4416 ********************************************************************/
4418 BOOL spool_io_printer_info_level_3(char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
4420 prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
4426 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4432 /*******************************************************************
4433 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4434 ********************************************************************/
4436 BOOL spool_io_printer_info_level_2(char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
4438 prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
4444 if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr))
4446 if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr))
4448 if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr))
4450 if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
4453 if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
4455 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4457 if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr))
4459 if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr))
4461 if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr))
4463 if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr))
4465 if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr))
4467 if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr))
4469 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4472 if(!prs_uint32("attributes", ps, depth, &il->attributes))
4474 if(!prs_uint32("priority", ps, depth, &il->priority))
4476 if(!prs_uint32("default_priority", ps, depth, &il->default_priority))
4478 if(!prs_uint32("starttime", ps, depth, &il->starttime))
4480 if(!prs_uint32("untiltime", ps, depth, &il->untiltime))
4482 if(!prs_uint32("status", ps, depth, &il->status))
4484 if(!prs_uint32("cjobs", ps, depth, &il->cjobs))
4486 if(!prs_uint32("averageppm", ps, depth, &il->averageppm))
4489 if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth))
4491 if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth))
4493 if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth))
4495 if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth))
4497 if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth))
4499 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4501 if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth))
4503 if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth))
4505 if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth))
4507 if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth))
4509 if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth))
4515 /*******************************************************************
4516 ********************************************************************/
4518 BOOL spool_io_printer_info_level(char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
4520 prs_debug(ps, depth, desc, "spool_io_printer_info_level");
4525 if(!prs_uint32("level", ps, depth, &il->level))
4527 if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr))
4530 /* if no struct inside just return */
4531 if (il->info_ptr==0) {
4532 if (UNMARSHALLING(ps)) {
4539 switch (il->level) {
4541 * level 0 is used by setprinter when managing the queue
4542 * (hold, stop, start a queue)
4546 /* DOCUMENT ME!!! What is level 1 used for? */
4549 if (UNMARSHALLING(ps)) {
4550 if ((il->info_1=(SPOOL_PRINTER_INFO_LEVEL_1 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_1))) == NULL)
4553 if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
4558 * level 2 is used by addprinter
4559 * and by setprinter when updating printer's info
4562 if (UNMARSHALLING(ps)) {
4563 if ((il->info_2=(SPOOL_PRINTER_INFO_LEVEL_2 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_2))) == NULL)
4566 if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
4569 /* DOCUMENT ME!!! What is level 3 used for? */
4572 if (UNMARSHALLING(ps)) {
4573 if ((il->info_3=(SPOOL_PRINTER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_3))) == NULL)
4576 if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
4585 /*******************************************************************
4586 ********************************************************************/
4588 BOOL spoolss_io_q_addprinterex(char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
4590 uint32 ptr_sec_desc = 0;
4592 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
4597 if(!prs_uint32("", ps, depth, &q_u->server_name_ptr))
4599 if(!smb_io_unistr2("", &q_u->server_name, q_u->server_name_ptr, ps, depth))
4605 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4608 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
4611 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
4617 switch (q_u->level) {
4619 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
4622 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
4626 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
4631 /* Parse a NULL security descriptor. This should really
4632 happen inside the sec_io_desc_buf() function. */
4634 prs_debug(ps, depth, "", "sec_io_desc_buf");
4635 if (!prs_uint32("size", ps, depth + 1, &dummy))
4637 if (!prs_uint32("ptr", ps, depth + 1, &dummy))
4641 if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
4643 if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
4649 /*******************************************************************
4650 ********************************************************************/
4652 BOOL spoolss_io_r_addprinterex(char *desc, SPOOL_R_ADDPRINTEREX *r_u,
4653 prs_struct *ps, int depth)
4655 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
4658 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
4661 if(!prs_werror("status", ps, depth, &r_u->status))
4667 /*******************************************************************
4668 ********************************************************************/
4670 BOOL spool_io_printer_driver_info_level_3(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
4671 prs_struct *ps, int depth)
4673 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il;
4675 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3");
4679 if (UNMARSHALLING(ps)) {
4680 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4692 if(!prs_uint32("cversion", ps, depth, &il->cversion))
4694 if(!prs_uint32("name", ps, depth, &il->name_ptr))
4696 if(!prs_uint32("environment", ps, depth, &il->environment_ptr))
4698 if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr))
4700 if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr))
4702 if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr))
4704 if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr))
4706 if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr))
4708 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4710 if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize))
4712 if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr))
4718 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4720 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4722 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4724 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4726 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4728 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4730 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4732 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4738 if (il->dependentfiles_ptr)
4739 smb_io_buffer5("", &il->dependentfiles, ps, depth);
4744 /*******************************************************************
4745 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4746 ********************************************************************/
4748 BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
4749 prs_struct *ps, int depth)
4751 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il;
4753 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6");
4757 if (UNMARSHALLING(ps)) {
4758 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6));
4771 /* parse the main elements the packet */
4773 if(!prs_uint32("version", ps, depth, &il->version))
4776 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4779 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4780 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4781 * from W2K CDROM (which uses unidriver). JohnR 010205
4783 if (!il->name_ptr) {
4784 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4785 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4789 if(!prs_uint32("environment_ptr", ps, depth, &il->environment_ptr))
4791 if(!prs_uint32("driverpath_ptr", ps, depth, &il->driverpath_ptr))
4793 if(!prs_uint32("datafile_ptr", ps, depth, &il->datafile_ptr))
4795 if(!prs_uint32("configfile_ptr", ps, depth, &il->configfile_ptr))
4797 if(!prs_uint32("helpfile_ptr", ps, depth, &il->helpfile_ptr))
4799 if(!prs_uint32("monitorname_ptr", ps, depth, &il->monitorname_ptr))
4801 if(!prs_uint32("defaultdatatype_ptr", ps, depth, &il->defaultdatatype_ptr))
4803 if(!prs_uint32("dependentfiles_len", ps, depth, &il->dependentfiles_len))
4805 if(!prs_uint32("dependentfiles_ptr", ps, depth, &il->dependentfiles_ptr))
4807 if(!prs_uint32("previousnames_len", ps, depth, &il->previousnames_len))
4809 if(!prs_uint32("previousnames_ptr", ps, depth, &il->previousnames_ptr))
4811 if(!smb_io_time("driverdate", &il->driverdate, ps, depth))
4813 if(!prs_uint32("dummy4", ps, depth, &il->dummy4))
4815 if(!prs_uint64("driverversion", ps, depth, &il->driverversion))
4817 if(!prs_uint32("mfgname_ptr", ps, depth, &il->mfgname_ptr))
4819 if(!prs_uint32("oemurl_ptr", ps, depth, &il->oemurl_ptr))
4821 if(!prs_uint32("hardwareid_ptr", ps, depth, &il->hardwareid_ptr))
4823 if(!prs_uint32("provider_ptr", ps, depth, &il->provider_ptr))
4826 /* parse the structures in the packet */
4828 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4833 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4838 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4843 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4848 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4853 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4858 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4863 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4867 if (il->dependentfiles_ptr) {
4868 if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth))
4873 if (il->previousnames_ptr) {
4874 if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth))
4879 if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth))
4883 if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth))
4887 if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth))
4891 if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth))
4897 /*******************************************************************
4898 convert a buffer of UNICODE strings null terminated
4899 the buffer is terminated by a NULL
4901 convert to an dos codepage array (null terminated)
4903 dynamically allocate memory
4905 ********************************************************************/
4906 static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
4915 src = (char *)buf5->buffer;
4918 while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
4919 rpcstr_pull(f, src, sizeof(f)-1, -1, 0);
4920 src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
4921 tar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2));
4926 fstrcpy((*ar)[n], f);
4929 fstrcpy((*ar)[n], "");
4937 /*******************************************************************
4938 read a UNICODE array with null terminated strings
4939 and null terminated array
4940 and size of array at beginning
4941 ********************************************************************/
4943 BOOL smb_io_unibuffer(char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
4945 if (buffer==NULL) return False;
4948 buffer->uni_str_len=buffer->uni_max_len;
4950 if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
4953 if(!prs_unistr2(True, "buffer ", ps, depth, buffer))
4959 /*******************************************************************
4960 ********************************************************************/
4962 BOOL spool_io_printer_driver_info_level(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
4964 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
4969 if(!prs_uint32("level", ps, depth, &il->level))
4971 if(!prs_uint32("ptr", ps, depth, &il->ptr))
4977 switch (il->level) {
4979 if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth))
4983 if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth))
4993 /*******************************************************************
4994 init a SPOOL_Q_ADDPRINTERDRIVER struct
4995 ******************************************************************/
4997 BOOL make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
4998 SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name,
4999 uint32 level, PRINTER_DRIVER_CTR *info)
5001 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5003 q_u->server_name_ptr = (srv_name!=NULL)?1:0;
5004 init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)+1);
5008 q_u->info.level = level;
5009 q_u->info.ptr = (info!=NULL)?1:0;
5012 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5014 make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3);
5018 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level));
5025 BOOL make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
5026 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
5027 DRIVER_INFO_3 *info3)
5030 uint16 *ptr = info3->dependentfiles;
5032 BOOL null_char = False;
5033 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf;
5035 if (!(inf=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3*)talloc_zero(mem_ctx, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3))))
5038 inf->cversion = info3->version;
5039 inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
5040 inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
5041 inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
5042 inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
5043 inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
5044 inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
5045 inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
5046 inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
5048 init_unistr2_from_unistr(&inf->name, &info3->name);
5049 init_unistr2_from_unistr(&inf->environment, &info3->architecture);
5050 init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
5051 init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
5052 init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
5053 init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
5054 init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
5055 init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
5062 /* the null_char BOOL is used to help locate
5063 two '\0's back to back */
5078 inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0;
5079 inf->dependentfilessize = len;
5080 if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles))
5086 *spool_drv_info = inf;
5091 /*******************************************************************
5092 make a BUFFER5 struct from a uint16*
5093 ******************************************************************/
5094 BOOL make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src)
5097 buf5->buf_len = len;
5098 if((buf5->buffer=(uint16*)talloc_memdup(mem_ctx, src, sizeof(uint16)*len)) == NULL)
5100 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5107 /*******************************************************************
5108 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5109 ********************************************************************/
5111 BOOL spoolss_io_q_addprinterdriver(char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5113 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
5119 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
5121 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
5126 if(!prs_uint32("info_level", ps, depth, &q_u->level))
5129 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
5135 /*******************************************************************
5136 ********************************************************************/
5138 BOOL spoolss_io_r_addprinterdriver(char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
5140 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
5143 if(!prs_werror("status", ps, depth, &q_u->status))
5149 /*******************************************************************
5150 ********************************************************************/
5152 BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
5153 NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc)
5155 NT_PRINTER_DRIVER_INFO_LEVEL_3 *d;
5157 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5161 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3));
5169 d->cversion=uni->cversion;
5171 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5172 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5173 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5174 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5175 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5176 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5177 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5178 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5180 DEBUGADD(8,( "version: %d\n", d->cversion));
5181 DEBUGADD(8,( "name: %s\n", d->name));
5182 DEBUGADD(8,( "environment: %s\n", d->environment));
5183 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5184 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5185 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5186 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5187 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5188 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5190 if (uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5197 /*******************************************************************
5198 ********************************************************************/
5199 BOOL uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *uni,
5200 NT_PRINTER_DRIVER_INFO_LEVEL_6 **asc)
5202 NT_PRINTER_DRIVER_INFO_LEVEL_6 *d;
5204 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5208 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_6 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6));
5216 d->version=uni->version;
5218 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
5219 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
5220 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
5221 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
5222 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
5223 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
5224 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
5225 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
5227 DEBUGADD(8,( "version: %d\n", d->version));
5228 DEBUGADD(8,( "name: %s\n", d->name));
5229 DEBUGADD(8,( "environment: %s\n", d->environment));
5230 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
5231 DEBUGADD(8,( "datafile: %s\n", d->datafile));
5232 DEBUGADD(8,( "configfile: %s\n", d->configfile));
5233 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
5234 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
5235 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
5237 if (!uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles ))
5239 if (!uniarray_2_dosarray(&uni->previousnames, &d->previousnames ))
5249 BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
5250 NT_PRINTER_INFO_LEVEL_2 **asc)
5252 NT_PRINTER_INFO_LEVEL_2 *d;
5255 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5256 time_unix=time(NULL);
5259 DEBUGADD(8,("allocating memory\n"));
5261 *asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2));
5266 /* we allocate memory iff called from
5267 * addprinter(ex) so we can do one time stuff here.
5269 (*asc)->setuptime=time_unix;
5272 DEBUGADD(8,("start converting\n"));
5276 d->attributes=uni->attributes;
5277 d->priority=uni->priority;
5278 d->default_priority=uni->default_priority;
5279 d->starttime=uni->starttime;
5280 d->untiltime=uni->untiltime;
5281 d->status=uni->status;
5282 d->cjobs=uni->cjobs;
5284 unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1);
5285 unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1);
5286 unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
5287 unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
5288 unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
5289 unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
5290 unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
5291 unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
5292 unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
5293 unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype)-1);
5294 unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters)-1);
5299 /*******************************************************************
5301 ********************************************************************/
5303 BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u,
5304 fstring servername, fstring env_name, uint32 level,
5305 NEW_BUFFER *buffer, uint32 offered)
5307 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
5308 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name);
5312 q_u->offered=offered;
5317 /*******************************************************************
5318 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5319 ********************************************************************/
5321 BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth)
5323 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir");
5328 if(!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5330 if(!smb_io_unistr2("", &q_u->name, q_u->name_ptr, ps, depth))
5336 if(!prs_uint32("", ps, depth, &q_u->environment_ptr))
5338 if(!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5344 if(!prs_uint32("level", ps, depth, &q_u->level))
5347 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5353 if(!prs_uint32("offered", ps, depth, &q_u->offered))
5359 /*******************************************************************
5360 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5361 ********************************************************************/
5363 BOOL spoolss_io_r_getprinterdriverdir(char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth)
5365 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir");
5371 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5377 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5380 if (!prs_werror("status", ps, depth, &r_u->status))
5386 /*******************************************************************
5387 ********************************************************************/
5389 BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
5391 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
5397 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5403 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5406 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5409 if (!prs_werror("status", ps, depth, &r_u->status))
5415 /*******************************************************************
5416 ********************************************************************/
5418 BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth)
5420 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
5426 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5428 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5434 if (!prs_uint32("", ps, depth, &q_u->environment_ptr))
5436 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5442 if (!prs_uint32("level", ps, depth, &q_u->level))
5445 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5451 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5457 /*******************************************************************
5458 ********************************************************************/
5460 BOOL spoolss_io_q_addprintprocessor(char *desc, SPOOL_Q_ADDPRINTPROCESSOR *q_u, prs_struct *ps, int depth)
5462 prs_debug(ps, depth, desc, "spoolss_io_q_addprintprocessor");
5468 if (!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr))
5470 if (!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth))
5475 if (!smb_io_unistr2("environment", &q_u->environment, True, ps, depth))
5480 if (!smb_io_unistr2("path", &q_u->path, True, ps, depth))
5485 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5491 /*******************************************************************
5492 ********************************************************************/
5494 BOOL spoolss_io_r_addprintprocessor(char *desc, SPOOL_R_ADDPRINTPROCESSOR *r_u, prs_struct *ps, int depth)
5496 prs_debug(ps, depth, desc, "spoolss_io_r_addprintproicessor");
5502 if (!prs_werror("status", ps, depth, &r_u->status))
5508 /*******************************************************************
5509 ********************************************************************/
5511 BOOL spoolss_io_r_enumprintprocdatatypes(char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth)
5513 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes");
5519 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5525 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5528 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5531 if (!prs_werror("status", ps, depth, &r_u->status))
5537 /*******************************************************************
5538 ********************************************************************/
5540 BOOL spoolss_io_q_enumprintprocdatatypes(char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth)
5542 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes");
5548 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5550 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5556 if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr))
5558 if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth))
5564 if (!prs_uint32("level", ps, depth, &q_u->level))
5567 if(!spoolss_io_buffer("buffer", ps, depth, &q_u->buffer))
5573 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5579 /*******************************************************************
5580 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5581 ********************************************************************/
5583 BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
5585 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
5591 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5593 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5599 if (!prs_uint32("level", ps, depth, &q_u->level))
5602 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5608 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5614 /*******************************************************************
5615 ********************************************************************/
5617 BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
5619 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
5625 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5631 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5634 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5637 if (!prs_werror("status", ps, depth, &r_u->status))
5643 /*******************************************************************
5644 ********************************************************************/
5646 BOOL spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth)
5648 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata");
5653 if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize))
5656 if(!prs_uint16uni(False, "value", ps, depth, r_u->value, r_u->valuesize ))
5662 if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize))
5665 if(!prs_uint32("type", ps, depth, &r_u->type))
5668 if(!prs_uint32("datasize", ps, depth, &r_u->datasize))
5670 if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize))
5675 if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize))
5677 if(!prs_werror("status", ps, depth, &r_u->status))
5683 /*******************************************************************
5684 ********************************************************************/
5686 BOOL spoolss_io_q_enumprinterdata(char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth)
5688 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata");
5693 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5695 if(!prs_uint32("index", ps, depth, &q_u->index))
5697 if(!prs_uint32("valuesize", ps, depth, &q_u->valuesize))
5699 if(!prs_uint32("datasize", ps, depth, &q_u->datasize))
5705 /*******************************************************************
5706 ********************************************************************/
5708 BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
5709 const POLICY_HND *hnd,
5710 uint32 idx, uint32 valuelen, uint32 datalen)
5712 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5714 q_u->valuesize=valuelen;
5715 q_u->datasize=datalen;
5720 /*******************************************************************
5721 ********************************************************************/
5722 BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, TALLOC_CTX *ctx, const POLICY_HND *hnd,
5723 char* value, char* data)
5727 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5729 init_unistr2(&q_u->value, value, strlen(value)+1);
5731 init_unistr2(&tmp, data, strlen(data)+1);
5732 q_u->max_len = q_u->real_len = tmp.uni_max_len*2;
5733 q_u->data = talloc(ctx, q_u->real_len);
5734 memcpy(q_u->data, tmp.buffer, q_u->real_len);
5738 /*******************************************************************
5739 ********************************************************************/
5741 BOOL spoolss_io_q_setprinterdata(char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
5743 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
5748 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5750 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
5756 if(!prs_uint32("type", ps, depth, &q_u->type))
5759 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
5769 if (UNMARSHALLING(ps))
5770 q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
5771 if(q_u->data == NULL)
5773 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
5781 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
5787 /*******************************************************************
5788 ********************************************************************/
5790 BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
5792 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
5797 if(!prs_werror("status", ps, depth, &r_u->status))
5803 /*******************************************************************
5804 ********************************************************************/
5805 BOOL spoolss_io_q_resetprinter(char *desc, SPOOL_Q_RESETPRINTER *q_u, prs_struct *ps, int depth)
5807 prs_debug(ps, depth, desc, "spoolss_io_q_resetprinter");
5812 if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5815 if (!prs_uint32("datatype_ptr", ps, depth, &q_u->datatype_ptr))
5818 if (q_u->datatype_ptr) {
5819 if (!smb_io_unistr2("datatype", &q_u->datatype, q_u->datatype_ptr?True:False, ps, depth))
5823 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
5830 /*******************************************************************
5831 ********************************************************************/
5832 BOOL spoolss_io_r_resetprinter(char *desc, SPOOL_R_RESETPRINTER *r_u, prs_struct *ps, int depth)
5834 prs_debug(ps, depth, desc, "spoolss_io_r_resetprinter");
5839 if(!prs_werror("status", ps, depth, &r_u->status))
5845 /*******************************************************************
5846 ********************************************************************/
5847 BOOL convert_specific_param(NT_PRINTER_PARAM **param, const UNISTR2 *value,
5848 uint32 type, const uint8 *data, uint32 len)
5850 DEBUG(5,("converting a specific param struct\n"));
5854 *param=(NT_PRINTER_PARAM *)malloc(sizeof(NT_PRINTER_PARAM));
5857 memset((char *)*param, '\0', sizeof(NT_PRINTER_PARAM));
5858 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5860 unistr2_to_ascii((*param)->value, value, sizeof((*param)->value)-1);
5861 (*param)->type = type;
5863 /* le champ data n'est pas NULL termine */
5864 /* on stocke donc la longueur */
5866 (*param)->data_len=len;
5869 (*param)->data=(uint8 *)malloc(len * sizeof(uint8));
5870 if((*param)->data == NULL)
5872 memcpy((*param)->data, data, len);
5875 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param)->value, (*param)->data_len));
5876 dump_data(10, (char *)(*param)->data, (*param)->data_len);
5881 /*******************************************************************
5882 ********************************************************************/
5884 static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth)
5886 prs_debug(ps, depth, desc, "spoolss_io_addform");
5893 if(!prs_uint32("flags", ps, depth, &f->flags))
5895 if(!prs_uint32("name_ptr", ps, depth, &f->name_ptr))
5897 if(!prs_uint32("size_x", ps, depth, &f->size_x))
5899 if(!prs_uint32("size_y", ps, depth, &f->size_y))
5901 if(!prs_uint32("left", ps, depth, &f->left))
5903 if(!prs_uint32("top", ps, depth, &f->top))
5905 if(!prs_uint32("right", ps, depth, &f->right))
5907 if(!prs_uint32("bottom", ps, depth, &f->bottom))
5910 if(!smb_io_unistr2("", &f->name, f->name_ptr, ps, depth))
5917 /*******************************************************************
5918 ********************************************************************/
5920 BOOL spoolss_io_q_deleteform(char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth)
5922 prs_debug(ps, depth, desc, "spoolss_io_q_deleteform");
5927 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5929 if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth))
5935 /*******************************************************************
5936 ********************************************************************/
5938 BOOL spoolss_io_r_deleteform(char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth)
5940 prs_debug(ps, depth, desc, "spoolss_io_r_deleteform");
5945 if(!prs_werror("status", ps, depth, &r_u->status))
5951 /*******************************************************************
5952 ********************************************************************/
5954 BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth)
5956 uint32 useless_ptr=1;
5957 prs_debug(ps, depth, desc, "spoolss_io_q_addform");
5962 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5964 if(!prs_uint32("level", ps, depth, &q_u->level))
5966 if(!prs_uint32("level2", ps, depth, &q_u->level2))
5971 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
5973 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
5980 /*******************************************************************
5981 ********************************************************************/
5983 BOOL spoolss_io_r_addform(char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth)
5985 prs_debug(ps, depth, desc, "spoolss_io_r_addform");
5990 if(!prs_werror("status", ps, depth, &r_u->status))
5996 /*******************************************************************
5997 ********************************************************************/
5999 BOOL spoolss_io_q_setform(char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth)
6001 uint32 useless_ptr=1;
6002 prs_debug(ps, depth, desc, "spoolss_io_q_setform");
6007 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6009 if(!smb_io_unistr2("", &q_u->name, True, ps, depth))
6015 if(!prs_uint32("level", ps, depth, &q_u->level))
6017 if(!prs_uint32("level2", ps, depth, &q_u->level2))
6022 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
6024 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
6031 /*******************************************************************
6032 ********************************************************************/
6034 BOOL spoolss_io_r_setform(char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth)
6036 prs_debug(ps, depth, desc, "spoolss_io_r_setform");
6041 if(!prs_werror("status", ps, depth, &r_u->status))
6047 /*******************************************************************
6048 Parse a SPOOL_R_GETJOB structure.
6049 ********************************************************************/
6051 BOOL spoolss_io_r_getjob(char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
6053 prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
6059 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
6065 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6068 if (!prs_werror("status", ps, depth, &r_u->status))
6074 /*******************************************************************
6075 Parse a SPOOL_Q_GETJOB structure.
6076 ********************************************************************/
6078 BOOL spoolss_io_q_getjob(char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
6080 prs_debug(ps, depth, desc, "");
6086 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6088 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
6090 if(!prs_uint32("level", ps, depth, &q_u->level))
6093 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
6099 if(!prs_uint32("offered", ps, depth, &q_u->offered))
6105 void free_devmode(DEVICEMODE *devmode)
6107 if (devmode!=NULL) {
6108 SAFE_FREE(devmode->private);
6113 void free_printer_info_1(PRINTER_INFO_1 *printer)
6118 void free_printer_info_2(PRINTER_INFO_2 *printer)
6120 if (printer!=NULL) {
6121 free_devmode(printer->devmode);
6122 printer->devmode = NULL;
6127 void free_printer_info_3(PRINTER_INFO_3 *printer)
6132 void free_printer_info_4(PRINTER_INFO_4 *printer)
6137 void free_printer_info_5(PRINTER_INFO_5 *printer)
6142 void free_job_info_2(JOB_INFO_2 *job)
6145 free_devmode(job->devmode);
6148 /*******************************************************************
6150 ********************************************************************/
6152 BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
6153 const fstring string, uint32 printer, uint32 type)
6158 init_unistr2(&q_u->string, string, strlen(string)+1);
6160 q_u->printer=printer;
6169 /*******************************************************************
6170 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6171 ********************************************************************/
6173 BOOL spoolss_io_q_replyopenprinter(char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
6175 prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
6181 if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
6187 if(!prs_uint32("printer", ps, depth, &q_u->printer))
6189 if(!prs_uint32("type", ps, depth, &q_u->type))
6192 if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6194 if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6200 /*******************************************************************
6201 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6202 ********************************************************************/
6204 BOOL spoolss_io_r_replyopenprinter(char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
6206 prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
6212 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6215 if (!prs_werror("status", ps, depth, &r_u->status))
6221 /*******************************************************************
6223 ********************************************************************/
6224 BOOL make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER *q_u, POLICY_HND *hnd,
6225 uint32 condition, uint32 change_id)
6228 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6230 q_u->condition = condition;
6231 q_u->change_id = change_id;
6234 q_u->unknown1 = 0x1;
6235 memset(q_u->unknown2, 0x0, 5);
6236 q_u->unknown2[0] = 0x1;
6241 /*******************************************************************
6242 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6243 ********************************************************************/
6244 BOOL spoolss_io_q_routerreplyprinter (char *desc, SPOOL_Q_ROUTERREPLYPRINTER *q_u, prs_struct *ps, int depth)
6247 prs_debug(ps, depth, desc, "spoolss_io_q_routerreplyprinter");
6253 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6256 if (!prs_uint32("condition", ps, depth, &q_u->condition))
6259 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6262 if (!prs_uint32("change_id", ps, depth, &q_u->change_id))
6265 if (!prs_uint8s(False, "private", ps, depth, q_u->unknown2, 5))
6271 /*******************************************************************
6272 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6273 ********************************************************************/
6274 BOOL spoolss_io_r_routerreplyprinter (char *desc, SPOOL_R_ROUTERREPLYPRINTER *r_u, prs_struct *ps, int depth)
6276 prs_debug(ps, depth, desc, "spoolss_io_r_routerreplyprinter");
6282 if (!prs_werror("status", ps, depth, &r_u->status))
6288 /*******************************************************************
6290 ********************************************************************/
6292 BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd)
6297 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6302 /*******************************************************************
6303 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6304 ********************************************************************/
6306 BOOL spoolss_io_q_replycloseprinter(char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth)
6308 prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
6314 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6320 /*******************************************************************
6321 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6322 ********************************************************************/
6324 BOOL spoolss_io_r_replycloseprinter(char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth)
6326 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
6332 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
6335 if (!prs_werror("status", ps, depth, &r_u->status))
6341 #if 0 /* JERRY - not currently used but could be :-) */
6343 /*******************************************************************
6344 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6345 ******************************************************************/
6346 static BOOL copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA *dst,
6347 SPOOL_NOTIFY_INFO_DATA *src, int n)
6351 memcpy(dst, src, sizeof(SPOOL_NOTIFY_INFO_DATA)*n);
6353 for (i=0; i<n; i++) {
6357 if (src->size != POINTER)
6359 len = src->notify_data.data.length;
6360 s = malloc(sizeof(uint16)*len);
6362 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6366 memcpy(s, src->notify_data.data.string, len*2);
6367 dst->notify_data.data.string = s;
6373 /*******************************************************************
6374 Deep copy a SPOOL_NOTIFY_INFO structure
6375 ******************************************************************/
6376 static BOOL copy_spool_notify_info(SPOOL_NOTIFY_INFO *dst, SPOOL_NOTIFY_INFO *src)
6379 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6383 dst->version = src->version;
6384 dst->flags = src->flags;
6385 dst->count = src->count;
6389 dst->data = malloc(dst->count * sizeof(SPOOL_NOTIFY_INFO_DATA));
6391 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6394 if (dst->data == NULL) {
6395 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6400 return (copy_spool_notify_info_data(dst->data, src->data, src->count));
6407 /*******************************************************************
6409 ********************************************************************/
6411 BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
6412 uint32 change_low, uint32 change_high,
6413 SPOOL_NOTIFY_INFO *info)
6418 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
6420 q_u->change_low=change_low;
6421 q_u->change_high=change_high;
6426 q_u->info_ptr=0xaddee11e;
6428 q_u->info.version=2;
6431 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6433 q_u->info.version = info->version;
6434 q_u->info.flags = info->flags;
6435 q_u->info.count = info->count;
6436 /* pointer field - be careful! */
6437 q_u->info.data = info->data;
6440 q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
6447 /*******************************************************************
6448 Parse a SPOOL_Q_REPLY_RRPCN structure.
6449 ********************************************************************/
6451 BOOL spoolss_io_q_reply_rrpcn(char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
6453 prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
6459 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6462 if (!prs_uint32("change_low", ps, depth, &q_u->change_low))
6465 if (!prs_uint32("change_high", ps, depth, &q_u->change_high))
6468 if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
6471 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
6474 if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr))
6477 if(q_u->info_ptr!=0)
6478 if(!smb_io_notify_info(desc, &q_u->info, ps, depth))
6484 /*******************************************************************
6485 Parse a SPOOL_R_REPLY_RRPCN structure.
6486 ********************************************************************/
6488 BOOL spoolss_io_r_reply_rrpcn(char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth)
6490 prs_debug(ps, depth, desc, "spoolss_io_r_reply_rrpcn");
6496 if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0))
6499 if (!prs_werror("status", ps, depth, &r_u->status))
6505 /*******************************************************************
6507 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6508 ********************************************************************/
6510 BOOL spoolss_io_q_getprinterdataex(char *desc, SPOOL_Q_GETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6515 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdataex");
6520 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
6524 if (!smb_io_unistr2("keyname", &q_u->keyname,True,ps,depth))
6528 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
6532 if (!prs_uint32("size", ps, depth, &q_u->size))
6538 /*******************************************************************
6539 * write a structure.
6540 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6541 ********************************************************************/
6543 BOOL spoolss_io_r_getprinterdataex(char *desc, SPOOL_R_GETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6548 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdataex");
6553 if (!prs_uint32("type", ps, depth, &r_u->type))
6555 if (!prs_uint32("size", ps, depth, &r_u->size))
6558 if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
6564 if (!prs_uint32("needed", ps, depth, &r_u->needed))
6566 if (!prs_werror("status", ps, depth, &r_u->status))
6572 /*******************************************************************
6574 ********************************************************************/
6576 BOOL spoolss_io_q_setprinterdataex(char *desc, SPOOL_Q_SETPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6578 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdataex");
6583 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6585 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6591 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
6597 if(!prs_uint32("type", ps, depth, &q_u->type))
6600 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
6610 if (UNMARSHALLING(ps))
6611 q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
6612 if(q_u->data == NULL)
6614 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
6622 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
6628 /*******************************************************************
6629 * write a structure.
6630 ********************************************************************/
6632 BOOL spoolss_io_r_setprinterdataex(char *desc, SPOOL_R_SETPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6634 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdataex");
6639 if(!prs_werror("status", ps, depth, &r_u->status))
6646 /*******************************************************************
6648 ********************************************************************/
6650 BOOL spoolss_io_q_enumprinterkey(char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth)
6652 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterkey");
6657 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6660 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6666 if(!prs_uint32("size", ps, depth, &q_u->size))
6672 /*******************************************************************
6673 * write a structure.
6674 ********************************************************************/
6676 BOOL spoolss_io_r_enumprinterkey(char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth)
6678 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterkey");
6684 if (!smb_io_buffer5("", &r_u->keys, ps, depth))
6690 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6693 if(!prs_werror("status", ps, depth, &r_u->status))
6700 /*******************************************************************
6702 ********************************************************************/
6704 BOOL spoolss_io_q_enumprinterdataex(char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth)
6706 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdataex");
6711 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
6714 if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
6720 if(!prs_uint32("size", ps, depth, &q_u->size))
6726 /*******************************************************************
6727 ********************************************************************/
6728 static BOOL spoolss_io_printer_enum_values_ctr(char *desc, prs_struct *ps,
6729 PRINTER_ENUM_VALUES_CTR *ctr, int depth)
6732 uint32 valuename_offset,
6735 const uint32 basic_unit = 20; /* size of static portion of enum_values */
6737 prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr");
6740 if (!prs_uint32("size", ps, depth, &ctr->size))
6743 /* offset data begins at 20 bytes per structure * size_of_array.
6744 Don't forget the uint32 at the beginning */
6746 current_offset = basic_unit * ctr->size_of_array;
6748 /* first loop to write basic enum_value information */
6750 for (i=0; i<ctr->size_of_array; i++)
6752 valuename_offset = current_offset;
6753 if (!prs_uint32("valuename_offset", ps, depth, &valuename_offset))
6756 if (!prs_uint32("value_len", ps, depth, &ctr->values[i].value_len))
6759 if (!prs_uint32("type", ps, depth, &ctr->values[i].type))
6762 data_offset = ctr->values[i].value_len + valuename_offset;
6763 if (!prs_uint32("data_offset", ps, depth, &data_offset))
6766 if (!prs_uint32("data_len", ps, depth, &ctr->values[i].data_len))
6769 current_offset = data_offset + ctr->values[i].data_len - basic_unit;
6772 /* loop #2 for writing the dynamically size objects
6773 while viewing conversations between Win2k -> Win2k,
6774 4-byte alignment does not seem to matter here --jerry */
6776 for (i=0; i<ctr->size_of_array; i++)
6779 if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename))
6782 if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len))
6792 /*******************************************************************
6793 * write a structure.
6794 ********************************************************************/
6796 BOOL spoolss_io_r_enumprinterdataex(char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth)
6798 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdataex");
6804 if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth ))
6810 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6813 if(!prs_uint32("returned", ps, depth, &r_u->returned))
6816 if(!prs_werror("status", ps, depth, &r_u->status))
6823 /*******************************************************************
6824 * write a structure.
6825 ********************************************************************/
6828 uint32 GetPrintProcessorDirectory(
6830 [in] unistr2 *environment,
6832 [in,out] NEW_BUFFER buffer,
6833 [in] uint32 offered,
6834 [out] uint32 needed,
6835 [out] uint32 returned
6840 BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, NEW_BUFFER *buffer, uint32 offered)
6842 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
6844 init_unistr2(&q_u->name, name, strlen(name)+1);
6845 init_unistr2(&q_u->environment, environment, strlen(environment)+1);
6849 q_u->buffer = buffer;
6850 q_u->offered = offered;
6855 BOOL spoolss_io_q_getprintprocessordirectory(char *desc, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, prs_struct *ps, int depth)
6859 prs_debug(ps, depth, desc, "spoolss_io_q_getprintprocessordirectory");
6865 if (!prs_uint32("ptr", ps, depth, &ptr))
6869 if(!smb_io_unistr2("name", &q_u->name, True, ps, depth))
6876 if (!prs_uint32("ptr", ps, depth, &ptr))
6880 if(!smb_io_unistr2("environment", &q_u->environment, True,
6888 if(!prs_uint32("level", ps, depth, &q_u->level))
6891 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
6897 if(!prs_uint32("offered", ps, depth, &q_u->offered))
6903 /*******************************************************************
6904 * write a structure.
6905 ********************************************************************/
6907 BOOL spoolss_io_r_getprintprocessordirectory(char *desc, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u, prs_struct *ps, int depth)
6909 prs_debug(ps, depth, desc, "spoolss_io_r_getprintprocessordirectory");
6915 if(!spoolss_io_buffer("", ps, depth, &r_u->buffer))
6921 if(!prs_uint32("needed", ps, depth, &r_u->needed))
6924 if(!prs_werror("status", ps, depth, &r_u->status))
6930 BOOL smb_io_printprocessordirectory_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth)
6932 prs_struct *ps=&buffer->prs;
6934 prs_debug(ps, depth, desc, "smb_io_printprocessordirectory_1");
6937 buffer->struct_start=prs_offset(ps);
6939 if (!smb_io_unistr(desc, &info->name, ps, depth))
6945 /*******************************************************************
6947 ********************************************************************/
6949 BOOL make_spoolss_q_addform(SPOOL_Q_ADDFORM *q_u, POLICY_HND *handle,
6950 int level, FORM *form)
6952 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
6954 q_u->level2 = level;
6955 memcpy(&q_u->form, form, sizeof(FORM));
6960 /*******************************************************************
6962 ********************************************************************/
6964 BOOL make_spoolss_q_setform(SPOOL_Q_SETFORM *q_u, POLICY_HND *handle,
6965 int level, char *form_name, FORM *form)
6967 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
6969 q_u->level2 = level;
6970 memcpy(&q_u->form, form, sizeof(FORM));
6971 init_unistr2(&q_u->name, form_name, strlen(form_name) + 1);
6976 /*******************************************************************
6978 ********************************************************************/
6980 BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle, char *form)
6982 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
6983 init_unistr2(&q_u->name, form, strlen(form) + 1);
6987 /*******************************************************************
6989 ********************************************************************/
6991 BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle,
6992 char *formname, uint32 level, NEW_BUFFER *buffer,
6995 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
6997 init_unistr2(&q_u->formname, formname, strlen(formname) + 1);
6999 q_u->offered=offered;
7004 /*******************************************************************
7006 ********************************************************************/
7008 BOOL make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
7009 uint32 level, NEW_BUFFER *buffer,
7012 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7015 q_u->offered=offered;
7020 /*******************************************************************
7022 ********************************************************************/
7024 BOOL make_spoolss_q_setjob(SPOOL_Q_SETJOB *q_u, POLICY_HND *handle,
7025 uint32 jobid, uint32 level, uint32 command)
7027 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7031 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7032 the server side code has it marked as unused. */
7034 q_u->command = command;
7039 /*******************************************************************
7041 ********************************************************************/
7043 BOOL make_spoolss_q_getjob(SPOOL_Q_GETJOB *q_u, POLICY_HND *handle,
7044 uint32 jobid, uint32 level, NEW_BUFFER *buffer,
7047 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7050 q_u->buffer = buffer;
7051 q_u->offered = offered;
7056 /*******************************************************************
7058 ********************************************************************/
7060 BOOL make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u,
7063 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
7068 /*******************************************************************
7070 ********************************************************************/
7072 BOOL make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u,
7075 memcpy(&q_u->handle, handle, sizeof(POLICY_HND));