2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Jean François Micouleau 1998-2000,
7 * Copyright (C) Gerald Carter 2000-2002,
8 * Copyright (C) Tim Potter 2001-2002.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /*******************************************************************
28 return the length of a UNISTR string.
29 ********************************************************************/
31 static uint32
str_len_uni(UNISTR
*source
)
38 while (source
->buffer
[i
])
44 /*******************************************************************
45 This should be moved in a more generic lib.
46 ********************************************************************/
48 static BOOL
spoolss_io_system_time(const char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
50 if(!prs_uint16("year", ps
, depth
, &systime
->year
))
52 if(!prs_uint16("month", ps
, depth
, &systime
->month
))
54 if(!prs_uint16("dayofweek", ps
, depth
, &systime
->dayofweek
))
56 if(!prs_uint16("day", ps
, depth
, &systime
->day
))
58 if(!prs_uint16("hour", ps
, depth
, &systime
->hour
))
60 if(!prs_uint16("minute", ps
, depth
, &systime
->minute
))
62 if(!prs_uint16("second", ps
, depth
, &systime
->second
))
64 if(!prs_uint16("milliseconds", ps
, depth
, &systime
->milliseconds
))
70 /*******************************************************************
71 ********************************************************************/
73 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
75 systime
->year
=unixtime
->tm_year
+1900;
76 systime
->month
=unixtime
->tm_mon
+1;
77 systime
->dayofweek
=unixtime
->tm_wday
;
78 systime
->day
=unixtime
->tm_mday
;
79 systime
->hour
=unixtime
->tm_hour
;
80 systime
->minute
=unixtime
->tm_min
;
81 systime
->second
=unixtime
->tm_sec
;
82 systime
->milliseconds
=0;
87 /*******************************************************************
88 reads or writes an DOC_INFO structure.
89 ********************************************************************/
91 static BOOL
smb_io_doc_info_1(const char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
93 if (info_1
== NULL
) return False
;
95 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
101 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
103 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
105 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
108 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
110 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
112 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
118 /*******************************************************************
119 reads or writes an DOC_INFO structure.
120 ********************************************************************/
122 static BOOL
smb_io_doc_info(const char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
124 uint32 useless_ptr
=0;
126 if (info
== NULL
) return False
;
128 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
134 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
137 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
140 switch (info
->switch_value
)
143 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
148 this is just a placeholder
150 MSDN July 1998 says doc_info_2 is only on
151 Windows 95, and as Win95 doesn't do RPC to print
152 this case is nearly impossible
154 Maybe one day with Windows for dishwasher 2037 ...
157 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
160 DEBUG(0,("Something is obviously wrong somewhere !\n"));
167 /*******************************************************************
168 reads or writes an DOC_INFO_CONTAINER structure.
169 ********************************************************************/
171 static BOOL
smb_io_doc_info_container(const char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
173 if (cont
== NULL
) return False
;
175 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
181 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
184 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
190 /*******************************************************************
191 reads or writes an NOTIFY OPTION TYPE structure.
192 ********************************************************************/
194 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
195 structure. The _TYPE structure is really the deferred referrants (i.e
196 the notify fields array) of the _TYPE structure. -tpot */
198 static BOOL
smb_io_notify_option_type(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
200 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
206 if(!prs_uint16("type", ps
, depth
, &type
->type
))
208 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
210 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
212 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
214 if(!prs_uint32("count", ps
, depth
, &type
->count
))
216 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
222 /*******************************************************************
223 reads or writes an NOTIFY OPTION TYPE DATA.
224 ********************************************************************/
226 static BOOL
smb_io_notify_option_type_data(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
230 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
233 /* if there are no fields just return */
234 if (type
->fields_ptr
==0)
240 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
243 if (type
->count2
!= type
->count
)
244 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
246 /* parse the option type data */
247 for(i
=0;i
<type
->count2
;i
++)
248 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
253 /*******************************************************************
254 reads or writes an NOTIFY OPTION structure.
255 ********************************************************************/
257 static BOOL
smb_io_notify_option_type_ctr(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
261 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
264 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
268 if (UNMARSHALLING(ps
))
269 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)prs_alloc_mem(ps
,ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
272 /* the option type struct */
273 for(i
=0;i
<ctr
->count
;i
++)
274 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
277 /* the type associated with the option type struct */
278 for(i
=0;i
<ctr
->count
;i
++)
279 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
285 /*******************************************************************
286 reads or writes an NOTIFY OPTION structure.
287 ********************************************************************/
289 static BOOL
smb_io_notify_option(const char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
291 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
294 if(!prs_uint32("version", ps
, depth
, &option
->version
))
296 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
298 if(!prs_uint32("count", ps
, depth
, &option
->count
))
300 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
303 /* marshalling or unmarshalling, that would work */
304 if (option
->option_type_ptr
!=0) {
305 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
309 option
->ctr
.type
=NULL
;
316 /*******************************************************************
317 reads or writes an NOTIFY INFO DATA structure.
318 ********************************************************************/
320 static BOOL
smb_io_notify_info_data(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
322 uint32 useless_ptr
=0xADDE0FF0;
324 uint32 how_many_words
;
328 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
331 how_many_words
=data
->size
;
332 if (how_many_words
==POINTER
) {
333 how_many_words
=TWO_VALUE
;
336 isvalue
=data
->enc_type
;
340 if(!prs_uint16("type", ps
, depth
, &data
->type
))
342 if(!prs_uint16("field", ps
, depth
, &data
->field
))
346 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
348 if(!prs_uint32("id", ps
, depth
, &data
->id
))
350 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
357 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
359 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
364 /* length in ascii including \0 */
365 x
=2*(data
->notify_data
.data
.length
+1);
366 if(!prs_uint32("string length", ps
, depth
, &x
))
368 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
376 /*******************************************************************
377 reads or writes an NOTIFY INFO DATA structure.
378 ********************************************************************/
380 BOOL
smb_io_notify_info_data_strings(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
381 prs_struct
*ps
, int depth
)
386 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
392 isvalue
=data
->enc_type
;
394 if (isvalue
==False
) {
395 /* length of string in unicode include \0 */
396 x
=data
->notify_data
.data
.length
+1;
397 if(!prs_uint32("string length", ps
, depth
, &x
))
399 if (MARSHALLING(ps
)) {
400 /* These are already in little endian format. Don't byte swap. */
403 /* No memory allocated for this string
404 therefore following the data.string
405 pointer is a bad idea. Use a pointer to
406 the uint32 length union member to
407 provide a source for a unicode NULL */
409 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
412 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
417 /* Tallocate memory for string */
419 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
420 if (!data
->notify_data
.data
.string
)
423 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
428 /* Win2k does not seem to put this parse align here */
436 /*******************************************************************
437 reads or writes an NOTIFY INFO structure.
438 ********************************************************************/
440 static BOOL
smb_io_notify_info(const char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
444 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
450 if(!prs_uint32("count", ps
, depth
, &info
->count
))
452 if(!prs_uint32("version", ps
, depth
, &info
->version
))
454 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
456 if(!prs_uint32("count", ps
, depth
, &info
->count
))
459 for (i
=0;i
<info
->count
;i
++) {
460 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
464 /* now do the strings at the end of the stream */
465 for (i
=0;i
<info
->count
;i
++) {
466 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
473 /*******************************************************************
474 ********************************************************************/
476 static BOOL
spool_io_user_level_1(const char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
478 prs_debug(ps
, depth
, desc
, "");
482 if (UNMARSHALLING(ps
))
487 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
489 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
491 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
493 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
495 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
497 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
499 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
502 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
506 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
512 /*******************************************************************
513 ********************************************************************/
515 static BOOL
spool_io_user_level(const char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
520 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
525 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
527 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
530 switch (q_u
->level
) {
532 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
542 /*******************************************************************
543 * read or write a DEVICEMODE struct.
544 * on reading allocate memory for the private member
545 ********************************************************************/
547 #define DM_NUM_OPTIONAL_FIELDS 8
549 BOOL
spoolss_io_devmode(const char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
551 uint32 available_space
; /* size of the device mode left to parse */
552 /* only important on unmarshalling */
555 struct optional_fields
{
558 } opt_fields
[DM_NUM_OPTIONAL_FIELDS
] = {
559 { "icmmethod", NULL
},
560 { "icmintent", NULL
},
561 { "mediatype", NULL
},
562 { "dithertype", NULL
},
563 { "reserved1", NULL
},
564 { "reserved2", NULL
},
565 { "panningwidth", NULL
},
566 { "panningheight", NULL
}
569 /* assign at run time to keep non-gcc vompilers happy */
571 opt_fields
[0].field
= &devmode
->icmmethod
;
572 opt_fields
[1].field
= &devmode
->icmintent
;
573 opt_fields
[2].field
= &devmode
->mediatype
;
574 opt_fields
[3].field
= &devmode
->dithertype
;
575 opt_fields
[4].field
= &devmode
->reserved1
;
576 opt_fields
[5].field
= &devmode
->reserved2
;
577 opt_fields
[6].field
= &devmode
->panningwidth
;
578 opt_fields
[7].field
= &devmode
->panningheight
;
581 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
584 if (UNMARSHALLING(ps
)) {
585 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
586 if (devmode
->devicename
.buffer
== NULL
)
590 if (!prs_uint16uni(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, MAXDEVICENAME
))
593 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
596 /* Sanity Check - look for unknown specversions, but don't fail if we see one.
597 Let the size determine that */
599 switch (devmode
->specversion
) {
606 DEBUG(0,("spoolss_io_devmode: Unknown specversion in devicemode [0x%x]\n",
607 devmode
->specversion
));
608 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
613 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
615 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
617 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
619 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
621 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
623 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
625 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
627 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
629 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
631 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
633 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
635 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
637 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
639 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
641 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
643 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
645 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
648 if (UNMARSHALLING(ps
)) {
649 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
650 if (devmode
->formname
.buffer
== NULL
)
654 if (!prs_uint16uni(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
656 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
658 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
660 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
662 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
664 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
666 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
669 * every device mode I've ever seen on the wire at least has up
670 * to the displayfrequency field. --jerry (05-09-2002)
673 /* add uint32's + uint16's + two UNICODE strings */
675 available_space
= devmode
->size
- (sizeof(uint32
)*6 + sizeof(uint16
)*18 + sizeof(uint16
)*64);
677 /* Sanity check - we only have uint32's left tp parse */
679 if ( available_space
&& ((available_space
% sizeof(uint32
)) != 0) ) {
680 DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n",
681 available_space
, devmode
->size
));
682 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
687 * Conditional parsing. Assume that the DeviceMode has been
688 * zero'd by the caller.
691 while ((available_space
> 0) && (i
< DM_NUM_OPTIONAL_FIELDS
))
693 DEBUG(10, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space
));
694 if (!prs_uint32(opt_fields
[i
].name
, ps
, depth
, opt_fields
[i
].field
))
696 available_space
-= sizeof(uint32
);
700 /* Sanity Check - we should no available space at this point unless
701 MS changes the device mode structure */
703 if (available_space
) {
704 DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n"));
705 DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n",
706 available_space
, devmode
->size
));
707 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
712 if (devmode
->driverextra
!=0) {
713 if (UNMARSHALLING(ps
)) {
714 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
715 if(devmode
->private == NULL
)
717 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
720 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
721 if (!prs_uint8s(False
, "private", ps
, depth
,
722 devmode
->private, devmode
->driverextra
))
729 /*******************************************************************
730 Read or write a DEVICEMODE container
731 ********************************************************************/
733 static BOOL
spoolss_io_devmode_cont(const char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
738 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
744 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
747 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
750 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
751 if (UNMARSHALLING(ps
))
752 /* if while reading there is no DEVMODE ... */
757 /* so we have a DEVICEMODE to follow */
758 if (UNMARSHALLING(ps
)) {
759 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
760 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
761 if(dm_c
->devmode
== NULL
)
765 /* this is bad code, shouldn't be there */
766 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
769 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
775 /*******************************************************************
776 ********************************************************************/
778 static BOOL
spoolss_io_printer_default(const char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
783 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
786 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
789 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
795 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
801 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
807 /*******************************************************************
809 ********************************************************************/
811 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
812 const fstring printername
,
813 const fstring datatype
,
814 uint32 access_required
,
815 const fstring clientname
,
816 const fstring user_name
)
818 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
819 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
820 init_unistr2(&q_u
->printername
, printername
, strlen(printername
)+1);
822 q_u
->printer_default
.datatype_ptr
= 0;
824 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
825 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
827 q_u
->printer_default
.devmode_cont
.size
=0;
828 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
829 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
830 q_u
->printer_default
.access_required
=access_required
;
832 q_u
->user_ctr
.level
=1;
834 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
835 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
836 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
837 q_u
->user_ctr
.user1
.build
=1381;
838 q_u
->user_ctr
.user1
.major
=2;
839 q_u
->user_ctr
.user1
.minor
=0;
840 q_u
->user_ctr
.user1
.processor
=0;
841 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
842 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
847 /*******************************************************************
849 ********************************************************************/
851 BOOL
make_spoolss_q_addprinterex(
853 SPOOL_Q_ADDPRINTEREX
*q_u
,
854 const char *srv_name
,
855 const char* clientname
,
856 const char* user_name
,
858 PRINTER_INFO_CTR
*ctr
)
860 DEBUG(5,("make_spoolss_q_addprinterex\n"));
862 if (!ctr
) return False
;
866 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
867 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
));
871 q_u
->info
.level
= level
;
872 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
875 /* init q_u->info.info2 from *info */
876 if (!make_spoolss_printer_info_2(mem_ctx
, &q_u
->info
.info_2
, ctr
->printers_2
)) {
877 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
887 q_u
->user_ctr
.level
=1;
889 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
890 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
891 q_u
->user_ctr
.user1
.build
=1381;
892 q_u
->user_ctr
.user1
.major
=2;
893 q_u
->user_ctr
.user1
.minor
=0;
894 q_u
->user_ctr
.user1
.processor
=0;
895 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
896 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
897 q_u
->user_ctr
.user1
.size
=q_u
->user_ctr
.user1
.user_name
.uni_str_len
+
898 q_u
->user_ctr
.user1
.client_name
.uni_str_len
+ 2;
903 /*******************************************************************
904 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
905 *******************************************************************/
907 BOOL
make_spoolss_printer_info_2(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
908 PRINTER_INFO_2
*info
)
911 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
913 /* allocate the necessary memory */
914 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_2
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_2
)))) {
915 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
919 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
920 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
921 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
922 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
923 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
924 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
925 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
926 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
927 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
928 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
929 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
930 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
931 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
932 inf
->attributes
= info
->attributes
;
933 inf
->priority
= info
->priority
;
934 inf
->default_priority
= info
->defaultpriority
;
935 inf
->starttime
= info
->starttime
;
936 inf
->untiltime
= info
->untiltime
;
937 inf
->cjobs
= info
->cjobs
;
938 inf
->averageppm
= info
->averageppm
;
939 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
940 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
941 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
942 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
943 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
944 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
945 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
946 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
947 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
948 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
949 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
950 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
958 /*******************************************************************
960 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
961 ********************************************************************/
963 BOOL
spoolss_io_q_open_printer(const char *desc
, SPOOL_Q_OPEN_PRINTER
*q_u
, prs_struct
*ps
, int depth
)
968 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer");
974 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
976 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
982 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
988 /*******************************************************************
990 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
991 * called from spoolss_open_printer_ex (cli_spoolss.c)
992 ********************************************************************/
994 BOOL
spoolss_io_r_open_printer(const char *desc
, SPOOL_R_OPEN_PRINTER
*r_u
, prs_struct
*ps
, int depth
)
996 if (r_u
== NULL
) return False
;
998 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer");
1004 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1007 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1014 /*******************************************************************
1016 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1017 ********************************************************************/
1019 BOOL
spoolss_io_q_open_printer_ex(const char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
1024 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
1030 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
1032 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
1038 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1041 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
1043 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
1049 /*******************************************************************
1050 * write a structure.
1051 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1052 * called from spoolss_open_printer_ex (cli_spoolss.c)
1053 ********************************************************************/
1055 BOOL
spoolss_io_r_open_printer_ex(const char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
1057 if (r_u
== NULL
) return False
;
1059 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
1065 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1068 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1074 /*******************************************************************
1076 ********************************************************************/
1077 BOOL
make_spoolss_q_deleteprinterdriver(
1078 TALLOC_CTX
*mem_ctx
,
1079 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
1085 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1087 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1089 /* these must be NULL terminated or else NT4 will
1090 complain about invalid parameters --jerry */
1091 init_unistr2(&q_u
->server
, server
, strlen(server
)+1);
1092 init_unistr2(&q_u
->arch
, arch
, strlen(arch
)+1);
1093 init_unistr2(&q_u
->driver
, driver
, strlen(driver
)+1);
1100 /*******************************************************************
1102 ********************************************************************/
1104 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
1105 const POLICY_HND
*handle
,
1106 UNISTR2
*valuename
, uint32 size
)
1108 if (q_u
== NULL
) return False
;
1110 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1112 q_u
->handle
= *handle
;
1113 copy_unistr2(&q_u
->valuename
, valuename
);
1119 /*******************************************************************
1121 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1122 ********************************************************************/
1124 BOOL
spoolss_io_q_getprinterdata(const char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1129 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1134 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1138 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1142 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1148 /*******************************************************************
1150 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1151 ********************************************************************/
1153 BOOL
spoolss_io_q_deleteprinterdata(const char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1158 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1163 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1167 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1173 /*******************************************************************
1174 * write a structure.
1175 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1176 ********************************************************************/
1178 BOOL
spoolss_io_r_deleteprinterdata(const char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1180 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1182 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1188 /*******************************************************************
1189 * write a structure.
1190 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1191 ********************************************************************/
1193 BOOL
spoolss_io_r_getprinterdata(const char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1198 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1203 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1205 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1208 if (UNMARSHALLING(ps
) && r_u
->size
) {
1209 r_u
->data
= prs_alloc_mem(ps
, r_u
->size
);
1214 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
1220 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1222 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1228 /*******************************************************************
1230 ********************************************************************/
1232 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1234 if (q_u
== NULL
) return False
;
1236 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1238 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1243 /*******************************************************************
1245 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1246 * called from spoolss_abortprinter (cli_spoolss.c)
1247 ********************************************************************/
1249 BOOL
spoolss_io_q_abortprinter(const char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1251 if (q_u
== NULL
) return False
;
1253 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1259 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1265 /*******************************************************************
1266 * write a structure.
1267 * called from spoolss_r_abortprinter (srv_spoolss.c)
1268 ********************************************************************/
1270 BOOL
spoolss_io_r_abortprinter(const char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1272 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1274 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1280 /*******************************************************************
1282 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1283 * called from spoolss_deleteprinter (cli_spoolss.c)
1284 ********************************************************************/
1286 BOOL
spoolss_io_q_deleteprinter(const char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1288 if (q_u
== NULL
) return False
;
1290 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1296 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1302 /*******************************************************************
1303 * write a structure.
1304 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1305 * called from spoolss_deleteprinter (cli_spoolss.c)
1306 ********************************************************************/
1308 BOOL
spoolss_io_r_deleteprinter(const char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1310 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1316 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1318 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1325 /*******************************************************************
1327 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1328 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1329 ********************************************************************/
1331 BOOL
spoolss_io_q_deleteprinterdriver(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1333 if (q_u
== NULL
) return False
;
1335 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1341 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1343 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1345 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1347 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1355 /*******************************************************************
1356 * write a structure.
1357 ********************************************************************/
1358 BOOL
spoolss_io_r_deleteprinterdriver(const char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1360 if (r_u
== NULL
) return False
;
1362 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1368 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1376 /*******************************************************************
1378 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1379 * called from spoolss_closeprinter (cli_spoolss.c)
1380 ********************************************************************/
1382 BOOL
spoolss_io_q_closeprinter(const char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1384 if (q_u
== NULL
) return False
;
1386 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1392 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1398 /*******************************************************************
1399 * write a structure.
1400 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1401 * called from spoolss_closeprinter (cli_spoolss.c)
1402 ********************************************************************/
1404 BOOL
spoolss_io_r_closeprinter(const char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1406 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1412 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1414 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1420 /*******************************************************************
1422 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1423 ********************************************************************/
1425 BOOL
spoolss_io_q_startdocprinter(const char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1427 if (q_u
== NULL
) return False
;
1429 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1435 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1438 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1444 /*******************************************************************
1445 * write a structure.
1446 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1447 ********************************************************************/
1449 BOOL
spoolss_io_r_startdocprinter(const char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1451 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1453 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1455 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1461 /*******************************************************************
1463 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1464 ********************************************************************/
1466 BOOL
spoolss_io_q_enddocprinter(const char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1468 if (q_u
== NULL
) return False
;
1470 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1476 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1482 /*******************************************************************
1483 * write a structure.
1484 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1485 ********************************************************************/
1487 BOOL
spoolss_io_r_enddocprinter(const char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1489 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1491 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1497 /*******************************************************************
1499 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1500 ********************************************************************/
1502 BOOL
spoolss_io_q_startpageprinter(const char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1504 if (q_u
== NULL
) return False
;
1506 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1512 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1518 /*******************************************************************
1519 * write a structure.
1520 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1521 ********************************************************************/
1523 BOOL
spoolss_io_r_startpageprinter(const char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1525 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1527 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1533 /*******************************************************************
1535 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1536 ********************************************************************/
1538 BOOL
spoolss_io_q_endpageprinter(const char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1540 if (q_u
== NULL
) return False
;
1542 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1548 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1554 /*******************************************************************
1555 * write a structure.
1556 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1557 ********************************************************************/
1559 BOOL
spoolss_io_r_endpageprinter(const char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1561 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1563 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1569 /*******************************************************************
1571 * called from spoolss_q_writeprinter (srv_spoolss.c)
1572 ********************************************************************/
1574 BOOL
spoolss_io_q_writeprinter(const char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1576 if (q_u
== NULL
) return False
;
1578 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1584 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1586 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1589 if (q_u
->buffer_size
!=0)
1591 if (UNMARSHALLING(ps
))
1592 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1593 if(q_u
->buffer
== NULL
)
1595 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1600 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1606 /*******************************************************************
1607 * write a structure.
1608 * called from spoolss_r_writeprinter (srv_spoolss.c)
1609 ********************************************************************/
1611 BOOL
spoolss_io_r_writeprinter(const char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1613 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1615 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1617 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1623 /*******************************************************************
1625 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1626 ********************************************************************/
1628 BOOL
spoolss_io_q_rffpcnex(const char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1630 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1636 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1638 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1640 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1642 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1644 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1650 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1653 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1656 if (q_u
->option_ptr
!=0) {
1658 if (UNMARSHALLING(ps
))
1659 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1662 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1669 /*******************************************************************
1670 * write a structure.
1671 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1672 ********************************************************************/
1674 BOOL
spoolss_io_r_rffpcnex(const char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1676 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1679 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1685 /*******************************************************************
1687 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1688 ********************************************************************/
1690 BOOL
spoolss_io_q_rfnpcnex(const char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1692 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1698 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1701 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1704 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1707 if (q_u
->option_ptr
!=0) {
1709 if (UNMARSHALLING(ps
))
1710 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1713 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1720 /*******************************************************************
1721 * write a structure.
1722 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1723 ********************************************************************/
1725 BOOL
spoolss_io_r_rfnpcnex(const char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1727 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1733 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1736 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1741 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1747 /*******************************************************************
1748 * return the length of a uint16 (obvious, but the code is clean)
1749 ********************************************************************/
1751 static uint32
size_of_uint16(uint16
*value
)
1753 return (sizeof(*value
));
1756 /*******************************************************************
1757 * return the length of a uint32 (obvious, but the code is clean)
1758 ********************************************************************/
1760 static uint32
size_of_uint32(uint32
*value
)
1762 return (sizeof(*value
));
1765 /*******************************************************************
1766 * return the length of a NTTIME (obvious, but the code is clean)
1767 ********************************************************************/
1769 static uint32
size_of_nttime(NTTIME
*value
)
1771 return (sizeof(*value
));
1774 /*******************************************************************
1775 * return the length of a UNICODE string in number of char, includes:
1776 * - the leading zero
1777 * - the relative pointer size
1778 ********************************************************************/
1780 static uint32
size_of_relative_string(UNISTR
*string
)
1784 size
=str_len_uni(string
); /* the string length */
1785 size
=size
+1; /* add the trailing zero */
1786 size
=size
*2; /* convert in char */
1787 size
=size
+4; /* add the size of the ptr */
1791 * Do not include alignment as Win2k does not align relative
1792 * strings within a buffer --jerry
1794 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1795 /* size += ((4 - (size & 3)) & 3); */
1801 /*******************************************************************
1802 * return the length of a uint32 (obvious, but the code is clean)
1803 ********************************************************************/
1805 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1810 return (4+devmode
->size
+devmode
->driverextra
);
1813 /*******************************************************************
1814 * return the length of a uint32 (obvious, but the code is clean)
1815 ********************************************************************/
1817 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1822 return (sizeof(SYSTEMTIME
) +4);
1825 /*******************************************************************
1826 * write a UNICODE string and its relative pointer.
1827 * used by all the RPC structs passing a buffer
1829 * As I'm a nice guy, I'm forcing myself to explain this code.
1830 * MS did a good job in the overall spoolss code except in some
1831 * functions where they are passing the API buffer directly in the
1832 * RPC request/reply. That's to maintain compatiility at the API level.
1833 * They could have done it the good way the first time.
1835 * So what happen is: the strings are written at the buffer's end,
1836 * in the reverse order of the original structure. Some pointers to
1837 * the strings are also in the buffer. Those are relative to the
1840 * If you don't understand or want to change that function,
1841 * first get in touch with me: jfm@samba.org
1843 ********************************************************************/
1845 static BOOL
smb_io_relstr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
1847 prs_struct
*ps
=&buffer
->prs
;
1849 if (MARSHALLING(ps
)) {
1850 uint32 struct_offset
= prs_offset(ps
);
1851 uint32 relative_offset
;
1853 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
1854 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1858 * Win2k does not align strings in a buffer
1859 * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry
1864 buffer
->string_at_end
= prs_offset(ps
);
1866 /* write the string */
1867 if (!smb_io_unistr(desc
, string
, ps
, depth
))
1870 if(!prs_set_offset(ps
, struct_offset
))
1873 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1874 /* write its offset */
1875 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1881 /* read the offset */
1882 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
1885 old_offset
= prs_offset(ps
);
1886 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
1889 /* read the string */
1890 if (!smb_io_unistr(desc
, string
, ps
, depth
))
1893 if(!prs_set_offset(ps
, old_offset
))
1899 /*******************************************************************
1900 * write a array of UNICODE strings and its relative pointer.
1901 * used by 2 RPC structs
1902 ********************************************************************/
1904 static BOOL
smb_io_relarraystr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
1908 prs_struct
*ps
=&buffer
->prs
;
1910 if (MARSHALLING(ps
)) {
1911 uint32 struct_offset
= prs_offset(ps
);
1912 uint32 relative_offset
;
1919 /* first write the last 0 */
1920 buffer
->string_at_end
-= 2;
1921 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1924 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
1927 while (p
&& (*p
!=0)) {
1931 /* Yes this should be malloc not talloc. Don't change. */
1933 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
1934 if (chaine
.buffer
== NULL
)
1937 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
1939 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
1941 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
1942 SAFE_FREE(chaine
.buffer
);
1946 /* write the string */
1947 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
1948 SAFE_FREE(chaine
.buffer
);
1954 SAFE_FREE(chaine
.buffer
);
1957 if(!prs_set_offset(ps
, struct_offset
))
1960 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1961 /* write its offset */
1962 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1970 uint16
*chaine2
=NULL
;
1973 size_t realloc_size
= 0;
1977 /* read the offset */
1978 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1981 old_offset
= prs_offset(ps
);
1982 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1986 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
))
1989 l_chaine
=str_len_uni(&chaine
);
1991 /* we're going to add two more bytes here in case this
1992 is the last string in the array and we need to add
1993 an extra NULL for termination */
1998 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
2000 /* Yes this should be realloc - it's freed below. JRA */
2002 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
2007 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
2008 l_chaine2
+=l_chaine
+1;
2011 } while(l_chaine
!=0);
2013 /* the end should be bould NULL terminated so add
2014 the second one here */
2017 chaine2
[l_chaine2
] = '\0';
2018 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
2022 if(!prs_set_offset(ps
, old_offset
))
2028 /*******************************************************************
2029 Parse a DEVMODE structure and its relative pointer.
2030 ********************************************************************/
2032 static BOOL
smb_io_relsecdesc(const char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
2034 prs_struct
*ps
= &buffer
->prs
;
2036 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
2039 if (MARSHALLING(ps
)) {
2040 uint32 struct_offset
= prs_offset(ps
);
2041 uint32 relative_offset
;
2044 relative_offset
= 0;
2045 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2050 if (*secdesc
!= NULL
) {
2051 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
2053 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2055 /* write the secdesc */
2056 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2059 if(!prs_set_offset(ps
, struct_offset
))
2063 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2064 /* write its offset */
2066 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2071 /* read the offset */
2072 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2075 old_offset
= prs_offset(ps
);
2076 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2080 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2083 if(!prs_set_offset(ps
, old_offset
))
2089 /*******************************************************************
2090 Parse a DEVMODE structure and its relative pointer.
2091 ********************************************************************/
2093 static BOOL
smb_io_reldevmode(const char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2095 prs_struct
*ps
=&buffer
->prs
;
2097 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2100 if (MARSHALLING(ps
)) {
2101 uint32 struct_offset
= prs_offset(ps
);
2102 uint32 relative_offset
;
2104 if (*devmode
== NULL
) {
2106 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2108 DEBUG(8, ("boing, the devmode was NULL\n"));
2113 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2115 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2118 /* write the DEVMODE */
2119 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2122 if(!prs_set_offset(ps
, struct_offset
))
2125 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2126 /* write its offset */
2127 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2133 /* read the offset */
2134 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2136 if (buffer
->string_at_end
== 0) {
2141 old_offset
= prs_offset(ps
);
2142 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2145 /* read the string */
2146 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2148 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2151 if(!prs_set_offset(ps
, old_offset
))
2157 /*******************************************************************
2158 Parse a PRINTER_INFO_0 structure.
2159 ********************************************************************/
2161 BOOL
smb_io_printer_info_0(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2163 prs_struct
*ps
=&buffer
->prs
;
2165 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2168 buffer
->struct_start
=prs_offset(ps
);
2170 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2172 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2175 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2177 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2179 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2182 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2184 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2186 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2188 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2190 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2192 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2194 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2196 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2199 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2201 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2204 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2206 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2208 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2210 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2212 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2214 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2216 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2218 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2220 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2222 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2224 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2226 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2228 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2230 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2232 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2234 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2236 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2238 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2240 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2242 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2244 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2246 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2248 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2250 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2252 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2258 /*******************************************************************
2259 Parse a PRINTER_INFO_1 structure.
2260 ********************************************************************/
2262 BOOL
smb_io_printer_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2264 prs_struct
*ps
=&buffer
->prs
;
2266 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2269 buffer
->struct_start
=prs_offset(ps
);
2271 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2273 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2275 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2277 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2283 /*******************************************************************
2284 Parse a PRINTER_INFO_2 structure.
2285 ********************************************************************/
2287 BOOL
smb_io_printer_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2289 prs_struct
*ps
=&buffer
->prs
;
2290 uint32 dm_offset
, sd_offset
, current_offset
;
2291 uint32 dummy_value
= 0, has_secdesc
= 0;
2293 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2296 buffer
->struct_start
=prs_offset(ps
);
2298 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2300 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2302 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2304 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2306 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2308 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2310 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2313 /* save current offset and wind forwared by a uint32 */
2314 dm_offset
= prs_offset(ps
);
2315 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
2318 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2320 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2322 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2324 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2327 /* save current offset for the sec_desc */
2328 sd_offset
= prs_offset(ps
);
2329 if (!prs_uint32("sec_desc", ps
, depth
, &has_secdesc
))
2332 /* save current location so we can pick back up here */
2333 current_offset
= prs_offset(ps
);
2335 /* parse the devmode */
2336 if (!prs_set_offset(ps
, dm_offset
))
2338 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2341 /* parse the sec_desc */
2343 if (!prs_set_offset(ps
, sd_offset
))
2345 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2349 /* pick up where we left off */
2350 if (!prs_set_offset(ps
, current_offset
))
2353 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2355 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2357 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2359 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2361 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2363 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2365 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2367 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2373 /*******************************************************************
2374 Parse a PRINTER_INFO_3 structure.
2375 ********************************************************************/
2377 BOOL
smb_io_printer_info_3(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2379 prs_struct
*ps
=&buffer
->prs
;
2381 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2384 buffer
->struct_start
=prs_offset(ps
);
2386 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2388 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2394 /*******************************************************************
2395 Parse a PRINTER_INFO_4 structure.
2396 ********************************************************************/
2398 BOOL
smb_io_printer_info_4(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2400 prs_struct
*ps
=&buffer
->prs
;
2402 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2405 buffer
->struct_start
=prs_offset(ps
);
2407 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2409 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2411 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2416 /*******************************************************************
2417 Parse a PRINTER_INFO_5 structure.
2418 ********************************************************************/
2420 BOOL
smb_io_printer_info_5(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2422 prs_struct
*ps
=&buffer
->prs
;
2424 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2427 buffer
->struct_start
=prs_offset(ps
);
2429 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2431 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2433 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2435 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2437 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2442 /*******************************************************************
2443 Parse a PORT_INFO_1 structure.
2444 ********************************************************************/
2446 BOOL
smb_io_port_info_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2448 prs_struct
*ps
=&buffer
->prs
;
2450 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2453 buffer
->struct_start
=prs_offset(ps
);
2455 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2461 /*******************************************************************
2462 Parse a PORT_INFO_2 structure.
2463 ********************************************************************/
2465 BOOL
smb_io_port_info_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2467 prs_struct
*ps
=&buffer
->prs
;
2469 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2472 buffer
->struct_start
=prs_offset(ps
);
2474 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2476 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2478 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2480 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2482 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2488 /*******************************************************************
2489 Parse a DRIVER_INFO_1 structure.
2490 ********************************************************************/
2492 BOOL
smb_io_printer_driver_info_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2494 prs_struct
*ps
=&buffer
->prs
;
2496 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2499 buffer
->struct_start
=prs_offset(ps
);
2501 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2507 /*******************************************************************
2508 Parse a DRIVER_INFO_2 structure.
2509 ********************************************************************/
2511 BOOL
smb_io_printer_driver_info_2(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2513 prs_struct
*ps
=&buffer
->prs
;
2515 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2518 buffer
->struct_start
=prs_offset(ps
);
2520 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2522 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2524 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2526 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2528 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2530 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2536 /*******************************************************************
2537 Parse a DRIVER_INFO_3 structure.
2538 ********************************************************************/
2540 BOOL
smb_io_printer_driver_info_3(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2542 prs_struct
*ps
=&buffer
->prs
;
2544 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2547 buffer
->struct_start
=prs_offset(ps
);
2549 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2551 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2553 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2555 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2557 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2559 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2561 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2564 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2567 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2569 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2575 /*******************************************************************
2576 Parse a DRIVER_INFO_6 structure.
2577 ********************************************************************/
2579 BOOL
smb_io_printer_driver_info_6(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2581 prs_struct
*ps
=&buffer
->prs
;
2583 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2586 buffer
->struct_start
=prs_offset(ps
);
2588 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2590 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2592 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2594 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2596 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2598 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2600 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2603 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2606 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2608 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2611 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2614 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2616 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2619 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2622 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2625 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2628 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2630 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2632 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2634 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2640 /*******************************************************************
2641 Parse a JOB_INFO_1 structure.
2642 ********************************************************************/
2644 BOOL
smb_io_job_info_1(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2646 prs_struct
*ps
=&buffer
->prs
;
2648 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2651 buffer
->struct_start
=prs_offset(ps
);
2653 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2655 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2657 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2659 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2661 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2663 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2665 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2667 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2669 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2671 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2673 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2675 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2677 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2683 /*******************************************************************
2684 Parse a JOB_INFO_2 structure.
2685 ********************************************************************/
2687 BOOL
smb_io_job_info_2(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2690 prs_struct
*ps
=&buffer
->prs
;
2692 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2695 buffer
->struct_start
=prs_offset(ps
);
2697 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2699 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2701 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2703 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2705 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2707 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2709 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2712 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2714 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2716 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2718 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2720 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2723 /* SEC_DESC sec_desc;*/
2724 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2727 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2729 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2731 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2733 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2735 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2737 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2739 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2741 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2743 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2745 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2751 /*******************************************************************
2752 ********************************************************************/
2754 BOOL
smb_io_form_1(const char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2756 prs_struct
*ps
=&buffer
->prs
;
2758 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
2761 buffer
->struct_start
=prs_offset(ps
);
2763 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2766 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2769 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2771 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2773 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2775 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2777 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2779 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2785 /*******************************************************************
2786 Read/write a BUFFER struct.
2787 ********************************************************************/
2789 static BOOL
spoolss_io_buffer(const char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
2791 NEW_BUFFER
*buffer
= *pp_buffer
;
2793 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
2796 if (UNMARSHALLING(ps
))
2797 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
2802 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2806 if (UNMARSHALLING(ps
)) {
2808 buffer
->string_at_end
=0;
2810 if (buffer
->ptr
==0) {
2812 * JRA. I'm not sure if the data in here is in big-endian format if
2813 * the client is big-endian. Leave as default (little endian) for now.
2816 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
2821 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2825 * JRA. I'm not sure if the data in here is in big-endian format if
2826 * the client is big-endian. Leave as default (little endian) for now.
2829 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
2832 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
2835 if (!prs_set_offset(&buffer
->prs
, 0))
2838 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
2841 buffer
->string_at_end
=buffer
->size
;
2849 if (buffer
->ptr
==0) {
2850 /* We have finished with the data in buffer->prs - free it. */
2851 prs_mem_free(&buffer
->prs
);
2855 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2858 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
2864 /* We have finished with the data in buffer->prs - free it. */
2865 prs_mem_free(&buffer
->prs
);
2871 /*******************************************************************
2872 move a BUFFER from the query to the reply.
2873 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2874 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2875 Clears the memory to zero also.
2876 ********************************************************************/
2878 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
2880 prs_switch_type(&src
->prs
, MARSHALL
);
2881 if(!prs_set_offset(&src
->prs
, 0))
2883 prs_force_dynamic(&src
->prs
);
2884 prs_mem_clear(&src
->prs
);
2888 /*******************************************************************
2889 Get the size of a BUFFER struct.
2890 ********************************************************************/
2892 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
2894 return (buffer
->size
);
2897 /*******************************************************************
2898 Parse a DRIVER_DIRECTORY_1 structure.
2899 ********************************************************************/
2901 BOOL
smb_io_driverdir_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2903 prs_struct
*ps
=&buffer
->prs
;
2905 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
2908 buffer
->struct_start
=prs_offset(ps
);
2910 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2916 /*******************************************************************
2917 Parse a PORT_INFO_1 structure.
2918 ********************************************************************/
2920 BOOL
smb_io_port_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2922 prs_struct
*ps
=&buffer
->prs
;
2924 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
2927 buffer
->struct_start
=prs_offset(ps
);
2929 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2935 /*******************************************************************
2936 Parse a PORT_INFO_2 structure.
2937 ********************************************************************/
2939 BOOL
smb_io_port_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2941 prs_struct
*ps
=&buffer
->prs
;
2943 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
2946 buffer
->struct_start
=prs_offset(ps
);
2948 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2950 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2952 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2954 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2956 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2962 /*******************************************************************
2963 ********************************************************************/
2965 BOOL
smb_io_printprocessor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2967 prs_struct
*ps
=&buffer
->prs
;
2969 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2972 buffer
->struct_start
=prs_offset(ps
);
2974 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2980 /*******************************************************************
2981 ********************************************************************/
2983 BOOL
smb_io_printprocdatatype_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2985 prs_struct
*ps
=&buffer
->prs
;
2987 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2990 buffer
->struct_start
=prs_offset(ps
);
2992 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2998 /*******************************************************************
2999 ********************************************************************/
3001 BOOL
smb_io_printmonitor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
3003 prs_struct
*ps
=&buffer
->prs
;
3005 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
3008 buffer
->struct_start
=prs_offset(ps
);
3010 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3016 /*******************************************************************
3017 ********************************************************************/
3019 BOOL
smb_io_printmonitor_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
3021 prs_struct
*ps
=&buffer
->prs
;
3023 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
3026 buffer
->struct_start
=prs_offset(ps
);
3028 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3030 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
3032 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
3038 /*******************************************************************
3039 return the size required by a struct in the stream
3040 ********************************************************************/
3042 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
3046 size
+=size_of_relative_string( &info
->printername
);
3047 size
+=size_of_relative_string( &info
->servername
);
3049 size
+=size_of_uint32( &info
->cjobs
);
3050 size
+=size_of_uint32( &info
->total_jobs
);
3051 size
+=size_of_uint32( &info
->total_bytes
);
3053 size
+=size_of_uint16( &info
->year
);
3054 size
+=size_of_uint16( &info
->month
);
3055 size
+=size_of_uint16( &info
->dayofweek
);
3056 size
+=size_of_uint16( &info
->day
);
3057 size
+=size_of_uint16( &info
->hour
);
3058 size
+=size_of_uint16( &info
->minute
);
3059 size
+=size_of_uint16( &info
->second
);
3060 size
+=size_of_uint16( &info
->milliseconds
);
3062 size
+=size_of_uint32( &info
->global_counter
);
3063 size
+=size_of_uint32( &info
->total_pages
);
3065 size
+=size_of_uint16( &info
->major_version
);
3066 size
+=size_of_uint16( &info
->build_version
);
3068 size
+=size_of_uint32( &info
->unknown7
);
3069 size
+=size_of_uint32( &info
->unknown8
);
3070 size
+=size_of_uint32( &info
->unknown9
);
3071 size
+=size_of_uint32( &info
->session_counter
);
3072 size
+=size_of_uint32( &info
->unknown11
);
3073 size
+=size_of_uint32( &info
->printer_errors
);
3074 size
+=size_of_uint32( &info
->unknown13
);
3075 size
+=size_of_uint32( &info
->unknown14
);
3076 size
+=size_of_uint32( &info
->unknown15
);
3077 size
+=size_of_uint32( &info
->unknown16
);
3078 size
+=size_of_uint32( &info
->change_id
);
3079 size
+=size_of_uint32( &info
->unknown18
);
3080 size
+=size_of_uint32( &info
->status
);
3081 size
+=size_of_uint32( &info
->unknown20
);
3082 size
+=size_of_uint32( &info
->c_setprinter
);
3084 size
+=size_of_uint16( &info
->unknown22
);
3085 size
+=size_of_uint16( &info
->unknown23
);
3086 size
+=size_of_uint16( &info
->unknown24
);
3087 size
+=size_of_uint16( &info
->unknown25
);
3088 size
+=size_of_uint16( &info
->unknown26
);
3089 size
+=size_of_uint16( &info
->unknown27
);
3090 size
+=size_of_uint16( &info
->unknown28
);
3091 size
+=size_of_uint16( &info
->unknown29
);
3096 /*******************************************************************
3097 return the size required by a struct in the stream
3098 ********************************************************************/
3100 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3104 size
+=size_of_uint32( &info
->flags
);
3105 size
+=size_of_relative_string( &info
->description
);
3106 size
+=size_of_relative_string( &info
->name
);
3107 size
+=size_of_relative_string( &info
->comment
);
3112 /*******************************************************************
3113 return the size required by a struct in the stream
3114 ********************************************************************/
3116 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3122 size
+= sec_desc_size( info
->secdesc
);
3124 size
+=size_of_device_mode( info
->devmode
);
3126 size
+=size_of_relative_string( &info
->servername
);
3127 size
+=size_of_relative_string( &info
->printername
);
3128 size
+=size_of_relative_string( &info
->sharename
);
3129 size
+=size_of_relative_string( &info
->portname
);
3130 size
+=size_of_relative_string( &info
->drivername
);
3131 size
+=size_of_relative_string( &info
->comment
);
3132 size
+=size_of_relative_string( &info
->location
);
3134 size
+=size_of_relative_string( &info
->sepfile
);
3135 size
+=size_of_relative_string( &info
->printprocessor
);
3136 size
+=size_of_relative_string( &info
->datatype
);
3137 size
+=size_of_relative_string( &info
->parameters
);
3139 size
+=size_of_uint32( &info
->attributes
);
3140 size
+=size_of_uint32( &info
->priority
);
3141 size
+=size_of_uint32( &info
->defaultpriority
);
3142 size
+=size_of_uint32( &info
->starttime
);
3143 size
+=size_of_uint32( &info
->untiltime
);
3144 size
+=size_of_uint32( &info
->status
);
3145 size
+=size_of_uint32( &info
->cjobs
);
3146 size
+=size_of_uint32( &info
->averageppm
);
3149 * add any adjustments for alignment. This is
3150 * not optimal since we could be calling this
3151 * function from a loop (e.g. enumprinters), but
3152 * it is easier to maintain the calculation here and
3153 * not place the burden on the caller to remember. --jerry
3155 if ((size
% 4) != 0)
3156 size
+= 4 - (size
% 4);
3161 /*******************************************************************
3162 return the size required by a struct in the stream
3163 ********************************************************************/
3165 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3169 size
+=size_of_relative_string( &info
->printername
);
3170 size
+=size_of_relative_string( &info
->servername
);
3172 size
+=size_of_uint32( &info
->attributes
);
3176 /*******************************************************************
3177 return the size required by a struct in the stream
3178 ********************************************************************/
3180 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3184 size
+=size_of_relative_string( &info
->printername
);
3185 size
+=size_of_relative_string( &info
->portname
);
3187 size
+=size_of_uint32( &info
->attributes
);
3188 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3189 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3194 /*******************************************************************
3195 return the size required by a struct in the stream
3196 ********************************************************************/
3198 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3200 /* The 4 is for the self relative pointer.. */
3201 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3202 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3205 /*******************************************************************
3206 return the size required by a struct in the stream
3207 ********************************************************************/
3209 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3212 size
+=size_of_relative_string( &info
->name
);
3217 /*******************************************************************
3218 return the size required by a struct in the stream
3219 ********************************************************************/
3221 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3224 size
+=size_of_uint32( &info
->version
);
3225 size
+=size_of_relative_string( &info
->name
);
3226 size
+=size_of_relative_string( &info
->architecture
);
3227 size
+=size_of_relative_string( &info
->driverpath
);
3228 size
+=size_of_relative_string( &info
->datafile
);
3229 size
+=size_of_relative_string( &info
->configfile
);
3234 /*******************************************************************
3235 return the size required by a string array.
3236 ********************************************************************/
3238 uint32
spoolss_size_string_array(uint16
*string
)
3243 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3245 i
=i
+2; /* to count all chars including the leading zero */
3246 i
=2*i
; /* because we need the value in bytes */
3247 i
=i
+4; /* the offset pointer size */
3252 /*******************************************************************
3253 return the size required by a struct in the stream
3254 ********************************************************************/
3256 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3260 size
+=size_of_uint32( &info
->version
);
3261 size
+=size_of_relative_string( &info
->name
);
3262 size
+=size_of_relative_string( &info
->architecture
);
3263 size
+=size_of_relative_string( &info
->driverpath
);
3264 size
+=size_of_relative_string( &info
->datafile
);
3265 size
+=size_of_relative_string( &info
->configfile
);
3266 size
+=size_of_relative_string( &info
->helpfile
);
3267 size
+=size_of_relative_string( &info
->monitorname
);
3268 size
+=size_of_relative_string( &info
->defaultdatatype
);
3270 size
+=spoolss_size_string_array(info
->dependentfiles
);
3275 /*******************************************************************
3276 return the size required by a struct in the stream
3277 ********************************************************************/
3279 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3283 size
+=size_of_uint32( &info
->version
);
3284 size
+=size_of_relative_string( &info
->name
);
3285 size
+=size_of_relative_string( &info
->architecture
);
3286 size
+=size_of_relative_string( &info
->driverpath
);
3287 size
+=size_of_relative_string( &info
->datafile
);
3288 size
+=size_of_relative_string( &info
->configfile
);
3289 size
+=size_of_relative_string( &info
->helpfile
);
3291 size
+=spoolss_size_string_array(info
->dependentfiles
);
3293 size
+=size_of_relative_string( &info
->monitorname
);
3294 size
+=size_of_relative_string( &info
->defaultdatatype
);
3296 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3298 size
+=size_of_nttime(&info
->driver_date
);
3299 size
+=size_of_uint32( &info
->padding
);
3300 size
+=size_of_uint32( &info
->driver_version_low
);
3301 size
+=size_of_uint32( &info
->driver_version_high
);
3302 size
+=size_of_relative_string( &info
->mfgname
);
3303 size
+=size_of_relative_string( &info
->oem_url
);
3304 size
+=size_of_relative_string( &info
->hardware_id
);
3305 size
+=size_of_relative_string( &info
->provider
);
3310 /*******************************************************************
3311 return the size required by a struct in the stream
3312 ********************************************************************/
3314 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3317 size
+=size_of_uint32( &info
->jobid
);
3318 size
+=size_of_relative_string( &info
->printername
);
3319 size
+=size_of_relative_string( &info
->machinename
);
3320 size
+=size_of_relative_string( &info
->username
);
3321 size
+=size_of_relative_string( &info
->document
);
3322 size
+=size_of_relative_string( &info
->datatype
);
3323 size
+=size_of_relative_string( &info
->text_status
);
3324 size
+=size_of_uint32( &info
->status
);
3325 size
+=size_of_uint32( &info
->priority
);
3326 size
+=size_of_uint32( &info
->position
);
3327 size
+=size_of_uint32( &info
->totalpages
);
3328 size
+=size_of_uint32( &info
->pagesprinted
);
3329 size
+=size_of_systemtime( &info
->submitted
);
3334 /*******************************************************************
3335 return the size required by a struct in the stream
3336 ********************************************************************/
3338 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3342 size
+=4; /* size of sec desc ptr */
3344 size
+=size_of_uint32( &info
->jobid
);
3345 size
+=size_of_relative_string( &info
->printername
);
3346 size
+=size_of_relative_string( &info
->machinename
);
3347 size
+=size_of_relative_string( &info
->username
);
3348 size
+=size_of_relative_string( &info
->document
);
3349 size
+=size_of_relative_string( &info
->notifyname
);
3350 size
+=size_of_relative_string( &info
->datatype
);
3351 size
+=size_of_relative_string( &info
->printprocessor
);
3352 size
+=size_of_relative_string( &info
->parameters
);
3353 size
+=size_of_relative_string( &info
->drivername
);
3354 size
+=size_of_device_mode( info
->devmode
);
3355 size
+=size_of_relative_string( &info
->text_status
);
3356 /* SEC_DESC sec_desc;*/
3357 size
+=size_of_uint32( &info
->status
);
3358 size
+=size_of_uint32( &info
->priority
);
3359 size
+=size_of_uint32( &info
->position
);
3360 size
+=size_of_uint32( &info
->starttime
);
3361 size
+=size_of_uint32( &info
->untiltime
);
3362 size
+=size_of_uint32( &info
->totalpages
);
3363 size
+=size_of_uint32( &info
->size
);
3364 size
+=size_of_systemtime( &info
->submitted
);
3365 size
+=size_of_uint32( &info
->timeelapsed
);
3366 size
+=size_of_uint32( &info
->pagesprinted
);
3371 /*******************************************************************
3372 return the size required by a struct in the stream
3373 ********************************************************************/
3375 uint32
spoolss_size_form_1(FORM_1
*info
)
3379 size
+=size_of_uint32( &info
->flag
);
3380 size
+=size_of_relative_string( &info
->name
);
3381 size
+=size_of_uint32( &info
->width
);
3382 size
+=size_of_uint32( &info
->length
);
3383 size
+=size_of_uint32( &info
->left
);
3384 size
+=size_of_uint32( &info
->top
);
3385 size
+=size_of_uint32( &info
->right
);
3386 size
+=size_of_uint32( &info
->bottom
);
3391 /*******************************************************************
3392 return the size required by a struct in the stream
3393 ********************************************************************/
3395 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3399 size
+=size_of_relative_string( &info
->port_name
);
3404 /*******************************************************************
3405 return the size required by a struct in the stream
3406 ********************************************************************/
3408 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3412 size
=str_len_uni(&info
->name
); /* the string length */
3413 size
=size
+1; /* add the leading zero */
3414 size
=size
*2; /* convert in char */
3419 /*******************************************************************
3420 return the size required by a struct in the stream
3421 ********************************************************************/
3423 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3427 size
=str_len_uni(&info
->name
); /* the string length */
3428 size
=size
+1; /* add the leading zero */
3429 size
=size
*2; /* convert in char */
3434 /*******************************************************************
3435 return the size required by a struct in the stream
3436 ********************************************************************/
3438 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3442 size
+=size_of_relative_string( &info
->port_name
);
3443 size
+=size_of_relative_string( &info
->monitor_name
);
3444 size
+=size_of_relative_string( &info
->description
);
3446 size
+=size_of_uint32( &info
->port_type
);
3447 size
+=size_of_uint32( &info
->reserved
);
3452 /*******************************************************************
3453 return the size required by a struct in the stream
3454 ********************************************************************/
3456 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3459 size
+=size_of_relative_string( &info
->name
);
3464 /*******************************************************************
3465 return the size required by a struct in the stream
3466 ********************************************************************/
3468 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3471 size
+=size_of_relative_string( &info
->name
);
3476 /*******************************************************************
3477 return the size required by a struct in the stream
3478 ********************************************************************/
3479 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3486 /* uint32(offset) + uint32(length) + length) */
3487 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3488 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
+ (p
->data_len
%2) ;
3490 size
+= size_of_uint32(&p
->type
);
3495 /*******************************************************************
3496 return the size required by a struct in the stream
3497 ********************************************************************/
3499 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3502 size
+=size_of_relative_string( &info
->name
);
3507 /*******************************************************************
3508 return the size required by a struct in the stream
3509 ********************************************************************/
3511 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3514 size
+=size_of_relative_string( &info
->name
);
3515 size
+=size_of_relative_string( &info
->environment
);
3516 size
+=size_of_relative_string( &info
->dll_name
);
3521 /*******************************************************************
3523 ********************************************************************/
3525 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3526 const POLICY_HND
*hnd
,
3527 const fstring architecture
,
3528 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3529 NEW_BUFFER
*buffer
, uint32 offered
)
3534 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3536 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3539 q_u
->clientmajorversion
=clientmajor
;
3540 q_u
->clientminorversion
=clientminor
;
3543 q_u
->offered
=offered
;
3548 /*******************************************************************
3550 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3551 ********************************************************************/
3553 BOOL
spoolss_io_q_getprinterdriver2(const char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3555 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3561 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3563 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3565 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3570 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3573 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3579 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3582 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3584 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3590 /*******************************************************************
3592 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3593 ********************************************************************/
3595 BOOL
spoolss_io_r_getprinterdriver2(const char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3597 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3603 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3608 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3610 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3612 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3614 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3620 /*******************************************************************
3622 ********************************************************************/
3624 BOOL
make_spoolss_q_enumprinters(
3625 SPOOL_Q_ENUMPRINTERS
*q_u
,
3635 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3636 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3640 q_u
->offered
=offered
;
3645 /*******************************************************************
3647 ********************************************************************/
3649 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3650 fstring servername
, uint32 level
,
3651 NEW_BUFFER
*buffer
, uint32 offered
)
3653 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3654 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3658 q_u
->offered
=offered
;
3663 /*******************************************************************
3665 * called from spoolss_enumprinters (srv_spoolss.c)
3666 ********************************************************************/
3668 BOOL
spoolss_io_q_enumprinters(const char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3670 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3676 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3678 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3681 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3686 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3689 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3694 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3700 /*******************************************************************
3701 Parse a SPOOL_R_ENUMPRINTERS structure.
3702 ********************************************************************/
3704 BOOL
spoolss_io_r_enumprinters(const char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3706 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3712 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3718 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3721 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3724 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3730 /*******************************************************************
3731 * write a structure.
3732 * called from spoolss_r_enum_printers (srv_spoolss.c)
3734 ********************************************************************/
3736 BOOL
spoolss_io_r_getprinter(const char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3738 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3744 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3750 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3753 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3759 /*******************************************************************
3761 * called from spoolss_getprinter (srv_spoolss.c)
3762 ********************************************************************/
3764 BOOL
spoolss_io_q_getprinter(const char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3766 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3772 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3774 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3777 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3782 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3788 /*******************************************************************
3790 ********************************************************************/
3792 BOOL
make_spoolss_q_getprinter(
3793 TALLOC_CTX
*mem_ctx
,
3794 SPOOL_Q_GETPRINTER
*q_u
,
3795 const POLICY_HND
*hnd
,
3805 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3809 q_u
->offered
=offered
;
3814 /*******************************************************************
3816 ********************************************************************/
3817 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
3818 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
3822 DEVICEMODE
*devmode
;
3827 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3830 q_u
->info
.level
= level
;
3831 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
3834 /* There's no such thing as a setprinter level 1 */
3837 secdesc
= info
->printers_2
->secdesc
;
3838 devmode
= info
->printers_2
->devmode
;
3840 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
3841 #if 1 /* JERRY TEST */
3842 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
3843 if (!q_u
->secdesc_ctr
)
3845 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
3846 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3847 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3848 q_u
->secdesc_ctr
->sec
= secdesc
;
3850 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
3851 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
3852 q_u
->devmode_ctr
.devmode
= devmode
;
3854 q_u
->secdesc_ctr
= NULL
;
3856 q_u
->devmode_ctr
.devmode_ptr
= 0;
3857 q_u
->devmode_ctr
.size
= 0;
3858 q_u
->devmode_ctr
.devmode
= NULL
;
3862 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
3867 q_u
->command
= command
;
3873 /*******************************************************************
3874 ********************************************************************/
3876 BOOL
spoolss_io_r_setprinter(const char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3878 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3884 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3890 /*******************************************************************
3891 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3892 ********************************************************************/
3894 BOOL
spoolss_io_q_setprinter(const char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3896 uint32 ptr_sec_desc
= 0;
3898 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3904 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3906 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3909 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3912 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3922 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3927 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3933 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3938 /* Parse a NULL security descriptor. This should really
3939 happen inside the sec_io_desc_buf() function. */
3941 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3942 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
3944 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
3948 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3954 /*******************************************************************
3955 ********************************************************************/
3957 BOOL
spoolss_io_r_fcpn(const char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
3959 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
3965 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3971 /*******************************************************************
3972 ********************************************************************/
3974 BOOL
spoolss_io_q_fcpn(const char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
3977 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
3983 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3990 /*******************************************************************
3991 ********************************************************************/
3993 BOOL
spoolss_io_r_addjob(const char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
3995 prs_debug(ps
, depth
, desc
, "");
4001 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4007 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4010 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4016 /*******************************************************************
4017 ********************************************************************/
4019 BOOL
spoolss_io_q_addjob(const char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
4021 prs_debug(ps
, depth
, desc
, "");
4027 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4029 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4032 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4038 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4044 /*******************************************************************
4045 ********************************************************************/
4047 BOOL
spoolss_io_r_enumjobs(const char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
4049 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
4055 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4061 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4064 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4067 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4073 /*******************************************************************
4074 ********************************************************************/
4076 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4087 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4088 q_u
->firstjob
= firstjob
;
4089 q_u
->numofjobs
= numofjobs
;
4091 q_u
->buffer
= buffer
;
4092 q_u
->offered
= offered
;
4096 /*******************************************************************
4097 ********************************************************************/
4099 BOOL
spoolss_io_q_enumjobs(const char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4101 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4107 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4110 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4112 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
4114 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4117 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4123 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4129 /*******************************************************************
4130 ********************************************************************/
4132 BOOL
spoolss_io_r_schedulejob(const char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4134 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4140 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4146 /*******************************************************************
4147 ********************************************************************/
4149 BOOL
spoolss_io_q_schedulejob(const char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4151 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4157 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4159 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4165 /*******************************************************************
4166 ********************************************************************/
4168 BOOL
spoolss_io_r_setjob(const char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4170 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4176 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4182 /*******************************************************************
4183 ********************************************************************/
4185 BOOL
spoolss_io_q_setjob(const char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4187 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4193 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4195 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4198 * level is usually 0. If (level!=0) then I'm in trouble !
4199 * I will try to generate setjob command with level!=0, one day.
4201 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4203 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4209 /*******************************************************************
4210 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4211 ********************************************************************/
4213 BOOL
spoolss_io_r_enumprinterdrivers(const char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4215 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4221 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4227 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4230 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4233 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4239 /*******************************************************************
4241 ********************************************************************/
4243 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4245 const char *environment
,
4247 NEW_BUFFER
*buffer
, uint32 offered
)
4249 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4250 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4254 q_u
->offered
=offered
;
4259 /*******************************************************************
4260 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4261 ********************************************************************/
4263 BOOL
spoolss_io_q_enumprinterdrivers(const char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4266 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4272 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4274 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4279 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4281 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4286 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4289 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4295 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4301 /*******************************************************************
4302 ********************************************************************/
4304 BOOL
spoolss_io_q_enumforms(const char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4307 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4312 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4314 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4317 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4322 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4328 /*******************************************************************
4329 ********************************************************************/
4331 BOOL
spoolss_io_r_enumforms(const char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4333 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4339 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4345 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4348 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4351 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4357 /*******************************************************************
4358 ********************************************************************/
4360 BOOL
spoolss_io_q_getform(const char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4363 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4368 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4370 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4376 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4379 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4384 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4390 /*******************************************************************
4391 ********************************************************************/
4393 BOOL
spoolss_io_r_getform(const char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4395 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4401 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4407 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4410 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4416 /*******************************************************************
4417 Parse a SPOOL_R_ENUMPORTS structure.
4418 ********************************************************************/
4420 BOOL
spoolss_io_r_enumports(const char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4422 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4428 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4434 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4437 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4440 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4446 /*******************************************************************
4447 ********************************************************************/
4449 BOOL
spoolss_io_q_enumports(const char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4451 prs_debug(ps
, depth
, desc
, "");
4457 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4459 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4464 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4467 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4472 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4478 /*******************************************************************
4479 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4480 ********************************************************************/
4482 BOOL
spool_io_printer_info_level_1(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4484 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4490 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4492 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4494 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4496 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4499 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4501 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4503 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4509 /*******************************************************************
4510 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4511 ********************************************************************/
4513 BOOL
spool_io_printer_info_level_3(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4515 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4521 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4527 /*******************************************************************
4528 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4529 ********************************************************************/
4531 BOOL
spool_io_printer_info_level_2(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4533 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4539 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4541 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4543 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4545 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4548 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4550 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4552 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4554 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4556 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4558 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4560 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4562 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4564 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4567 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4569 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4571 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4573 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4575 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4577 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4579 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4581 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4584 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4586 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4588 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4590 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4592 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4594 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4596 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4598 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4600 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4602 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4604 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4610 /*******************************************************************
4611 ********************************************************************/
4613 BOOL
spool_io_printer_info_level(const char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4615 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4620 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4622 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4625 /* if no struct inside just return */
4626 if (il
->info_ptr
==0) {
4627 if (UNMARSHALLING(ps
)) {
4634 switch (il
->level
) {
4636 * level 0 is used by setprinter when managing the queue
4637 * (hold, stop, start a queue)
4641 /* DOCUMENT ME!!! What is level 1 used for? */
4644 if (UNMARSHALLING(ps
)) {
4645 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4648 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4653 * level 2 is used by addprinter
4654 * and by setprinter when updating printer's info
4657 if (UNMARSHALLING(ps
)) {
4658 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4661 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4664 /* DOCUMENT ME!!! What is level 3 used for? */
4667 if (UNMARSHALLING(ps
)) {
4668 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4671 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4680 /*******************************************************************
4681 ********************************************************************/
4683 BOOL
spoolss_io_q_addprinterex(const char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4685 uint32 ptr_sec_desc
= 0;
4687 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4692 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4694 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4700 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4703 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4706 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4712 switch (q_u
->level
) {
4714 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4717 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4721 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4726 /* Parse a NULL security descriptor. This should really
4727 happen inside the sec_io_desc_buf() function. */
4729 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4730 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4732 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
4736 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4738 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4744 /*******************************************************************
4745 ********************************************************************/
4747 BOOL
spoolss_io_r_addprinterex(const char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4748 prs_struct
*ps
, int depth
)
4750 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4753 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4756 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4762 /*******************************************************************
4763 ********************************************************************/
4765 BOOL
spool_io_printer_driver_info_level_3(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4766 prs_struct
*ps
, int depth
)
4768 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4770 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4774 if (UNMARSHALLING(ps
)) {
4775 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4787 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4789 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4791 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4793 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4795 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4797 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4799 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4801 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4803 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4805 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4807 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4813 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4815 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4817 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4819 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4821 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4823 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4825 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4827 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4833 if (il
->dependentfiles_ptr
)
4834 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
4839 /*******************************************************************
4840 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4841 ********************************************************************/
4843 BOOL
spool_io_printer_driver_info_level_6(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4844 prs_struct
*ps
, int depth
)
4846 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4848 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4852 if (UNMARSHALLING(ps
)) {
4853 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
4866 * I know this seems weird, but I have no other explanation.
4867 * This is observed behavior on both NT4 and 2K servers.
4871 if (!prs_align_uint64(ps
))
4874 /* parse the main elements the packet */
4876 if(!prs_uint32("cversion ", ps
, depth
, &il
->version
))
4878 if(!prs_uint32("name ", ps
, depth
, &il
->name_ptr
))
4880 if(!prs_uint32("environment ", ps
, depth
, &il
->environment_ptr
))
4882 if(!prs_uint32("driverpath ", ps
, depth
, &il
->driverpath_ptr
))
4884 if(!prs_uint32("datafile ", ps
, depth
, &il
->datafile_ptr
))
4886 if(!prs_uint32("configfile ", ps
, depth
, &il
->configfile_ptr
))
4888 if(!prs_uint32("helpfile ", ps
, depth
, &il
->helpfile_ptr
))
4890 if(!prs_uint32("monitorname ", ps
, depth
, &il
->monitorname_ptr
))
4892 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4894 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_len
))
4896 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_ptr
))
4898 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_len
))
4900 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_ptr
))
4902 if(!smb_io_time("driverdate ", &il
->driverdate
, ps
, depth
))
4904 if(!prs_uint32("dummy4 ", ps
, depth
, &il
->dummy4
))
4906 if(!prs_uint64("driverversion ", ps
, depth
, &il
->driverversion
))
4908 if(!prs_uint32("mfgname ", ps
, depth
, &il
->mfgname_ptr
))
4910 if(!prs_uint32("oemurl ", ps
, depth
, &il
->oemurl_ptr
))
4912 if(!prs_uint32("hardwareid ", ps
, depth
, &il
->hardwareid_ptr
))
4914 if(!prs_uint32("provider ", ps
, depth
, &il
->provider_ptr
))
4917 /* parse the structures in the packet */
4919 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4924 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4929 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4934 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4939 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4944 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4949 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4954 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4958 if (il
->dependentfiles_ptr
) {
4959 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
4964 if (il
->previousnames_ptr
) {
4965 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
4970 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
4974 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
4978 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
4982 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
4988 /*******************************************************************
4989 convert a buffer of UNICODE strings null terminated
4990 the buffer is terminated by a NULL
4992 convert to an dos codepage array (null terminated)
4994 dynamically allocate memory
4996 ********************************************************************/
4997 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
5006 src
= (char *)buf5
->buffer
;
5009 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
5010 unistr_to_dos(f
, src
, sizeof(f
)-1);
5011 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
5012 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
5017 fstrcpy((*ar
)[n
], f
);
5020 fstrcpy((*ar
)[n
], "");
5028 /*******************************************************************
5029 read a UNICODE array with null terminated strings
5030 and null terminated array
5031 and size of array at beginning
5032 ********************************************************************/
5034 BOOL
smb_io_unibuffer(const char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
5036 if (buffer
==NULL
) return False
;
5039 buffer
->uni_str_len
=buffer
->uni_max_len
;
5041 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
5044 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
5050 /*******************************************************************
5051 ********************************************************************/
5053 BOOL
spool_io_printer_driver_info_level(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
5055 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
5060 if(!prs_uint32("level", ps
, depth
, &il
->level
))
5062 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
5068 switch (il
->level
) {
5070 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
5074 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5084 /*******************************************************************
5085 init a SPOOL_Q_ADDPRINTERDRIVER struct
5086 ******************************************************************/
5088 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5089 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5090 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5092 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5094 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
5095 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
5099 q_u
->info
.level
= level
;
5100 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
5103 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5105 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5109 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5116 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5117 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5118 DRIVER_INFO_3
*info3
)
5121 uint16
*ptr
= info3
->dependentfiles
;
5123 BOOL null_char
= False
;
5124 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5126 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
5129 inf
->cversion
= info3
->version
;
5130 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5131 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5132 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5133 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5134 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5135 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5136 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5137 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5139 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5140 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5141 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5142 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5143 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5144 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5145 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5146 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5153 /* the null_char BOOL is used to help locate
5154 two '\0's back to back */
5169 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5170 inf
->dependentfilessize
= len
;
5171 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5177 *spool_drv_info
= inf
;
5182 /*******************************************************************
5183 make a BUFFER5 struct from a uint16*
5184 ******************************************************************/
5185 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5188 buf5
->buf_len
= len
;
5189 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5191 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5198 /*******************************************************************
5199 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5200 ********************************************************************/
5202 BOOL
spoolss_io_q_addprinterdriver(const char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5204 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5210 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5212 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5217 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5220 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5226 /*******************************************************************
5227 ********************************************************************/
5229 BOOL
spoolss_io_r_addprinterdriver(const char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5231 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5234 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5240 /*******************************************************************
5241 ********************************************************************/
5243 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5244 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5246 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5248 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5252 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5260 d
->cversion
=uni
->cversion
;
5262 unistr2_to_dos(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5263 unistr2_to_dos(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5264 unistr2_to_dos(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5265 unistr2_to_dos(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5266 unistr2_to_dos(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5267 unistr2_to_dos(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5268 unistr2_to_dos(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5269 unistr2_to_dos(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5271 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5272 DEBUGADD(8,( "name: %s\n", d
->name
));
5273 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5274 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5275 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5276 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5277 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5278 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5279 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5281 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5288 /*******************************************************************
5289 ********************************************************************/
5290 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5291 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5293 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5295 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5299 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5307 d
->version
=uni
->version
;
5309 unistr2_to_dos(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5310 unistr2_to_dos(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5311 unistr2_to_dos(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5312 unistr2_to_dos(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5313 unistr2_to_dos(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5314 unistr2_to_dos(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5315 unistr2_to_dos(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5316 unistr2_to_dos(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5318 DEBUGADD(8,( "version: %d\n", d
->version
));
5319 DEBUGADD(8,( "name: %s\n", d
->name
));
5320 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5321 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5322 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5323 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5324 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5325 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5326 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5328 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5330 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5340 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5341 NT_PRINTER_INFO_LEVEL_2
**asc
)
5343 NT_PRINTER_INFO_LEVEL_2
*d
;
5346 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5347 time_unix
=time(NULL
);
5350 DEBUGADD(8,("allocating memory\n"));
5352 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5357 /* we allocate memory iff called from
5358 * addprinter(ex) so we can do one time stuff here.
5360 (*asc
)->setuptime
=time_unix
;
5362 DEBUGADD(8,("start converting\n"));
5366 d
->attributes
=uni
->attributes
;
5367 d
->priority
=uni
->priority
;
5368 d
->default_priority
=uni
->default_priority
;
5369 d
->starttime
=uni
->starttime
;
5370 d
->untiltime
=uni
->untiltime
;
5371 d
->status
=uni
->status
;
5372 d
->cjobs
=uni
->cjobs
;
5374 unistr2_to_dos(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5375 unistr2_to_dos(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5376 unistr2_to_dos(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5377 unistr2_to_dos(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5378 unistr2_to_dos(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5379 unistr2_to_dos(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5380 unistr2_to_dos(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5381 unistr2_to_dos(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5382 unistr2_to_dos(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5383 unistr2_to_dos(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5384 unistr2_to_dos(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5389 /*******************************************************************
5391 ********************************************************************/
5393 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5394 fstring servername
, fstring env_name
, uint32 level
,
5395 NEW_BUFFER
*buffer
, uint32 offered
)
5397 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5398 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5402 q_u
->offered
=offered
;
5407 /*******************************************************************
5408 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5409 ********************************************************************/
5411 BOOL
spoolss_io_q_getprinterdriverdir(const char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5413 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5418 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5420 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5426 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5428 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5434 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5437 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5443 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5449 /*******************************************************************
5450 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5451 ********************************************************************/
5453 BOOL
spoolss_io_r_getprinterdriverdir(const char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5455 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5461 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5467 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5470 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5476 /*******************************************************************
5477 ********************************************************************/
5479 BOOL
spoolss_io_r_enumprintprocessors(const char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5481 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5487 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5493 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5496 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5499 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5505 /*******************************************************************
5506 ********************************************************************/
5508 BOOL
spoolss_io_q_enumprintprocessors(const char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5510 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5516 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5518 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5524 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5526 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5532 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5535 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5541 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5547 /*******************************************************************
5548 ********************************************************************/
5550 BOOL
spoolss_io_q_addprintprocessor(const char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5552 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5558 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5560 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5565 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5570 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5575 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5581 /*******************************************************************
5582 ********************************************************************/
5584 BOOL
spoolss_io_r_addprintprocessor(const char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5586 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5592 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5598 /*******************************************************************
5599 ********************************************************************/
5601 BOOL
spoolss_io_r_enumprintprocdatatypes(const char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5603 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5609 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5615 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5618 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5621 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5627 /*******************************************************************
5628 ********************************************************************/
5630 BOOL
spoolss_io_q_enumprintprocdatatypes(const char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5632 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5638 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5640 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5646 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5648 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5654 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5657 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5663 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5669 /*******************************************************************
5670 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5671 ********************************************************************/
5673 BOOL
spoolss_io_q_enumprintmonitors(const char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5675 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5681 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5683 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5689 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5692 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5698 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5704 /*******************************************************************
5705 ********************************************************************/
5707 BOOL
spoolss_io_r_enumprintmonitors(const char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5709 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5715 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5721 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5724 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5727 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5733 /*******************************************************************
5734 ********************************************************************/
5736 BOOL
spoolss_io_r_enumprinterdata(const char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5738 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5743 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5746 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
5747 r_u
->value
= (uint16
*)prs_alloc_mem(ps
, r_u
->valuesize
* 2);
5749 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
5754 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5760 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5763 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5766 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5769 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
5770 r_u
->data
= (uint8
*)prs_alloc_mem(ps
, r_u
->datasize
);
5772 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
5777 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
5782 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
5784 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5790 /*******************************************************************
5791 ********************************************************************/
5793 BOOL
spoolss_io_q_enumprinterdata(const char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5795 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
5800 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5802 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
5804 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
5806 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
5812 /*******************************************************************
5813 ********************************************************************/
5815 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
5816 const POLICY_HND
*hnd
,
5817 uint32 idx
, uint32 valuelen
, uint32 datalen
)
5819 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5821 q_u
->valuesize
=valuelen
;
5822 q_u
->datasize
=datalen
;
5827 /*******************************************************************
5828 ********************************************************************/
5829 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, TALLOC_CTX
*ctx
, const POLICY_HND
*hnd
,
5830 char* value
, char* data
)
5834 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5836 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
5838 init_unistr2(&tmp
, data
, strlen(data
)+1);
5839 q_u
->max_len
= q_u
->real_len
= tmp
.uni_max_len
*2;
5840 q_u
->data
= talloc(ctx
, q_u
->real_len
);
5841 memcpy(q_u
->data
, tmp
.buffer
, q_u
->real_len
);
5845 /*******************************************************************
5846 ********************************************************************/
5848 BOOL
spoolss_io_q_setprinterdata(const char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5850 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
5855 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5857 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
5863 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5866 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
5876 if (UNMARSHALLING(ps
))
5877 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
5878 if(q_u
->data
== NULL
)
5880 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
5888 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
5894 /*******************************************************************
5895 ********************************************************************/
5897 BOOL
spoolss_io_r_setprinterdata(const char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5899 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
5904 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5910 /*******************************************************************
5911 ********************************************************************/
5912 BOOL
spoolss_io_q_resetprinter(const char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5914 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
5919 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5922 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
5925 if (q_u
->datatype_ptr
) {
5926 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
5930 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
5937 /*******************************************************************
5938 ********************************************************************/
5939 BOOL
spoolss_io_r_resetprinter(const char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5941 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
5946 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5952 /*******************************************************************
5953 ********************************************************************/
5954 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
5955 uint32 type
, const uint8
*data
, uint32 len
)
5957 DEBUG(5,("converting a specific param struct\n"));
5961 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
5964 memset((char *)*param
, '\0', sizeof(NT_PRINTER_PARAM
));
5965 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5967 unistr2_to_dos((*param
)->value
, value
, sizeof((*param
)->value
)-1);
5968 (*param
)->type
= type
;
5970 /* le champ data n'est pas NULL termine */
5971 /* on stocke donc la longueur */
5973 (*param
)->data_len
=len
;
5976 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
5977 if((*param
)->data
== NULL
)
5979 memcpy((*param
)->data
, data
, len
);
5982 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
5983 dump_data(10, (char *)(*param
)->data
, (*param
)->data_len
);
5988 /*******************************************************************
5989 ********************************************************************/
5991 static BOOL
spoolss_io_addform(const char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
5993 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
6000 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
6002 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
6004 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
6006 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
6008 if(!prs_uint32("left", ps
, depth
, &f
->left
))
6010 if(!prs_uint32("top", ps
, depth
, &f
->top
))
6012 if(!prs_uint32("right", ps
, depth
, &f
->right
))
6014 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
6017 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
6024 /*******************************************************************
6025 ********************************************************************/
6027 BOOL
spoolss_io_q_deleteform(const char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
6029 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
6034 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6036 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
6042 /*******************************************************************
6043 ********************************************************************/
6045 BOOL
spoolss_io_r_deleteform(const char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
6047 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
6052 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6058 /*******************************************************************
6059 ********************************************************************/
6061 BOOL
spoolss_io_q_addform(const char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
6063 uint32 useless_ptr
=1;
6064 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
6069 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6071 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6073 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6078 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6080 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6087 /*******************************************************************
6088 ********************************************************************/
6090 BOOL
spoolss_io_r_addform(const char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6092 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6097 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6103 /*******************************************************************
6104 ********************************************************************/
6106 BOOL
spoolss_io_q_setform(const char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6108 uint32 useless_ptr
=1;
6109 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6114 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6116 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6122 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6124 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6129 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6131 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6138 /*******************************************************************
6139 ********************************************************************/
6141 BOOL
spoolss_io_r_setform(const char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6143 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6148 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6154 /*******************************************************************
6155 Parse a SPOOL_R_GETJOB structure.
6156 ********************************************************************/
6158 BOOL
spoolss_io_r_getjob(const char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6160 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6166 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6172 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6175 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6181 /*******************************************************************
6182 Parse a SPOOL_Q_GETJOB structure.
6183 ********************************************************************/
6185 BOOL
spoolss_io_q_getjob(const char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6187 prs_debug(ps
, depth
, desc
, "");
6193 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6195 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6197 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6200 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6206 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6212 void free_devmode(DEVICEMODE
*devmode
)
6214 if (devmode
!=NULL
) {
6215 SAFE_FREE(devmode
->private);
6220 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6225 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6227 if (printer
!=NULL
) {
6228 free_devmode(printer
->devmode
);
6229 printer
->devmode
= NULL
;
6234 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6239 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6244 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6249 void free_job_info_2(JOB_INFO_2
*job
)
6252 free_devmode(job
->devmode
);
6255 /*******************************************************************
6257 ********************************************************************/
6259 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6260 const fstring string
, uint32 printer
, uint32 type
)
6265 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
6267 q_u
->printer
=printer
;
6276 /*******************************************************************
6277 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6278 ********************************************************************/
6280 BOOL
spoolss_io_q_replyopenprinter(const char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6282 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6288 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6294 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6296 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6299 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6301 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6307 /*******************************************************************
6308 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6309 ********************************************************************/
6311 BOOL
spoolss_io_r_replyopenprinter(const char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6313 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6319 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6322 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6328 /*******************************************************************
6330 ********************************************************************/
6331 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6332 uint32 condition
, uint32 change_id
)
6335 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6337 q_u
->condition
= condition
;
6338 q_u
->change_id
= change_id
;
6341 q_u
->unknown1
= 0x1;
6342 memset(q_u
->unknown2
, 0x0, 5);
6343 q_u
->unknown2
[0] = 0x1;
6348 /*******************************************************************
6349 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6350 ********************************************************************/
6351 BOOL
spoolss_io_q_routerreplyprinter (const char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6354 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6360 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6363 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6366 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6369 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6372 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6378 /*******************************************************************
6379 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6380 ********************************************************************/
6381 BOOL
spoolss_io_r_routerreplyprinter (const char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6383 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6389 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6395 /*******************************************************************
6397 ********************************************************************/
6399 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6404 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6409 /*******************************************************************
6410 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6411 ********************************************************************/
6413 BOOL
spoolss_io_q_replycloseprinter(const char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6415 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6421 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6427 /*******************************************************************
6428 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6429 ********************************************************************/
6431 BOOL
spoolss_io_r_replycloseprinter(const char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6433 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6439 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6442 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6448 #if 0 /* JERRY - not currently used but could be :-) */
6450 /*******************************************************************
6451 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6452 ******************************************************************/
6453 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6454 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6458 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6460 for (i
=0; i
<n
; i
++) {
6464 if (src
->size
!= POINTER
)
6466 len
= src
->notify_data
.data
.length
;
6467 s
= malloc(sizeof(uint16
)*len
);
6469 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6473 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6474 dst
->notify_data
.data
.string
= s
;
6480 /*******************************************************************
6481 Deep copy a SPOOL_NOTIFY_INFO structure
6482 ******************************************************************/
6483 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6486 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6490 dst
->version
= src
->version
;
6491 dst
->flags
= src
->flags
;
6492 dst
->count
= src
->count
;
6496 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6498 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6501 if (dst
->data
== NULL
) {
6502 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6507 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6514 /*******************************************************************
6516 ********************************************************************/
6518 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6519 uint32 change_low
, uint32 change_high
,
6520 SPOOL_NOTIFY_INFO
*info
)
6525 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6527 q_u
->change_low
=change_low
;
6528 q_u
->change_high
=change_high
;
6533 q_u
->info_ptr
=0xaddee11e;
6535 q_u
->info
.version
=2;
6538 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6540 q_u
->info
.version
= info
->version
;
6541 q_u
->info
.flags
= info
->flags
;
6542 q_u
->info
.count
= info
->count
;
6543 /* pointer field - be careful! */
6544 q_u
->info
.data
= info
->data
;
6547 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6554 /*******************************************************************
6555 Parse a SPOOL_Q_REPLY_RRPCN structure.
6556 ********************************************************************/
6558 BOOL
spoolss_io_q_reply_rrpcn(const char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6560 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6566 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6569 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6572 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6575 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6578 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6581 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6584 if(q_u
->info_ptr
!=0)
6585 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6591 /*******************************************************************
6592 Parse a SPOOL_R_REPLY_RRPCN structure.
6593 ********************************************************************/
6595 BOOL
spoolss_io_r_reply_rrpcn(const char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6597 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6603 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6606 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6612 /*******************************************************************
6614 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6615 ********************************************************************/
6617 BOOL
spoolss_io_q_getprinterdataex(const char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6622 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6627 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6631 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6635 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6639 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6645 /*******************************************************************
6646 * write a structure.
6647 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6648 ********************************************************************/
6650 BOOL
spoolss_io_r_getprinterdataex(const char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6655 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6660 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6662 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6665 if (UNMARSHALLING(ps
) && r_u
->size
) {
6666 r_u
->data
= prs_alloc_mem(ps
, r_u
->size
);
6671 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
6677 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6679 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6685 /*******************************************************************
6687 ********************************************************************/
6689 BOOL
spoolss_io_q_setprinterdataex(const char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6691 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
6696 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6698 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6704 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6710 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6713 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6723 if (UNMARSHALLING(ps
))
6724 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6725 if(q_u
->data
== NULL
)
6727 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6735 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6741 /*******************************************************************
6742 * write a structure.
6743 ********************************************************************/
6745 BOOL
spoolss_io_r_setprinterdataex(const char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6747 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
6752 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6759 /*******************************************************************
6761 ********************************************************************/
6763 BOOL
spoolss_io_q_enumprinterkey(const char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
6765 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
6770 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6773 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6779 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6785 /*******************************************************************
6786 * write a structure.
6787 ********************************************************************/
6789 BOOL
spoolss_io_r_enumprinterkey(const char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
6791 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
6797 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
6803 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6806 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6813 /*******************************************************************
6815 ********************************************************************/
6817 BOOL
spoolss_io_q_enumprinterdataex(const char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6819 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
6824 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6827 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6833 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6839 /*******************************************************************
6840 ********************************************************************/
6842 static BOOL
spoolss_io_printer_enum_values_ctr(const char *desc
, prs_struct
*ps
,
6843 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
6846 uint32 valuename_offset
,
6849 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
6851 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
6855 * offset data begins at 20 bytes per structure * size_of_array.
6856 * Don't forget the uint32 at the beginning
6859 current_offset
= basic_unit
* ctr
->size_of_array
;
6861 /* first loop to write basic enum_value information */
6863 if (UNMARSHALLING(ps
)) {
6864 ctr
->values
= (PRINTER_ENUM_VALUES
*)prs_alloc_mem(
6865 ps
, ctr
->size_of_array
* sizeof(PRINTER_ENUM_VALUES
));
6870 for (i
=0; i
<ctr
->size_of_array
; i
++) {
6871 valuename_offset
= current_offset
;
6872 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
6875 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
6878 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
6881 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
6883 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
6886 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
6889 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
6890 /* account for 2 byte alignment */
6891 current_offset
+= (current_offset
% 2);
6895 * loop #2 for writing the dynamically size objects; pay
6896 * attention to 2-byte alignment here....
6899 for (i
=0; i
<ctr
->size_of_array
; i
++) {
6901 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
6904 if (UNMARSHALLING(ps
)) {
6905 ctr
->values
[i
].data
= (uint8
*)prs_alloc_mem(
6906 ps
, ctr
->values
[i
].data_len
);
6907 if (!ctr
->values
[i
].data
)
6911 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
6914 if ( !prs_align_uint16(ps
) )
6921 /*******************************************************************
6922 * write a structure.
6923 ********************************************************************/
6925 BOOL
spoolss_io_r_enumprinterdataex(const char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6927 uint32 data_offset
, end_offset
;
6928 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
6934 if (!prs_uint32("size", ps
, depth
, &r_u
->ctr
.size
))
6937 data_offset
= prs_offset(ps
);
6939 if (!prs_set_offset(ps
, data_offset
+ r_u
->ctr
.size
))
6945 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6948 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6951 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6954 r_u
->ctr
.size_of_array
= r_u
->returned
;
6956 end_offset
= prs_offset(ps
);
6958 if (!prs_set_offset(ps
, data_offset
))
6962 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
6965 if (!prs_set_offset(ps
, end_offset
))
6970 /*******************************************************************
6971 * write a structure.
6972 ********************************************************************/
6975 uint32 GetPrintProcessorDirectory(
6977 [in] unistr2 *environment,
6979 [in,out] NEW_BUFFER buffer,
6980 [in] uint32 offered,
6981 [out] uint32 needed,
6982 [out] uint32 returned
6987 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, NEW_BUFFER
*buffer
, uint32 offered
)
6989 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
6991 init_unistr2(&q_u
->name
, name
, strlen(name
)+1);
6992 init_unistr2(&q_u
->environment
, environment
, strlen(environment
)+1);
6996 q_u
->buffer
= buffer
;
6997 q_u
->offered
= offered
;
7002 BOOL
spoolss_io_q_getprintprocessordirectory(const char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
7006 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
7012 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7016 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
7023 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7027 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
7035 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7038 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
7044 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
7050 /*******************************************************************
7051 * write a structure.
7052 ********************************************************************/
7054 BOOL
spoolss_io_r_getprintprocessordirectory(const char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
7056 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
7062 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
7068 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7071 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7077 BOOL
smb_io_printprocessordirectory_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
7079 prs_struct
*ps
=&buffer
->prs
;
7081 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
7084 buffer
->struct_start
=prs_offset(ps
);
7086 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
7092 /*******************************************************************
7094 ********************************************************************/
7096 BOOL
make_spoolss_q_addform(SPOOL_Q_ADDFORM
*q_u
, POLICY_HND
*handle
,
7097 int level
, FORM
*form
)
7099 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7101 q_u
->level2
= level
;
7102 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7107 /*******************************************************************
7109 ********************************************************************/
7111 BOOL
make_spoolss_q_setform(SPOOL_Q_SETFORM
*q_u
, POLICY_HND
*handle
,
7112 int level
, char *form_name
, FORM
*form
)
7114 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7116 q_u
->level2
= level
;
7117 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7118 init_unistr2(&q_u
->name
, form_name
, strlen(form_name
) + 1);
7123 /*******************************************************************
7125 ********************************************************************/
7127 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
, char *form
)
7129 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7130 init_unistr2(&q_u
->name
, form
, strlen(form
) + 1);
7134 /*******************************************************************
7136 ********************************************************************/
7138 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7139 char *formname
, uint32 level
, NEW_BUFFER
*buffer
,
7142 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7144 init_unistr2(&q_u
->formname
, formname
, strlen(formname
) + 1);
7146 q_u
->offered
=offered
;
7151 /*******************************************************************
7153 ********************************************************************/
7155 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7156 uint32 level
, NEW_BUFFER
*buffer
,
7159 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7162 q_u
->offered
=offered
;