merge from 2.2
[Samba/gbeck.git] / source / rpc_parse / parse_spoolss.c
blobff3e53273a0a9f542a7c6b2e05062cc5e5d9b914
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Jean François Micouleau 1998-2000.
8 * Copyright (C) Gerald Carter 2000
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "includes.h"
27 extern int DEBUGLEVEL;
29 /*******************************************************************
30 return the length of a UNISTR string.
31 ********************************************************************/
33 static uint32 str_len_uni(UNISTR *source)
35 uint32 i=0;
37 if (!source->buffer)
38 return 0;
40 while (source->buffer[i])
41 i++;
43 return i;
46 /*******************************************************************
47 This should be moved in a more generic lib.
48 ********************************************************************/
50 static BOOL spoolss_io_system_time(char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime)
52 if(!prs_uint16("year", ps, depth, &(systime->year)))
53 return False;
54 if(!prs_uint16("month", ps, depth, &(systime->month)))
55 return False;
56 if(!prs_uint16("dayofweek", ps, depth, &(systime->dayofweek)))
57 return False;
58 if(!prs_uint16("day", ps, depth, &(systime->day)))
59 return False;
60 if(!prs_uint16("hour", ps, depth, &(systime->hour)))
61 return False;
62 if(!prs_uint16("minute", ps, depth, &(systime->minute)))
63 return False;
64 if(!prs_uint16("second", ps, depth, &(systime->second)))
65 return False;
66 if(!prs_uint16("milliseconds", ps, depth, &(systime->milliseconds)))
67 return False;
69 return True;
72 /*******************************************************************
73 ********************************************************************/
75 BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime)
77 systime->year=unixtime->tm_year+1900;
78 systime->month=unixtime->tm_mon+1;
79 systime->dayofweek=unixtime->tm_wday;
80 systime->day=unixtime->tm_mday;
81 systime->hour=unixtime->tm_hour;
82 systime->minute=unixtime->tm_min;
83 systime->second=unixtime->tm_sec;
84 systime->milliseconds=0;
86 return True;
89 /*******************************************************************
90 reads or writes an DOC_INFO structure.
91 ********************************************************************/
93 static BOOL smb_io_doc_info_1(char *desc, DOC_INFO_1 *info_1, prs_struct *ps, int depth)
95 if (info_1 == NULL) return False;
97 prs_debug(ps, depth, desc, "smb_io_doc_info_1");
98 depth++;
100 if(!prs_align(ps))
101 return False;
103 if(!prs_uint32("p_docname", ps, depth, &info_1->p_docname))
104 return False;
105 if(!prs_uint32("p_outputfile", ps, depth, &info_1->p_outputfile))
106 return False;
107 if(!prs_uint32("p_datatype", ps, depth, &info_1->p_datatype))
108 return False;
110 if(!smb_io_unistr2("", &info_1->docname, info_1->p_docname, ps, depth))
111 return False;
112 if(!smb_io_unistr2("", &info_1->outputfile, info_1->p_outputfile, ps, depth))
113 return False;
114 if(!smb_io_unistr2("", &info_1->datatype, info_1->p_datatype, ps, depth))
115 return False;
117 return True;
120 /*******************************************************************
121 reads or writes an DOC_INFO structure.
122 ********************************************************************/
124 static BOOL smb_io_doc_info(char *desc, DOC_INFO *info, prs_struct *ps, int depth)
126 uint32 useless_ptr=0;
128 if (info == NULL) return False;
130 prs_debug(ps, depth, desc, "smb_io_doc_info");
131 depth++;
133 if(!prs_align(ps))
134 return False;
136 if(!prs_uint32("switch_value", ps, depth, &info->switch_value))
137 return False;
139 if(!prs_uint32("doc_info_X ptr", ps, depth, &useless_ptr))
140 return False;
142 switch (info->switch_value)
144 case 1:
145 if(!smb_io_doc_info_1("",&info->doc_info_1, ps, depth))
146 return False;
147 break;
148 case 2:
150 this is just a placeholder
152 MSDN July 1998 says doc_info_2 is only on
153 Windows 95, and as Win95 doesn't do RPC to print
154 this case is nearly impossible
156 Maybe one day with Windows for dishwasher 2037 ...
159 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
160 break;
161 default:
162 DEBUG(0,("Something is obviously wrong somewhere !\n"));
163 break;
166 return True;
169 /*******************************************************************
170 reads or writes an DOC_INFO_CONTAINER structure.
171 ********************************************************************/
173 static BOOL smb_io_doc_info_container(char *desc, DOC_INFO_CONTAINER *cont, prs_struct *ps, int depth)
175 if (cont == NULL) return False;
177 prs_debug(ps, depth, desc, "smb_io_doc_info_container");
178 depth++;
180 if(!prs_align(ps))
181 return False;
183 if(!prs_uint32("level", ps, depth, &cont->level))
184 return False;
186 if(!smb_io_doc_info("",&cont->docinfo, ps, depth))
187 return False;
189 return True;
192 /*******************************************************************
193 reads or writes an NOTIFY OPTION TYPE structure.
194 ********************************************************************/
196 static BOOL smb_io_notify_option_type(char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
198 prs_debug(ps, depth, desc, "smb_io_notify_option_type");
199 depth++;
201 if (!prs_align(ps))
202 return False;
204 if(!prs_uint16("type", ps, depth, &type->type))
205 return False;
206 if(!prs_uint16("reserved0", ps, depth, &type->reserved0))
207 return False;
208 if(!prs_uint32("reserved1", ps, depth, &type->reserved1))
209 return False;
210 if(!prs_uint32("reserved2", ps, depth, &type->reserved2))
211 return False;
212 if(!prs_uint32("count", ps, depth, &type->count))
213 return False;
214 if(!prs_uint32("fields_ptr", ps, depth, &type->fields_ptr))
215 return False;
217 return True;
220 /*******************************************************************
221 reads or writes an NOTIFY OPTION TYPE DATA.
222 ********************************************************************/
224 static BOOL smb_io_notify_option_type_data(char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth)
226 int i;
228 prs_debug(ps, depth, desc, "smb_io_notify_option_type_data");
229 depth++;
231 /* if there are no fields just return */
232 if (type->fields_ptr==0)
233 return True;
235 if(!prs_align(ps))
236 return False;
238 if(!prs_uint32("count2", ps, depth, &type->count2))
239 return False;
241 if (type->count2 != type->count)
242 DEBUG(4,("What a mess, count was %x now is %x !\n", type->count, type->count2));
244 /* parse the option type data */
245 for(i=0;i<type->count2;i++)
246 if(!prs_uint16("fields",ps,depth,&type->fields[i]))
247 return False;
248 return True;
251 /*******************************************************************
252 reads or writes an NOTIFY OPTION structure.
253 ********************************************************************/
255 static BOOL smb_io_notify_option_type_ctr(char *desc, SPOOL_NOTIFY_OPTION_TYPE_CTR *ctr , prs_struct *ps, int depth)
257 int i;
259 prs_debug(ps, depth, desc, "smb_io_notify_option_type_ctr");
260 depth++;
262 if(!prs_uint32("count", ps, depth, &ctr->count))
263 return False;
265 /* reading */
266 if (UNMARSHALLING(ps))
267 if((ctr->type=(SPOOL_NOTIFY_OPTION_TYPE *)prs_alloc_mem(ps,ctr->count*sizeof(SPOOL_NOTIFY_OPTION_TYPE))) == NULL)
268 return False;
270 /* the option type struct */
271 for(i=0;i<ctr->count;i++)
272 if(!smb_io_notify_option_type("", &ctr->type[i] , ps, depth))
273 return False;
275 /* the type associated with the option type struct */
276 for(i=0;i<ctr->count;i++)
277 if(!smb_io_notify_option_type_data("", &ctr->type[i] , ps, depth))
278 return False;
280 return True;
283 /*******************************************************************
284 reads or writes an NOTIFY OPTION structure.
285 ********************************************************************/
287 static BOOL smb_io_notify_option(char *desc, SPOOL_NOTIFY_OPTION *option, prs_struct *ps, int depth)
289 prs_debug(ps, depth, desc, "smb_io_notify_option");
290 depth++;
292 if(!prs_uint32("version", ps, depth, &option->version))
293 return False;
294 if(!prs_uint32("flags", ps, depth, &option->flags))
295 return False;
296 if(!prs_uint32("count", ps, depth, &option->count))
297 return False;
298 if(!prs_uint32("option_type_ptr", ps, depth, &option->option_type_ptr))
299 return False;
301 /* marshalling or unmarshalling, that would work */
302 if (option->option_type_ptr!=0) {
303 if(!smb_io_notify_option_type_ctr("", &option->ctr ,ps, depth))
304 return False;
306 else {
307 option->ctr.type=NULL;
308 option->ctr.count=0;
311 return True;
314 /*******************************************************************
315 reads or writes an NOTIFY INFO DATA structure.
316 ********************************************************************/
318 static BOOL smb_io_notify_info_data(char *desc,SPOOL_NOTIFY_INFO_DATA *data, prs_struct *ps, int depth)
320 uint32 useless_ptr=0xADDE0FF0;
322 uint32 how_many_words;
323 BOOL isvalue;
324 uint32 x;
326 prs_debug(ps, depth, desc, "smb_io_notify_info_data");
327 depth++;
329 how_many_words=data->size;
330 if (how_many_words==POINTER) {
331 how_many_words=TWO_VALUE;
334 isvalue=data->enc_type;
336 if(!prs_align(ps))
337 return False;
338 if(!prs_uint16("type", ps, depth, &data->type))
339 return False;
340 if(!prs_uint16("field", ps, depth, &data->field))
341 return False;
342 /*prs_align(ps);*/
344 if(!prs_uint32("how many words", ps, depth, &how_many_words))
345 return False;
346 if(!prs_uint32("id", ps, depth, &data->id))
347 return False;
348 if(!prs_uint32("how many words", ps, depth, &how_many_words))
349 return False;
352 /*prs_align(ps);*/
354 if (isvalue==True) {
355 if(!prs_uint32("value[0]", ps, depth, &data->notify_data.value[0]))
356 return False;
357 if(!prs_uint32("value[1]", ps, depth, &data->notify_data.value[1]))
358 return False;
359 /*prs_align(ps);*/
360 } else {
361 /* it's a string */
362 /* length in ascii including \0 */
363 x=2*(data->notify_data.data.length+1);
364 if(!prs_uint32("string length", ps, depth, &x ))
365 return False;
366 if(!prs_uint32("pointer", ps, depth, &useless_ptr))
367 return False;
368 /*prs_align(ps);*/
371 return True;
374 /*******************************************************************
375 reads or writes an NOTIFY INFO DATA structure.
376 ********************************************************************/
378 BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data,
379 prs_struct *ps, int depth)
381 uint32 x;
382 BOOL isvalue;
384 prs_debug(ps, depth, desc, "smb_io_notify_info_data_strings");
385 depth++;
387 if(!prs_align(ps))
388 return False;
390 isvalue=data->enc_type;
392 if (isvalue==False) {
393 /* length of string in unicode include \0 */
394 x=data->notify_data.data.length+1;
395 if(!prs_uint32("string length", ps, depth, &x ))
396 return False;
397 if (MARSHALLING(ps)) {
398 /* These are already in little endian format. Don't byte swap. */
399 if (x == 1) {
401 /* No memory allocated for this string
402 therefore following the data.string
403 pointer is a bad idea. Use a pointer to
404 the uint32 length union member to
405 provide a source for a unicode NULL */
407 if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2))
408 return False;
409 } else {
410 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
411 return False;
413 } else {
415 /* Tallocate memory for string */
417 data->notify_data.data.string = (uint16 *)prs_alloc_mem(ps, x * 2);
418 if (!data->notify_data.data.string)
419 return False;
421 if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x))
422 return False;
425 if(!prs_align(ps))
426 return False;
428 return True;
431 /*******************************************************************
432 reads or writes an NOTIFY INFO structure.
433 ********************************************************************/
435 static BOOL smb_io_notify_info(char *desc, SPOOL_NOTIFY_INFO *info, prs_struct *ps, int depth)
437 int i;
439 prs_debug(ps, depth, desc, "smb_io_notify_info");
440 depth++;
442 if(!prs_align(ps))
443 return False;
445 if(!prs_uint32("count", ps, depth, &info->count))
446 return False;
447 if(!prs_uint32("version", ps, depth, &info->version))
448 return False;
449 if(!prs_uint32("flags", ps, depth, &info->flags))
450 return False;
451 if(!prs_uint32("count", ps, depth, &info->count))
452 return False;
454 for (i=0;i<info->count;i++) {
455 if(!smb_io_notify_info_data(desc, &info->data[i], ps, depth))
456 return False;
459 /* now do the strings at the end of the stream */
460 for (i=0;i<info->count;i++) {
461 if(!smb_io_notify_info_data_strings(desc, &info->data[i], ps, depth))
462 return False;
465 return True;
468 /*******************************************************************
469 ********************************************************************/
471 static BOOL spool_io_user_level_1(char *desc, SPOOL_USER_1 *q_u, prs_struct *ps, int depth)
473 prs_debug(ps, depth, desc, "");
474 depth++;
476 /* reading */
477 if (UNMARSHALLING(ps))
478 ZERO_STRUCTP(q_u);
480 if (!prs_align(ps))
481 return False;
482 if (!prs_uint32("size", ps, depth, &q_u->size))
483 return False;
484 if (!prs_uint32("client_name_ptr", ps, depth, &q_u->client_name_ptr))
485 return False;
486 if (!prs_uint32("user_name_ptr", ps, depth, &q_u->user_name_ptr))
487 return False;
488 if (!prs_uint32("build", ps, depth, &q_u->build))
489 return False;
490 if (!prs_uint32("major", ps, depth, &q_u->major))
491 return False;
492 if (!prs_uint32("minor", ps, depth, &q_u->minor))
493 return False;
494 if (!prs_uint32("processor", ps, depth, &q_u->processor))
495 return False;
497 if (!smb_io_unistr2("", &q_u->client_name, q_u->client_name_ptr, ps, depth))
498 return False;
499 if (!prs_align(ps))
500 return False;
501 if (!smb_io_unistr2("", &q_u->user_name, q_u->user_name_ptr, ps, depth))
502 return False;
504 return True;
507 /*******************************************************************
508 ********************************************************************/
510 static BOOL spool_io_user_level(char *desc, SPOOL_USER_CTR *q_u, prs_struct *ps, int depth)
512 if (q_u==NULL)
513 return False;
515 prs_debug(ps, depth, desc, "spool_io_user_level");
516 depth++;
518 if (!prs_align(ps))
519 return False;
520 if (!prs_uint32("level", ps, depth, &q_u->level))
521 return False;
522 if (!prs_uint32("ptr", ps, depth, &q_u->ptr))
523 return False;
525 switch (q_u->level) {
526 case 1:
527 if (!spool_io_user_level_1("", &q_u->user1, ps, depth))
528 return False;
529 break;
530 default:
531 return False;
534 return True;
537 /*******************************************************************
538 * read or write a DEVICEMODE struct.
539 * on reading allocate memory for the private member
540 ********************************************************************/
542 static BOOL spoolss_io_devmode(char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode)
544 prs_debug(ps, depth, desc, "spoolss_io_devmode");
545 depth++;
547 if (UNMARSHALLING(ps)) {
548 devmode->devicename.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) );
549 if (devmode->devicename.buffer == NULL)
550 return False;
553 if (!prs_uint16uni(True,"devicename", ps, depth, devmode->devicename.buffer, 32))
554 return False;
555 if (!prs_uint16("specversion", ps, depth, &devmode->specversion))
556 return False;
557 if (!prs_uint16("driverversion", ps, depth, &devmode->driverversion))
558 return False;
559 if (!prs_uint16("size", ps, depth, &devmode->size))
560 return False;
561 if (!prs_uint16("driverextra", ps, depth, &devmode->driverextra))
562 return False;
563 if (!prs_uint32("fields", ps, depth, &devmode->fields))
564 return False;
565 if (!prs_uint16("orientation", ps, depth, &devmode->orientation))
566 return False;
567 if (!prs_uint16("papersize", ps, depth, &devmode->papersize))
568 return False;
569 if (!prs_uint16("paperlength", ps, depth, &devmode->paperlength))
570 return False;
571 if (!prs_uint16("paperwidth", ps, depth, &devmode->paperwidth))
572 return False;
573 if (!prs_uint16("scale", ps, depth, &devmode->scale))
574 return False;
575 if (!prs_uint16("copies", ps, depth, &devmode->copies))
576 return False;
577 if (!prs_uint16("defaultsource", ps, depth, &devmode->defaultsource))
578 return False;
579 if (!prs_uint16("printquality", ps, depth, &devmode->printquality))
580 return False;
581 if (!prs_uint16("color", ps, depth, &devmode->color))
582 return False;
583 if (!prs_uint16("duplex", ps, depth, &devmode->duplex))
584 return False;
585 if (!prs_uint16("yresolution", ps, depth, &devmode->yresolution))
586 return False;
587 if (!prs_uint16("ttoption", ps, depth, &devmode->ttoption))
588 return False;
589 if (!prs_uint16("collate", ps, depth, &devmode->collate))
590 return False;
592 if (UNMARSHALLING(ps)) {
593 devmode->formname.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) );
594 if (devmode->formname.buffer == NULL)
595 return False;
598 if (!prs_uint16uni(True, "formname", ps, depth, devmode->formname.buffer, 32))
599 return False;
600 if (!prs_uint16("logpixels", ps, depth, &devmode->logpixels))
601 return False;
602 if (!prs_uint32("bitsperpel", ps, depth, &devmode->bitsperpel))
603 return False;
604 if (!prs_uint32("pelswidth", ps, depth, &devmode->pelswidth))
605 return False;
606 if (!prs_uint32("pelsheight", ps, depth, &devmode->pelsheight))
607 return False;
608 if (!prs_uint32("displayflags", ps, depth, &devmode->displayflags))
609 return False;
610 if (!prs_uint32("displayfrequency", ps, depth, &devmode->displayfrequency))
611 return False;
612 if (!prs_uint32("icmmethod", ps, depth, &devmode->icmmethod))
613 return False;
614 if (!prs_uint32("icmintent", ps, depth, &devmode->icmintent))
615 return False;
616 if (!prs_uint32("mediatype", ps, depth, &devmode->mediatype))
617 return False;
618 if (!prs_uint32("dithertype", ps, depth, &devmode->dithertype))
619 return False;
620 if (!prs_uint32("reserved1", ps, depth, &devmode->reserved1))
621 return False;
622 if (!prs_uint32("reserved2", ps, depth, &devmode->reserved2))
623 return False;
624 if (!prs_uint32("panningwidth", ps, depth, &devmode->panningwidth))
625 return False;
626 if (!prs_uint32("panningheight", ps, depth, &devmode->panningheight))
627 return False;
629 if (devmode->driverextra!=0) {
630 if (UNMARSHALLING(ps)) {
631 devmode->private=(uint8 *)prs_alloc_mem(ps, devmode->driverextra*sizeof(uint8));
632 if(devmode->private == NULL)
633 return False;
634 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode->driverextra));
637 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode->driverextra));
638 if (!prs_uint8s(True, "private", ps, depth, devmode->private, devmode->driverextra))
639 return False;
642 return True;
645 /*******************************************************************
646 Read or write a DEVICEMODE container
647 ********************************************************************/
649 static BOOL spoolss_io_devmode_cont(char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth)
651 if (dm_c==NULL)
652 return False;
654 prs_debug(ps, depth, desc, "spoolss_io_devmode_cont");
655 depth++;
657 if(!prs_align(ps))
658 return False;
660 if (!prs_uint32("size", ps, depth, &dm_c->size))
661 return False;
663 if (!prs_uint32("devmode_ptr", ps, depth, &dm_c->devmode_ptr))
664 return False;
666 if (dm_c->size==0 || dm_c->devmode_ptr==0) {
667 if (UNMARSHALLING(ps))
668 /* if while reading there is no DEVMODE ... */
669 dm_c->devmode=NULL;
670 return True;
673 /* so we have a DEVICEMODE to follow */
674 if (UNMARSHALLING(ps)) {
675 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
676 dm_c->devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE));
677 if(dm_c->devmode == NULL)
678 return False;
681 /* this is bad code, shouldn't be there */
682 if (!prs_uint32("size", ps, depth, &dm_c->size))
683 return False;
685 if (!spoolss_io_devmode(desc, ps, depth, dm_c->devmode))
686 return False;
688 return True;
691 /*******************************************************************
692 ********************************************************************/
694 static BOOL spoolss_io_printer_default(char *desc, PRINTER_DEFAULT *pd, prs_struct *ps, int depth)
696 if (pd==NULL)
697 return False;
699 prs_debug(ps, depth, desc, "spoolss_io_printer_default");
700 depth++;
702 if (!prs_uint32("datatype_ptr", ps, depth, &pd->datatype_ptr))
703 return False;
705 if (!smb_io_unistr2("datatype", &pd->datatype, pd->datatype_ptr, ps,depth))
706 return False;
708 if (!prs_align(ps))
709 return False;
711 if (!spoolss_io_devmode_cont("", &pd->devmode_cont, ps, depth))
712 return False;
714 if (!prs_uint32("access_required", ps, depth, &pd->access_required))
715 return False;
717 return True;
720 /*******************************************************************
721 * init a structure.
722 ********************************************************************/
724 BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
725 const fstring printername,
726 const fstring datatype,
727 uint32 access_required,
728 const fstring clientname,
729 const fstring user_name)
731 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
732 q_u->printername_ptr = (printername!=NULL)?1:0;
733 init_unistr2(&q_u->printername, printername, strlen(printername)+1);
735 q_u->printer_default.datatype_ptr = 0;
737 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
738 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
740 q_u->printer_default.devmode_cont.size=0;
741 q_u->printer_default.devmode_cont.devmode_ptr=0;
742 q_u->printer_default.devmode_cont.devmode=NULL;
743 q_u->printer_default.access_required=access_required;
744 q_u->user_switch=1;
745 q_u->user_ctr.level=1;
746 q_u->user_ctr.ptr=1;
747 q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+10;
748 q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
749 q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
750 q_u->user_ctr.user1.build=1381;
751 q_u->user_ctr.user1.major=2;
752 q_u->user_ctr.user1.minor=0;
753 q_u->user_ctr.user1.processor=0;
754 init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
755 init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
757 return True;
760 /*******************************************************************
761 * init a structure.
762 ********************************************************************/
763 BOOL make_spoolss_q_addprinterex(
764 SPOOL_Q_ADDPRINTEREX *q_u,
765 const char *srv_name,
766 const char* clientname,
767 const char* user_name,
768 uint32 level,
769 PRINTER_INFO_CTR *ctr)
771 DEBUG(5,("make_spoolss_q_addprinterex\n"));
773 if (!ctr) return False;
775 q_u->server_name_ptr = (srv_name!=NULL)?1:0;
776 init_unistr2(&q_u->server_name, srv_name, strlen(srv_name));
778 q_u->level = level;
780 q_u->info.level = level;
781 q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0;
782 switch (level)
784 case 2:
785 /* init q_u->info.info2 from *info */
786 if (!make_spoolss_printer_info_2(&q_u->info.info_2, ctr->printers_2))
788 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
789 return False;
791 break;
792 default :
793 break;
796 q_u->unk0 = q_u->unk1 = q_u->unk2 = q_u->unk3 = 0;
798 q_u->user_switch=1;
800 q_u->user_ctr.level=1;
801 q_u->user_ctr.ptr=1;
802 q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0;
803 q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0;
804 q_u->user_ctr.user1.build=1381;
805 q_u->user_ctr.user1.major=2;
806 q_u->user_ctr.user1.minor=0;
807 q_u->user_ctr.user1.processor=0;
808 init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
809 init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
810 q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len +
811 q_u->user_ctr.user1.client_name.uni_str_len + 2;
813 return True;
816 /*******************************************************************
817 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
818 *******************************************************************/
820 BOOL make_spoolss_printer_info_2(
821 SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
822 PRINTER_INFO_2 *info
826 SPOOL_PRINTER_INFO_LEVEL_2 *inf;
828 /* allocate the necessary memory */
829 inf = (SPOOL_PRINTER_INFO_LEVEL_2*)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_2));
830 if (!spool_info2)
832 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
833 return False;
836 inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
837 inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
838 inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
839 inf->portname_ptr = (info->portname.buffer!=NULL)?1:0;
840 inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0;
841 inf->comment_ptr = (info->comment.buffer!=NULL)?1:0;
842 inf->location_ptr = (info->location.buffer!=NULL)?1:0;
843 inf->devmode_ptr = (info->devmode!=NULL)?1:0;
844 inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0;
845 inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0;
846 inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0;
847 inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0;
848 inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
849 inf->attributes = info->attributes;
850 inf->priority = info->priority;
851 inf->default_priority = info->defaultpriority;
852 inf->starttime = info->starttime;
853 inf->untiltime = info->untiltime;
854 inf->cjobs = info->cjobs;
855 inf->averageppm = info->averageppm;
856 init_unistr2_from_unistr(&inf->servername, &info->servername);
857 init_unistr2_from_unistr(&inf->printername, &info->printername);
858 init_unistr2_from_unistr(&inf->sharename, &info->sharename);
859 init_unistr2_from_unistr(&inf->portname, &info->portname);
860 init_unistr2_from_unistr(&inf->drivername, &info->drivername);
861 init_unistr2_from_unistr(&inf->comment, &info->comment);
862 init_unistr2_from_unistr(&inf->location, &info->location);
863 init_unistr2_from_unistr(&inf->sepfile, &info->sepfile);
864 init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor);
865 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
866 init_unistr2_from_unistr(&inf->parameters, &info->parameters);
867 init_unistr2_from_unistr(&inf->datatype, &info->datatype);
868 inf->secdesc = inf->secdesc;
870 *spool_info2 = inf;
872 return True;
875 /*******************************************************************
876 * read a structure.
877 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
878 ********************************************************************/
880 BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
882 if (q_u == NULL)
883 return False;
885 prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
886 depth++;
888 if (!prs_align(ps))
889 return False;
891 if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr))
892 return False;
893 if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth))
894 return False;
896 if (!prs_align(ps))
897 return False;
899 if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth))
900 return False;
902 if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
903 return False;
904 if (!spool_io_user_level("", &q_u->user_ctr, ps, depth))
905 return False;
907 return True;
910 /*******************************************************************
911 * write a structure.
912 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
913 * called from spoolss_open_printer_ex (cli_spoolss.c)
914 ********************************************************************/
916 BOOL spoolss_io_r_open_printer_ex(char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth)
918 if (r_u == NULL) return False;
920 prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex");
921 depth++;
923 if (!prs_align(ps))
924 return False;
926 if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth))
927 return False;
929 if (!prs_uint32("status code", ps, depth, &(r_u->status)))
930 return False;
932 return True;
935 /*******************************************************************
936 * make a structure.
937 ********************************************************************/
939 BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
940 const POLICY_HND *handle,
941 UNISTR2 *valuename, uint32 size)
943 if (q_u == NULL) return False;
945 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
947 q_u->handle = *handle;
948 copy_unistr2(&q_u->valuename, valuename);
949 q_u->size = size;
951 return True;
954 /*******************************************************************
955 * read a structure.
956 * called from spoolss_q_getprinterdata (srv_spoolss.c)
957 ********************************************************************/
959 BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth)
961 if (q_u == NULL)
962 return False;
964 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata");
965 depth++;
967 if (!prs_align(ps))
968 return False;
969 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
970 return False;
971 if (!prs_align(ps))
972 return False;
973 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
974 return False;
975 if (!prs_align(ps))
976 return False;
977 if (!prs_uint32("size", ps, depth, &q_u->size))
978 return False;
980 return True;
983 /*******************************************************************
984 * read a structure.
985 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
986 ********************************************************************/
988 BOOL spoolss_io_q_deleteprinterdata(char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth)
990 if (q_u == NULL)
991 return False;
993 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata");
994 depth++;
996 if (!prs_align(ps))
997 return False;
998 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
999 return False;
1000 if (!prs_align(ps))
1001 return False;
1002 if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth))
1003 return False;
1005 return True;
1008 /*******************************************************************
1009 * write a structure.
1010 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1011 ********************************************************************/
1013 BOOL spoolss_io_r_deleteprinterdata(char *desc, SPOOL_R_DELETEPRINTERDATA *r_u, prs_struct *ps, int depth)
1015 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdata");
1016 depth++;
1017 if(!prs_uint32("status", ps, depth, &r_u->status))
1018 return False;
1020 return True;
1023 /*******************************************************************
1024 * write a structure.
1025 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1026 ********************************************************************/
1028 BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth)
1030 if (r_u == NULL)
1031 return False;
1033 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata");
1034 depth++;
1036 if (!prs_align(ps))
1037 return False;
1038 if (!prs_uint32("type", ps, depth, &r_u->type))
1039 return False;
1040 if (!prs_uint32("size", ps, depth, &r_u->size))
1041 return False;
1043 if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size))
1044 return False;
1046 if (!prs_align(ps))
1047 return False;
1049 if (!prs_uint32("needed", ps, depth, &r_u->needed))
1050 return False;
1051 if (!prs_uint32("status", ps, depth, &r_u->status))
1052 return False;
1054 return True;
1057 /*******************************************************************
1058 * make a structure.
1059 ********************************************************************/
1061 BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
1063 if (q_u == NULL) return False;
1065 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1067 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
1069 return True;
1072 /*******************************************************************
1073 * read a structure.
1074 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1075 * called from spoolss_abortprinter (cli_spoolss.c)
1076 ********************************************************************/
1078 BOOL spoolss_io_q_abortprinter(char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth)
1080 if (q_u == NULL) return False;
1082 prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter");
1083 depth++;
1085 if (!prs_align(ps))
1086 return False;
1088 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1089 return False;
1091 return True;
1094 /*******************************************************************
1095 * write a structure.
1096 * called from spoolss_r_abortprinter (srv_spoolss.c)
1097 ********************************************************************/
1099 BOOL spoolss_io_r_abortprinter(char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth)
1101 prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter");
1102 depth++;
1103 if(!prs_uint32("status", ps, depth, &r_u->status))
1104 return False;
1106 return True;
1109 /*******************************************************************
1110 * read a structure.
1111 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1112 * called from spoolss_deleteprinter (cli_spoolss.c)
1113 ********************************************************************/
1115 BOOL spoolss_io_q_deleteprinter(char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
1117 if (q_u == NULL) return False;
1119 prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
1120 depth++;
1122 if (!prs_align(ps))
1123 return False;
1125 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1126 return False;
1128 return True;
1131 /*******************************************************************
1132 * write a structure.
1133 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1134 * called from spoolss_deleteprinter (cli_spoolss.c)
1135 ********************************************************************/
1137 BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
1139 prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
1140 depth++;
1142 if (!prs_align(ps))
1143 return False;
1145 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1146 return False;
1147 if (!prs_uint32("status", ps, depth, &r_u->status))
1148 return False;
1150 return True;
1153 /*******************************************************************
1154 * read a structure.
1155 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1156 * called from spoolss_closeprinter (cli_spoolss.c)
1157 ********************************************************************/
1159 BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
1161 if (q_u == NULL) return False;
1163 prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
1164 depth++;
1166 if (!prs_align(ps))
1167 return False;
1169 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1170 return False;
1172 return True;
1175 /*******************************************************************
1176 * write a structure.
1177 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1178 * called from spoolss_closeprinter (cli_spoolss.c)
1179 ********************************************************************/
1181 BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth)
1183 prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter");
1184 depth++;
1186 if (!prs_align(ps))
1187 return False;
1189 if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
1190 return False;
1191 if (!prs_uint32("status", ps, depth, &r_u->status))
1192 return False;
1194 return True;
1197 /*******************************************************************
1198 * read a structure.
1199 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1200 ********************************************************************/
1202 BOOL spoolss_io_q_startdocprinter(char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth)
1204 if (q_u == NULL) return False;
1206 prs_debug(ps, depth, desc, "spoolss_io_q_startdocprinter");
1207 depth++;
1209 if(!prs_align(ps))
1210 return False;
1212 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1213 return False;
1215 if(!smb_io_doc_info_container("",&q_u->doc_info_container, ps, depth))
1216 return False;
1218 return True;
1221 /*******************************************************************
1222 * write a structure.
1223 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1224 ********************************************************************/
1226 BOOL spoolss_io_r_startdocprinter(char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth)
1228 prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter");
1229 depth++;
1230 if(!prs_uint32("jobid", ps, depth, &r_u->jobid))
1231 return False;
1232 if(!prs_uint32("status", ps, depth, &r_u->status))
1233 return False;
1235 return True;
1238 /*******************************************************************
1239 * read a structure.
1240 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1241 ********************************************************************/
1243 BOOL spoolss_io_q_enddocprinter(char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth)
1245 if (q_u == NULL) return False;
1247 prs_debug(ps, depth, desc, "spoolss_io_q_enddocprinter");
1248 depth++;
1250 if(!prs_align(ps))
1251 return False;
1253 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1254 return False;
1256 return True;
1259 /*******************************************************************
1260 * write a structure.
1261 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1262 ********************************************************************/
1264 BOOL spoolss_io_r_enddocprinter(char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth)
1266 prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter");
1267 depth++;
1268 if(!prs_uint32("status", ps, depth, &r_u->status))
1269 return False;
1271 return True;
1274 /*******************************************************************
1275 * read a structure.
1276 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1277 ********************************************************************/
1279 BOOL spoolss_io_q_startpageprinter(char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth)
1281 if (q_u == NULL) return False;
1283 prs_debug(ps, depth, desc, "spoolss_io_q_startpageprinter");
1284 depth++;
1286 if(!prs_align(ps))
1287 return False;
1289 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1290 return False;
1292 return True;
1295 /*******************************************************************
1296 * write a structure.
1297 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1298 ********************************************************************/
1300 BOOL spoolss_io_r_startpageprinter(char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth)
1302 prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter");
1303 depth++;
1304 if(!prs_uint32("status", ps, depth, &r_u->status))
1305 return False;
1307 return True;
1310 /*******************************************************************
1311 * read a structure.
1312 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1313 ********************************************************************/
1315 BOOL spoolss_io_q_endpageprinter(char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth)
1317 if (q_u == NULL) return False;
1319 prs_debug(ps, depth, desc, "spoolss_io_q_endpageprinter");
1320 depth++;
1322 if(!prs_align(ps))
1323 return False;
1325 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1326 return False;
1328 return True;
1331 /*******************************************************************
1332 * write a structure.
1333 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1334 ********************************************************************/
1336 BOOL spoolss_io_r_endpageprinter(char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth)
1338 prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter");
1339 depth++;
1340 if(!prs_uint32("status", ps, depth, &r_u->status))
1341 return False;
1343 return True;
1346 /*******************************************************************
1347 * read a structure.
1348 * called from spoolss_q_writeprinter (srv_spoolss.c)
1349 ********************************************************************/
1351 BOOL spoolss_io_q_writeprinter(char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth)
1353 if (q_u == NULL) return False;
1355 prs_debug(ps, depth, desc, "spoolss_io_q_writeprinter");
1356 depth++;
1358 if(!prs_align(ps))
1359 return False;
1361 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1362 return False;
1363 if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size))
1364 return False;
1366 if (q_u->buffer_size!=0)
1368 if (UNMARSHALLING(ps))
1369 q_u->buffer=(uint8 *)prs_alloc_mem(ps,q_u->buffer_size*sizeof(uint8));
1370 if(q_u->buffer == NULL)
1371 return False;
1372 if(!prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size))
1373 return False;
1375 if(!prs_align(ps))
1376 return False;
1377 if(!prs_uint32("buffer_size2", ps, depth, &q_u->buffer_size2))
1378 return False;
1380 return True;
1383 /*******************************************************************
1384 * write a structure.
1385 * called from spoolss_r_writeprinter (srv_spoolss.c)
1386 ********************************************************************/
1388 BOOL spoolss_io_r_writeprinter(char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth)
1390 prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter");
1391 depth++;
1392 if(!prs_uint32("buffer_written", ps, depth, &r_u->buffer_written))
1393 return False;
1394 if(!prs_uint32("status", ps, depth, &r_u->status))
1395 return False;
1397 return True;
1400 /*******************************************************************
1401 * read a structure.
1402 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1403 ********************************************************************/
1405 BOOL spoolss_io_q_rffpcnex(char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, int depth)
1407 prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex");
1408 depth++;
1410 if(!prs_align(ps))
1411 return False;
1413 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
1414 return False;
1415 if(!prs_uint32("flags", ps, depth, &q_u->flags))
1416 return False;
1417 if(!prs_uint32("options", ps, depth, &q_u->options))
1418 return False;
1419 if(!prs_uint32("localmachine_ptr", ps, depth, &q_u->localmachine_ptr))
1420 return False;
1421 if(!smb_io_unistr2("localmachine", &q_u->localmachine, q_u->localmachine_ptr, ps, depth))
1422 return False;
1424 if(!prs_align(ps))
1425 return False;
1427 if(!prs_uint32("printerlocal", ps, depth, &q_u->printerlocal))
1428 return False;
1430 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1431 return False;
1433 if (q_u->option_ptr!=0) {
1435 if (UNMARSHALLING(ps))
1436 if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
1437 return False;
1439 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1440 return False;
1443 return True;
1446 /*******************************************************************
1447 * write a structure.
1448 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1449 ********************************************************************/
1451 BOOL spoolss_io_r_rffpcnex(char *desc, SPOOL_R_RFFPCNEX *r_u, prs_struct *ps, int depth)
1453 prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex");
1454 depth++;
1456 if(!prs_uint32("status", ps, depth, &r_u->status))
1457 return False;
1459 return True;
1462 /*******************************************************************
1463 * read a structure.
1464 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1465 ********************************************************************/
1467 BOOL spoolss_io_q_rfnpcnex(char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, int depth)
1469 prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex");
1470 depth++;
1472 if(!prs_align(ps))
1473 return False;
1475 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
1476 return False;
1478 if(!prs_uint32("change", ps, depth, &q_u->change))
1479 return False;
1481 if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr))
1482 return False;
1484 if (q_u->option_ptr!=0) {
1486 if (UNMARSHALLING(ps))
1487 if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
1488 return False;
1490 if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
1491 return False;
1494 return True;
1497 /*******************************************************************
1498 * write a structure.
1499 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1500 ********************************************************************/
1502 BOOL spoolss_io_r_rfnpcnex(char *desc, SPOOL_R_RFNPCNEX *r_u, prs_struct *ps, int depth)
1504 prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex");
1505 depth++;
1507 if(!prs_align(ps))
1508 return False;
1510 if (!prs_uint32("info_ptr", ps, depth, &r_u->info_ptr))
1511 return False;
1513 if(!smb_io_notify_info("notify info", &r_u->info ,ps,depth))
1514 return False;
1516 if(!prs_align(ps))
1517 return False;
1518 if(!prs_uint32("status", ps, depth, &r_u->status))
1519 return False;
1521 return True;
1524 /*******************************************************************
1525 * return the length of a uint16 (obvious, but the code is clean)
1526 ********************************************************************/
1528 static uint32 size_of_uint16(uint16 *value)
1530 return (sizeof(*value));
1533 /*******************************************************************
1534 * return the length of a uint32 (obvious, but the code is clean)
1535 ********************************************************************/
1537 static uint32 size_of_uint32(uint32 *value)
1539 return (sizeof(*value));
1542 /*******************************************************************
1543 * return the length of a NTTIME (obvious, but the code is clean)
1544 ********************************************************************/
1546 static uint32 size_of_nttime(NTTIME *value)
1548 return (sizeof(*value));
1551 /*******************************************************************
1552 * return the length of a UNICODE string in number of char, includes:
1553 * - the leading zero
1554 * - the relative pointer size
1555 ********************************************************************/
1557 static uint32 size_of_relative_string(UNISTR *string)
1559 uint32 size=0;
1561 size=str_len_uni(string); /* the string length */
1562 size=size+1; /* add the leading zero */
1563 size=size*2; /* convert in char */
1564 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1565 size += ((4 - (size & 3)) & 3);
1566 size=size+4; /* add the size of the ptr */
1568 return size;
1571 /*******************************************************************
1572 * return the length of a uint32 (obvious, but the code is clean)
1573 ********************************************************************/
1575 static uint32 size_of_device_mode(DEVICEMODE *devmode)
1577 if (devmode==NULL)
1578 return (4);
1579 else
1580 return (4+devmode->size+devmode->driverextra);
1583 /*******************************************************************
1584 * return the length of a uint32 (obvious, but the code is clean)
1585 ********************************************************************/
1587 static uint32 size_of_systemtime(SYSTEMTIME *systime)
1589 if (systime==NULL)
1590 return (4);
1591 else
1592 return (sizeof(SYSTEMTIME) +4);
1595 /*******************************************************************
1596 * write a UNICODE string.
1597 * used by all the RPC structs passing a buffer
1598 ********************************************************************/
1600 static BOOL spoolss_smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
1602 if (uni == NULL)
1603 return False;
1605 prs_debug(ps, depth, desc, "spoolss_smb_io_unistr");
1606 depth++;
1608 /* there should be no align here as it can mess up
1609 parsing a NEW_BUFFER->prs */
1610 #if 0 /* JERRY */
1611 if (!prs_align(ps))
1612 return False;
1613 #endif
1615 if (!prs_unistr("unistr", ps, depth, uni))
1616 return False;
1618 return True;
1621 /*******************************************************************
1622 * write a UNICODE string and its relative pointer.
1623 * used by all the RPC structs passing a buffer
1625 * As I'm a nice guy, I'm forcing myself to explain this code.
1626 * MS did a good job in the overall spoolss code except in some
1627 * functions where they are passing the API buffer directly in the
1628 * RPC request/reply. That's to maintain compatiility at the API level.
1629 * They could have done it the good way the first time.
1631 * So what happen is: the strings are written at the buffer's end,
1632 * in the reverse order of the original structure. Some pointers to
1633 * the strings are also in the buffer. Those are relative to the
1634 * buffer's start.
1636 * If you don't understand or want to change that function,
1637 * first get in touch with me: jfm@samba.org
1639 ********************************************************************/
1641 static BOOL smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR *string)
1643 prs_struct *ps=&buffer->prs;
1645 if (MARSHALLING(ps)) {
1646 uint32 struct_offset = prs_offset(ps);
1647 uint32 relative_offset;
1649 buffer->string_at_end -= (size_of_relative_string(string) - 4);
1650 if(!prs_set_offset(ps, buffer->string_at_end))
1651 return False;
1652 if (!prs_align(ps))
1653 return False;
1654 buffer->string_at_end = prs_offset(ps);
1656 /* write the string */
1657 if (!smb_io_unistr(desc, string, ps, depth))
1658 return False;
1660 if(!prs_set_offset(ps, struct_offset))
1661 return False;
1663 relative_offset=buffer->string_at_end - buffer->struct_start;
1664 /* write its offset */
1665 if (!prs_uint32("offset", ps, depth, &relative_offset))
1666 return False;
1668 else {
1669 uint32 old_offset;
1671 /* read the offset */
1672 if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end)))
1673 return False;
1675 old_offset = prs_offset(ps);
1676 if(!prs_set_offset(ps, buffer->string_at_end+buffer->struct_start))
1677 return False;
1679 /* read the string */
1680 if (!spoolss_smb_io_unistr(desc, string, ps, depth))
1681 return False;
1683 if(!prs_set_offset(ps, old_offset))
1684 return False;
1686 return True;
1689 /*******************************************************************
1690 * write a array of UNICODE strings and its relative pointer.
1691 * used by 2 RPC structs
1692 ********************************************************************/
1694 static BOOL smb_io_relarraystr(char *desc, NEW_BUFFER *buffer, int depth, uint16 **string)
1696 UNISTR chaine;
1698 prs_struct *ps=&buffer->prs;
1700 if (MARSHALLING(ps)) {
1701 uint32 struct_offset = prs_offset(ps);
1702 uint32 relative_offset;
1703 uint16 *p;
1704 uint16 *q;
1705 uint16 zero=0;
1706 p=*string;
1707 q=*string;
1709 /* first write the last 0 */
1710 buffer->string_at_end -= 2;
1711 if(!prs_set_offset(ps, buffer->string_at_end))
1712 return False;
1714 if(!prs_uint16("leading zero", ps, depth, &zero))
1715 return False;
1717 while (p && (*p!=0)) {
1718 while (*q!=0)
1719 q++;
1721 /* Yes this should be malloc not talloc. Don't change. */
1723 chaine.buffer = malloc((q-p+1)*sizeof(uint16));
1724 if (chaine.buffer == NULL)
1725 return False;
1727 memcpy(chaine.buffer, p, (q-p+1)*sizeof(uint16));
1729 buffer->string_at_end -= (q-p+1)*sizeof(uint16);
1731 if(!prs_set_offset(ps, buffer->string_at_end)) {
1732 free(chaine.buffer);
1733 return False;
1736 /* write the string */
1737 if (!spoolss_smb_io_unistr(desc, &chaine, ps, depth)) {
1738 free(chaine.buffer);
1739 return False;
1741 q++;
1742 p=q;
1744 free(chaine.buffer);
1747 if(!prs_set_offset(ps, struct_offset))
1748 return False;
1750 relative_offset=buffer->string_at_end - buffer->struct_start;
1751 /* write its offset */
1752 if (!prs_uint32("offset", ps, depth, &relative_offset))
1753 return False;
1755 } else {
1757 /* UNMARSHALLING */
1759 uint32 old_offset;
1760 uint16 *chaine2=NULL;
1761 int l_chaine=0;
1762 int l_chaine2=0;
1763 size_t realloc_size = 0;
1765 *string=NULL;
1767 /* read the offset */
1768 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
1769 return False;
1771 old_offset = prs_offset(ps);
1772 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
1773 return False;
1775 do {
1776 if (!spoolss_smb_io_unistr(desc, &chaine, ps, depth))
1777 return False;
1779 l_chaine=str_len_uni(&chaine);
1781 /* we're going to add two more bytes here in case this
1782 is the last string in the array and we need to add
1783 an extra NULL for termination */
1784 if (l_chaine > 0)
1786 realloc_size = (l_chaine2+l_chaine+2)*sizeof(uint16);
1788 /* Yes this should be realloc - it's freed below. JRA */
1790 if((chaine2=(uint16 *)Realloc(chaine2, realloc_size)) == NULL)
1791 return False;
1792 memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16));
1793 l_chaine2+=l_chaine+1;
1796 } while(l_chaine!=0);
1798 /* the end should be bould NULL terminated so add
1799 the second one here */
1800 if (chaine2)
1802 chaine2[l_chaine2] = '\0';
1803 *string=(uint16 *)talloc_memdup(prs_get_mem_context(ps),chaine2,realloc_size);
1804 free(chaine2);
1807 if(!prs_set_offset(ps, old_offset))
1808 return False;
1810 return True;
1813 /*******************************************************************
1814 Parse a DEVMODE structure and its relative pointer.
1815 ********************************************************************/
1817 static BOOL smb_io_relsecdesc(char *desc, NEW_BUFFER *buffer, int depth, SEC_DESC **secdesc)
1819 prs_struct *ps= &buffer->prs;
1821 prs_debug(ps, depth, desc, "smb_io_relsecdesc");
1822 depth++;
1824 if (MARSHALLING(ps)) {
1825 uint32 struct_offset = prs_offset(ps);
1826 uint32 relative_offset;
1828 if (! *secdesc) {
1829 relative_offset = 0;
1830 if (!prs_uint32("offset", ps, depth, &relative_offset))
1831 return False;
1832 return True;
1835 if (*secdesc != NULL) {
1836 buffer->string_at_end -= sec_desc_size(*secdesc);
1838 if(!prs_set_offset(ps, buffer->string_at_end))
1839 return False;
1840 /* write the secdesc */
1841 if (!sec_io_desc(desc, secdesc, ps, depth))
1842 return False;
1844 if(!prs_set_offset(ps, struct_offset))
1845 return False;
1848 relative_offset=buffer->string_at_end - buffer->struct_start;
1849 /* write its offset */
1851 if (!prs_uint32("offset", ps, depth, &relative_offset))
1852 return False;
1853 } else {
1854 uint32 old_offset;
1856 /* read the offset */
1857 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
1858 return False;
1860 old_offset = prs_offset(ps);
1861 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
1862 return False;
1864 /* read the sd */
1865 if (!sec_io_desc(desc, secdesc, ps, depth))
1866 return False;
1868 if(!prs_set_offset(ps, old_offset))
1869 return False;
1871 return True;
1874 /*******************************************************************
1875 Parse a DEVMODE structure and its relative pointer.
1876 ********************************************************************/
1878 static BOOL smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode)
1880 prs_struct *ps=&buffer->prs;
1882 prs_debug(ps, depth, desc, "smb_io_reldevmode");
1883 depth++;
1885 if (MARSHALLING(ps)) {
1886 uint32 struct_offset = prs_offset(ps);
1887 uint32 relative_offset;
1889 if (*devmode == NULL) {
1890 relative_offset=0;
1891 if (!prs_uint32("offset", ps, depth, &relative_offset))
1892 return False;
1893 DEBUG(8, ("boing, the devmode was NULL\n"));
1895 return True;
1898 buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra);
1900 if(!prs_set_offset(ps, buffer->string_at_end))
1901 return False;
1903 /* write the DEVMODE */
1904 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
1905 return False;
1907 if(!prs_set_offset(ps, struct_offset))
1908 return False;
1910 relative_offset=buffer->string_at_end - buffer->struct_start;
1911 /* write its offset */
1912 if (!prs_uint32("offset", ps, depth, &relative_offset))
1913 return False;
1915 else {
1916 uint32 old_offset;
1918 /* read the offset */
1919 if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
1920 return False;
1922 old_offset = prs_offset(ps);
1923 if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
1924 return False;
1926 /* read the string */
1927 if((*devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE))) == NULL)
1928 return False;
1929 if (!spoolss_io_devmode(desc, ps, depth, *devmode))
1930 return False;
1932 if(!prs_set_offset(ps, old_offset))
1933 return False;
1935 return True;
1938 /*******************************************************************
1939 Parse a PRINTER_INFO_0 structure.
1940 ********************************************************************/
1942 BOOL smb_io_printer_info_0(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
1944 prs_struct *ps=&buffer->prs;
1946 prs_debug(ps, depth, desc, "smb_io_printer_info_0");
1947 depth++;
1949 buffer->struct_start=prs_offset(ps);
1951 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
1952 return False;
1953 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
1954 return False;
1956 if(!prs_uint32("cjobs", ps, depth, &info->cjobs))
1957 return False;
1958 if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs))
1959 return False;
1960 if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes))
1961 return False;
1963 if(!prs_uint16("year", ps, depth, &info->year))
1964 return False;
1965 if(!prs_uint16("month", ps, depth, &info->month))
1966 return False;
1967 if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek))
1968 return False;
1969 if(!prs_uint16("day", ps, depth, &info->day))
1970 return False;
1971 if(!prs_uint16("hour", ps, depth, &info->hour))
1972 return False;
1973 if(!prs_uint16("minute", ps, depth, &info->minute))
1974 return False;
1975 if(!prs_uint16("second", ps, depth, &info->second))
1976 return False;
1977 if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds))
1978 return False;
1980 if(!prs_uint32("global_counter", ps, depth, &info->global_counter))
1981 return False;
1982 if(!prs_uint32("total_pages", ps, depth, &info->total_pages))
1983 return False;
1985 if(!prs_uint16("major_version", ps, depth, &info->major_version))
1986 return False;
1987 if(!prs_uint16("build_version", ps, depth, &info->build_version))
1988 return False;
1989 if(!prs_uint32("unknown7", ps, depth, &info->unknown7))
1990 return False;
1991 if(!prs_uint32("unknown8", ps, depth, &info->unknown8))
1992 return False;
1993 if(!prs_uint32("unknown9", ps, depth, &info->unknown9))
1994 return False;
1995 if(!prs_uint32("session_counter", ps, depth, &info->session_counter))
1996 return False;
1997 if(!prs_uint32("unknown11", ps, depth, &info->unknown11))
1998 return False;
1999 if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors))
2000 return False;
2001 if(!prs_uint32("unknown13", ps, depth, &info->unknown13))
2002 return False;
2003 if(!prs_uint32("unknown14", ps, depth, &info->unknown14))
2004 return False;
2005 if(!prs_uint32("unknown15", ps, depth, &info->unknown15))
2006 return False;
2007 if(!prs_uint32("unknown16", ps, depth, &info->unknown16))
2008 return False;
2009 if(!prs_uint32("change_id", ps, depth, &info->change_id))
2010 return False;
2011 if(!prs_uint32("unknown18", ps, depth, &info->unknown18))
2012 return False;
2013 if(!prs_uint32("status" , ps, depth, &info->status))
2014 return False;
2015 if(!prs_uint32("unknown20", ps, depth, &info->unknown20))
2016 return False;
2017 if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter))
2018 return False;
2019 if(!prs_uint16("unknown22", ps, depth, &info->unknown22))
2020 return False;
2021 if(!prs_uint16("unknown23", ps, depth, &info->unknown23))
2022 return False;
2023 if(!prs_uint16("unknown24", ps, depth, &info->unknown24))
2024 return False;
2025 if(!prs_uint16("unknown25", ps, depth, &info->unknown25))
2026 return False;
2027 if(!prs_uint16("unknown26", ps, depth, &info->unknown26))
2028 return False;
2029 if(!prs_uint16("unknown27", ps, depth, &info->unknown27))
2030 return False;
2031 if(!prs_uint16("unknown28", ps, depth, &info->unknown28))
2032 return False;
2033 if(!prs_uint16("unknown29", ps, depth, &info->unknown29))
2034 return False;
2036 return True;
2039 /*******************************************************************
2040 Parse a PRINTER_INFO_1 structure.
2041 ********************************************************************/
2043 BOOL smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
2045 prs_struct *ps=&buffer->prs;
2047 prs_debug(ps, depth, desc, "smb_io_printer_info_1");
2048 depth++;
2050 buffer->struct_start=prs_offset(ps);
2052 if (!prs_uint32("flags", ps, depth, &info->flags))
2053 return False;
2054 if (!smb_io_relstr("description", buffer, depth, &info->description))
2055 return False;
2056 if (!smb_io_relstr("name", buffer, depth, &info->name))
2057 return False;
2058 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2059 return False;
2061 return True;
2064 /*******************************************************************
2065 Parse a PRINTER_INFO_2 structure.
2066 ********************************************************************/
2068 BOOL smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
2070 prs_struct *ps=&buffer->prs;
2072 prs_debug(ps, depth, desc, "smb_io_printer_info_2");
2073 depth++;
2075 buffer->struct_start=prs_offset(ps);
2077 if (!smb_io_relstr("servername", buffer, depth, &info->servername))
2078 return False;
2079 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2080 return False;
2081 if (!smb_io_relstr("sharename", buffer, depth, &info->sharename))
2082 return False;
2083 if (!smb_io_relstr("portname", buffer, depth, &info->portname))
2084 return False;
2085 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2086 return False;
2087 if (!smb_io_relstr("comment", buffer, depth, &info->comment))
2088 return False;
2089 if (!smb_io_relstr("location", buffer, depth, &info->location))
2090 return False;
2092 /* NT parses the DEVMODE at the end of the struct */
2093 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2094 return False;
2096 if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
2097 return False;
2098 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2099 return False;
2100 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2101 return False;
2102 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2103 return False;
2105 if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
2106 return False;
2108 if (!prs_uint32("attributes", ps, depth, &info->attributes))
2109 return False;
2110 if (!prs_uint32("priority", ps, depth, &info->priority))
2111 return False;
2112 if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority))
2113 return False;
2114 if (!prs_uint32("starttime", ps, depth, &info->starttime))
2115 return False;
2116 if (!prs_uint32("untiltime", ps, depth, &info->untiltime))
2117 return False;
2118 if (!prs_uint32("status", ps, depth, &info->status))
2119 return False;
2120 if (!prs_uint32("jobs", ps, depth, &info->cjobs))
2121 return False;
2122 if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
2123 return False;
2125 #if 0 /* JFMTEST */
2126 if (!prs_uint32_post("secdesc_ptr", ps, depth, NULL, sec_offset, info->secdesc ? prs_offset(ps)-buffer->struct_start : 0 ))
2127 return False;
2129 if (!sec_io_desc("secdesc", &info->secdesc, ps, depth))
2130 return False;
2131 #endif
2132 return True;
2135 /*******************************************************************
2136 Parse a PRINTER_INFO_3 structure.
2137 ********************************************************************/
2139 BOOL smb_io_printer_info_3(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
2141 prs_struct *ps=&buffer->prs;
2143 prs_debug(ps, depth, desc, "smb_io_printer_info_3");
2144 depth++;
2146 buffer->struct_start=prs_offset(ps);
2148 if (!prs_uint32("flags", ps, depth, &info->flags))
2149 return False;
2150 if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth))
2151 return False;
2153 return True;
2156 /*******************************************************************
2157 Parse a PORT_INFO_1 structure.
2158 ********************************************************************/
2160 BOOL smb_io_port_info_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2162 prs_struct *ps=&buffer->prs;
2164 prs_debug(ps, depth, desc, "smb_io_port_info_1");
2165 depth++;
2167 buffer->struct_start=prs_offset(ps);
2169 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2170 return False;
2172 return True;
2175 /*******************************************************************
2176 Parse a PORT_INFO_2 structure.
2177 ********************************************************************/
2179 BOOL smb_io_port_info_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2181 prs_struct *ps=&buffer->prs;
2183 prs_debug(ps, depth, desc, "smb_io_port_info_2");
2184 depth++;
2186 buffer->struct_start=prs_offset(ps);
2188 if (!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2189 return False;
2190 if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2191 return False;
2192 if (!smb_io_relstr("description", buffer, depth, &info->description))
2193 return False;
2194 if (!prs_uint32("port_type", ps, depth, &info->port_type))
2195 return False;
2196 if (!prs_uint32("reserved", ps, depth, &info->reserved))
2197 return False;
2199 return True;
2202 /*******************************************************************
2203 Parse a DRIVER_INFO_1 structure.
2204 ********************************************************************/
2206 BOOL smb_io_printer_driver_info_1(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
2208 prs_struct *ps=&buffer->prs;
2210 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
2211 depth++;
2213 buffer->struct_start=prs_offset(ps);
2215 if (!smb_io_relstr("name", buffer, depth, &info->name))
2216 return False;
2218 return True;
2221 /*******************************************************************
2222 Parse a DRIVER_INFO_2 structure.
2223 ********************************************************************/
2225 BOOL smb_io_printer_driver_info_2(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
2227 prs_struct *ps=&buffer->prs;
2229 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
2230 depth++;
2232 buffer->struct_start=prs_offset(ps);
2234 if (!prs_uint32("version", ps, depth, &info->version))
2235 return False;
2236 if (!smb_io_relstr("name", buffer, depth, &info->name))
2237 return False;
2238 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2239 return False;
2240 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2241 return False;
2242 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2243 return False;
2244 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2245 return False;
2247 return True;
2250 /*******************************************************************
2251 Parse a DRIVER_INFO_3 structure.
2252 ********************************************************************/
2254 BOOL smb_io_printer_driver_info_3(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
2256 prs_struct *ps=&buffer->prs;
2258 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
2259 depth++;
2261 buffer->struct_start=prs_offset(ps);
2263 if (!prs_uint32("version", ps, depth, &info->version))
2264 return False;
2265 if (!smb_io_relstr("name", buffer, depth, &info->name))
2266 return False;
2267 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2268 return False;
2269 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2270 return False;
2271 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2272 return False;
2273 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2274 return False;
2275 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2276 return False;
2278 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2279 return False;
2281 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2282 return False;
2283 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2284 return False;
2286 return True;
2289 /*******************************************************************
2290 Parse a DRIVER_INFO_6 structure.
2291 ********************************************************************/
2293 BOOL smb_io_printer_driver_info_6(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
2295 prs_struct *ps=&buffer->prs;
2297 prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
2298 depth++;
2300 buffer->struct_start=prs_offset(ps);
2302 if (!prs_uint32("version", ps, depth, &info->version))
2303 return False;
2304 if (!smb_io_relstr("name", buffer, depth, &info->name))
2305 return False;
2306 if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
2307 return False;
2308 if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2309 return False;
2310 if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
2311 return False;
2312 if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
2313 return False;
2314 if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2315 return False;
2317 if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2318 return False;
2320 if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2321 return False;
2322 if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2323 return False;
2325 if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
2326 return False;
2328 if (!prs_uint32("date.low", ps, depth, &info->driver_date.low))
2329 return False;
2330 if (!prs_uint32("date.high", ps, depth, &info->driver_date.high))
2331 return False;
2333 if (!prs_uint32("padding", ps, depth, &info->padding))
2334 return False;
2336 if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
2337 return False;
2339 if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
2340 return False;
2342 if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
2343 return False;
2344 if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
2345 return False;
2346 if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
2347 return False;
2348 if (!smb_io_relstr("provider", buffer, depth, &info->provider))
2349 return False;
2351 return True;
2354 /*******************************************************************
2355 Parse a JOB_INFO_1 structure.
2356 ********************************************************************/
2358 BOOL smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth)
2360 prs_struct *ps=&buffer->prs;
2362 prs_debug(ps, depth, desc, "smb_io_job_info_1");
2363 depth++;
2365 buffer->struct_start=prs_offset(ps);
2367 if (!prs_uint32("jobid", ps, depth, &info->jobid))
2368 return False;
2369 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2370 return False;
2371 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2372 return False;
2373 if (!smb_io_relstr("username", buffer, depth, &info->username))
2374 return False;
2375 if (!smb_io_relstr("document", buffer, depth, &info->document))
2376 return False;
2377 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2378 return False;
2379 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2380 return False;
2381 if (!prs_uint32("status", ps, depth, &info->status))
2382 return False;
2383 if (!prs_uint32("priority", ps, depth, &info->priority))
2384 return False;
2385 if (!prs_uint32("position", ps, depth, &info->position))
2386 return False;
2387 if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
2388 return False;
2389 if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
2390 return False;
2391 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
2392 return False;
2394 return True;
2397 /*******************************************************************
2398 Parse a JOB_INFO_2 structure.
2399 ********************************************************************/
2401 BOOL smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth)
2403 uint32 pipo=0;
2404 prs_struct *ps=&buffer->prs;
2406 prs_debug(ps, depth, desc, "smb_io_job_info_2");
2407 depth++;
2409 buffer->struct_start=prs_offset(ps);
2411 if (!prs_uint32("jobid",ps, depth, &info->jobid))
2412 return False;
2413 if (!smb_io_relstr("printername", buffer, depth, &info->printername))
2414 return False;
2415 if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
2416 return False;
2417 if (!smb_io_relstr("username", buffer, depth, &info->username))
2418 return False;
2419 if (!smb_io_relstr("document", buffer, depth, &info->document))
2420 return False;
2421 if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
2422 return False;
2423 if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
2424 return False;
2426 if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2427 return False;
2428 if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
2429 return False;
2430 if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
2431 return False;
2432 if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2433 return False;
2434 if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
2435 return False;
2437 /* SEC_DESC sec_desc;*/
2438 if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
2439 return False;
2441 if (!prs_uint32("status",ps, depth, &info->status))
2442 return False;
2443 if (!prs_uint32("priority",ps, depth, &info->priority))
2444 return False;
2445 if (!prs_uint32("position",ps, depth, &info->position))
2446 return False;
2447 if (!prs_uint32("starttime",ps, depth, &info->starttime))
2448 return False;
2449 if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
2450 return False;
2451 if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
2452 return False;
2453 if (!prs_uint32("size",ps, depth, &info->size))
2454 return False;
2455 if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
2456 return False;
2457 if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
2458 return False;
2459 if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
2460 return False;
2462 return True;
2465 /*******************************************************************
2466 ********************************************************************/
2468 BOOL smb_io_form_1(char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth)
2470 prs_struct *ps=&buffer->prs;
2472 prs_debug(ps, depth, desc, "smb_io_form_1");
2473 depth++;
2475 buffer->struct_start=prs_offset(ps);
2477 if (!prs_uint32("flag", ps, depth, &info->flag))
2478 return False;
2480 if (!smb_io_relstr("name", buffer, depth, &info->name))
2481 return False;
2483 if (!prs_uint32("width", ps, depth, &info->width))
2484 return False;
2485 if (!prs_uint32("length", ps, depth, &info->length))
2486 return False;
2487 if (!prs_uint32("left", ps, depth, &info->left))
2488 return False;
2489 if (!prs_uint32("top", ps, depth, &info->top))
2490 return False;
2491 if (!prs_uint32("right", ps, depth, &info->right))
2492 return False;
2493 if (!prs_uint32("bottom", ps, depth, &info->bottom))
2494 return False;
2496 return True;
2499 /*******************************************************************
2500 Read/write a BUFFER struct.
2501 ********************************************************************/
2503 static BOOL spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUFFER **pp_buffer)
2505 NEW_BUFFER *buffer = *pp_buffer;
2507 prs_debug(ps, depth, desc, "spoolss_io_buffer");
2508 depth++;
2510 if (UNMARSHALLING(ps))
2511 buffer = *pp_buffer = (NEW_BUFFER *)prs_alloc_mem(ps, sizeof(NEW_BUFFER));
2513 if (buffer == NULL)
2514 return False;
2516 if (!prs_uint32("ptr", ps, depth, &buffer->ptr))
2517 return False;
2519 /* reading */
2520 if (UNMARSHALLING(ps)) {
2521 buffer->size=0;
2522 buffer->string_at_end=0;
2524 if (buffer->ptr==0) {
2526 * JRA. I'm not sure if the data in here is in big-endian format if
2527 * the client is big-endian. Leave as default (little endian) for now.
2530 if (!prs_init(&buffer->prs, 0, prs_get_mem_context(ps), UNMARSHALL))
2531 return False;
2532 return True;
2535 if (!prs_uint32("size", ps, depth, &buffer->size))
2536 return False;
2539 * JRA. I'm not sure if the data in here is in big-endian format if
2540 * the client is big-endian. Leave as default (little endian) for now.
2543 if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL))
2544 return False;
2546 if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size))
2547 return False;
2549 if (!prs_set_offset(&buffer->prs, 0))
2550 return False;
2552 if (!prs_set_offset(ps, buffer->size+prs_offset(ps)))
2553 return False;
2555 buffer->string_at_end=buffer->size;
2557 return True;
2559 else {
2560 BOOL ret = False;
2562 /* writing */
2563 if (buffer->ptr==0) {
2564 /* We have finished with the data in buffer->prs - free it. */
2565 prs_mem_free(&buffer->prs);
2566 return True;
2569 if (!prs_uint32("size", ps, depth, &buffer->size))
2570 goto out;
2572 if (!prs_append_some_prs_data(ps, &buffer->prs, 0, buffer->size))
2573 goto out;
2575 ret = True;
2576 out:
2578 /* We have finished with the data in buffer->prs - free it. */
2579 prs_mem_free(&buffer->prs);
2581 return ret;
2585 /*******************************************************************
2586 move a BUFFER from the query to the reply.
2587 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2588 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2589 ********************************************************************/
2591 void spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest)
2593 prs_switch_type(&src->prs, MARSHALL);
2594 if(!prs_set_offset(&src->prs, 0))
2595 return;
2596 prs_force_dynamic(&(src->prs));
2598 *dest=src;
2601 /*******************************************************************
2602 Get the size of a BUFFER struct.
2603 ********************************************************************/
2605 uint32 new_get_buffer_size(NEW_BUFFER *buffer)
2607 return (buffer->size);
2610 /*******************************************************************
2611 Parse a DRIVER_DIRECTORY_1 structure.
2612 ********************************************************************/
2614 BOOL smb_io_driverdir_1(char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth)
2616 prs_struct *ps=&buffer->prs;
2618 prs_debug(ps, depth, desc, "smb_io_driverdir_1");
2619 depth++;
2621 buffer->struct_start=prs_offset(ps);
2623 if (!smb_io_unistr(desc, &info->name, ps, depth))
2624 return False;
2626 return True;
2629 /*******************************************************************
2630 Parse a PORT_INFO_1 structure.
2631 ********************************************************************/
2633 BOOL smb_io_port_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
2635 prs_struct *ps=&buffer->prs;
2637 prs_debug(ps, depth, desc, "smb_io_port_1");
2638 depth++;
2640 buffer->struct_start=prs_offset(ps);
2642 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2643 return False;
2645 return True;
2648 /*******************************************************************
2649 Parse a PORT_INFO_2 structure.
2650 ********************************************************************/
2652 BOOL smb_io_port_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
2654 prs_struct *ps=&buffer->prs;
2656 prs_debug(ps, depth, desc, "smb_io_port_2");
2657 depth++;
2659 buffer->struct_start=prs_offset(ps);
2661 if(!smb_io_relstr("port_name", buffer, depth, &info->port_name))
2662 return False;
2663 if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2664 return False;
2665 if(!smb_io_relstr("description", buffer, depth, &info->description))
2666 return False;
2667 if(!prs_uint32("port_type", ps, depth, &info->port_type))
2668 return False;
2669 if(!prs_uint32("reserved", ps, depth, &info->reserved))
2670 return False;
2672 return True;
2675 /*******************************************************************
2676 ********************************************************************/
2678 BOOL smb_io_printprocessor_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
2680 prs_struct *ps=&buffer->prs;
2682 prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1");
2683 depth++;
2685 buffer->struct_start=prs_offset(ps);
2687 if (smb_io_relstr("name", buffer, depth, &info->name))
2688 return False;
2690 return True;
2693 /*******************************************************************
2694 ********************************************************************/
2696 BOOL smb_io_printprocdatatype_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth)
2698 prs_struct *ps=&buffer->prs;
2700 prs_debug(ps, depth, desc, "smb_io_printprocdatatype_info_1");
2701 depth++;
2703 buffer->struct_start=prs_offset(ps);
2705 if (smb_io_relstr("name", buffer, depth, &info->name))
2706 return False;
2708 return True;
2711 /*******************************************************************
2712 ********************************************************************/
2714 BOOL smb_io_printmonitor_info_1(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
2716 prs_struct *ps=&buffer->prs;
2718 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1");
2719 depth++;
2721 buffer->struct_start=prs_offset(ps);
2723 if (!smb_io_relstr("name", buffer, depth, &info->name))
2724 return False;
2726 return True;
2729 /*******************************************************************
2730 ********************************************************************/
2732 BOOL smb_io_printmonitor_info_2(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
2734 prs_struct *ps=&buffer->prs;
2736 prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
2737 depth++;
2739 buffer->struct_start=prs_offset(ps);
2741 if (!smb_io_relstr("name", buffer, depth, &info->name))
2742 return False;
2743 if (!smb_io_relstr("environment", buffer, depth, &info->environment))
2744 return False;
2745 if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
2746 return False;
2748 return True;
2751 /*******************************************************************
2752 return the size required by a struct in the stream
2753 ********************************************************************/
2755 uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
2757 int size=0;
2759 size+=size_of_relative_string( &info->printername );
2760 size+=size_of_relative_string( &info->servername );
2762 size+=size_of_uint32( &info->cjobs);
2763 size+=size_of_uint32( &info->total_jobs);
2764 size+=size_of_uint32( &info->total_bytes);
2766 size+=size_of_uint16( &info->year);
2767 size+=size_of_uint16( &info->month);
2768 size+=size_of_uint16( &info->dayofweek);
2769 size+=size_of_uint16( &info->day);
2770 size+=size_of_uint16( &info->hour);
2771 size+=size_of_uint16( &info->minute);
2772 size+=size_of_uint16( &info->second);
2773 size+=size_of_uint16( &info->milliseconds);
2775 size+=size_of_uint32( &info->global_counter);
2776 size+=size_of_uint32( &info->total_pages);
2778 size+=size_of_uint16( &info->major_version);
2779 size+=size_of_uint16( &info->build_version);
2781 size+=size_of_uint32( &info->unknown7);
2782 size+=size_of_uint32( &info->unknown8);
2783 size+=size_of_uint32( &info->unknown9);
2784 size+=size_of_uint32( &info->session_counter);
2785 size+=size_of_uint32( &info->unknown11);
2786 size+=size_of_uint32( &info->printer_errors);
2787 size+=size_of_uint32( &info->unknown13);
2788 size+=size_of_uint32( &info->unknown14);
2789 size+=size_of_uint32( &info->unknown15);
2790 size+=size_of_uint32( &info->unknown16);
2791 size+=size_of_uint32( &info->change_id);
2792 size+=size_of_uint32( &info->unknown18);
2793 size+=size_of_uint32( &info->status);
2794 size+=size_of_uint32( &info->unknown20);
2795 size+=size_of_uint32( &info->c_setprinter);
2797 size+=size_of_uint16( &info->unknown22);
2798 size+=size_of_uint16( &info->unknown23);
2799 size+=size_of_uint16( &info->unknown24);
2800 size+=size_of_uint16( &info->unknown25);
2801 size+=size_of_uint16( &info->unknown26);
2802 size+=size_of_uint16( &info->unknown27);
2803 size+=size_of_uint16( &info->unknown28);
2804 size+=size_of_uint16( &info->unknown29);
2806 return size;
2809 /*******************************************************************
2810 return the size required by a struct in the stream
2811 ********************************************************************/
2813 uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
2815 int size=0;
2817 size+=size_of_uint32( &info->flags );
2818 size+=size_of_relative_string( &info->description );
2819 size+=size_of_relative_string( &info->name );
2820 size+=size_of_relative_string( &info->comment );
2822 return size;
2825 /*******************************************************************
2826 return the size required by a struct in the stream
2827 ********************************************************************/
2829 uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
2831 uint32 size=0;
2833 size += 4;
2834 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2835 size += sec_desc_size( info->secdesc );
2837 size+=size_of_device_mode( info->devmode );
2839 size+=size_of_relative_string( &info->servername );
2840 size+=size_of_relative_string( &info->printername );
2841 size+=size_of_relative_string( &info->sharename );
2842 size+=size_of_relative_string( &info->portname );
2843 size+=size_of_relative_string( &info->drivername );
2844 size+=size_of_relative_string( &info->comment );
2845 size+=size_of_relative_string( &info->location );
2847 size+=size_of_relative_string( &info->sepfile );
2848 size+=size_of_relative_string( &info->printprocessor );
2849 size+=size_of_relative_string( &info->datatype );
2850 size+=size_of_relative_string( &info->parameters );
2852 size+=size_of_uint32( &info->attributes );
2853 size+=size_of_uint32( &info->priority );
2854 size+=size_of_uint32( &info->defaultpriority );
2855 size+=size_of_uint32( &info->starttime );
2856 size+=size_of_uint32( &info->untiltime );
2857 size+=size_of_uint32( &info->status );
2858 size+=size_of_uint32( &info->cjobs );
2859 size+=size_of_uint32( &info->averageppm );
2860 return size;
2863 /*******************************************************************
2864 return the size required by a struct in the stream
2865 ********************************************************************/
2867 uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
2869 /* The 4 is for the self relative pointer.. */
2870 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2871 return 4 + (uint32)sec_desc_size( info->secdesc );
2874 /*******************************************************************
2875 return the size required by a struct in the stream
2876 ********************************************************************/
2878 uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
2880 int size=0;
2881 size+=size_of_relative_string( &info->name );
2883 return size;
2886 /*******************************************************************
2887 return the size required by a struct in the stream
2888 ********************************************************************/
2890 uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
2892 int size=0;
2893 size+=size_of_uint32( &info->version );
2894 size+=size_of_relative_string( &info->name );
2895 size+=size_of_relative_string( &info->architecture );
2896 size+=size_of_relative_string( &info->driverpath );
2897 size+=size_of_relative_string( &info->datafile );
2898 size+=size_of_relative_string( &info->configfile );
2900 return size;
2903 /*******************************************************************
2904 return the size required by a string array.
2905 ********************************************************************/
2907 uint32 spoolss_size_string_array(uint16 *string)
2909 uint32 i = 0;
2911 if (string) {
2912 for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
2914 i=i+2; /* to count all chars including the leading zero */
2915 i=2*i; /* because we need the value in bytes */
2916 i=i+4; /* the offset pointer size */
2918 return i;
2921 /*******************************************************************
2922 return the size required by a struct in the stream
2923 ********************************************************************/
2925 uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
2927 int size=0;
2929 size+=size_of_uint32( &info->version );
2930 size+=size_of_relative_string( &info->name );
2931 size+=size_of_relative_string( &info->architecture );
2932 size+=size_of_relative_string( &info->driverpath );
2933 size+=size_of_relative_string( &info->datafile );
2934 size+=size_of_relative_string( &info->configfile );
2935 size+=size_of_relative_string( &info->helpfile );
2936 size+=size_of_relative_string( &info->monitorname );
2937 size+=size_of_relative_string( &info->defaultdatatype );
2939 size+=spoolss_size_string_array(info->dependentfiles);
2941 return size;
2944 /*******************************************************************
2945 return the size required by a struct in the stream
2946 ********************************************************************/
2948 uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
2950 uint32 size=0;
2952 size+=size_of_uint32( &info->version );
2953 size+=size_of_relative_string( &info->name );
2954 size+=size_of_relative_string( &info->architecture );
2955 size+=size_of_relative_string( &info->driverpath );
2956 size+=size_of_relative_string( &info->datafile );
2957 size+=size_of_relative_string( &info->configfile );
2958 size+=size_of_relative_string( &info->helpfile );
2960 size+=spoolss_size_string_array(info->dependentfiles);
2962 size+=size_of_relative_string( &info->monitorname );
2963 size+=size_of_relative_string( &info->defaultdatatype );
2965 size+=spoolss_size_string_array(info->previousdrivernames);
2967 size+=size_of_nttime(&info->driver_date);
2968 size+=size_of_uint32( &info->padding );
2969 size+=size_of_uint32( &info->driver_version_low );
2970 size+=size_of_uint32( &info->driver_version_high );
2971 size+=size_of_relative_string( &info->mfgname );
2972 size+=size_of_relative_string( &info->oem_url );
2973 size+=size_of_relative_string( &info->hardware_id );
2974 size+=size_of_relative_string( &info->provider );
2976 return size;
2979 /*******************************************************************
2980 return the size required by a struct in the stream
2981 ********************************************************************/
2983 uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
2985 int size=0;
2986 size+=size_of_uint32( &info->jobid );
2987 size+=size_of_relative_string( &info->printername );
2988 size+=size_of_relative_string( &info->machinename );
2989 size+=size_of_relative_string( &info->username );
2990 size+=size_of_relative_string( &info->document );
2991 size+=size_of_relative_string( &info->datatype );
2992 size+=size_of_relative_string( &info->text_status );
2993 size+=size_of_uint32( &info->status );
2994 size+=size_of_uint32( &info->priority );
2995 size+=size_of_uint32( &info->position );
2996 size+=size_of_uint32( &info->totalpages );
2997 size+=size_of_uint32( &info->pagesprinted );
2998 size+=size_of_systemtime( &info->submitted );
3000 return size;
3003 /*******************************************************************
3004 return the size required by a struct in the stream
3005 ********************************************************************/
3007 uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
3009 int size=0;
3011 size+=4; /* size of sec desc ptr */
3013 size+=size_of_uint32( &info->jobid );
3014 size+=size_of_relative_string( &info->printername );
3015 size+=size_of_relative_string( &info->machinename );
3016 size+=size_of_relative_string( &info->username );
3017 size+=size_of_relative_string( &info->document );
3018 size+=size_of_relative_string( &info->notifyname );
3019 size+=size_of_relative_string( &info->datatype );
3020 size+=size_of_relative_string( &info->printprocessor );
3021 size+=size_of_relative_string( &info->parameters );
3022 size+=size_of_relative_string( &info->drivername );
3023 size+=size_of_device_mode( info->devmode );
3024 size+=size_of_relative_string( &info->text_status );
3025 /* SEC_DESC sec_desc;*/
3026 size+=size_of_uint32( &info->status );
3027 size+=size_of_uint32( &info->priority );
3028 size+=size_of_uint32( &info->position );
3029 size+=size_of_uint32( &info->starttime );
3030 size+=size_of_uint32( &info->untiltime );
3031 size+=size_of_uint32( &info->totalpages );
3032 size+=size_of_uint32( &info->size );
3033 size+=size_of_systemtime( &info->submitted );
3034 size+=size_of_uint32( &info->timeelapsed );
3035 size+=size_of_uint32( &info->pagesprinted );
3037 return size;
3040 /*******************************************************************
3041 return the size required by a struct in the stream
3042 ********************************************************************/
3044 uint32 spoolss_size_form_1(FORM_1 *info)
3046 int size=0;
3048 size+=size_of_uint32( &info->flag );
3049 size+=size_of_relative_string( &info->name );
3050 size+=size_of_uint32( &info->width );
3051 size+=size_of_uint32( &info->length );
3052 size+=size_of_uint32( &info->left );
3053 size+=size_of_uint32( &info->top );
3054 size+=size_of_uint32( &info->right );
3055 size+=size_of_uint32( &info->bottom );
3057 return size;
3060 /*******************************************************************
3061 return the size required by a struct in the stream
3062 ********************************************************************/
3064 uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
3066 int size=0;
3068 size+=size_of_relative_string( &info->port_name );
3070 return size;
3073 /*******************************************************************
3074 return the size required by a struct in the stream
3075 ********************************************************************/
3077 uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info)
3079 int size=0;
3081 size=str_len_uni(&info->name); /* the string length */
3082 size=size+1; /* add the leading zero */
3083 size=size*2; /* convert in char */
3085 return size;
3088 /*******************************************************************
3089 return the size required by a struct in the stream
3090 ********************************************************************/
3092 uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
3094 int size=0;
3096 size+=size_of_relative_string( &info->port_name );
3097 size+=size_of_relative_string( &info->monitor_name );
3098 size+=size_of_relative_string( &info->description );
3100 size+=size_of_uint32( &info->port_type );
3101 size+=size_of_uint32( &info->reserved );
3103 return size;
3106 /*******************************************************************
3107 return the size required by a struct in the stream
3108 ********************************************************************/
3110 uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
3112 int size=0;
3113 size+=size_of_relative_string( &info->name );
3115 return size;
3118 /*******************************************************************
3119 return the size required by a struct in the stream
3120 ********************************************************************/
3122 uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info)
3124 int size=0;
3125 size+=size_of_relative_string( &info->name );
3127 return size;
3130 /*******************************************************************
3131 return the size required by a struct in the stream
3132 ********************************************************************/
3134 uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
3136 int size=0;
3137 size+=size_of_relative_string( &info->name );
3139 return size;
3142 /*******************************************************************
3143 return the size required by a struct in the stream
3144 ********************************************************************/
3146 uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
3148 int size=0;
3149 size+=size_of_relative_string( &info->name);
3150 size+=size_of_relative_string( &info->environment);
3151 size+=size_of_relative_string( &info->dll_name);
3153 return size;
3156 /*******************************************************************
3157 * init a structure.
3158 ********************************************************************/
3160 BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
3161 const POLICY_HND *hnd,
3162 const fstring architecture,
3163 uint32 level, uint32 clientmajor, uint32 clientminor,
3164 NEW_BUFFER *buffer, uint32 offered)
3166 if (q_u == NULL)
3167 return False;
3169 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3171 init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture);
3173 q_u->level=level;
3174 q_u->clientmajorversion=clientmajor;
3175 q_u->clientminorversion=clientminor;
3177 q_u->buffer=buffer;
3178 q_u->offered=offered;
3180 return True;
3183 /*******************************************************************
3184 * read a structure.
3185 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3186 ********************************************************************/
3188 BOOL spoolss_io_q_getprinterdriver2(char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
3190 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
3191 depth++;
3193 if(!prs_align(ps))
3194 return False;
3196 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3197 return False;
3198 if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr))
3199 return False;
3200 if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth))
3201 return False;
3203 if(!prs_align(ps))
3204 return False;
3205 if(!prs_uint32("level", ps, depth, &q_u->level))
3206 return False;
3208 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3209 return False;
3211 if(!prs_align(ps))
3212 return False;
3214 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3215 return False;
3217 if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion))
3218 return False;
3219 if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion))
3220 return False;
3222 return True;
3225 /*******************************************************************
3226 * read a structure.
3227 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3228 ********************************************************************/
3230 BOOL spoolss_io_r_getprinterdriver2(char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
3232 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
3233 depth++;
3235 if (!prs_align(ps))
3236 return False;
3238 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3239 return False;
3241 if (!prs_align(ps))
3242 return False;
3243 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3244 return False;
3245 if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion))
3246 return False;
3247 if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
3248 return False;
3249 if (!prs_uint32("status", ps, depth, &r_u->status))
3250 return False;
3252 return True;
3255 /*******************************************************************
3256 * init a structure.
3257 ********************************************************************/
3259 BOOL make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, uint32 flags,
3260 fstring servername, uint32 level,
3261 NEW_BUFFER *buffer, uint32 offered)
3263 q_u->flags=flags;
3265 q_u->servername_ptr = (servername != NULL) ? 1 : 0;
3266 init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
3268 q_u->level=level;
3269 q_u->buffer=buffer;
3270 q_u->offered=offered;
3272 return True;
3275 /*******************************************************************
3276 * init a structure.
3277 ********************************************************************/
3279 BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u,
3280 fstring servername, uint32 level,
3281 NEW_BUFFER *buffer, uint32 offered)
3283 q_u->name_ptr = (servername != NULL) ? 1 : 0;
3284 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
3286 q_u->level=level;
3287 q_u->buffer=buffer;
3288 q_u->offered=offered;
3290 return True;
3293 /*******************************************************************
3294 * read a structure.
3295 * called from spoolss_enumprinters (srv_spoolss.c)
3296 ********************************************************************/
3298 BOOL spoolss_io_q_enumprinters(char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
3300 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
3301 depth++;
3303 if (!prs_align(ps))
3304 return False;
3306 if (!prs_uint32("flags", ps, depth, &q_u->flags))
3307 return False;
3308 if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
3309 return False;
3311 if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
3312 return False;
3314 if (!prs_align(ps))
3315 return False;
3316 if (!prs_uint32("level", ps, depth, &q_u->level))
3317 return False;
3319 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3320 return False;
3322 if (!prs_align(ps))
3323 return False;
3324 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3325 return False;
3327 return True;
3330 /*******************************************************************
3331 Parse a SPOOL_R_ENUMPRINTERS structure.
3332 ********************************************************************/
3334 BOOL spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
3336 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
3337 depth++;
3339 if (!prs_align(ps))
3340 return False;
3342 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3343 return False;
3345 if (!prs_align(ps))
3346 return False;
3348 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3349 return False;
3351 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3352 return False;
3354 if (!prs_uint32("status", ps, depth, &r_u->status))
3355 return False;
3357 return True;
3360 /*******************************************************************
3361 * write a structure.
3362 * called from spoolss_r_enum_printers (srv_spoolss.c)
3364 ********************************************************************/
3366 BOOL spoolss_io_r_getprinter(char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
3368 prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
3369 depth++;
3371 if (!prs_align(ps))
3372 return False;
3374 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3375 return False;
3377 if (!prs_align(ps))
3378 return False;
3380 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3381 return False;
3383 if (!prs_uint32("status", ps, depth, &r_u->status))
3384 return False;
3386 return True;
3389 /*******************************************************************
3390 * read a structure.
3391 * called from spoolss_getprinter (srv_spoolss.c)
3392 ********************************************************************/
3394 BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
3396 prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
3397 depth++;
3399 if (!prs_align(ps))
3400 return False;
3402 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3403 return False;
3404 if (!prs_uint32("level", ps, depth, &q_u->level))
3405 return False;
3407 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3408 return False;
3410 if (!prs_align(ps))
3411 return False;
3412 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3413 return False;
3415 return True;
3418 /*******************************************************************
3419 * init a structure.
3420 ********************************************************************/
3422 BOOL make_spoolss_q_getprinter(
3423 SPOOL_Q_GETPRINTER *q_u,
3424 const POLICY_HND *hnd,
3425 uint32 level,
3426 NEW_BUFFER *buffer,
3427 uint32 offered
3430 if (q_u == NULL)
3432 return False;
3434 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3436 q_u->level=level;
3437 q_u->buffer=buffer;
3438 q_u->offered=offered;
3440 return True;
3443 /*******************************************************************
3444 * init a structure.
3445 ********************************************************************/
3446 BOOL make_spoolss_q_setprinter(
3447 SPOOL_Q_SETPRINTER *q_u,
3448 const POLICY_HND *hnd,
3449 uint32 level,
3450 PRINTER_INFO_CTR *info,
3451 uint32 command
3454 SEC_DESC *secdesc;
3455 DEVICEMODE *devmode;
3457 if (q_u == NULL)
3459 return False;
3462 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3464 q_u->level = level;
3465 q_u->info.level = level;
3466 q_u->info.info_ptr = (info != NULL) ? 1 : 0;
3467 switch (level)
3469 case 2:
3470 secdesc = info->printers_2->secdesc;
3471 devmode = info->printers_2->devmode;
3473 /* FIXMEE!! HACK ALERT!!! --jerry */
3474 info->printers_2->devmode = NULL;
3475 info->printers_2->secdesc = NULL;
3477 make_spoolss_printer_info_2 (&q_u->info.info_2, info->printers_2);
3478 #if 0 /* JERRY TEST */
3479 q_u->secdesc_ctr = (SEC_DESC_BUF*)malloc(sizeof(SEC_DESC_BUF));
3480 if (!q_u->secdesc_ctr)
3481 return False;
3482 q_u->secdesc_ctr->ptr = (secdesc != NULL) ? 1: 0;
3483 q_u->secdesc_ctr->max_len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3484 q_u->secdesc_ctr->len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
3485 q_u->secdesc_ctr->sec = secdesc;
3487 q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
3488 q_u->devmode_ctr.size = sizeof(DEVICEMODE) + (3*sizeof(uint32));
3489 q_u->devmode_ctr.devmode = devmode;
3490 #else
3491 q_u->secdesc_ctr = NULL;
3493 q_u->devmode_ctr.devmode_ptr = 0;
3494 q_u->devmode_ctr.size = 0;
3495 q_u->devmode_ctr.devmode = NULL;
3496 #endif
3497 break;
3498 default:
3499 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
3500 break;
3504 q_u->command = command;
3506 return True;
3510 /*******************************************************************
3511 ********************************************************************/
3513 BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
3515 prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
3516 depth++;
3518 if(!prs_align(ps))
3519 return False;
3521 if(!prs_uint32("status", ps, depth, &r_u->status))
3522 return False;
3524 return True;
3527 /*******************************************************************
3528 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3529 ********************************************************************/
3531 BOOL spoolss_io_q_setprinter(char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
3533 uint32 ptr_sec_desc = 0;
3535 prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
3536 depth++;
3538 if(!prs_align(ps))
3539 return False;
3541 if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
3542 return False;
3543 if(!prs_uint32("level", ps, depth, &q_u->level))
3544 return False;
3546 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
3547 return False;
3549 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
3550 return False;
3552 switch (q_u->level)
3554 case 2:
3556 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
3557 break;
3559 case 3:
3561 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
3562 break;
3565 if (ptr_sec_desc)
3567 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
3568 return False;
3569 } else {
3570 uint32 dummy;
3572 /* Parse a NULL security descriptor. This should really
3573 happen inside the sec_io_desc_buf() function. */
3575 prs_debug(ps, depth, "", "sec_io_desc_buf");
3576 if (!prs_uint32("size", ps, depth + 1, &dummy)) return False;
3577 if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return
3578 False;
3581 if(!prs_uint32("command", ps, depth, &q_u->command))
3582 return False;
3584 return True;
3587 /*******************************************************************
3588 ********************************************************************/
3590 BOOL spoolss_io_r_fcpn(char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
3592 prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
3593 depth++;
3595 if(!prs_align(ps))
3596 return False;
3598 if(!prs_uint32("status", ps, depth, &r_u->status))
3599 return False;
3601 return True;
3604 /*******************************************************************
3605 ********************************************************************/
3607 BOOL spoolss_io_q_fcpn(char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
3610 prs_debug(ps, depth, desc, "spoolss_io_q_fcpn");
3611 depth++;
3613 if(!prs_align(ps))
3614 return False;
3616 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3617 return False;
3619 return True;
3623 /*******************************************************************
3624 ********************************************************************/
3626 BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
3628 prs_debug(ps, depth, desc, "");
3629 depth++;
3631 if(!prs_align(ps))
3632 return False;
3634 if(!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3635 return False;
3637 if(!prs_align(ps))
3638 return False;
3640 if(!prs_uint32("needed", ps, depth, &r_u->needed))
3641 return False;
3643 if(!prs_uint32("status", ps, depth, &r_u->status))
3644 return False;
3646 return True;
3649 /*******************************************************************
3650 ********************************************************************/
3652 BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
3654 prs_debug(ps, depth, desc, "");
3655 depth++;
3657 if(!prs_align(ps))
3658 return False;
3660 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3661 return False;
3662 if(!prs_uint32("level", ps, depth, &q_u->level))
3663 return False;
3665 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3666 return False;
3668 if(!prs_align(ps))
3669 return False;
3671 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3672 return False;
3674 return True;
3677 /*******************************************************************
3678 ********************************************************************/
3680 BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
3682 prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
3683 depth++;
3685 if (!prs_align(ps))
3686 return False;
3688 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3689 return False;
3691 if (!prs_align(ps))
3692 return False;
3694 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3695 return False;
3697 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3698 return False;
3700 if (!prs_uint32("status", ps, depth, &r_u->status))
3701 return False;
3703 return True;
3706 /*******************************************************************
3707 ********************************************************************/
3709 BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
3710 uint32 firstjob,
3711 uint32 numofjobs,
3712 uint32 level,
3713 NEW_BUFFER *buffer,
3714 uint32 offered)
3716 if (q_u == NULL)
3718 return False;
3720 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3721 q_u->firstjob = firstjob;
3722 q_u->numofjobs = numofjobs;
3723 q_u->level = level;
3724 q_u->buffer= buffer;
3725 q_u->offered = offered;
3726 return True;
3729 /*******************************************************************
3730 ********************************************************************/
3732 BOOL spoolss_io_q_enumjobs(char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
3734 prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
3735 depth++;
3737 if (!prs_align(ps))
3738 return False;
3740 if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth))
3741 return False;
3743 if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
3744 return False;
3745 if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
3746 return False;
3747 if (!prs_uint32("level", ps, depth, &q_u->level))
3748 return False;
3750 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3751 return False;
3753 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3754 return False;
3756 return True;
3759 /*******************************************************************
3760 ********************************************************************/
3762 BOOL spoolss_io_r_schedulejob(char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth)
3764 prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob");
3765 depth++;
3767 if(!prs_align(ps))
3768 return False;
3770 if(!prs_uint32("status", ps, depth, &r_u->status))
3771 return False;
3773 return True;
3776 /*******************************************************************
3777 ********************************************************************/
3779 BOOL spoolss_io_q_schedulejob(char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth)
3781 prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob");
3782 depth++;
3784 if(!prs_align(ps))
3785 return False;
3787 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3788 return False;
3789 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
3790 return False;
3792 return True;
3795 /*******************************************************************
3796 ********************************************************************/
3798 BOOL spoolss_io_r_setjob(char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth)
3800 prs_debug(ps, depth, desc, "spoolss_io_r_setjob");
3801 depth++;
3803 if(!prs_align(ps))
3804 return False;
3806 if(!prs_uint32("status", ps, depth, &r_u->status))
3807 return False;
3809 return True;
3812 /*******************************************************************
3813 ********************************************************************/
3815 BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth)
3817 prs_debug(ps, depth, desc, "spoolss_io_q_setjob");
3818 depth++;
3820 if(!prs_align(ps))
3821 return False;
3823 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3824 return False;
3825 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
3826 return False;
3828 * level is usually 0. If (level!=0) then I'm in trouble !
3829 * I will try to generate setjob command with level!=0, one day.
3831 if(!prs_uint32("level", ps, depth, &q_u->level))
3832 return False;
3833 if(!prs_uint32("command", ps, depth, &q_u->command))
3834 return False;
3836 return True;
3839 /*******************************************************************
3840 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
3841 ********************************************************************/
3843 BOOL spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
3845 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
3846 depth++;
3848 if (!prs_align(ps))
3849 return False;
3851 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3852 return False;
3854 if (!prs_align(ps))
3855 return False;
3857 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3858 return False;
3860 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3861 return False;
3863 if (!prs_uint32("status", ps, depth, &r_u->status))
3864 return False;
3866 return True;
3869 /*******************************************************************
3870 * init a structure.
3871 ********************************************************************/
3873 BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
3874 const char *name,
3875 const char *environment,
3876 uint32 level,
3877 NEW_BUFFER *buffer, uint32 offered)
3879 init_buf_unistr2(&q_u->name, &q_u->name_ptr, name);
3880 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment);
3882 q_u->level=level;
3883 q_u->buffer=buffer;
3884 q_u->offered=offered;
3886 return True;
3889 /*******************************************************************
3890 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
3891 ********************************************************************/
3893 BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
3896 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
3897 depth++;
3899 if (!prs_align(ps))
3900 return False;
3902 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
3903 return False;
3904 if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
3905 return False;
3907 if (!prs_align(ps))
3908 return False;
3909 if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
3910 return False;
3911 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
3912 return False;
3914 if (!prs_align(ps))
3915 return False;
3916 if (!prs_uint32("level", ps, depth, &q_u->level))
3917 return False;
3919 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3920 return False;
3922 if (!prs_align(ps))
3923 return False;
3925 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3926 return False;
3928 return True;
3931 /*******************************************************************
3932 ********************************************************************/
3934 BOOL spoolss_io_q_enumforms(char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
3937 prs_debug(ps, depth, desc, "spoolss_io_q_enumforms");
3938 depth++;
3940 if (!prs_align(ps))
3941 return False;
3942 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3943 return False;
3944 if (!prs_uint32("level", ps, depth, &q_u->level))
3945 return False;
3947 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
3948 return False;
3950 if (!prs_align(ps))
3951 return False;
3952 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3953 return False;
3955 return True;
3958 /*******************************************************************
3959 ********************************************************************/
3961 BOOL spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
3963 prs_debug(ps, depth, desc, "spoolss_io_r_enumforms");
3964 depth++;
3966 if (!prs_align(ps))
3967 return False;
3969 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
3970 return False;
3972 if (!prs_align(ps))
3973 return False;
3975 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
3976 return False;
3978 if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
3979 return False;
3981 if (!prs_uint32("status", ps, depth, &r_u->status))
3982 return False;
3984 return True;
3987 /*******************************************************************
3988 ********************************************************************/
3990 BOOL spoolss_io_q_getform(char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
3993 prs_debug(ps, depth, desc, "spoolss_io_q_getform");
3994 depth++;
3996 if (!prs_align(ps))
3997 return False;
3998 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3999 return False;
4000 if (!smb_io_unistr2("", &q_u->formname,True,ps,depth))
4001 return False;
4003 if (!prs_align(ps))
4004 return False;
4006 if (!prs_uint32("level", ps, depth, &q_u->level))
4007 return False;
4009 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4010 return False;
4012 if (!prs_align(ps))
4013 return False;
4014 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4015 return False;
4017 return True;
4020 /*******************************************************************
4021 ********************************************************************/
4023 BOOL spoolss_io_r_getform(char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
4025 prs_debug(ps, depth, desc, "spoolss_io_r_getform");
4026 depth++;
4028 if (!prs_align(ps))
4029 return False;
4031 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4032 return False;
4034 if (!prs_align(ps))
4035 return False;
4037 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
4038 return False;
4040 if (!prs_uint32("status", ps, depth, &r_u->status))
4041 return False;
4043 return True;
4046 /*******************************************************************
4047 Parse a SPOOL_R_ENUMPORTS structure.
4048 ********************************************************************/
4050 BOOL spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
4052 prs_debug(ps, depth, desc, "spoolss_io_r_enumports");
4053 depth++;
4055 if (!prs_align(ps))
4056 return False;
4058 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
4059 return False;
4061 if (!prs_align(ps))
4062 return False;
4064 if (!prs_uint32("needed", ps, depth, &r_u->needed))
4065 return False;
4067 if (!prs_uint32("returned", ps, depth, &r_u->returned))
4068 return False;
4070 if (!prs_uint32("status", ps, depth, &r_u->status))
4071 return False;
4073 return True;
4076 /*******************************************************************
4077 ********************************************************************/
4079 BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
4081 prs_debug(ps, depth, desc, "");
4082 depth++;
4084 if (!prs_align(ps))
4085 return False;
4087 if (!prs_uint32("", ps, depth, &q_u->name_ptr))
4088 return False;
4089 if (!smb_io_unistr2("", &q_u->name,True,ps,depth))
4090 return False;
4092 if (!prs_align(ps))
4093 return False;
4094 if (!prs_uint32("level", ps, depth, &q_u->level))
4095 return False;
4097 if (!spoolss_io_buffer("", ps, depth, &q_u->buffer))
4098 return False;
4100 if (!prs_align(ps))
4101 return False;
4102 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4103 return False;
4105 return True;
4108 /*******************************************************************
4109 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4110 ********************************************************************/
4112 BOOL spool_io_printer_info_level_1(char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
4114 prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
4115 depth++;
4117 if(!prs_align(ps))
4118 return False;
4120 if(!prs_uint32("flags", ps, depth, &il->flags))
4121 return False;
4122 if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr))
4123 return False;
4124 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4125 return False;
4126 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4127 return False;
4129 if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth))
4130 return False;
4131 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4132 return False;
4133 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4134 return False;
4136 return True;
4139 /*******************************************************************
4140 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4141 ********************************************************************/
4143 BOOL spool_io_printer_info_level_3(char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
4145 prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
4146 depth++;
4148 if(!prs_align(ps))
4149 return False;
4151 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4152 return False;
4154 return True;
4157 /*******************************************************************
4158 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4159 ********************************************************************/
4161 BOOL spool_io_printer_info_level_2(char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
4163 prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
4164 depth++;
4166 if(!prs_align(ps))
4167 return False;
4169 if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr))
4170 return False;
4171 if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr))
4172 return False;
4173 if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr))
4174 return False;
4175 if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
4176 return False;
4178 if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
4179 return False;
4180 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4181 return False;
4182 if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr))
4183 return False;
4184 if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr))
4185 return False;
4186 if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr))
4187 return False;
4188 if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr))
4189 return False;
4190 if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr))
4191 return False;
4192 if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr))
4193 return False;
4194 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4195 return False;
4197 if(!prs_uint32("attributes", ps, depth, &il->attributes))
4198 return False;
4199 if(!prs_uint32("priority", ps, depth, &il->priority))
4200 return False;
4201 if(!prs_uint32("default_priority", ps, depth, &il->default_priority))
4202 return False;
4203 if(!prs_uint32("starttime", ps, depth, &il->starttime))
4204 return False;
4205 if(!prs_uint32("untiltime", ps, depth, &il->untiltime))
4206 return False;
4207 if(!prs_uint32("status", ps, depth, &il->status))
4208 return False;
4209 if(!prs_uint32("cjobs", ps, depth, &il->cjobs))
4210 return False;
4211 if(!prs_uint32("averageppm", ps, depth, &il->averageppm))
4212 return False;
4214 if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth))
4215 return False;
4216 if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth))
4217 return False;
4218 if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth))
4219 return False;
4220 if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth))
4221 return False;
4222 if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth))
4223 return False;
4224 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4225 return False;
4226 if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth))
4227 return False;
4228 if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth))
4229 return False;
4230 if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth))
4231 return False;
4232 if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth))
4233 return False;
4234 if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth))
4235 return False;
4237 return True;
4240 /*******************************************************************
4241 ********************************************************************/
4243 BOOL spool_io_printer_info_level(char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
4245 prs_debug(ps, depth, desc, "spool_io_printer_info_level");
4246 depth++;
4248 if(!prs_align(ps))
4249 return False;
4250 if(!prs_uint32("level", ps, depth, &il->level))
4251 return False;
4252 if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr))
4253 return False;
4255 /* if no struct inside just return */
4256 if (il->info_ptr==0) {
4257 if (UNMARSHALLING(ps)) {
4258 il->info_1=NULL;
4259 il->info_2=NULL;
4261 return True;
4264 switch (il->level) {
4266 * level 0 is used by setprinter when managing the queue
4267 * (hold, stop, start a queue)
4269 case 0:
4270 break;
4271 /* DOCUMENT ME!!! What is level 1 used for? */
4272 case 1:
4274 if (UNMARSHALLING(ps)) {
4275 if ((il->info_1=(SPOOL_PRINTER_INFO_LEVEL_1 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_1))) == NULL)
4276 return False;
4278 if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
4279 return False;
4280 break;
4283 * level 2 is used by addprinter
4284 * and by setprinter when updating printer's info
4286 case 2:
4287 if (UNMARSHALLING(ps)) {
4288 if ((il->info_2=(SPOOL_PRINTER_INFO_LEVEL_2 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_2))) == NULL)
4289 return False;
4291 if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
4292 return False;
4293 break;
4294 /* DOCUMENT ME!!! What is level 3 used for? */
4295 case 3:
4297 if (UNMARSHALLING(ps)) {
4298 if ((il->info_3=(SPOOL_PRINTER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_3))) == NULL)
4299 return False;
4301 if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
4302 return False;
4303 break;
4307 return True;
4310 /*******************************************************************
4311 ********************************************************************/
4313 BOOL spoolss_io_q_addprinterex(char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
4315 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
4316 depth++;
4318 if(!prs_align(ps))
4319 return False;
4320 if(!prs_uint32("", ps, depth, &q_u->server_name_ptr))
4321 return False;
4322 if(!smb_io_unistr2("", &q_u->server_name, q_u->server_name_ptr, ps, depth))
4323 return False;
4325 if(!prs_align(ps))
4326 return False;
4328 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4329 return False;
4331 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
4332 return False;
4334 /* the 4 unknown are all 0 */
4337 * en fait ils sont pas inconnu
4338 * par recoupement avec rpcSetPrinter
4339 * c'est le devicemode
4340 * et le security descriptor.
4343 if(!prs_align(ps))
4344 return False;
4345 if(!prs_uint32("unk0", ps, depth, &q_u->unk0))
4346 return False;
4347 if(!prs_uint32("unk1", ps, depth, &q_u->unk1))
4348 return False;
4349 if(!prs_uint32("unk2", ps, depth, &q_u->unk2))
4350 return False;
4351 if(!prs_uint32("unk3", ps, depth, &q_u->unk3))
4352 return False;
4354 if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
4355 return False;
4356 if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
4357 return False;
4359 return True;
4362 /*******************************************************************
4363 ********************************************************************/
4365 BOOL spoolss_io_r_addprinterex(char *desc, SPOOL_R_ADDPRINTEREX *r_u,
4366 prs_struct *ps, int depth)
4368 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
4369 depth++;
4371 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
4372 return False;
4374 if(!prs_uint32("status", ps, depth, &r_u->status))
4375 return False;
4377 return True;
4380 /*******************************************************************
4381 ********************************************************************/
4383 BOOL spool_io_printer_driver_info_level_3(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
4384 prs_struct *ps, int depth)
4386 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il;
4388 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3");
4389 depth++;
4391 /* reading */
4392 if (UNMARSHALLING(ps)) {
4393 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4394 if(il == NULL)
4395 return False;
4396 *q_u=il;
4398 else {
4399 il=*q_u;
4402 if(!prs_align(ps))
4403 return False;
4405 if(!prs_uint32("cversion", ps, depth, &il->cversion))
4406 return False;
4407 if(!prs_uint32("name", ps, depth, &il->name_ptr))
4408 return False;
4409 if(!prs_uint32("environment", ps, depth, &il->environment_ptr))
4410 return False;
4411 if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr))
4412 return False;
4413 if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr))
4414 return False;
4415 if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr))
4416 return False;
4417 if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr))
4418 return False;
4419 if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr))
4420 return False;
4421 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4422 return False;
4423 if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize))
4424 return False;
4425 if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr))
4426 return False;
4428 if(!prs_align(ps))
4429 return False;
4431 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4432 return False;
4433 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4434 return False;
4435 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4436 return False;
4437 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4438 return False;
4439 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4440 return False;
4441 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4442 return False;
4443 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4444 return False;
4445 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4446 return False;
4448 if(!prs_align(ps))
4449 return False;
4451 if (il->dependentfiles_ptr)
4452 smb_io_buffer5("", &il->dependentfiles, ps, depth);
4454 return True;
4457 /*******************************************************************
4458 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4459 ********************************************************************/
4461 BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
4462 prs_struct *ps, int depth)
4464 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il;
4466 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6");
4467 depth++;
4469 /* reading */
4470 if (UNMARSHALLING(ps)) {
4471 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6));
4472 if(il == NULL)
4473 return False;
4474 *q_u=il;
4476 else {
4477 il=*q_u;
4480 if(!prs_align(ps))
4481 return False;
4484 /* parse the main elements the packet */
4486 if(!prs_uint32("version", ps, depth, &il->version))
4487 return False;
4489 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4490 return False;
4492 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4493 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4494 * from W2K CDROM (which uses unidriver). JohnR 010205
4496 if (!il->name_ptr) {
4497 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4498 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4499 return False;
4502 if(!prs_uint32("environment_ptr", ps, depth, &il->environment_ptr))
4503 return False;
4504 if(!prs_uint32("driverpath_ptr", ps, depth, &il->driverpath_ptr))
4505 return False;
4506 if(!prs_uint32("datafile_ptr", ps, depth, &il->datafile_ptr))
4507 return False;
4508 if(!prs_uint32("configfile_ptr", ps, depth, &il->configfile_ptr))
4509 return False;
4510 if(!prs_uint32("helpfile_ptr", ps, depth, &il->helpfile_ptr))
4511 return False;
4512 if(!prs_uint32("monitorname_ptr", ps, depth, &il->monitorname_ptr))
4513 return False;
4514 if(!prs_uint32("defaultdatatype_ptr", ps, depth, &il->defaultdatatype_ptr))
4515 return False;
4516 if(!prs_uint32("dependentfiles_len", ps, depth, &il->dependentfiles_len))
4517 return False;
4518 if(!prs_uint32("dependentfiles_ptr", ps, depth, &il->dependentfiles_ptr))
4519 return False;
4520 if(!prs_uint32("previousnames_len", ps, depth, &il->previousnames_len))
4521 return False;
4522 if(!prs_uint32("previousnames_ptr", ps, depth, &il->previousnames_ptr))
4523 return False;
4524 if(!smb_io_time("driverdate", &il->driverdate, ps, depth))
4525 return False;
4526 if(!prs_uint32("dummy4", ps, depth, &il->dummy4))
4527 return False;
4528 if(!prs_uint64("driverversion", ps, depth, &il->driverversion))
4529 return False;
4530 if(!prs_uint32("mfgname_ptr", ps, depth, &il->mfgname_ptr))
4531 return False;
4532 if(!prs_uint32("oemurl_ptr", ps, depth, &il->oemurl_ptr))
4533 return False;
4534 if(!prs_uint32("hardwareid_ptr", ps, depth, &il->hardwareid_ptr))
4535 return False;
4536 if(!prs_uint32("provider_ptr", ps, depth, &il->provider_ptr))
4537 return False;
4539 /* parse the structures in the packet */
4541 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4542 return False;
4543 if(!prs_align(ps))
4544 return False;
4546 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4547 return False;
4548 if(!prs_align(ps))
4549 return False;
4551 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4552 return False;
4553 if(!prs_align(ps))
4554 return False;
4556 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4557 return False;
4558 if(!prs_align(ps))
4559 return False;
4561 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4562 return False;
4563 if(!prs_align(ps))
4564 return False;
4566 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4567 return False;
4568 if(!prs_align(ps))
4569 return False;
4571 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4572 return False;
4573 if(!prs_align(ps))
4574 return False;
4576 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4577 return False;
4578 if(!prs_align(ps))
4579 return False;
4580 if (il->dependentfiles_ptr) {
4581 if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth))
4582 return False;
4583 if(!prs_align(ps))
4584 return False;
4586 if (il->previousnames_ptr) {
4587 if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth))
4588 return False;
4589 if(!prs_align(ps))
4590 return False;
4592 if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth))
4593 return False;
4594 if(!prs_align(ps))
4595 return False;
4596 if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth))
4597 return False;
4598 if(!prs_align(ps))
4599 return False;
4600 if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth))
4601 return False;
4602 if(!prs_align(ps))
4603 return False;
4604 if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth))
4605 return False;
4607 return True;
4610 /*******************************************************************
4611 convert a buffer of UNICODE strings null terminated
4612 the buffer is terminated by a NULL
4614 convert to an dos codepage array (null terminated)
4616 dynamically allocate memory
4618 ********************************************************************/
4619 static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
4621 fstring f;
4622 int n = 0;
4623 char *src;
4625 if (buf5==NULL) return False;
4627 src = (char *)buf5->buffer;
4628 *ar = NULL;
4630 while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
4631 unistr_to_dos(f, src, sizeof(f)-1);
4632 src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
4633 *ar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2));
4634 fstrcpy((*ar)[n], f);
4635 n++;
4637 fstrcpy((*ar)[n], "");
4639 return True;
4642 /*******************************************************************
4643 read a UNICODE array with null terminated strings
4644 and null terminated array
4645 and size of array at beginning
4646 ********************************************************************/
4648 BOOL smb_io_unibuffer(char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
4650 if (buffer==NULL) return False;
4652 buffer->undoc=0;
4653 buffer->uni_str_len=buffer->uni_max_len;
4655 if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
4656 return False;
4658 if(!prs_unistr2(True, "buffer ", ps, depth, buffer))
4659 return False;
4661 return True;
4664 /*******************************************************************
4665 ********************************************************************/
4667 BOOL spool_io_printer_driver_info_level(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
4669 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
4670 depth++;
4672 if(!prs_align(ps))
4673 return False;
4674 if(!prs_uint32("level", ps, depth, &il->level))
4675 return False;
4676 if(!prs_uint32("ptr", ps, depth, &il->ptr))
4677 return False;
4679 if (il->ptr==0)
4680 return True;
4682 switch (il->level) {
4683 case 3:
4684 if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth))
4685 return False;
4686 break;
4687 case 6:
4688 if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth))
4689 return False;
4690 break;
4691 default:
4692 return False;
4695 return True;
4698 /*******************************************************************
4699 init a SPOOL_Q_ADDPRINTERDRIVER struct
4700 ******************************************************************/
4702 BOOL make_spoolss_q_addprinterdriver(
4703 SPOOL_Q_ADDPRINTERDRIVER *q_u,
4704 const char* srv_name,
4705 uint32 level,
4706 PRINTER_DRIVER_CTR *info)
4708 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
4710 q_u->server_name_ptr = (srv_name!=NULL)?1:0;
4711 init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)+1);
4713 q_u->level = level;
4715 q_u->info.level = level;
4716 q_u->info.ptr = (info!=NULL)?1:0;
4717 switch (level)
4719 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
4720 case 3 :
4721 make_spoolss_driver_info_3(&q_u->info.info_3, info->info3);
4722 break;
4724 /* info level 6 is supported by WinME and Win2k */
4725 case 6:
4726 /* WRITEME!! will add later --jerry */
4727 break;
4729 default:
4730 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level));
4731 break;
4734 return True;
4737 BOOL make_spoolss_driver_info_3(
4738 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
4739 DRIVER_INFO_3 *info3
4742 uint32 len = 0;
4743 uint16 *ptr = info3->dependentfiles;
4744 BOOL done = False;
4745 BOOL null_char = False;
4746 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf;
4748 inf = (SPOOL_PRINTER_DRIVER_INFO_LEVEL_3*)
4749 malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4750 if (!inf)
4751 return False;
4752 memset (inf, 0x0, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4754 inf->cversion = info3->version;
4755 inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
4756 inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
4757 inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
4758 inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
4759 inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
4760 inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
4761 inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
4762 inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
4764 init_unistr2_from_unistr(&inf->name, &info3->name);
4765 init_unistr2_from_unistr(&inf->environment, &info3->architecture);
4766 init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
4767 init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
4768 init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
4769 init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
4770 init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
4771 init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
4773 while (!done)
4775 switch (*ptr)
4777 case 0:
4778 /* the null_char BOOL is used to help locate
4779 two '\0's back to back */
4780 if (null_char)
4781 done = True;
4782 else
4783 null_char = True;
4784 break;
4786 default:
4787 null_char = False;
4789 break;
4791 len++;
4792 ptr++;
4794 inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0;
4795 inf->dependentfilessize = len;
4796 if(!make_spoolss_buffer5(&inf->dependentfiles, len, info3->dependentfiles))
4798 safe_free (inf);
4799 return False;
4802 *spool_drv_info = inf;
4804 return True;
4807 /*******************************************************************
4808 make a BUFFER5 struct from a uint16*
4809 ******************************************************************/
4811 BOOL make_spoolss_buffer5(BUFFER5 *buf5, uint32 len, uint16 *src)
4814 buf5->buf_len = len;
4815 if((buf5->buffer=(uint16*)malloc(sizeof(uint16)*len)) == NULL)
4817 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
4818 return False;
4821 memcpy(buf5->buffer, src, sizeof(uint16)*len);
4823 return True;
4826 /*******************************************************************
4827 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
4828 ********************************************************************/
4830 BOOL spoolss_io_q_addprinterdriver(char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
4832 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
4833 depth++;
4835 if(!prs_align(ps))
4836 return False;
4838 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
4839 return False;
4840 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
4841 return False;
4843 if(!prs_align(ps))
4844 return False;
4845 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4846 return False;
4848 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
4849 return False;
4851 return True;
4854 /*******************************************************************
4855 ********************************************************************/
4857 BOOL spoolss_io_r_addprinterdriver(char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
4859 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
4860 depth++;
4862 if(!prs_uint32("status", ps, depth, &q_u->status))
4863 return False;
4865 return True;
4868 /*******************************************************************
4869 ********************************************************************/
4871 BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
4872 NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc)
4874 NT_PRINTER_DRIVER_INFO_LEVEL_3 *d;
4876 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
4878 if (*asc==NULL)
4880 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3));
4881 if(*asc == NULL)
4882 return False;
4883 ZERO_STRUCTP(*asc);
4886 d=*asc;
4888 d->cversion=uni->cversion;
4890 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
4891 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
4892 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
4893 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
4894 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
4895 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
4896 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
4897 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
4899 DEBUGADD(8,( "version: %d\n", d->cversion));
4900 DEBUGADD(8,( "name: %s\n", d->name));
4901 DEBUGADD(8,( "environment: %s\n", d->environment));
4902 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
4903 DEBUGADD(8,( "datafile: %s\n", d->datafile));
4904 DEBUGADD(8,( "configfile: %s\n", d->configfile));
4905 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
4906 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
4907 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
4909 uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles );
4911 return True;
4914 /*******************************************************************
4915 ********************************************************************/
4916 BOOL uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *uni,
4917 NT_PRINTER_DRIVER_INFO_LEVEL_6 **asc)
4919 NT_PRINTER_DRIVER_INFO_LEVEL_6 *d;
4921 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
4923 if (*asc==NULL)
4925 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_6 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6));
4926 if(*asc == NULL)
4927 return False;
4928 ZERO_STRUCTP(*asc);
4931 d=*asc;
4933 d->version=uni->version;
4935 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
4936 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
4937 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
4938 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
4939 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
4940 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
4941 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
4942 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
4944 DEBUGADD(8,( "version: %d\n", d->version));
4945 DEBUGADD(8,( "name: %s\n", d->name));
4946 DEBUGADD(8,( "environment: %s\n", d->environment));
4947 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
4948 DEBUGADD(8,( "datafile: %s\n", d->datafile));
4949 DEBUGADD(8,( "configfile: %s\n", d->configfile));
4950 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
4951 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
4952 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
4954 uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles );
4955 uniarray_2_dosarray(&uni->previousnames, &d->previousnames );
4957 return True;
4960 BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
4961 NT_PRINTER_INFO_LEVEL_2 **asc)
4963 NT_PRINTER_INFO_LEVEL_2 *d;
4964 time_t time_unix;
4966 DEBUG(7,("Converting from UNICODE to ASCII\n"));
4967 time_unix=time(NULL);
4969 if (*asc==NULL) {
4970 DEBUGADD(8,("allocating memory\n"));
4972 *asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2));
4973 if(*asc == NULL)
4974 return False;
4975 ZERO_STRUCTP(*asc);
4977 /* we allocate memory iff called from
4978 * addprinter(ex) so we can do one time stuff here.
4980 (*asc)->setuptime=time_unix;
4983 DEBUGADD(8,("start converting\n"));
4985 d=*asc;
4987 d->attributes=uni->attributes;
4988 d->priority=uni->priority;
4989 d->default_priority=uni->default_priority;
4990 d->starttime=uni->starttime;
4991 d->untiltime=uni->untiltime;
4992 d->status=uni->status;
4993 d->cjobs=uni->cjobs;
4995 unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1);
4996 unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1);
4997 unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
4998 unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
4999 unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
5000 unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
5001 unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
5002 unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
5003 unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
5004 unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype)-1);
5005 unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters)-1);
5007 return True;
5010 /*******************************************************************
5011 * init a structure.
5012 ********************************************************************/
5014 BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u,
5015 fstring servername, fstring env_name, uint32 level,
5016 NEW_BUFFER *buffer, uint32 offered)
5018 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
5019 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name);
5021 q_u->level=level;
5022 q_u->buffer=buffer;
5023 q_u->offered=offered;
5025 return True;
5028 /*******************************************************************
5029 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5030 ********************************************************************/
5032 BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth)
5034 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir");
5035 depth++;
5037 if(!prs_align(ps))
5038 return False;
5039 if(!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5040 return False;
5041 if(!smb_io_unistr2("", &q_u->name, q_u->name_ptr, ps, depth))
5042 return False;
5044 if(!prs_align(ps))
5045 return False;
5047 if(!prs_uint32("", ps, depth, &q_u->environment_ptr))
5048 return False;
5049 if(!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5050 return False;
5052 if(!prs_align(ps))
5053 return False;
5055 if(!prs_uint32("level", ps, depth, &q_u->level))
5056 return False;
5058 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5059 return False;
5061 if(!prs_align(ps))
5062 return False;
5064 if(!prs_uint32("offered", ps, depth, &q_u->offered))
5065 return False;
5067 return True;
5070 /*******************************************************************
5071 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5072 ********************************************************************/
5074 BOOL spoolss_io_r_getprinterdriverdir(char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth)
5076 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir");
5077 depth++;
5079 if (!prs_align(ps))
5080 return False;
5082 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5083 return False;
5085 if (!prs_align(ps))
5086 return False;
5088 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5089 return False;
5091 if (!prs_uint32("status", ps, depth, &r_u->status))
5092 return False;
5094 return True;
5097 /*******************************************************************
5098 ********************************************************************/
5100 BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
5102 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
5103 depth++;
5105 if (!prs_align(ps))
5106 return False;
5108 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5109 return False;
5111 if (!prs_align(ps))
5112 return False;
5114 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5115 return False;
5117 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5118 return False;
5120 if (!prs_uint32("status", ps, depth, &r_u->status))
5121 return False;
5123 return True;
5126 /*******************************************************************
5127 ********************************************************************/
5129 BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth)
5131 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
5132 depth++;
5134 if (!prs_align(ps))
5135 return False;
5137 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5138 return False;
5139 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5140 return False;
5142 if (!prs_align(ps))
5143 return False;
5145 if (!prs_uint32("", ps, depth, &q_u->environment_ptr))
5146 return False;
5147 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5148 return False;
5150 if (!prs_align(ps))
5151 return False;
5153 if (!prs_uint32("level", ps, depth, &q_u->level))
5154 return False;
5156 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5157 return False;
5159 if (!prs_align(ps))
5160 return False;
5162 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5163 return False;
5165 return True;
5168 /*******************************************************************
5169 ********************************************************************/
5171 BOOL spoolss_io_r_enumprintprocdatatypes(char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth)
5173 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes");
5174 depth++;
5176 if (!prs_align(ps))
5177 return False;
5179 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5180 return False;
5182 if (!prs_align(ps))
5183 return False;
5185 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5186 return False;
5188 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5189 return False;
5191 if (!prs_uint32("status", ps, depth, &r_u->status))
5192 return False;
5194 return True;
5197 /*******************************************************************
5198 ********************************************************************/
5200 BOOL spoolss_io_q_enumprintprocdatatypes(char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth)
5202 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes");
5203 depth++;
5205 if (!prs_align(ps))
5206 return False;
5208 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5209 return False;
5210 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5211 return False;
5213 if (!prs_align(ps))
5214 return False;
5216 if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr))
5217 return False;
5218 if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth))
5219 return False;
5221 if (!prs_align(ps))
5222 return False;
5224 if (!prs_uint32("level", ps, depth, &q_u->level))
5225 return False;
5227 if(!spoolss_io_buffer("buffer", ps, depth, &q_u->buffer))
5228 return False;
5230 if (!prs_align(ps))
5231 return False;
5233 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5234 return False;
5236 return True;
5239 /*******************************************************************
5240 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5241 ********************************************************************/
5243 BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
5245 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
5246 depth++;
5248 if (!prs_align(ps))
5249 return False;
5251 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5252 return False;
5253 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5254 return False;
5256 if (!prs_align(ps))
5257 return False;
5259 if (!prs_uint32("level", ps, depth, &q_u->level))
5260 return False;
5262 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5263 return False;
5265 if (!prs_align(ps))
5266 return False;
5268 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5269 return False;
5271 return True;
5274 /*******************************************************************
5275 ********************************************************************/
5277 BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
5279 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
5280 depth++;
5282 if (!prs_align(ps))
5283 return False;
5285 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5286 return False;
5288 if (!prs_align(ps))
5289 return False;
5291 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5292 return False;
5294 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5295 return False;
5297 if (!prs_uint32("status", ps, depth, &r_u->status))
5298 return False;
5300 return True;
5303 /*******************************************************************
5304 ********************************************************************/
5306 BOOL spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth)
5308 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata");
5309 depth++;
5311 if(!prs_align(ps))
5312 return False;
5313 if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize))
5314 return False;
5316 if(!prs_uint16uni(False, "value", ps, depth, r_u->value, r_u->valuesize ))
5317 return False;
5319 if(!prs_align(ps))
5320 return False;
5322 if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize))
5323 return False;
5325 if(!prs_uint32("type", ps, depth, &r_u->type))
5326 return False;
5328 if(!prs_uint32("datasize", ps, depth, &r_u->datasize))
5329 return False;
5330 if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize))
5331 return False;
5332 if(!prs_align(ps))
5333 return False;
5335 if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize))
5336 return False;
5337 if(!prs_uint32("status", ps, depth, &r_u->status))
5338 return False;
5340 return True;
5343 /*******************************************************************
5344 ********************************************************************/
5346 BOOL spoolss_io_q_enumprinterdata(char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth)
5348 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata");
5349 depth++;
5351 if(!prs_align(ps))
5352 return False;
5353 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5354 return False;
5355 if(!prs_uint32("index", ps, depth, &q_u->index))
5356 return False;
5357 if(!prs_uint32("valuesize", ps, depth, &q_u->valuesize))
5358 return False;
5359 if(!prs_uint32("datasize", ps, depth, &q_u->datasize))
5360 return False;
5362 return True;
5365 /*******************************************************************
5366 ********************************************************************/
5368 BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
5369 const POLICY_HND *hnd,
5370 uint32 idx, uint32 valuelen, uint32 datalen)
5372 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5373 q_u->index=idx;
5374 q_u->valuesize=valuelen;
5375 q_u->datasize=datalen;
5377 return True;
5380 /*******************************************************************
5381 ********************************************************************/
5383 BOOL spoolss_io_q_setprinterdata(char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
5385 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
5386 depth++;
5388 if(!prs_align(ps))
5389 return False;
5390 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5391 return False;
5392 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
5393 return False;
5395 if(!prs_align(ps))
5396 return False;
5398 if(!prs_uint32("type", ps, depth, &q_u->type))
5399 return False;
5401 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
5402 return False;
5404 switch (q_u->type)
5406 case 0x1:
5407 case 0x3:
5408 case 0x4:
5409 case 0x7:
5410 if (UNMARSHALLING(ps))
5411 q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
5412 if(q_u->data == NULL)
5413 return False;
5414 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
5415 return False;
5416 if(!prs_align(ps))
5417 return False;
5418 break;
5421 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
5422 return False;
5424 return True;
5427 /*******************************************************************
5428 ********************************************************************/
5430 BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
5432 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
5433 depth++;
5435 if(!prs_align(ps))
5436 return False;
5437 if(!prs_uint32("status", ps, depth, &r_u->status))
5438 return False;
5440 return True;
5443 /*******************************************************************
5444 ********************************************************************/
5446 BOOL convert_specific_param(NT_PRINTER_PARAM **param, const UNISTR2 *value,
5447 uint32 type, const uint8 *data, uint32 len)
5449 DEBUG(5,("converting a specific param struct\n"));
5451 if (*param == NULL)
5453 *param=(NT_PRINTER_PARAM *)malloc(sizeof(NT_PRINTER_PARAM));
5454 if(*param == NULL)
5455 return False;
5456 memset((char *)*param, '\0', sizeof(NT_PRINTER_PARAM));
5457 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5459 unistr2_to_ascii((*param)->value, value, sizeof((*param)->value)-1);
5460 (*param)->type = type;
5462 /* le champ data n'est pas NULL termine */
5463 /* on stocke donc la longueur */
5465 (*param)->data_len=len;
5467 if (len) {
5468 (*param)->data=(uint8 *)malloc(len * sizeof(uint8));
5469 if((*param)->data == NULL)
5470 return False;
5471 memcpy((*param)->data, data, len);
5474 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param)->value, (*param)->data_len));
5475 dump_data(10, (char *)(*param)->data, (*param)->data_len);
5477 return True;
5480 /*******************************************************************
5481 ********************************************************************/
5483 static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth)
5485 prs_debug(ps, depth, desc, "spoolss_io_addform");
5486 depth++;
5487 if(!prs_align(ps))
5488 return False;
5490 if (ptr!=0)
5492 if(!prs_uint32("flags", ps, depth, &f->flags))
5493 return False;
5494 if(!prs_uint32("name_ptr", ps, depth, &f->name_ptr))
5495 return False;
5496 if(!prs_uint32("size_x", ps, depth, &f->size_x))
5497 return False;
5498 if(!prs_uint32("size_y", ps, depth, &f->size_y))
5499 return False;
5500 if(!prs_uint32("left", ps, depth, &f->left))
5501 return False;
5502 if(!prs_uint32("top", ps, depth, &f->top))
5503 return False;
5504 if(!prs_uint32("right", ps, depth, &f->right))
5505 return False;
5506 if(!prs_uint32("bottom", ps, depth, &f->bottom))
5507 return False;
5509 if(!smb_io_unistr2("", &f->name, f->name_ptr, ps, depth))
5510 return False;
5513 return True;
5516 /*******************************************************************
5517 ********************************************************************/
5519 BOOL spoolss_io_q_deleteform(char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth)
5521 prs_debug(ps, depth, desc, "spoolss_io_q_deleteform");
5522 depth++;
5524 if(!prs_align(ps))
5525 return False;
5526 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5527 return False;
5528 if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth))
5529 return False;
5531 return True;
5534 /*******************************************************************
5535 ********************************************************************/
5537 BOOL spoolss_io_r_deleteform(char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth)
5539 prs_debug(ps, depth, desc, "spoolss_io_r_deleteform");
5540 depth++;
5542 if(!prs_align(ps))
5543 return False;
5544 if(!prs_uint32("status", ps, depth, &r_u->status))
5545 return False;
5547 return True;
5550 /*******************************************************************
5551 ********************************************************************/
5553 BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth)
5555 uint32 useless_ptr=0;
5556 prs_debug(ps, depth, desc, "spoolss_io_q_addform");
5557 depth++;
5559 if(!prs_align(ps))
5560 return False;
5561 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5562 return False;
5563 if(!prs_uint32("level", ps, depth, &q_u->level))
5564 return False;
5565 if(!prs_uint32("level2", ps, depth, &q_u->level2))
5566 return False;
5568 if (q_u->level==1)
5570 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
5571 return False;
5572 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
5573 return False;
5576 return True;
5579 /*******************************************************************
5580 ********************************************************************/
5582 BOOL spoolss_io_r_addform(char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth)
5584 prs_debug(ps, depth, desc, "spoolss_io_r_addform");
5585 depth++;
5587 if(!prs_align(ps))
5588 return False;
5589 if(!prs_uint32("status", ps, depth, &r_u->status))
5590 return False;
5592 return True;
5595 /*******************************************************************
5596 ********************************************************************/
5598 BOOL spoolss_io_q_setform(char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth)
5600 uint32 useless_ptr=0;
5601 prs_debug(ps, depth, desc, "spoolss_io_q_setform");
5602 depth++;
5604 if(!prs_align(ps))
5605 return False;
5606 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5607 return False;
5608 if(!smb_io_unistr2("", &q_u->name, True, ps, depth))
5609 return False;
5611 if(!prs_align(ps))
5612 return False;
5614 if(!prs_uint32("level", ps, depth, &q_u->level))
5615 return False;
5616 if(!prs_uint32("level2", ps, depth, &q_u->level2))
5617 return False;
5619 if (q_u->level==1)
5621 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
5622 return False;
5623 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
5624 return False;
5627 return True;
5630 /*******************************************************************
5631 ********************************************************************/
5633 BOOL spoolss_io_r_setform(char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth)
5635 prs_debug(ps, depth, desc, "spoolss_io_r_setform");
5636 depth++;
5638 if(!prs_align(ps))
5639 return False;
5640 if(!prs_uint32("status", ps, depth, &r_u->status))
5641 return False;
5643 return True;
5646 /*******************************************************************
5647 Parse a SPOOL_R_GETJOB structure.
5648 ********************************************************************/
5650 BOOL spoolss_io_r_getjob(char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
5652 prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
5653 depth++;
5655 if (!prs_align(ps))
5656 return False;
5658 if (!spoolss_io_buffer("", ps, depth, &r_u->buffer))
5659 return False;
5661 if (!prs_align(ps))
5662 return False;
5664 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5665 return False;
5667 if (!prs_uint32("status", ps, depth, &r_u->status))
5668 return False;
5670 return True;
5673 /*******************************************************************
5674 Parse a SPOOL_Q_GETJOB structure.
5675 ********************************************************************/
5677 BOOL spoolss_io_q_getjob(char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
5679 prs_debug(ps, depth, desc, "");
5680 depth++;
5682 if(!prs_align(ps))
5683 return False;
5685 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5686 return False;
5687 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
5688 return False;
5689 if(!prs_uint32("level", ps, depth, &q_u->level))
5690 return False;
5692 if(!spoolss_io_buffer("", ps, depth, &q_u->buffer))
5693 return False;
5695 if(!prs_align(ps))
5696 return False;
5698 if(!prs_uint32("offered", ps, depth, &q_u->offered))
5699 return False;
5701 return True;
5704 void free_devmode(DEVICEMODE *devmode)
5706 if (devmode!=NULL) {
5707 safe_free(devmode->private);
5708 safe_free(devmode);
5712 void free_printer_info_1(PRINTER_INFO_1 *printer)
5714 safe_free(printer);
5717 void free_printer_info_2(PRINTER_INFO_2 *printer)
5719 if (printer!=NULL) {
5720 free_devmode(printer->devmode);
5721 printer->devmode = NULL;
5722 safe_free(printer);
5726 void free_printer_info_3(PRINTER_INFO_3 *printer)
5728 if (printer!=NULL) {
5729 safe_free(printer);
5733 void free_job_info_2(JOB_INFO_2 *job)
5735 if (job!=NULL)
5736 free_devmode(job->devmode);
5739 /*******************************************************************
5740 * init a structure.
5741 ********************************************************************/
5743 BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
5744 const fstring string, uint32 printer, uint32 type)
5746 if (q_u == NULL)
5747 return False;
5749 init_unistr2(&q_u->string, string, strlen(string)+1);
5751 q_u->printer=printer;
5752 q_u->type=type;
5754 q_u->unknown0=0x0;
5755 q_u->unknown1=0x0;
5757 return True;
5760 /*******************************************************************
5761 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
5762 ********************************************************************/
5764 BOOL spoolss_io_q_replyopenprinter(char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
5766 prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
5767 depth++;
5769 if(!prs_align(ps))
5770 return False;
5772 if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
5773 return False;
5775 if(!prs_align(ps))
5776 return False;
5778 if(!prs_uint32("printer", ps, depth, &q_u->printer))
5779 return False;
5780 if(!prs_uint32("type", ps, depth, &q_u->type))
5781 return False;
5783 if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
5784 return False;
5785 if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
5786 return False;
5788 return True;
5791 /*******************************************************************
5792 Parse a SPOOL_R_REPLYOPENPRINTER structure.
5793 ********************************************************************/
5795 BOOL spoolss_io_r_replyopenprinter(char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
5797 prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
5798 depth++;
5800 if (!prs_align(ps))
5801 return False;
5803 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
5804 return False;
5806 if (!prs_uint32("status", ps, depth, &r_u->status))
5807 return False;
5809 return True;
5812 /*******************************************************************
5813 * init a structure.
5814 ********************************************************************/
5816 BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd)
5818 if (q_u == NULL)
5819 return False;
5821 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5823 return True;
5826 /*******************************************************************
5827 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
5828 ********************************************************************/
5830 BOOL spoolss_io_q_replycloseprinter(char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth)
5832 prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
5833 depth++;
5835 if(!prs_align(ps))
5836 return False;
5838 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5839 return False;
5841 return True;
5844 /*******************************************************************
5845 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
5846 ********************************************************************/
5848 BOOL spoolss_io_r_replycloseprinter(char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth)
5850 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
5851 depth++;
5853 if (!prs_align(ps))
5854 return False;
5856 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
5857 return False;
5859 if (!prs_uint32("status", ps, depth, &r_u->status))
5860 return False;
5862 return True;
5865 /*******************************************************************
5866 * init a structure.
5867 ********************************************************************/
5869 BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
5870 uint32 change_low, uint32 change_high)
5872 if (q_u == NULL)
5873 return False;
5875 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5877 q_u->change_low=change_low;
5878 q_u->change_high=change_high;
5880 q_u->unknown0=0x0;
5881 q_u->unknown1=0x0;
5883 q_u->info_ptr=1;
5885 q_u->info.version=2;
5886 q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
5887 q_u->info.count=0;
5889 return True;
5892 /*******************************************************************
5893 Parse a SPOOL_Q_REPLY_RRPCN structure.
5894 ********************************************************************/
5896 BOOL spoolss_io_q_reply_rrpcn(char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
5898 prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
5899 depth++;
5901 if(!prs_align(ps))
5902 return False;
5904 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5905 return False;
5907 if (!prs_uint32("change_low", ps, depth, &q_u->change_low))
5908 return False;
5910 if (!prs_uint32("change_high", ps, depth, &q_u->change_high))
5911 return False;
5913 if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
5914 return False;
5916 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
5917 return False;
5919 if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr))
5920 return False;
5922 if(q_u->info_ptr!=0)
5923 if(!smb_io_notify_info(desc, &q_u->info, ps, depth))
5924 return False;
5926 return True;
5929 /*******************************************************************
5930 Parse a SPOOL_R_REPLY_RRPCN structure.
5931 ********************************************************************/
5933 BOOL spoolss_io_r_reply_rrpcn(char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth)
5935 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
5936 depth++;
5938 if (!prs_align(ps))
5939 return False;
5941 if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0))
5942 return False;
5944 if (!prs_uint32("status", ps, depth, &r_u->status))
5945 return False;
5947 return True;