reverted the rename of new_spoolss_io_r_enumprinterdrivers()
[Samba/gbeck.git] / source / rpc_parse / parse_spoolss.c
blobd6987b46aa0e97b6f60673ff411a91a929ce1a58
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_uint8s(True,"string",ps,depth,(uint8 *)data->notify_data.data.string,x*2))
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_uint16s(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_uint16s(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_uint16s(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_spool_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_spool_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 == NULL)
832 DEBUG(0,("make_spool_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 = NULL;
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 new_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 new_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 new_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, "new_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 new_smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode)
1880 prs_struct *ps=&buffer->prs;
1882 prs_debug(ps, depth, desc, "new_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 new_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 (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
1952 return False;
1953 if (!new_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 new_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, "new_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 (!new_smb_io_relstr("description", buffer, depth, &info->description))
2055 return False;
2056 if (!new_smb_io_relstr("name", buffer, depth, &info->name))
2057 return False;
2058 if (!new_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 new_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, "new_smb_io_printer_info_2");
2073 depth++;
2075 buffer->struct_start=prs_offset(ps);
2077 if (!new_smb_io_relstr("servername", buffer, depth, &info->servername))
2078 return False;
2079 if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
2080 return False;
2081 if (!new_smb_io_relstr("sharename", buffer, depth, &info->sharename))
2082 return False;
2083 if (!new_smb_io_relstr("portname", buffer, depth, &info->portname))
2084 return False;
2085 if (!new_smb_io_relstr("drivername", buffer, depth, &info->drivername))
2086 return False;
2087 if (!new_smb_io_relstr("comment", buffer, depth, &info->comment))
2088 return False;
2089 if (!new_smb_io_relstr("location", buffer, depth, &info->location))
2090 return False;
2092 /* NT parses the DEVMODE at the end of the struct */
2093 if (!new_smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2094 return False;
2096 if (!new_smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
2097 return False;
2098 if (!new_smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2099 return False;
2100 if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
2101 return False;
2102 if (!new_smb_io_relstr("parameters", buffer, depth, &info->parameters))
2103 return False;
2105 if (!new_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 new_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, "new_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 new_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, "new_smb_io_port_info_1");
2165 depth++;
2167 buffer->struct_start=prs_offset(ps);
2169 if (!new_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 new_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, "new_smb_io_port_info_2");
2184 depth++;
2186 buffer->struct_start=prs_offset(ps);
2188 if (!new_smb_io_relstr("port_name", buffer, depth, &info->port_name))
2189 return False;
2190 if (!new_smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2191 return False;
2192 if (!new_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 new_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, "new_smb_io_printer_driver_info_1");
2211 depth++;
2213 buffer->struct_start=prs_offset(ps);
2215 if (!new_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 new_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, "new_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 (!new_smb_io_relstr("name", buffer, depth, &info->name))
2237 return False;
2238 if (!new_smb_io_relstr("architecture", buffer, depth, &info->architecture))
2239 return False;
2240 if (!new_smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2241 return False;
2242 if (!new_smb_io_relstr("datafile", buffer, depth, &info->datafile))
2243 return False;
2244 if (!new_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 new_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, "new_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 (!new_smb_io_relstr("name", buffer, depth, &info->name))
2266 return False;
2267 if (!new_smb_io_relstr("architecture", buffer, depth, &info->architecture))
2268 return False;
2269 if (!new_smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2270 return False;
2271 if (!new_smb_io_relstr("datafile", buffer, depth, &info->datafile))
2272 return False;
2273 if (!new_smb_io_relstr("configfile", buffer, depth, &info->configfile))
2274 return False;
2275 if (!new_smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2276 return False;
2278 if (!new_smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2279 return False;
2281 if (!new_smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2282 return False;
2283 if (!new_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 new_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, "new_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 (!new_smb_io_relstr("name", buffer, depth, &info->name))
2305 return False;
2306 if (!new_smb_io_relstr("architecture", buffer, depth, &info->architecture))
2307 return False;
2308 if (!new_smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
2309 return False;
2310 if (!new_smb_io_relstr("datafile", buffer, depth, &info->datafile))
2311 return False;
2312 if (!new_smb_io_relstr("configfile", buffer, depth, &info->configfile))
2313 return False;
2314 if (!new_smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
2315 return False;
2317 if (!new_smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
2318 return False;
2320 if (!new_smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
2321 return False;
2322 if (!new_smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
2323 return False;
2325 if (!new_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 (!new_smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
2343 return False;
2344 if (!new_smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
2345 return False;
2346 if (!new_smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
2347 return False;
2348 if (!new_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 new_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, "new_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 (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
2370 return False;
2371 if (!new_smb_io_relstr("machinename", buffer, depth, &info->machinename))
2372 return False;
2373 if (!new_smb_io_relstr("username", buffer, depth, &info->username))
2374 return False;
2375 if (!new_smb_io_relstr("document", buffer, depth, &info->document))
2376 return False;
2377 if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
2378 return False;
2379 if (!new_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 new_smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth)
2403 uint pipo=0;
2404 prs_struct *ps=&buffer->prs;
2406 prs_debug(ps, depth, desc, "new_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 (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
2414 return False;
2415 if (!new_smb_io_relstr("machinename", buffer, depth, &info->machinename))
2416 return False;
2417 if (!new_smb_io_relstr("username", buffer, depth, &info->username))
2418 return False;
2419 if (!new_smb_io_relstr("document", buffer, depth, &info->document))
2420 return False;
2421 if (!new_smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
2422 return False;
2423 if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
2424 return False;
2426 if (!new_smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
2427 return False;
2428 if (!new_smb_io_relstr("parameters", buffer, depth, &info->parameters))
2429 return False;
2430 if (!new_smb_io_relstr("drivername", buffer, depth, &info->drivername))
2431 return False;
2432 if (!new_smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
2433 return False;
2434 if (!new_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 new_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, "new_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 (!new_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 new_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, "new_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 new_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 new_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, "new_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 new_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, "new_smb_io_port_1");
2638 depth++;
2640 buffer->struct_start=prs_offset(ps);
2642 if(!new_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 new_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, "new_smb_io_port_2");
2657 depth++;
2659 buffer->struct_start=prs_offset(ps);
2661 if(!new_smb_io_relstr("port_name", buffer, depth, &info->port_name))
2662 return False;
2663 if(!new_smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
2664 return False;
2665 if(!new_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 (new_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 (new_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 (!new_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 (!new_smb_io_relstr("name", buffer, depth, &info->name))
2742 return False;
2743 if (!new_smb_io_relstr("environment", buffer, depth, &info->environment))
2744 return False;
2745 if (!new_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(!new_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 (!new_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 (!new_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 new_spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
3336 prs_debug(ps, depth, desc, "new_spoolss_io_r_enumprinters");
3337 depth++;
3339 if (!prs_align(ps))
3340 return False;
3342 if (!new_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 (!new_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 (!new_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(SPOOL_Q_GETPRINTER *q_u, const POLICY_HND *hnd, uint32 level,
3423 NEW_BUFFER *buffer, uint32 offered)
3425 if (q_u == NULL)
3427 return False;
3429 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3431 q_u->level=level;
3432 q_u->buffer=buffer;
3433 q_u->offered=offered;
3435 return True;
3438 /*******************************************************************
3439 ********************************************************************/
3441 BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
3443 prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
3444 depth++;
3446 if(!prs_align(ps))
3447 return False;
3449 if(!prs_uint32("status", ps, depth, &r_u->status))
3450 return False;
3452 return True;
3455 /*******************************************************************
3456 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3457 ********************************************************************/
3459 BOOL spoolss_io_q_setprinter(char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
3461 uint32 ptr_sec_desc = 0;
3463 prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
3464 depth++;
3466 if(!prs_align(ps))
3467 return False;
3469 if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
3470 return False;
3471 if(!prs_uint32("level", ps, depth, &q_u->level))
3472 return False;
3474 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
3475 return False;
3477 if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
3478 return False;
3480 switch (q_u->level)
3482 case 2:
3484 ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
3485 break;
3487 case 3:
3489 ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
3490 break;
3493 if (ptr_sec_desc)
3495 if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
3496 return False;
3497 } else {
3498 uint32 dummy;
3500 /* Parse a NULL security descriptor. This should really
3501 happen inside the sec_io_desc_buf() function. */
3503 prs_debug(ps, depth, "", "sec_io_desc_buf");
3504 if (!prs_uint32("size", ps, depth + 1, &dummy)) return False;
3505 if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return
3506 False;
3509 if(!prs_uint32("command", ps, depth, &q_u->command))
3510 return False;
3512 return True;
3515 /*******************************************************************
3516 ********************************************************************/
3518 BOOL spoolss_io_r_fcpn(char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
3520 prs_debug(ps, depth, desc, "spoolss_io_r_fcpn");
3521 depth++;
3523 if(!prs_align(ps))
3524 return False;
3526 if(!prs_uint32("status", ps, depth, &r_u->status))
3527 return False;
3529 return True;
3532 /*******************************************************************
3533 ********************************************************************/
3535 BOOL spoolss_io_q_fcpn(char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth)
3538 prs_debug(ps, depth, desc, "spoolss_io_q_fcpn");
3539 depth++;
3541 if(!prs_align(ps))
3542 return False;
3544 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3545 return False;
3547 return True;
3551 /*******************************************************************
3552 ********************************************************************/
3554 BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth)
3556 prs_debug(ps, depth, desc, "");
3557 depth++;
3559 if(!prs_align(ps))
3560 return False;
3562 if(!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
3563 return False;
3565 if(!prs_align(ps))
3566 return False;
3568 if(!prs_uint32("needed", ps, depth, &r_u->needed))
3569 return False;
3571 if(!prs_uint32("status", ps, depth, &r_u->status))
3572 return False;
3574 return True;
3577 /*******************************************************************
3578 ********************************************************************/
3580 BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth)
3582 prs_debug(ps, depth, desc, "");
3583 depth++;
3585 if(!prs_align(ps))
3586 return False;
3588 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
3589 return False;
3590 if(!prs_uint32("level", ps, depth, &q_u->level))
3591 return False;
3593 if(!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
3594 return False;
3596 if(!prs_align(ps))
3597 return False;
3599 if(!prs_uint32("offered", ps, depth, &q_u->offered))
3600 return False;
3602 return True;
3605 /*******************************************************************
3606 ********************************************************************/
3608 BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
3610 prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
3611 depth++;
3613 if (!prs_align(ps))
3614 return False;
3616 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
3617 return False;
3619 if (!prs_align(ps))
3620 return False;
3622 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3623 return False;
3625 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3626 return False;
3628 if (!prs_uint32("status", ps, depth, &r_u->status))
3629 return False;
3631 return True;
3634 /*******************************************************************
3635 ********************************************************************/
3637 BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
3638 uint32 firstjob,
3639 uint32 numofjobs,
3640 uint32 level,
3641 NEW_BUFFER *buffer,
3642 uint32 offered)
3644 if (q_u == NULL)
3646 return False;
3648 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
3649 q_u->firstjob = firstjob;
3650 q_u->numofjobs = numofjobs;
3651 q_u->level = level;
3652 q_u->buffer= buffer;
3653 q_u->offered = offered;
3654 return True;
3657 /*******************************************************************
3658 ********************************************************************/
3660 BOOL spoolss_io_q_enumjobs(char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
3662 prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
3663 depth++;
3665 if (!prs_align(ps))
3666 return False;
3668 if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth))
3669 return False;
3671 if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
3672 return False;
3673 if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
3674 return False;
3675 if (!prs_uint32("level", ps, depth, &q_u->level))
3676 return False;
3678 if (!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
3679 return False;
3681 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3682 return False;
3684 return True;
3687 /*******************************************************************
3688 ********************************************************************/
3690 BOOL spoolss_io_r_schedulejob(char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth)
3692 prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob");
3693 depth++;
3695 if(!prs_align(ps))
3696 return False;
3698 if(!prs_uint32("status", ps, depth, &r_u->status))
3699 return False;
3701 return True;
3704 /*******************************************************************
3705 ********************************************************************/
3707 BOOL spoolss_io_q_schedulejob(char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth)
3709 prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob");
3710 depth++;
3712 if(!prs_align(ps))
3713 return False;
3715 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3716 return False;
3717 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
3718 return False;
3720 return True;
3723 /*******************************************************************
3724 ********************************************************************/
3726 BOOL spoolss_io_r_setjob(char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth)
3728 prs_debug(ps, depth, desc, "spoolss_io_r_setjob");
3729 depth++;
3731 if(!prs_align(ps))
3732 return False;
3734 if(!prs_uint32("status", ps, depth, &r_u->status))
3735 return False;
3737 return True;
3740 /*******************************************************************
3741 ********************************************************************/
3743 BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth)
3745 prs_debug(ps, depth, desc, "spoolss_io_q_setjob");
3746 depth++;
3748 if(!prs_align(ps))
3749 return False;
3751 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3752 return False;
3753 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
3754 return False;
3756 * level is usually 0. If (level!=0) then I'm in trouble !
3757 * I will try to generate setjob command with level!=0, one day.
3759 if(!prs_uint32("level", ps, depth, &q_u->level))
3760 return False;
3761 if(!prs_uint32("command", ps, depth, &q_u->command))
3762 return False;
3764 return True;
3767 /*******************************************************************
3768 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
3769 ********************************************************************/
3771 BOOL new_spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
3773 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
3774 depth++;
3776 if (!prs_align(ps))
3777 return False;
3779 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
3780 return False;
3782 if (!prs_align(ps))
3783 return False;
3785 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3786 return False;
3788 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3789 return False;
3791 if (!prs_uint32("status", ps, depth, &r_u->status))
3792 return False;
3794 return True;
3797 /*******************************************************************
3798 * init a structure.
3799 ********************************************************************/
3801 BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
3802 const char *name,
3803 const char *environment,
3804 uint32 level,
3805 NEW_BUFFER *buffer, uint32 offered)
3807 init_buf_unistr2(&q_u->name, &q_u->name_ptr, name);
3808 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment);
3810 q_u->level=level;
3811 q_u->buffer=buffer;
3812 q_u->offered=offered;
3814 return True;
3817 /*******************************************************************
3818 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
3819 ********************************************************************/
3821 BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
3824 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
3825 depth++;
3827 if (!prs_align(ps))
3828 return False;
3830 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
3831 return False;
3832 if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
3833 return False;
3835 if (!prs_align(ps))
3836 return False;
3837 if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
3838 return False;
3839 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
3840 return False;
3842 if (!prs_align(ps))
3843 return False;
3844 if (!prs_uint32("level", ps, depth, &q_u->level))
3845 return False;
3847 if (!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
3848 return False;
3850 if (!prs_align(ps))
3851 return False;
3853 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3854 return False;
3856 return True;
3859 /*******************************************************************
3860 ********************************************************************/
3862 BOOL spoolss_io_q_enumforms(char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
3865 prs_debug(ps, depth, desc, "spoolss_io_q_enumforms");
3866 depth++;
3868 if (!prs_align(ps))
3869 return False;
3870 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3871 return False;
3872 if (!prs_uint32("level", ps, depth, &q_u->level))
3873 return False;
3875 if (!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
3876 return False;
3878 if (!prs_align(ps))
3879 return False;
3880 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3881 return False;
3883 return True;
3886 /*******************************************************************
3887 ********************************************************************/
3889 BOOL new_spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
3891 prs_debug(ps, depth, desc, "new_spoolss_io_r_enumforms");
3892 depth++;
3894 if (!prs_align(ps))
3895 return False;
3897 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
3898 return False;
3900 if (!prs_align(ps))
3901 return False;
3903 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
3904 return False;
3906 if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
3907 return False;
3909 if (!prs_uint32("status", ps, depth, &r_u->status))
3910 return False;
3912 return True;
3915 /*******************************************************************
3916 ********************************************************************/
3918 BOOL spoolss_io_q_getform(char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
3921 prs_debug(ps, depth, desc, "spoolss_io_q_getform");
3922 depth++;
3924 if (!prs_align(ps))
3925 return False;
3926 if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
3927 return False;
3928 if (!smb_io_unistr2("", &q_u->formname,True,ps,depth))
3929 return False;
3931 if (!prs_align(ps))
3932 return False;
3934 if (!prs_uint32("level", ps, depth, &q_u->level))
3935 return False;
3937 if (!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
3938 return False;
3940 if (!prs_align(ps))
3941 return False;
3942 if (!prs_uint32("offered", ps, depth, &q_u->offered))
3943 return False;
3945 return True;
3948 /*******************************************************************
3949 ********************************************************************/
3951 BOOL new_spoolss_io_r_getform(char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
3953 prs_debug(ps, depth, desc, "new_spoolss_io_r_getform");
3954 depth++;
3956 if (!prs_align(ps))
3957 return False;
3959 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
3960 return False;
3962 if (!prs_align(ps))
3963 return False;
3965 if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
3966 return False;
3968 if (!prs_uint32("status", ps, depth, &r_u->status))
3969 return False;
3971 return True;
3974 /*******************************************************************
3975 Parse a SPOOL_R_ENUMPORTS structure.
3976 ********************************************************************/
3978 BOOL new_spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
3980 prs_debug(ps, depth, desc, "new_spoolss_io_r_enumports");
3981 depth++;
3983 if (!prs_align(ps))
3984 return False;
3986 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
3987 return False;
3989 if (!prs_align(ps))
3990 return False;
3992 if (!prs_uint32("needed", ps, depth, &r_u->needed))
3993 return False;
3995 if (!prs_uint32("returned", ps, depth, &r_u->returned))
3996 return False;
3998 if (!prs_uint32("status", ps, depth, &r_u->status))
3999 return False;
4001 return True;
4004 /*******************************************************************
4005 ********************************************************************/
4007 BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
4009 prs_debug(ps, depth, desc, "");
4010 depth++;
4012 if (!prs_align(ps))
4013 return False;
4015 if (!prs_uint32("", ps, depth, &q_u->name_ptr))
4016 return False;
4017 if (!smb_io_unistr2("", &q_u->name,True,ps,depth))
4018 return False;
4020 if (!prs_align(ps))
4021 return False;
4022 if (!prs_uint32("level", ps, depth, &q_u->level))
4023 return False;
4025 if (!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
4026 return False;
4028 if (!prs_align(ps))
4029 return False;
4030 if (!prs_uint32("offered", ps, depth, &q_u->offered))
4031 return False;
4033 return True;
4036 /*******************************************************************
4037 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4038 ********************************************************************/
4040 BOOL spool_io_printer_info_level_1(char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
4042 prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
4043 depth++;
4045 if(!prs_align(ps))
4046 return False;
4048 if(!prs_uint32("flags", ps, depth, &il->flags))
4049 return False;
4050 if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr))
4051 return False;
4052 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4053 return False;
4054 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4055 return False;
4057 if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth))
4058 return False;
4059 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4060 return False;
4061 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4062 return False;
4064 return True;
4067 /*******************************************************************
4068 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4069 ********************************************************************/
4071 BOOL spool_io_printer_info_level_3(char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
4073 prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
4074 depth++;
4076 if(!prs_align(ps))
4077 return False;
4079 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4080 return False;
4082 return True;
4085 /*******************************************************************
4086 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4087 ********************************************************************/
4089 BOOL spool_io_printer_info_level_2(char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
4091 prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
4092 depth++;
4094 if(!prs_align(ps))
4095 return False;
4097 if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr))
4098 return False;
4099 if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr))
4100 return False;
4101 if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr))
4102 return False;
4103 if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
4104 return False;
4106 if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
4107 return False;
4108 if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
4109 return False;
4110 if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr))
4111 return False;
4112 if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr))
4113 return False;
4114 if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr))
4115 return False;
4116 if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr))
4117 return False;
4118 if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr))
4119 return False;
4120 if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr))
4121 return False;
4122 if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
4123 return False;
4125 if(!prs_uint32("attributes", ps, depth, &il->attributes))
4126 return False;
4127 if(!prs_uint32("priority", ps, depth, &il->priority))
4128 return False;
4129 if(!prs_uint32("default_priority", ps, depth, &il->default_priority))
4130 return False;
4131 if(!prs_uint32("starttime", ps, depth, &il->starttime))
4132 return False;
4133 if(!prs_uint32("untiltime", ps, depth, &il->untiltime))
4134 return False;
4135 if(!prs_uint32("status", ps, depth, &il->status))
4136 return False;
4137 if(!prs_uint32("cjobs", ps, depth, &il->cjobs))
4138 return False;
4139 if(!prs_uint32("averageppm", ps, depth, &il->averageppm))
4140 return False;
4142 if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth))
4143 return False;
4144 if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth))
4145 return False;
4146 if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth))
4147 return False;
4148 if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth))
4149 return False;
4150 if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth))
4151 return False;
4152 if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
4153 return False;
4154 if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth))
4155 return False;
4156 if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth))
4157 return False;
4158 if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth))
4159 return False;
4160 if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth))
4161 return False;
4162 if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth))
4163 return False;
4165 return True;
4168 /*******************************************************************
4169 ********************************************************************/
4171 BOOL spool_io_printer_info_level(char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
4173 prs_debug(ps, depth, desc, "spool_io_printer_info_level");
4174 depth++;
4176 if(!prs_align(ps))
4177 return False;
4178 if(!prs_uint32("level", ps, depth, &il->level))
4179 return False;
4180 if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr))
4181 return False;
4183 /* if no struct inside just return */
4184 if (il->info_ptr==0) {
4185 if (UNMARSHALLING(ps)) {
4186 il->info_1=NULL;
4187 il->info_2=NULL;
4189 return True;
4192 switch (il->level) {
4194 * level 0 is used by setprinter when managing the queue
4195 * (hold, stop, start a queue)
4197 case 0:
4198 break;
4199 /* DOCUMENT ME!!! What is level 1 used for? */
4200 case 1:
4202 if (UNMARSHALLING(ps)) {
4203 if ((il->info_1=(SPOOL_PRINTER_INFO_LEVEL_1 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_1))) == NULL)
4204 return False;
4206 if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
4207 return False;
4208 break;
4211 * level 2 is used by addprinter
4212 * and by setprinter when updating printer's info
4214 case 2:
4215 if (UNMARSHALLING(ps)) {
4216 if ((il->info_2=(SPOOL_PRINTER_INFO_LEVEL_2 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_2))) == NULL)
4217 return False;
4219 if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
4220 return False;
4221 break;
4222 /* DOCUMENT ME!!! What is level 3 used for? */
4223 case 3:
4225 if (UNMARSHALLING(ps)) {
4226 if ((il->info_3=(SPOOL_PRINTER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_3))) == NULL)
4227 return False;
4229 if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
4230 return False;
4231 break;
4235 return True;
4238 /*******************************************************************
4239 ********************************************************************/
4241 BOOL spoolss_io_q_addprinterex(char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
4243 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
4244 depth++;
4246 if(!prs_align(ps))
4247 return False;
4248 if(!prs_uint32("", ps, depth, &q_u->server_name_ptr))
4249 return False;
4250 if(!smb_io_unistr2("", &q_u->server_name, q_u->server_name_ptr, ps, depth))
4251 return False;
4253 if(!prs_align(ps))
4254 return False;
4256 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4257 return False;
4259 if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
4260 return False;
4262 /* the 4 unknown are all 0 */
4265 * en fait ils sont pas inconnu
4266 * par recoupement avec rpcSetPrinter
4267 * c'est le devicemode
4268 * et le security descriptor.
4271 if(!prs_align(ps))
4272 return False;
4273 if(!prs_uint32("unk0", ps, depth, &q_u->unk0))
4274 return False;
4275 if(!prs_uint32("unk1", ps, depth, &q_u->unk1))
4276 return False;
4277 if(!prs_uint32("unk2", ps, depth, &q_u->unk2))
4278 return False;
4279 if(!prs_uint32("unk3", ps, depth, &q_u->unk3))
4280 return False;
4282 if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
4283 return False;
4284 if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
4285 return False;
4287 return True;
4290 /*******************************************************************
4291 ********************************************************************/
4293 BOOL spoolss_io_r_addprinterex(char *desc, SPOOL_R_ADDPRINTEREX *r_u,
4294 prs_struct *ps, int depth)
4296 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
4297 depth++;
4299 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
4300 return False;
4302 if(!prs_uint32("status", ps, depth, &r_u->status))
4303 return False;
4305 return True;
4308 /*******************************************************************
4309 ********************************************************************/
4311 BOOL spool_io_printer_driver_info_level_3(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
4312 prs_struct *ps, int depth)
4314 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il;
4316 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3");
4317 depth++;
4319 /* reading */
4320 if (UNMARSHALLING(ps)) {
4321 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4322 if(il == NULL)
4323 return False;
4324 *q_u=il;
4326 else {
4327 il=*q_u;
4330 if(!prs_align(ps))
4331 return False;
4333 if(!prs_uint32("cversion", ps, depth, &il->cversion))
4334 return False;
4335 if(!prs_uint32("name", ps, depth, &il->name_ptr))
4336 return False;
4337 if(!prs_uint32("environment", ps, depth, &il->environment_ptr))
4338 return False;
4339 if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr))
4340 return False;
4341 if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr))
4342 return False;
4343 if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr))
4344 return False;
4345 if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr))
4346 return False;
4347 if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr))
4348 return False;
4349 if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
4350 return False;
4351 if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize))
4352 return False;
4353 if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr))
4354 return False;
4356 if(!prs_align(ps))
4357 return False;
4359 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4360 return False;
4361 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4362 return False;
4363 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4364 return False;
4365 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4366 return False;
4367 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4368 return False;
4369 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4370 return False;
4371 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4372 return False;
4373 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4374 return False;
4376 if(!prs_align(ps))
4377 return False;
4379 if (il->dependentfiles_ptr)
4380 smb_io_buffer5("", &il->dependentfiles, ps, depth);
4382 return True;
4385 /*******************************************************************
4386 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4387 ********************************************************************/
4389 BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
4390 prs_struct *ps, int depth)
4392 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il;
4394 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6");
4395 depth++;
4397 /* reading */
4398 if (UNMARSHALLING(ps)) {
4399 il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6));
4400 if(il == NULL)
4401 return False;
4402 *q_u=il;
4404 else {
4405 il=*q_u;
4408 if(!prs_align(ps))
4409 return False;
4412 /* parse the main elements the packet */
4414 if(!prs_uint32("version", ps, depth, &il->version))
4415 return False;
4417 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4418 return False;
4420 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4421 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4422 * from W2K CDROM (which uses unidriver). JohnR 010205
4424 if (!il->name_ptr) {
4425 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4426 if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
4427 return False;
4430 if(!prs_uint32("environment_ptr", ps, depth, &il->environment_ptr))
4431 return False;
4432 if(!prs_uint32("driverpath_ptr", ps, depth, &il->driverpath_ptr))
4433 return False;
4434 if(!prs_uint32("datafile_ptr", ps, depth, &il->datafile_ptr))
4435 return False;
4436 if(!prs_uint32("configfile_ptr", ps, depth, &il->configfile_ptr))
4437 return False;
4438 if(!prs_uint32("helpfile_ptr", ps, depth, &il->helpfile_ptr))
4439 return False;
4440 if(!prs_uint32("monitorname_ptr", ps, depth, &il->monitorname_ptr))
4441 return False;
4442 if(!prs_uint32("defaultdatatype_ptr", ps, depth, &il->defaultdatatype_ptr))
4443 return False;
4444 if(!prs_uint32("dependentfiles_len", ps, depth, &il->dependentfiles_len))
4445 return False;
4446 if(!prs_uint32("dependentfiles_ptr", ps, depth, &il->dependentfiles_ptr))
4447 return False;
4448 if(!prs_uint32("previousnames_len", ps, depth, &il->previousnames_len))
4449 return False;
4450 if(!prs_uint32("previousnames_ptr", ps, depth, &il->previousnames_ptr))
4451 return False;
4452 if(!smb_io_time("driverdate", &il->driverdate, ps, depth))
4453 return False;
4454 if(!prs_uint32("dummy4", ps, depth, &il->dummy4))
4455 return False;
4456 if(!prs_uint64("driverversion", ps, depth, &il->driverversion))
4457 return False;
4458 if(!prs_uint32("mfgname_ptr", ps, depth, &il->mfgname_ptr))
4459 return False;
4460 if(!prs_uint32("oemurl_ptr", ps, depth, &il->oemurl_ptr))
4461 return False;
4462 if(!prs_uint32("hardwareid_ptr", ps, depth, &il->hardwareid_ptr))
4463 return False;
4464 if(!prs_uint32("provider_ptr", ps, depth, &il->provider_ptr))
4465 return False;
4467 /* parse the structures in the packet */
4469 if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
4470 return False;
4471 if(!prs_align(ps))
4472 return False;
4474 if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
4475 return False;
4476 if(!prs_align(ps))
4477 return False;
4479 if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
4480 return False;
4481 if(!prs_align(ps))
4482 return False;
4484 if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
4485 return False;
4486 if(!prs_align(ps))
4487 return False;
4489 if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
4490 return False;
4491 if(!prs_align(ps))
4492 return False;
4494 if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
4495 return False;
4496 if(!prs_align(ps))
4497 return False;
4499 if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
4500 return False;
4501 if(!prs_align(ps))
4502 return False;
4504 if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
4505 return False;
4506 if(!prs_align(ps))
4507 return False;
4508 if (il->dependentfiles_ptr) {
4509 if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth))
4510 return False;
4511 if(!prs_align(ps))
4512 return False;
4514 if (il->previousnames_ptr) {
4515 if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth))
4516 return False;
4517 if(!prs_align(ps))
4518 return False;
4520 if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth))
4521 return False;
4522 if(!prs_align(ps))
4523 return False;
4524 if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth))
4525 return False;
4526 if(!prs_align(ps))
4527 return False;
4528 if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth))
4529 return False;
4530 if(!prs_align(ps))
4531 return False;
4532 if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth))
4533 return False;
4535 return True;
4538 /*******************************************************************
4539 convert a buffer of UNICODE strings null terminated
4540 the buffer is terminated by a NULL
4542 convert to an dos codepage array (null terminated)
4544 dynamically allocate memory
4546 ********************************************************************/
4547 static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
4549 fstring f;
4550 int n = 0;
4551 char *src;
4553 if (buf5==NULL) return False;
4555 src = (char *)buf5->buffer;
4556 *ar = NULL;
4558 while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
4559 unistr_to_dos(f, src, sizeof(f)-1);
4560 src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
4561 *ar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2));
4562 fstrcpy((*ar)[n], f);
4563 n++;
4565 fstrcpy((*ar)[n], "");
4567 return True;
4570 /*******************************************************************
4571 read a UNICODE array with null terminated strings
4572 and null terminated array
4573 and size of array at beginning
4574 ********************************************************************/
4576 BOOL smb_io_unibuffer(char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
4578 if (buffer==NULL) return False;
4580 buffer->undoc=0;
4581 buffer->uni_str_len=buffer->uni_max_len;
4583 if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
4584 return False;
4586 if(!prs_unistr2(True, "buffer ", ps, depth, buffer))
4587 return False;
4589 return True;
4592 /*******************************************************************
4593 ********************************************************************/
4595 BOOL spool_io_printer_driver_info_level(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
4597 prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
4598 depth++;
4600 if(!prs_align(ps))
4601 return False;
4602 if(!prs_uint32("level", ps, depth, &il->level))
4603 return False;
4604 if(!prs_uint32("ptr", ps, depth, &il->ptr))
4605 return False;
4607 if (il->ptr==0)
4608 return True;
4610 switch (il->level) {
4611 case 3:
4612 if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth))
4613 return False;
4614 break;
4615 case 6:
4616 if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth))
4617 return False;
4618 break;
4619 default:
4620 return False;
4623 return True;
4626 /*******************************************************************
4627 init a SPOOL_Q_ADDPRINTERDRIVER struct
4628 ******************************************************************/
4630 BOOL make_spoolss_q_addprinterdriver(
4631 SPOOL_Q_ADDPRINTERDRIVER *q_u,
4632 const char* srv_name,
4633 uint32 level,
4634 PRINTER_DRIVER_CTR *info)
4636 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
4638 q_u->server_name_ptr = (srv_name!=NULL)?1:0;
4639 init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)+1);
4641 q_u->level = level;
4643 q_u->info.level = level;
4644 q_u->info.ptr = (info!=NULL)?1:0;
4645 switch (level)
4647 /* info level 3 is supported by Windows 95/98,
4648 WinNT and Win2k */
4649 case 3 :
4650 q_u->info.info_3=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3*)
4651 malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4652 memset (q_u->info.info_3, 0x0, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3));
4653 make_spool_driver_info_3(q_u->info.info_3, info->info3);
4654 break;
4656 /* info level 6 is supported by WinME and Win2k */
4657 case 6:
4658 /* WRITEME!! will add later --jerry */
4659 break;
4660 default:
4661 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown \
4662 info level [%d]\n", level));
4663 break;
4667 return True;
4670 BOOL make_spool_driver_info_3(
4671 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *spool_drv_info,
4672 DRIVER_INFO_3 *info3
4675 uint32 len = 0;
4676 uint16 *ptr = info3->dependentfiles;
4677 BOOL done = False;
4678 BOOL null_char = False;
4680 spool_drv_info->cversion = info3->version;
4681 spool_drv_info->name_ptr = (info3->name.buffer!=NULL)?1:0;
4682 spool_drv_info->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
4683 spool_drv_info->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
4684 spool_drv_info->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
4685 spool_drv_info->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
4686 spool_drv_info->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
4687 spool_drv_info->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
4688 spool_drv_info->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
4690 init_unistr2_from_unistr(&spool_drv_info->name, &info3->name);
4691 init_unistr2_from_unistr(&spool_drv_info->environment, &info3->architecture);
4692 init_unistr2_from_unistr(&spool_drv_info->driverpath, &info3->driverpath);
4693 init_unistr2_from_unistr(&spool_drv_info->datafile, &info3->datafile);
4694 init_unistr2_from_unistr(&spool_drv_info->configfile, &info3->configfile);
4695 init_unistr2_from_unistr(&spool_drv_info->helpfile, &info3->helpfile);
4696 init_unistr2_from_unistr(&spool_drv_info->monitorname, &info3->monitorname);
4697 init_unistr2_from_unistr(&spool_drv_info->defaultdatatype, &info3->defaultdatatype);
4699 while (!done)
4701 switch (*ptr)
4703 case 0:
4704 /* the null_char BOOL is used to help locate
4705 two '\0's back to back */
4706 if (null_char)
4707 done = True;
4708 else
4709 null_char = True;
4710 break;
4712 default:
4713 null_char = False;
4715 break;
4717 len++;
4718 ptr++;
4720 spool_drv_info->dependentfiles_ptr = (info3->dependentfiles!=NULL)?1:0;
4721 spool_drv_info->dependentfilessize = len;
4722 if(!make_spool_buffer5(&spool_drv_info->dependentfiles, len, info3->dependentfiles))
4723 return False;
4725 return True;
4728 /*******************************************************************
4729 make a BUFFER5 struct from a uint16*
4730 ******************************************************************/
4732 BOOL make_spool_buffer5(BUFFER5 *buf5, uint32 len, uint16 *src)
4735 buf5->buf_len = len;
4736 if((buf5->buffer=(uint16*)malloc(sizeof(uint16)*len)) == NULL)
4738 DEBUG(0,("make_spool_buffer5: Unable to talloc memory for buffer!\n"));
4739 return False;
4742 memcpy(buf5->buffer, src, sizeof(uint16)*len);
4744 return True;
4747 /*******************************************************************
4748 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
4749 ********************************************************************/
4751 BOOL spoolss_io_q_addprinterdriver(char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
4753 prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
4754 depth++;
4756 if(!prs_align(ps))
4757 return False;
4759 if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
4760 return False;
4761 if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
4762 return False;
4764 if(!prs_align(ps))
4765 return False;
4766 if(!prs_uint32("info_level", ps, depth, &q_u->level))
4767 return False;
4769 if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
4770 return False;
4772 return True;
4775 /*******************************************************************
4776 ********************************************************************/
4778 BOOL spoolss_io_r_addprinterdriver(char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
4780 prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
4781 depth++;
4783 if(!prs_uint32("status", ps, depth, &q_u->status))
4784 return False;
4786 return True;
4789 /*******************************************************************
4790 ********************************************************************/
4792 BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
4793 NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc)
4795 NT_PRINTER_DRIVER_INFO_LEVEL_3 *d;
4797 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
4799 if (*asc==NULL)
4801 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3));
4802 if(*asc == NULL)
4803 return False;
4804 ZERO_STRUCTP(*asc);
4807 d=*asc;
4809 d->cversion=uni->cversion;
4811 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
4812 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
4813 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
4814 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
4815 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
4816 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
4817 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
4818 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
4820 DEBUGADD(8,( "version: %d\n", d->cversion));
4821 DEBUGADD(8,( "name: %s\n", d->name));
4822 DEBUGADD(8,( "environment: %s\n", d->environment));
4823 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
4824 DEBUGADD(8,( "datafile: %s\n", d->datafile));
4825 DEBUGADD(8,( "configfile: %s\n", d->configfile));
4826 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
4827 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
4828 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
4830 uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles );
4832 return True;
4835 /*******************************************************************
4836 ********************************************************************/
4837 BOOL uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *uni,
4838 NT_PRINTER_DRIVER_INFO_LEVEL_6 **asc)
4840 NT_PRINTER_DRIVER_INFO_LEVEL_6 *d;
4842 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
4844 if (*asc==NULL)
4846 *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_6 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6));
4847 if(*asc == NULL)
4848 return False;
4849 ZERO_STRUCTP(*asc);
4852 d=*asc;
4854 d->version=uni->version;
4856 unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1);
4857 unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1);
4858 unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1);
4859 unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1);
4860 unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1);
4861 unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1);
4862 unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1);
4863 unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1);
4865 DEBUGADD(8,( "version: %d\n", d->version));
4866 DEBUGADD(8,( "name: %s\n", d->name));
4867 DEBUGADD(8,( "environment: %s\n", d->environment));
4868 DEBUGADD(8,( "driverpath: %s\n", d->driverpath));
4869 DEBUGADD(8,( "datafile: %s\n", d->datafile));
4870 DEBUGADD(8,( "configfile: %s\n", d->configfile));
4871 DEBUGADD(8,( "helpfile: %s\n", d->helpfile));
4872 DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
4873 DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
4875 uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles );
4876 uniarray_2_dosarray(&uni->previousnames, &d->previousnames );
4878 return True;
4881 BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
4882 NT_PRINTER_INFO_LEVEL_2 **asc)
4884 NT_PRINTER_INFO_LEVEL_2 *d;
4885 time_t time_unix;
4887 DEBUG(7,("Converting from UNICODE to ASCII\n"));
4888 time_unix=time(NULL);
4890 if (*asc==NULL) {
4891 DEBUGADD(8,("allocating memory\n"));
4893 *asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2));
4894 if(*asc == NULL)
4895 return False;
4896 ZERO_STRUCTP(*asc);
4898 /* we allocate memory iff called from
4899 * addprinter(ex) so we can do one time stuff here.
4901 (*asc)->setuptime=time_unix;
4904 DEBUGADD(8,("start converting\n"));
4906 d=*asc;
4908 d->attributes=uni->attributes;
4909 d->priority=uni->priority;
4910 d->default_priority=uni->default_priority;
4911 d->starttime=uni->starttime;
4912 d->untiltime=uni->untiltime;
4913 d->status=uni->status;
4914 d->cjobs=uni->cjobs;
4916 unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1);
4917 unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1);
4918 unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);
4919 unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1);
4920 unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1);
4921 unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1);
4922 unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1);
4923 unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1);
4924 unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1);
4925 unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype)-1);
4926 unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters)-1);
4928 return True;
4931 /*******************************************************************
4932 * init a structure.
4933 ********************************************************************/
4935 BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u,
4936 fstring servername, fstring env_name, uint32 level,
4937 NEW_BUFFER *buffer, uint32 offered)
4939 init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername);
4940 init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name);
4942 q_u->level=level;
4943 q_u->buffer=buffer;
4944 q_u->offered=offered;
4946 return True;
4949 /*******************************************************************
4950 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
4951 ********************************************************************/
4953 BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth)
4955 prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir");
4956 depth++;
4958 if(!prs_align(ps))
4959 return False;
4960 if(!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
4961 return False;
4962 if(!smb_io_unistr2("", &q_u->name, q_u->name_ptr, ps, depth))
4963 return False;
4965 if(!prs_align(ps))
4966 return False;
4968 if(!prs_uint32("", ps, depth, &q_u->environment_ptr))
4969 return False;
4970 if(!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
4971 return False;
4973 if(!prs_align(ps))
4974 return False;
4976 if(!prs_uint32("level", ps, depth, &q_u->level))
4977 return False;
4979 if(!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
4980 return False;
4982 if(!prs_align(ps))
4983 return False;
4985 if(!prs_uint32("offered", ps, depth, &q_u->offered))
4986 return False;
4988 return True;
4991 /*******************************************************************
4992 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
4993 ********************************************************************/
4995 BOOL spoolss_io_r_getprinterdriverdir(char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth)
4997 prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir");
4998 depth++;
5000 if (!prs_align(ps))
5001 return False;
5003 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
5004 return False;
5006 if (!prs_align(ps))
5007 return False;
5009 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5010 return False;
5012 if (!prs_uint32("status", ps, depth, &r_u->status))
5013 return False;
5015 return True;
5018 /*******************************************************************
5019 ********************************************************************/
5021 BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
5023 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
5024 depth++;
5026 if (!prs_align(ps))
5027 return False;
5029 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
5030 return False;
5032 if (!prs_align(ps))
5033 return False;
5035 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5036 return False;
5038 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5039 return False;
5041 if (!prs_uint32("status", ps, depth, &r_u->status))
5042 return False;
5044 return True;
5047 /*******************************************************************
5048 ********************************************************************/
5050 BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth)
5052 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
5053 depth++;
5055 if (!prs_align(ps))
5056 return False;
5058 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5059 return False;
5060 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5061 return False;
5063 if (!prs_align(ps))
5064 return False;
5066 if (!prs_uint32("", ps, depth, &q_u->environment_ptr))
5067 return False;
5068 if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
5069 return False;
5071 if (!prs_align(ps))
5072 return False;
5074 if (!prs_uint32("level", ps, depth, &q_u->level))
5075 return False;
5077 if(!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
5078 return False;
5080 if (!prs_align(ps))
5081 return False;
5083 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5084 return False;
5086 return True;
5089 /*******************************************************************
5090 ********************************************************************/
5092 BOOL spoolss_io_r_enumprintprocdatatypes(char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth)
5094 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes");
5095 depth++;
5097 if (!prs_align(ps))
5098 return False;
5100 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
5101 return False;
5103 if (!prs_align(ps))
5104 return False;
5106 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5107 return False;
5109 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5110 return False;
5112 if (!prs_uint32("status", ps, depth, &r_u->status))
5113 return False;
5115 return True;
5118 /*******************************************************************
5119 ********************************************************************/
5121 BOOL spoolss_io_q_enumprintprocdatatypes(char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth)
5123 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes");
5124 depth++;
5126 if (!prs_align(ps))
5127 return False;
5129 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5130 return False;
5131 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5132 return False;
5134 if (!prs_align(ps))
5135 return False;
5137 if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr))
5138 return False;
5139 if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth))
5140 return False;
5142 if (!prs_align(ps))
5143 return False;
5145 if (!prs_uint32("level", ps, depth, &q_u->level))
5146 return False;
5148 if(!new_spoolss_io_buffer("buffer", ps, depth, &q_u->buffer))
5149 return False;
5151 if (!prs_align(ps))
5152 return False;
5154 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5155 return False;
5157 return True;
5160 /*******************************************************************
5161 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5162 ********************************************************************/
5164 BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
5166 prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
5167 depth++;
5169 if (!prs_align(ps))
5170 return False;
5172 if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
5173 return False;
5174 if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
5175 return False;
5177 if (!prs_align(ps))
5178 return False;
5180 if (!prs_uint32("level", ps, depth, &q_u->level))
5181 return False;
5183 if(!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
5184 return False;
5186 if (!prs_align(ps))
5187 return False;
5189 if (!prs_uint32("offered", ps, depth, &q_u->offered))
5190 return False;
5192 return True;
5195 /*******************************************************************
5196 ********************************************************************/
5198 BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
5200 prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
5201 depth++;
5203 if (!prs_align(ps))
5204 return False;
5206 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
5207 return False;
5209 if (!prs_align(ps))
5210 return False;
5212 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5213 return False;
5215 if (!prs_uint32("returned", ps, depth, &r_u->returned))
5216 return False;
5218 if (!prs_uint32("status", ps, depth, &r_u->status))
5219 return False;
5221 return True;
5224 /*******************************************************************
5225 ********************************************************************/
5227 BOOL spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth)
5229 prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata");
5230 depth++;
5232 if(!prs_align(ps))
5233 return False;
5234 if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize))
5235 return False;
5237 if (MARSHALLING(ps)) {
5238 /* "Value is actually a UNICODE string. It's already little-endian so don't reverse. */
5239 if(!prs_uint8s(False, "value", ps, depth, (uint8 *)r_u->value, r_u->valuesize * 2))
5240 return False;
5241 } else {
5242 if(!prs_uint16s(False, "value", ps, depth, r_u->value, r_u->valuesize ))
5243 return False;
5246 if(!prs_align(ps))
5247 return False;
5249 if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize))
5250 return False;
5252 if(!prs_uint32("type", ps, depth, &r_u->type))
5253 return False;
5255 if(!prs_uint32("datasize", ps, depth, &r_u->datasize))
5256 return False;
5257 if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize))
5258 return False;
5259 if(!prs_align(ps))
5260 return False;
5262 if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize))
5263 return False;
5264 if(!prs_uint32("status", ps, depth, &r_u->status))
5265 return False;
5267 return True;
5270 /*******************************************************************
5271 ********************************************************************/
5273 BOOL spoolss_io_q_enumprinterdata(char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth)
5275 prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata");
5276 depth++;
5278 if(!prs_align(ps))
5279 return False;
5280 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5281 return False;
5282 if(!prs_uint32("index", ps, depth, &q_u->index))
5283 return False;
5284 if(!prs_uint32("valuesize", ps, depth, &q_u->valuesize))
5285 return False;
5286 if(!prs_uint32("datasize", ps, depth, &q_u->datasize))
5287 return False;
5289 return True;
5292 /*******************************************************************
5293 ********************************************************************/
5295 BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
5296 const POLICY_HND *hnd,
5297 uint32 idx, uint32 valuelen, uint32 datalen)
5299 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5300 q_u->index=idx;
5301 q_u->valuesize=valuelen;
5302 q_u->datasize=datalen;
5304 return True;
5307 /*******************************************************************
5308 ********************************************************************/
5310 BOOL spoolss_io_q_setprinterdata(char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
5312 prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
5313 depth++;
5315 if(!prs_align(ps))
5316 return False;
5317 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5318 return False;
5319 if(!smb_io_unistr2("", &q_u->value, True, ps, depth))
5320 return False;
5322 if(!prs_align(ps))
5323 return False;
5325 if(!prs_uint32("type", ps, depth, &q_u->type))
5326 return False;
5328 if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
5329 return False;
5331 switch (q_u->type)
5333 case 0x1:
5334 case 0x3:
5335 case 0x4:
5336 case 0x7:
5337 if (UNMARSHALLING(ps))
5338 q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8));
5339 if(q_u->data == NULL)
5340 return False;
5341 if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
5342 return False;
5343 if(!prs_align(ps))
5344 return False;
5345 break;
5348 if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
5349 return False;
5351 return True;
5354 /*******************************************************************
5355 ********************************************************************/
5357 BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
5359 prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
5360 depth++;
5362 if(!prs_align(ps))
5363 return False;
5364 if(!prs_uint32("status", ps, depth, &r_u->status))
5365 return False;
5367 return True;
5370 /*******************************************************************
5371 ********************************************************************/
5373 BOOL convert_specific_param(NT_PRINTER_PARAM **param, const UNISTR2 *value,
5374 uint32 type, const uint8 *data, uint32 len)
5376 DEBUG(5,("converting a specific param struct\n"));
5378 if (*param == NULL)
5380 *param=(NT_PRINTER_PARAM *)malloc(sizeof(NT_PRINTER_PARAM));
5381 if(*param == NULL)
5382 return False;
5383 memset((char *)*param, '\0', sizeof(NT_PRINTER_PARAM));
5384 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5386 unistr2_to_ascii((*param)->value, value, sizeof((*param)->value)-1);
5387 (*param)->type = type;
5389 /* le champ data n'est pas NULL termine */
5390 /* on stocke donc la longueur */
5392 (*param)->data_len=len;
5394 if (len) {
5395 (*param)->data=(uint8 *)malloc(len * sizeof(uint8));
5396 if((*param)->data == NULL)
5397 return False;
5398 memcpy((*param)->data, data, len);
5401 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param)->value, (*param)->data_len));
5402 dump_data(10, (char *)(*param)->data, (*param)->data_len);
5404 return True;
5407 /*******************************************************************
5408 ********************************************************************/
5410 static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth)
5412 prs_debug(ps, depth, desc, "spoolss_io_addform");
5413 depth++;
5414 if(!prs_align(ps))
5415 return False;
5417 if (ptr!=0)
5419 if(!prs_uint32("flags", ps, depth, &f->flags))
5420 return False;
5421 if(!prs_uint32("name_ptr", ps, depth, &f->name_ptr))
5422 return False;
5423 if(!prs_uint32("size_x", ps, depth, &f->size_x))
5424 return False;
5425 if(!prs_uint32("size_y", ps, depth, &f->size_y))
5426 return False;
5427 if(!prs_uint32("left", ps, depth, &f->left))
5428 return False;
5429 if(!prs_uint32("top", ps, depth, &f->top))
5430 return False;
5431 if(!prs_uint32("right", ps, depth, &f->right))
5432 return False;
5433 if(!prs_uint32("bottom", ps, depth, &f->bottom))
5434 return False;
5436 if(!smb_io_unistr2("", &f->name, f->name_ptr, ps, depth))
5437 return False;
5440 return True;
5443 /*******************************************************************
5444 ********************************************************************/
5446 BOOL spoolss_io_q_deleteform(char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth)
5448 prs_debug(ps, depth, desc, "spoolss_io_q_deleteform");
5449 depth++;
5451 if(!prs_align(ps))
5452 return False;
5453 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5454 return False;
5455 if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth))
5456 return False;
5458 return True;
5461 /*******************************************************************
5462 ********************************************************************/
5464 BOOL spoolss_io_r_deleteform(char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth)
5466 prs_debug(ps, depth, desc, "spoolss_io_r_deleteform");
5467 depth++;
5469 if(!prs_align(ps))
5470 return False;
5471 if(!prs_uint32("status", ps, depth, &r_u->status))
5472 return False;
5474 return True;
5477 /*******************************************************************
5478 ********************************************************************/
5480 BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth)
5482 uint32 useless_ptr=0;
5483 prs_debug(ps, depth, desc, "spoolss_io_q_addform");
5484 depth++;
5486 if(!prs_align(ps))
5487 return False;
5488 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5489 return False;
5490 if(!prs_uint32("level", ps, depth, &q_u->level))
5491 return False;
5492 if(!prs_uint32("level2", ps, depth, &q_u->level2))
5493 return False;
5495 if (q_u->level==1)
5497 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
5498 return False;
5499 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
5500 return False;
5503 return True;
5506 /*******************************************************************
5507 ********************************************************************/
5509 BOOL spoolss_io_r_addform(char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth)
5511 prs_debug(ps, depth, desc, "spoolss_io_r_addform");
5512 depth++;
5514 if(!prs_align(ps))
5515 return False;
5516 if(!prs_uint32("status", ps, depth, &r_u->status))
5517 return False;
5519 return True;
5522 /*******************************************************************
5523 ********************************************************************/
5525 BOOL spoolss_io_q_setform(char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth)
5527 uint32 useless_ptr=0;
5528 prs_debug(ps, depth, desc, "spoolss_io_q_setform");
5529 depth++;
5531 if(!prs_align(ps))
5532 return False;
5533 if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
5534 return False;
5535 if(!smb_io_unistr2("", &q_u->name, True, ps, depth))
5536 return False;
5538 if(!prs_align(ps))
5539 return False;
5541 if(!prs_uint32("level", ps, depth, &q_u->level))
5542 return False;
5543 if(!prs_uint32("level2", ps, depth, &q_u->level2))
5544 return False;
5546 if (q_u->level==1)
5548 if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr))
5549 return False;
5550 if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth))
5551 return False;
5554 return True;
5557 /*******************************************************************
5558 ********************************************************************/
5560 BOOL spoolss_io_r_setform(char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth)
5562 prs_debug(ps, depth, desc, "spoolss_io_r_setform");
5563 depth++;
5565 if(!prs_align(ps))
5566 return False;
5567 if(!prs_uint32("status", ps, depth, &r_u->status))
5568 return False;
5570 return True;
5573 /*******************************************************************
5574 Parse a SPOOL_R_GETJOB structure.
5575 ********************************************************************/
5577 BOOL spoolss_io_r_getjob(char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
5579 prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
5580 depth++;
5582 if (!prs_align(ps))
5583 return False;
5585 if (!new_spoolss_io_buffer("", ps, depth, &r_u->buffer))
5586 return False;
5588 if (!prs_align(ps))
5589 return False;
5591 if (!prs_uint32("needed", ps, depth, &r_u->needed))
5592 return False;
5594 if (!prs_uint32("status", ps, depth, &r_u->status))
5595 return False;
5597 return True;
5600 /*******************************************************************
5601 Parse a SPOOL_Q_GETJOB structure.
5602 ********************************************************************/
5604 BOOL spoolss_io_q_getjob(char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
5606 prs_debug(ps, depth, desc, "");
5607 depth++;
5609 if(!prs_align(ps))
5610 return False;
5612 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5613 return False;
5614 if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
5615 return False;
5616 if(!prs_uint32("level", ps, depth, &q_u->level))
5617 return False;
5619 if(!new_spoolss_io_buffer("", ps, depth, &q_u->buffer))
5620 return False;
5622 if(!prs_align(ps))
5623 return False;
5625 if(!prs_uint32("offered", ps, depth, &q_u->offered))
5626 return False;
5628 return True;
5631 void free_devmode(DEVICEMODE *devmode)
5633 if (devmode!=NULL) {
5634 safe_free(devmode->private);
5635 safe_free(devmode);
5639 void free_printer_info_1(PRINTER_INFO_1 *printer)
5641 safe_free(printer);
5644 void free_printer_info_2(PRINTER_INFO_2 *printer)
5646 if (printer!=NULL) {
5647 free_devmode(printer->devmode);
5648 printer->devmode = NULL;
5649 safe_free(printer);
5653 void free_printer_info_3(PRINTER_INFO_3 *printer)
5655 if (printer!=NULL) {
5656 safe_free(printer);
5660 void free_job_info_2(JOB_INFO_2 *job)
5662 if (job!=NULL)
5663 free_devmode(job->devmode);
5666 /*******************************************************************
5667 * init a structure.
5668 ********************************************************************/
5670 BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
5671 const fstring string, uint32 printer, uint32 type)
5673 if (q_u == NULL)
5674 return False;
5676 init_unistr2(&q_u->string, string, strlen(string)+1);
5678 q_u->printer=printer;
5679 q_u->type=type;
5681 q_u->unknown0=0x0;
5682 q_u->unknown1=0x0;
5684 return True;
5687 /*******************************************************************
5688 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
5689 ********************************************************************/
5691 BOOL spoolss_io_q_replyopenprinter(char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth)
5693 prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter");
5694 depth++;
5696 if(!prs_align(ps))
5697 return False;
5699 if(!smb_io_unistr2("", &q_u->string, True, ps, depth))
5700 return False;
5702 if(!prs_align(ps))
5703 return False;
5705 if(!prs_uint32("printer", ps, depth, &q_u->printer))
5706 return False;
5707 if(!prs_uint32("type", ps, depth, &q_u->type))
5708 return False;
5710 if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
5711 return False;
5712 if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
5713 return False;
5715 return True;
5718 /*******************************************************************
5719 Parse a SPOOL_R_REPLYOPENPRINTER structure.
5720 ********************************************************************/
5722 BOOL spoolss_io_r_replyopenprinter(char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth)
5724 prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter");
5725 depth++;
5727 if (!prs_align(ps))
5728 return False;
5730 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
5731 return False;
5733 if (!prs_uint32("status", ps, depth, &r_u->status))
5734 return False;
5736 return True;
5739 /*******************************************************************
5740 * init a structure.
5741 ********************************************************************/
5743 BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd)
5745 if (q_u == NULL)
5746 return False;
5748 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5750 return True;
5753 /*******************************************************************
5754 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
5755 ********************************************************************/
5757 BOOL spoolss_io_q_replycloseprinter(char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth)
5759 prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
5760 depth++;
5762 if(!prs_align(ps))
5763 return False;
5765 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5766 return False;
5768 return True;
5771 /*******************************************************************
5772 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
5773 ********************************************************************/
5775 BOOL spoolss_io_r_replycloseprinter(char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth)
5777 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
5778 depth++;
5780 if (!prs_align(ps))
5781 return False;
5783 if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
5784 return False;
5786 if (!prs_uint32("status", ps, depth, &r_u->status))
5787 return False;
5789 return True;
5792 /*******************************************************************
5793 * init a structure.
5794 ********************************************************************/
5796 BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
5797 uint32 change_low, uint32 change_high)
5799 if (q_u == NULL)
5800 return False;
5802 memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
5804 q_u->change_low=change_low;
5805 q_u->change_high=change_high;
5807 q_u->unknown0=0x0;
5808 q_u->unknown1=0x0;
5810 q_u->info_ptr=1;
5812 q_u->info.version=2;
5813 q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED;
5814 q_u->info.count=0;
5816 return True;
5819 /*******************************************************************
5820 Parse a SPOOL_Q_REPLY_RRPCN structure.
5821 ********************************************************************/
5823 BOOL spoolss_io_q_reply_rrpcn(char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
5825 prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
5826 depth++;
5828 if(!prs_align(ps))
5829 return False;
5831 if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
5832 return False;
5834 if (!prs_uint32("change_low", ps, depth, &q_u->change_low))
5835 return False;
5837 if (!prs_uint32("change_high", ps, depth, &q_u->change_high))
5838 return False;
5840 if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0))
5841 return False;
5843 if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1))
5844 return False;
5846 if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr))
5847 return False;
5849 if(q_u->info_ptr!=0)
5850 if(!smb_io_notify_info(desc, &q_u->info, ps, depth))
5851 return False;
5853 return True;
5856 /*******************************************************************
5857 Parse a SPOOL_R_REPLY_RRPCN structure.
5858 ********************************************************************/
5860 BOOL spoolss_io_r_reply_rrpcn(char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth)
5862 prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter");
5863 depth++;
5865 if (!prs_align(ps))
5866 return False;
5868 if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0))
5869 return False;
5871 if (!prs_uint32("status", ps, depth, &r_u->status))
5872 return False;
5874 return True;