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.
28 #define DBGC_CLASS DBGC_RPC_PARSE
30 /*******************************************************************
31 return the length of a UNISTR string.
32 ********************************************************************/
34 static uint32
str_len_uni(UNISTR
*source
)
41 while (source
->buffer
[i
])
47 /*******************************************************************
48 This should be moved in a more generic lib.
49 ********************************************************************/
51 BOOL
spoolss_io_system_time(char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
53 if(!prs_uint16("year", ps
, depth
, &systime
->year
))
55 if(!prs_uint16("month", ps
, depth
, &systime
->month
))
57 if(!prs_uint16("dayofweek", ps
, depth
, &systime
->dayofweek
))
59 if(!prs_uint16("day", ps
, depth
, &systime
->day
))
61 if(!prs_uint16("hour", ps
, depth
, &systime
->hour
))
63 if(!prs_uint16("minute", ps
, depth
, &systime
->minute
))
65 if(!prs_uint16("second", ps
, depth
, &systime
->second
))
67 if(!prs_uint16("milliseconds", ps
, depth
, &systime
->milliseconds
))
73 /*******************************************************************
74 ********************************************************************/
76 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
78 systime
->year
=unixtime
->tm_year
+1900;
79 systime
->month
=unixtime
->tm_mon
+1;
80 systime
->dayofweek
=unixtime
->tm_wday
;
81 systime
->day
=unixtime
->tm_mday
;
82 systime
->hour
=unixtime
->tm_hour
;
83 systime
->minute
=unixtime
->tm_min
;
84 systime
->second
=unixtime
->tm_sec
;
85 systime
->milliseconds
=0;
90 /*******************************************************************
91 reads or writes an DOC_INFO structure.
92 ********************************************************************/
94 static BOOL
smb_io_doc_info_1(char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
96 if (info_1
== NULL
) return False
;
98 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
104 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
106 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
108 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
111 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
113 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
115 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
121 /*******************************************************************
122 reads or writes an DOC_INFO structure.
123 ********************************************************************/
125 static BOOL
smb_io_doc_info(char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
127 uint32 useless_ptr
=0;
129 if (info
== NULL
) return False
;
131 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
137 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
140 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
143 switch (info
->switch_value
)
146 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
151 this is just a placeholder
153 MSDN July 1998 says doc_info_2 is only on
154 Windows 95, and as Win95 doesn't do RPC to print
155 this case is nearly impossible
157 Maybe one day with Windows for dishwasher 2037 ...
160 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
163 DEBUG(0,("Something is obviously wrong somewhere !\n"));
170 /*******************************************************************
171 reads or writes an DOC_INFO_CONTAINER structure.
172 ********************************************************************/
174 static BOOL
smb_io_doc_info_container(char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
176 if (cont
== NULL
) return False
;
178 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
184 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
187 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
193 /*******************************************************************
194 reads or writes an NOTIFY OPTION TYPE structure.
195 ********************************************************************/
197 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
198 structure. The _TYPE structure is really the deferred referrants (i.e
199 the notify fields array) of the _TYPE structure. -tpot */
201 static BOOL
smb_io_notify_option_type(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
203 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
209 if(!prs_uint16("type", ps
, depth
, &type
->type
))
211 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
213 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
215 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
217 if(!prs_uint32("count", ps
, depth
, &type
->count
))
219 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
225 /*******************************************************************
226 reads or writes an NOTIFY OPTION TYPE DATA.
227 ********************************************************************/
229 static BOOL
smb_io_notify_option_type_data(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
233 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
236 /* if there are no fields just return */
237 if (type
->fields_ptr
==0)
243 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
246 if (type
->count2
!= type
->count
)
247 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
249 /* parse the option type data */
250 for(i
=0;i
<type
->count2
;i
++)
251 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
256 /*******************************************************************
257 reads or writes an NOTIFY OPTION structure.
258 ********************************************************************/
260 static BOOL
smb_io_notify_option_type_ctr(char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
264 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
267 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
271 if (UNMARSHALLING(ps
))
272 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)prs_alloc_mem(ps
,ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
275 /* the option type struct */
276 for(i
=0;i
<ctr
->count
;i
++)
277 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
280 /* the type associated with the option type struct */
281 for(i
=0;i
<ctr
->count
;i
++)
282 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
288 /*******************************************************************
289 reads or writes an NOTIFY OPTION structure.
290 ********************************************************************/
292 static BOOL
smb_io_notify_option(char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
294 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
297 if(!prs_uint32("version", ps
, depth
, &option
->version
))
299 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
301 if(!prs_uint32("count", ps
, depth
, &option
->count
))
303 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
306 /* marshalling or unmarshalling, that would work */
307 if (option
->option_type_ptr
!=0) {
308 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
312 option
->ctr
.type
=NULL
;
319 /*******************************************************************
320 reads or writes an NOTIFY INFO DATA structure.
321 ********************************************************************/
323 static BOOL
smb_io_notify_info_data(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
325 uint32 useless_ptr
=0xADDE0FF0;
327 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
332 if(!prs_uint16("type", ps
, depth
, &data
->type
))
334 if(!prs_uint16("field", ps
, depth
, &data
->field
))
337 if(!prs_uint32("how many words", ps
, depth
, &data
->size
))
339 if(!prs_uint32("id", ps
, depth
, &data
->id
))
341 if(!prs_uint32("how many words", ps
, depth
, &data
->size
))
344 switch (data
->enc_type
) {
346 /* One and two value data has two uint32 values */
348 case NOTIFY_ONE_VALUE
:
349 case NOTIFY_TWO_VALUE
:
351 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
353 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
357 /* Pointers and strings have a string length and a
358 pointer. For a string the length is expressed as
359 the number of uint16 characters plus a trailing
364 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
366 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
373 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
376 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
382 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data\n",
390 /*******************************************************************
391 reads or writes an NOTIFY INFO DATA structure.
392 ********************************************************************/
394 BOOL
smb_io_notify_info_data_strings(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
395 prs_struct
*ps
, int depth
)
397 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
403 switch(data
->enc_type
) {
405 /* No data for values */
407 case NOTIFY_ONE_VALUE
:
408 case NOTIFY_TWO_VALUE
:
412 /* Strings start with a length in uint16s */
416 if (UNMARSHALLING(ps
)) {
417 data
->notify_data
.data
.string
=
418 (uint16
*)prs_alloc_mem(ps
, data
->notify_data
.data
.length
);
420 if (!data
->notify_data
.data
.string
)
425 data
->notify_data
.data
.length
/= 2;
427 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
430 if (!prs_uint16uni(True
, "string", ps
, depth
, data
->notify_data
.data
.string
,
431 data
->notify_data
.data
.length
))
435 data
->notify_data
.data
.length
*= 2;
441 if (UNMARSHALLING(ps
)) {
442 data
->notify_data
.data
.string
=
443 (uint16
*)prs_alloc_mem(ps
, data
->notify_data
.data
.length
);
445 if (!data
->notify_data
.data
.string
)
449 if(!prs_uint8s(True
,"buffer",ps
,depth
,(uint8
*)data
->notify_data
.data
.string
,data
->notify_data
.data
.length
))
455 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data_strings\n",
461 if (isvalue
==False
) {
463 /* length of string in unicode include \0 */
464 x
=data
->notify_data
.data
.length
+1;
466 if (data
->field
!= 16)
467 if(!prs_uint32("string length", ps
, depth
, &x
))
470 if (MARSHALLING(ps
)) {
471 /* These are already in little endian format. Don't byte swap. */
474 /* No memory allocated for this string
475 therefore following the data.string
476 pointer is a bad idea. Use a pointer to
477 the uint32 length union member to
478 provide a source for a unicode NULL */
480 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
484 if (data
->field
== 16)
487 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
492 /* Tallocate memory for string */
494 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
495 if (!data
->notify_data
.data
.string
)
498 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
506 /* Win2k does not seem to put this parse align here */
514 /*******************************************************************
515 reads or writes an NOTIFY INFO structure.
516 ********************************************************************/
518 static BOOL
smb_io_notify_info(char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
522 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
528 if(!prs_uint32("count", ps
, depth
, &info
->count
))
530 if(!prs_uint32("version", ps
, depth
, &info
->version
))
532 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
534 if(!prs_uint32("count", ps
, depth
, &info
->count
))
537 for (i
=0;i
<info
->count
;i
++) {
538 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
542 /* now do the strings at the end of the stream */
543 for (i
=0;i
<info
->count
;i
++) {
544 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
551 /*******************************************************************
552 ********************************************************************/
554 static BOOL
spool_io_user_level_1(char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
556 prs_debug(ps
, depth
, desc
, "");
560 if (UNMARSHALLING(ps
))
565 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
567 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
569 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
571 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
573 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
575 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
577 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
580 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
584 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
590 /*******************************************************************
591 ********************************************************************/
593 static BOOL
spool_io_user_level(char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
598 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
603 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
605 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
608 switch (q_u
->level
) {
610 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
620 /*******************************************************************
621 * read or write a DEVICEMODE struct.
622 * on reading allocate memory for the private member
623 ********************************************************************/
625 #define DM_NUM_OPTIONAL_FIELDS 8
627 BOOL
spoolss_io_devmode(char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
629 uint32 available_space
; /* size of the device mode left to parse */
630 /* only important on unmarshalling */
633 struct optional_fields
{
636 } opt_fields
[DM_NUM_OPTIONAL_FIELDS
] = {
637 { "icmmethod", NULL
},
638 { "icmintent", NULL
},
639 { "mediatype", NULL
},
640 { "dithertype", NULL
},
641 { "reserved1", NULL
},
642 { "reserved2", NULL
},
643 { "panningwidth", NULL
},
644 { "panningheight", NULL
}
647 /* assign at run time to keep non-gcc vompilers happy */
649 opt_fields
[0].field
= &devmode
->icmmethod
;
650 opt_fields
[1].field
= &devmode
->icmintent
;
651 opt_fields
[2].field
= &devmode
->mediatype
;
652 opt_fields
[3].field
= &devmode
->dithertype
;
653 opt_fields
[4].field
= &devmode
->reserved1
;
654 opt_fields
[5].field
= &devmode
->reserved2
;
655 opt_fields
[6].field
= &devmode
->panningwidth
;
656 opt_fields
[7].field
= &devmode
->panningheight
;
659 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
662 if (UNMARSHALLING(ps
)) {
663 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
664 if (devmode
->devicename
.buffer
== NULL
)
668 if (!prs_uint16uni(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, 32))
671 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
674 /* Sanity Check - look for unknown specversions, but don't fail if we see one.
675 Let the size determine that */
677 switch (devmode
->specversion
) {
684 DEBUG(0,("spoolss_io_devmode: Unknown specversion in devicemode [0x%x]\n",
685 devmode
->specversion
));
686 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
691 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
693 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
695 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
697 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
699 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
701 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
703 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
705 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
707 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
709 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
711 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
713 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
715 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
717 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
719 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
721 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
723 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
726 if (UNMARSHALLING(ps
)) {
727 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
728 if (devmode
->formname
.buffer
== NULL
)
732 if (!prs_uint16uni(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
734 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
736 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
738 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
740 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
742 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
744 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
747 * every device mode I've ever seen on the wire at least has up
748 * to the displayfrequency field. --jerry (05-09-2002)
751 /* add uint32's + uint16's + two UNICODE strings */
753 available_space
= devmode
->size
- (sizeof(uint32
)*6 + sizeof(uint16
)*18 + sizeof(uint16
)*64);
755 /* Sanity check - we only have uint32's left tp parse */
757 if ( available_space
&& ((available_space
% sizeof(uint32
)) != 0) ) {
758 DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n",
759 available_space
, devmode
->size
));
760 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
765 * Conditional parsing. Assume that the DeviceMode has been
766 * zero'd by the caller.
769 while ((available_space
> 0) && (i
< DM_NUM_OPTIONAL_FIELDS
))
771 DEBUG(10, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space
));
772 if (!prs_uint32(opt_fields
[i
].name
, ps
, depth
, opt_fields
[i
].field
))
774 available_space
-= sizeof(uint32
);
778 /* Sanity Check - we should no available space at this point unless
779 MS changes the device mode structure */
781 if (available_space
) {
782 DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n"));
783 DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n",
784 available_space
, devmode
->size
));
785 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
790 if (devmode
->driverextra
!=0) {
791 if (UNMARSHALLING(ps
)) {
792 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
793 if(devmode
->private == NULL
)
795 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
798 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
799 if (!prs_uint8s(False
, "private", ps
, depth
,
800 devmode
->private, devmode
->driverextra
))
807 /*******************************************************************
808 Read or write a DEVICEMODE container
809 ********************************************************************/
811 static BOOL
spoolss_io_devmode_cont(char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
816 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
822 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
825 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
828 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
829 if (UNMARSHALLING(ps
))
830 /* if while reading there is no DEVMODE ... */
835 /* so we have a DEVICEMODE to follow */
836 if (UNMARSHALLING(ps
)) {
837 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
838 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
839 if(dm_c
->devmode
== NULL
)
843 /* this is bad code, shouldn't be there */
844 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
847 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
853 /*******************************************************************
854 ********************************************************************/
856 static BOOL
spoolss_io_printer_default(char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
861 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
864 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
867 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
873 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
879 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
885 /*******************************************************************
887 ********************************************************************/
889 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
890 const fstring printername
,
891 const fstring datatype
,
892 uint32 access_required
,
893 const fstring clientname
,
894 const fstring user_name
)
896 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
897 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
898 init_unistr2(&q_u
->printername
, printername
, strlen(printername
)+1);
900 q_u
->printer_default
.datatype_ptr
= 0;
902 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
903 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
905 q_u
->printer_default
.devmode_cont
.size
=0;
906 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
907 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
908 q_u
->printer_default
.access_required
=access_required
;
910 q_u
->user_ctr
.level
=1;
912 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
913 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
914 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
915 q_u
->user_ctr
.user1
.build
=1381;
916 q_u
->user_ctr
.user1
.major
=2;
917 q_u
->user_ctr
.user1
.minor
=0;
918 q_u
->user_ctr
.user1
.processor
=0;
919 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
920 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
925 /*******************************************************************
927 ********************************************************************/
929 BOOL
make_spoolss_q_addprinterex(
931 SPOOL_Q_ADDPRINTEREX
*q_u
,
932 const char *srv_name
,
933 const char* clientname
,
934 const char* user_name
,
936 PRINTER_INFO_CTR
*ctr
)
938 DEBUG(5,("make_spoolss_q_addprinterex\n"));
940 if (!ctr
) return False
;
944 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
945 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
));
949 q_u
->info
.level
= level
;
950 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
953 /* init q_u->info.info2 from *info */
954 if (!make_spoolss_printer_info_2(mem_ctx
, &q_u
->info
.info_2
, ctr
->printers_2
)) {
955 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
965 q_u
->user_ctr
.level
=1;
967 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
968 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
969 q_u
->user_ctr
.user1
.build
=1381;
970 q_u
->user_ctr
.user1
.major
=2;
971 q_u
->user_ctr
.user1
.minor
=0;
972 q_u
->user_ctr
.user1
.processor
=0;
973 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
974 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
975 q_u
->user_ctr
.user1
.size
=q_u
->user_ctr
.user1
.user_name
.uni_str_len
+
976 q_u
->user_ctr
.user1
.client_name
.uni_str_len
+ 2;
981 /*******************************************************************
982 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
983 *******************************************************************/
985 BOOL
make_spoolss_printer_info_2(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
986 PRINTER_INFO_2
*info
)
989 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
991 /* allocate the necessary memory */
992 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_2
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_2
)))) {
993 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
997 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
998 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
999 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
1000 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
1001 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
1002 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
1003 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
1004 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
1005 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
1006 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
1007 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
1008 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
1009 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
1010 inf
->attributes
= info
->attributes
;
1011 inf
->priority
= info
->priority
;
1012 inf
->default_priority
= info
->defaultpriority
;
1013 inf
->starttime
= info
->starttime
;
1014 inf
->untiltime
= info
->untiltime
;
1015 inf
->cjobs
= info
->cjobs
;
1016 inf
->averageppm
= info
->averageppm
;
1017 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
1018 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
1019 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
1020 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
1021 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
1022 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
1023 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
1024 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
1025 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
1026 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
1027 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
1028 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
1036 /*******************************************************************
1038 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1039 ********************************************************************/
1041 BOOL
spoolss_io_q_open_printer(char *desc
, SPOOL_Q_OPEN_PRINTER
*q_u
, prs_struct
*ps
, int depth
)
1046 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer");
1052 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
1054 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
1060 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1066 /*******************************************************************
1067 * write a structure.
1068 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1069 * called from spoolss_open_printer_ex (cli_spoolss.c)
1070 ********************************************************************/
1072 BOOL
spoolss_io_r_open_printer(char *desc
, SPOOL_R_OPEN_PRINTER
*r_u
, prs_struct
*ps
, int depth
)
1074 if (r_u
== NULL
) return False
;
1076 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer");
1082 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1085 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1092 /*******************************************************************
1094 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1095 ********************************************************************/
1097 BOOL
spoolss_io_q_open_printer_ex(char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
1102 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
1108 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
1110 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
1116 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1119 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
1121 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
1127 /*******************************************************************
1128 * write a structure.
1129 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1130 * called from spoolss_open_printer_ex (cli_spoolss.c)
1131 ********************************************************************/
1133 BOOL
spoolss_io_r_open_printer_ex(char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
1135 if (r_u
== NULL
) return False
;
1137 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
1143 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1146 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1152 /*******************************************************************
1154 ********************************************************************/
1155 BOOL
make_spoolss_q_deleteprinterdriver(
1156 TALLOC_CTX
*mem_ctx
,
1157 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
1163 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1165 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1167 /* these must be NULL terminated or else NT4 will
1168 complain about invalid parameters --jerry */
1169 init_unistr2(&q_u
->server
, server
, strlen(server
)+1);
1170 init_unistr2(&q_u
->arch
, arch
, strlen(arch
)+1);
1171 init_unistr2(&q_u
->driver
, driver
, strlen(driver
)+1);
1178 /*******************************************************************
1180 ********************************************************************/
1182 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
1183 const POLICY_HND
*handle
,
1184 char *valuename
, uint32 size
)
1186 if (q_u
== NULL
) return False
;
1188 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1190 q_u
->handle
= *handle
;
1191 init_unistr2(&q_u
->valuename
, valuename
, strlen(valuename
) + 1);
1197 /*******************************************************************
1199 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1200 ********************************************************************/
1202 BOOL
spoolss_io_q_getprinterdata(char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1207 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1212 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1216 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1220 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1226 /*******************************************************************
1228 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1229 ********************************************************************/
1231 BOOL
spoolss_io_q_deleteprinterdata(char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1236 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1241 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1245 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1251 /*******************************************************************
1252 * write a structure.
1253 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1254 ********************************************************************/
1256 BOOL
spoolss_io_r_deleteprinterdata(char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1258 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1260 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1266 /*******************************************************************
1268 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1269 ********************************************************************/
1271 BOOL
spoolss_io_q_deleteprinterdataex(char *desc
, SPOOL_Q_DELETEPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
1276 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdataex");
1281 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1284 if (!smb_io_unistr2("keyname ", &q_u
->keyname
, True
, ps
, depth
))
1286 if (!smb_io_unistr2("valuename", &q_u
->valuename
, True
, ps
, depth
))
1292 /*******************************************************************
1293 * write a structure.
1294 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1295 ********************************************************************/
1297 BOOL
spoolss_io_r_deleteprinterdataex(char *desc
, SPOOL_R_DELETEPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
1299 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdataex");
1302 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1308 /*******************************************************************
1309 * write a structure.
1310 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1311 ********************************************************************/
1313 BOOL
spoolss_io_r_getprinterdata(char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1318 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1323 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1325 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1328 if (UNMARSHALLING(ps
) && r_u
->size
) {
1329 r_u
->data
= prs_alloc_mem(ps
, r_u
->size
);
1334 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
1340 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1342 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1348 /*******************************************************************
1350 ********************************************************************/
1352 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1354 if (q_u
== NULL
) return False
;
1356 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1358 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1363 /*******************************************************************
1365 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1366 * called from spoolss_abortprinter (cli_spoolss.c)
1367 ********************************************************************/
1369 BOOL
spoolss_io_q_abortprinter(char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1371 if (q_u
== NULL
) return False
;
1373 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1379 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1385 /*******************************************************************
1386 * write a structure.
1387 * called from spoolss_r_abortprinter (srv_spoolss.c)
1388 ********************************************************************/
1390 BOOL
spoolss_io_r_abortprinter(char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1392 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1394 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1400 /*******************************************************************
1402 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1403 * called from spoolss_deleteprinter (cli_spoolss.c)
1404 ********************************************************************/
1406 BOOL
spoolss_io_q_deleteprinter(char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1408 if (q_u
== NULL
) return False
;
1410 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1416 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1422 /*******************************************************************
1423 * write a structure.
1424 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1425 * called from spoolss_deleteprinter (cli_spoolss.c)
1426 ********************************************************************/
1428 BOOL
spoolss_io_r_deleteprinter(char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1430 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1436 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1438 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1445 /*******************************************************************
1447 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1448 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1449 ********************************************************************/
1451 BOOL
spoolss_io_q_deleteprinterdriver(char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1453 if (q_u
== NULL
) return False
;
1455 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1461 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1463 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1465 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1467 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1475 /*******************************************************************
1476 * write a structure.
1477 ********************************************************************/
1478 BOOL
spoolss_io_r_deleteprinterdriver(char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1480 if (r_u
== NULL
) return False
;
1482 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1488 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1495 /*******************************************************************
1497 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1498 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1499 ********************************************************************/
1501 BOOL
spoolss_io_q_deleteprinterdriverex(char *desc
, SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
1503 if (q_u
== NULL
) return False
;
1505 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriverex");
1511 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1513 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1515 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1517 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1519 if(!prs_uint32("delete_flags ", ps
, depth
, &q_u
->delete_flags
))
1521 if(!prs_uint32("version ", ps
, depth
, &q_u
->version
))
1529 /*******************************************************************
1530 * write a structure.
1531 ********************************************************************/
1532 BOOL
spoolss_io_r_deleteprinterdriverex(char *desc
, SPOOL_R_DELETEPRINTERDRIVEREX
*r_u
, prs_struct
*ps
, int depth
)
1534 if (r_u
== NULL
) return False
;
1536 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriverex");
1542 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1550 /*******************************************************************
1552 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1553 * called from spoolss_closeprinter (cli_spoolss.c)
1554 ********************************************************************/
1556 BOOL
spoolss_io_q_closeprinter(char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1558 if (q_u
== NULL
) return False
;
1560 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1566 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1572 /*******************************************************************
1573 * write a structure.
1574 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1575 * called from spoolss_closeprinter (cli_spoolss.c)
1576 ********************************************************************/
1578 BOOL
spoolss_io_r_closeprinter(char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1580 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1586 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1588 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1594 /*******************************************************************
1596 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1597 ********************************************************************/
1599 BOOL
spoolss_io_q_startdocprinter(char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1601 if (q_u
== NULL
) return False
;
1603 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1609 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1612 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1618 /*******************************************************************
1619 * write a structure.
1620 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1621 ********************************************************************/
1623 BOOL
spoolss_io_r_startdocprinter(char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1625 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1627 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1629 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1635 /*******************************************************************
1637 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1638 ********************************************************************/
1640 BOOL
spoolss_io_q_enddocprinter(char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1642 if (q_u
== NULL
) return False
;
1644 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1650 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1656 /*******************************************************************
1657 * write a structure.
1658 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1659 ********************************************************************/
1661 BOOL
spoolss_io_r_enddocprinter(char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1663 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1665 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1671 /*******************************************************************
1673 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1674 ********************************************************************/
1676 BOOL
spoolss_io_q_startpageprinter(char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1678 if (q_u
== NULL
) return False
;
1680 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1686 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1692 /*******************************************************************
1693 * write a structure.
1694 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1695 ********************************************************************/
1697 BOOL
spoolss_io_r_startpageprinter(char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1699 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1701 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1707 /*******************************************************************
1709 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1710 ********************************************************************/
1712 BOOL
spoolss_io_q_endpageprinter(char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1714 if (q_u
== NULL
) return False
;
1716 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1722 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1728 /*******************************************************************
1729 * write a structure.
1730 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1731 ********************************************************************/
1733 BOOL
spoolss_io_r_endpageprinter(char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1735 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1737 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1743 /*******************************************************************
1745 * called from spoolss_q_writeprinter (srv_spoolss.c)
1746 ********************************************************************/
1748 BOOL
spoolss_io_q_writeprinter(char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1750 if (q_u
== NULL
) return False
;
1752 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1758 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1760 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1763 if (q_u
->buffer_size
!=0)
1765 if (UNMARSHALLING(ps
))
1766 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1767 if(q_u
->buffer
== NULL
)
1769 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1774 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1780 /*******************************************************************
1781 * write a structure.
1782 * called from spoolss_r_writeprinter (srv_spoolss.c)
1783 ********************************************************************/
1785 BOOL
spoolss_io_r_writeprinter(char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1787 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1789 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1791 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1797 /*******************************************************************
1799 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1800 ********************************************************************/
1802 BOOL
spoolss_io_q_rffpcnex(char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1804 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1810 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1812 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1814 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1816 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1818 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1824 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1827 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1830 if (q_u
->option_ptr
!=0) {
1832 if (UNMARSHALLING(ps
))
1833 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1836 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1843 /*******************************************************************
1844 * write a structure.
1845 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1846 ********************************************************************/
1848 BOOL
spoolss_io_r_rffpcnex(char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1850 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1853 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1859 /*******************************************************************
1861 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1862 ********************************************************************/
1864 BOOL
spoolss_io_q_rfnpcnex(char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1866 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1872 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1875 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1878 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1881 if (q_u
->option_ptr
!=0) {
1883 if (UNMARSHALLING(ps
))
1884 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1887 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1894 /*******************************************************************
1895 * write a structure.
1896 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1897 ********************************************************************/
1899 BOOL
spoolss_io_r_rfnpcnex(char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1901 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1907 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1910 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1915 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1921 /*******************************************************************
1922 * return the length of a uint16 (obvious, but the code is clean)
1923 ********************************************************************/
1925 static uint32
size_of_uint16(uint16
*value
)
1927 return (sizeof(*value
));
1930 /*******************************************************************
1931 * return the length of a uint32 (obvious, but the code is clean)
1932 ********************************************************************/
1934 static uint32
size_of_uint32(uint32
*value
)
1936 return (sizeof(*value
));
1939 /*******************************************************************
1940 * return the length of a NTTIME (obvious, but the code is clean)
1941 ********************************************************************/
1943 static uint32
size_of_nttime(NTTIME
*value
)
1945 return (sizeof(*value
));
1948 /*******************************************************************
1949 * return the length of a UNICODE string in number of char, includes:
1950 * - the leading zero
1951 * - the relative pointer size
1952 ********************************************************************/
1954 static uint32
size_of_relative_string(UNISTR
*string
)
1958 size
=str_len_uni(string
); /* the string length */
1959 size
=size
+1; /* add the trailing zero */
1960 size
=size
*2; /* convert in char */
1961 size
=size
+4; /* add the size of the ptr */
1965 * Do not include alignment as Win2k does not align relative
1966 * strings within a buffer --jerry
1968 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1969 /* size += ((4 - (size & 3)) & 3); */
1975 /*******************************************************************
1976 * return the length of a uint32 (obvious, but the code is clean)
1977 ********************************************************************/
1979 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1984 return (4+devmode
->size
+devmode
->driverextra
);
1987 /*******************************************************************
1988 * return the length of a uint32 (obvious, but the code is clean)
1989 ********************************************************************/
1991 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1996 return (sizeof(SYSTEMTIME
) +4);
1999 /*******************************************************************
2000 * write a UNICODE string and its relative pointer.
2001 * used by all the RPC structs passing a buffer
2003 * As I'm a nice guy, I'm forcing myself to explain this code.
2004 * MS did a good job in the overall spoolss code except in some
2005 * functions where they are passing the API buffer directly in the
2006 * RPC request/reply. That's to maintain compatiility at the API level.
2007 * They could have done it the good way the first time.
2009 * So what happen is: the strings are written at the buffer's end,
2010 * in the reverse order of the original structure. Some pointers to
2011 * the strings are also in the buffer. Those are relative to the
2014 * If you don't understand or want to change that function,
2015 * first get in touch with me: jfm@samba.org
2017 ********************************************************************/
2019 static BOOL
smb_io_relstr(char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
2021 prs_struct
*ps
=&buffer
->prs
;
2023 if (MARSHALLING(ps
)) {
2024 uint32 struct_offset
= prs_offset(ps
);
2025 uint32 relative_offset
;
2027 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
2028 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2032 * Win2k does not align strings in a buffer
2033 * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry
2038 buffer
->string_at_end
= prs_offset(ps
);
2040 /* write the string */
2041 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2044 if(!prs_set_offset(ps
, struct_offset
))
2047 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2048 /* write its offset */
2049 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2055 /* read the offset */
2056 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
2059 old_offset
= prs_offset(ps
);
2060 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
2063 /* read the string */
2064 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2067 if(!prs_set_offset(ps
, old_offset
))
2073 /*******************************************************************
2074 * write a array of UNICODE strings and its relative pointer.
2075 * used by 2 RPC structs
2076 ********************************************************************/
2078 static BOOL
smb_io_relarraystr(char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
2082 prs_struct
*ps
=&buffer
->prs
;
2084 if (MARSHALLING(ps
)) {
2085 uint32 struct_offset
= prs_offset(ps
);
2086 uint32 relative_offset
;
2093 /* first write the last 0 */
2094 buffer
->string_at_end
-= 2;
2095 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2098 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
2101 while (p
&& (*p
!=0)) {
2105 /* Yes this should be malloc not talloc. Don't change. */
2107 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
2108 if (chaine
.buffer
== NULL
)
2111 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
2113 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
2115 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
2116 SAFE_FREE(chaine
.buffer
);
2120 /* write the string */
2121 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
2122 SAFE_FREE(chaine
.buffer
);
2128 SAFE_FREE(chaine
.buffer
);
2131 if(!prs_set_offset(ps
, struct_offset
))
2134 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2135 /* write its offset */
2136 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2144 uint16
*chaine2
=NULL
;
2147 size_t realloc_size
= 0;
2151 /* read the offset */
2152 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2155 old_offset
= prs_offset(ps
);
2156 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2160 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
))
2163 l_chaine
=str_len_uni(&chaine
);
2165 /* we're going to add two more bytes here in case this
2166 is the last string in the array and we need to add
2167 an extra NULL for termination */
2172 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
2174 /* Yes this should be realloc - it's freed below. JRA */
2176 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
2181 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
2182 l_chaine2
+=l_chaine
+1;
2185 } while(l_chaine
!=0);
2187 /* the end should be bould NULL terminated so add
2188 the second one here */
2191 chaine2
[l_chaine2
] = '\0';
2192 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
2196 if(!prs_set_offset(ps
, old_offset
))
2202 /*******************************************************************
2203 Parse a DEVMODE structure and its relative pointer.
2204 ********************************************************************/
2206 static BOOL
smb_io_relsecdesc(char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
2208 prs_struct
*ps
= &buffer
->prs
;
2210 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
2213 if (MARSHALLING(ps
)) {
2214 uint32 struct_offset
= prs_offset(ps
);
2215 uint32 relative_offset
;
2218 relative_offset
= 0;
2219 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2224 if (*secdesc
!= NULL
) {
2225 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
2227 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2229 /* write the secdesc */
2230 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2233 if(!prs_set_offset(ps
, struct_offset
))
2237 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2238 /* write its offset */
2240 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2245 /* read the offset */
2246 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2249 old_offset
= prs_offset(ps
);
2250 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2254 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2257 if(!prs_set_offset(ps
, old_offset
))
2263 /*******************************************************************
2264 Parse a DEVMODE structure and its relative pointer.
2265 ********************************************************************/
2267 static BOOL
smb_io_reldevmode(char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2269 prs_struct
*ps
=&buffer
->prs
;
2271 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2274 if (MARSHALLING(ps
)) {
2275 uint32 struct_offset
= prs_offset(ps
);
2276 uint32 relative_offset
;
2278 if (*devmode
== NULL
) {
2280 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2282 DEBUG(8, ("boing, the devmode was NULL\n"));
2287 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2289 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2292 /* write the DEVMODE */
2293 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2296 if(!prs_set_offset(ps
, struct_offset
))
2299 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2300 /* write its offset */
2301 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2307 /* read the offset */
2308 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2310 if (buffer
->string_at_end
== 0) {
2315 old_offset
= prs_offset(ps
);
2316 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2319 /* read the string */
2320 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2322 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2325 if(!prs_set_offset(ps
, old_offset
))
2331 /*******************************************************************
2332 Parse a PRINTER_INFO_0 structure.
2333 ********************************************************************/
2335 BOOL
smb_io_printer_info_0(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2337 prs_struct
*ps
=&buffer
->prs
;
2339 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2342 buffer
->struct_start
=prs_offset(ps
);
2344 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2346 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2349 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2351 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2353 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2356 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2358 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2360 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2362 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2364 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2366 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2368 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2370 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2373 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2375 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2378 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2380 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2382 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2384 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2386 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2388 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2390 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2392 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2394 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2396 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2398 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2400 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2402 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2404 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2406 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2408 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2410 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2412 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2414 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2416 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2418 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2420 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2422 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2424 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2426 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2432 /*******************************************************************
2433 Parse a PRINTER_INFO_1 structure.
2434 ********************************************************************/
2436 BOOL
smb_io_printer_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2438 prs_struct
*ps
=&buffer
->prs
;
2440 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2443 buffer
->struct_start
=prs_offset(ps
);
2445 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2447 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2449 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2451 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2457 /*******************************************************************
2458 Parse a PRINTER_INFO_2 structure.
2459 ********************************************************************/
2461 BOOL
smb_io_printer_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2463 prs_struct
*ps
=&buffer
->prs
;
2464 uint32 dm_offset
, sd_offset
, current_offset
;
2465 uint32 dummy_value
= 0;
2467 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2470 buffer
->struct_start
=prs_offset(ps
);
2472 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2474 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2476 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2478 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2480 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2482 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2484 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2487 /* save current offset and wind forwared by a uint32 */
2488 dm_offset
= prs_offset(ps
);
2489 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
2492 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2494 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2496 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2498 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2501 /* save current offset for the sec_desc */
2502 sd_offset
= prs_offset(ps
);
2503 if (!prs_uint32("sec_desc", ps
, depth
, &dummy_value
))
2507 /* save current location so we can pick back up here */
2508 current_offset
= prs_offset(ps
);
2510 /* parse the devmode */
2511 if (!prs_set_offset(ps
, dm_offset
))
2513 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2516 /* parse the sec_desc */
2517 if (!prs_set_offset(ps
, sd_offset
))
2519 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2522 /* pick up where we left off */
2523 if (!prs_set_offset(ps
, current_offset
))
2526 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2528 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2530 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2532 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2534 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2536 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2538 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2540 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2546 /*******************************************************************
2547 Parse a PRINTER_INFO_3 structure.
2548 ********************************************************************/
2550 BOOL
smb_io_printer_info_3(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2552 prs_struct
*ps
=&buffer
->prs
;
2554 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2557 buffer
->struct_start
=prs_offset(ps
);
2559 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2561 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2567 /*******************************************************************
2568 Parse a PRINTER_INFO_4 structure.
2569 ********************************************************************/
2571 BOOL
smb_io_printer_info_4(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2573 prs_struct
*ps
=&buffer
->prs
;
2575 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2578 buffer
->struct_start
=prs_offset(ps
);
2580 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2582 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2584 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2589 /*******************************************************************
2590 Parse a PRINTER_INFO_5 structure.
2591 ********************************************************************/
2593 BOOL
smb_io_printer_info_5(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2595 prs_struct
*ps
=&buffer
->prs
;
2597 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2600 buffer
->struct_start
=prs_offset(ps
);
2602 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2604 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2606 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2608 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2610 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2615 /*******************************************************************
2616 Parse a PORT_INFO_1 structure.
2617 ********************************************************************/
2619 BOOL
smb_io_port_info_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2621 prs_struct
*ps
=&buffer
->prs
;
2623 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2626 buffer
->struct_start
=prs_offset(ps
);
2628 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2634 /*******************************************************************
2635 Parse a PORT_INFO_2 structure.
2636 ********************************************************************/
2638 BOOL
smb_io_port_info_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2640 prs_struct
*ps
=&buffer
->prs
;
2642 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2645 buffer
->struct_start
=prs_offset(ps
);
2647 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2649 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2651 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2653 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2655 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2661 /*******************************************************************
2662 Parse a DRIVER_INFO_1 structure.
2663 ********************************************************************/
2665 BOOL
smb_io_printer_driver_info_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2667 prs_struct
*ps
=&buffer
->prs
;
2669 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2672 buffer
->struct_start
=prs_offset(ps
);
2674 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2680 /*******************************************************************
2681 Parse a DRIVER_INFO_2 structure.
2682 ********************************************************************/
2684 BOOL
smb_io_printer_driver_info_2(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2686 prs_struct
*ps
=&buffer
->prs
;
2688 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2691 buffer
->struct_start
=prs_offset(ps
);
2693 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2695 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2697 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2699 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2701 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2703 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2709 /*******************************************************************
2710 Parse a DRIVER_INFO_3 structure.
2711 ********************************************************************/
2713 BOOL
smb_io_printer_driver_info_3(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2715 prs_struct
*ps
=&buffer
->prs
;
2717 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2720 buffer
->struct_start
=prs_offset(ps
);
2722 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2724 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2726 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2728 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2730 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2732 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2734 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2737 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2740 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2742 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2748 /*******************************************************************
2749 Parse a DRIVER_INFO_6 structure.
2750 ********************************************************************/
2752 BOOL
smb_io_printer_driver_info_6(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2754 prs_struct
*ps
=&buffer
->prs
;
2756 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2759 buffer
->struct_start
=prs_offset(ps
);
2761 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2763 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2765 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2767 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2769 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2771 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2773 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2776 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2779 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2781 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2784 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2787 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2789 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2792 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2795 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2798 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2801 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2803 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2805 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2807 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2813 /*******************************************************************
2814 Parse a JOB_INFO_1 structure.
2815 ********************************************************************/
2817 BOOL
smb_io_job_info_1(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2819 prs_struct
*ps
=&buffer
->prs
;
2821 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2824 buffer
->struct_start
=prs_offset(ps
);
2826 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2828 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2830 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2832 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2834 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2836 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2838 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2840 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2842 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2844 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2846 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2848 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2850 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2856 /*******************************************************************
2857 Parse a JOB_INFO_2 structure.
2858 ********************************************************************/
2860 BOOL
smb_io_job_info_2(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2863 prs_struct
*ps
=&buffer
->prs
;
2865 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2868 buffer
->struct_start
=prs_offset(ps
);
2870 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2872 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2874 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2876 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2878 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2880 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2882 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2885 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2887 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2889 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2891 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2893 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2896 /* SEC_DESC sec_desc;*/
2897 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2900 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2902 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2904 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2906 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2908 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2910 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2912 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2914 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2916 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2918 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2924 /*******************************************************************
2925 ********************************************************************/
2927 BOOL
smb_io_form_1(char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2929 prs_struct
*ps
=&buffer
->prs
;
2931 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
2934 buffer
->struct_start
=prs_offset(ps
);
2936 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2939 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2942 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2944 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2946 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2948 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2950 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2952 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2958 /*******************************************************************
2959 Read/write a BUFFER struct.
2960 ********************************************************************/
2962 static BOOL
spoolss_io_buffer(char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
2964 NEW_BUFFER
*buffer
= *pp_buffer
;
2966 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
2969 if (UNMARSHALLING(ps
))
2970 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
2975 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2979 if (UNMARSHALLING(ps
)) {
2981 buffer
->string_at_end
=0;
2983 if (buffer
->ptr
==0) {
2985 * JRA. I'm not sure if the data in here is in big-endian format if
2986 * the client is big-endian. Leave as default (little endian) for now.
2989 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
2994 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2998 * JRA. I'm not sure if the data in here is in big-endian format if
2999 * the client is big-endian. Leave as default (little endian) for now.
3002 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
3005 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
3008 if (!prs_set_offset(&buffer
->prs
, 0))
3011 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
3014 buffer
->string_at_end
=buffer
->size
;
3022 if (buffer
->ptr
==0) {
3023 /* We have finished with the data in buffer->prs - free it. */
3024 prs_mem_free(&buffer
->prs
);
3028 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3031 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
3037 /* We have finished with the data in buffer->prs - free it. */
3038 prs_mem_free(&buffer
->prs
);
3044 /*******************************************************************
3045 move a BUFFER from the query to the reply.
3046 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
3047 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
3048 Clears the memory to zero also.
3049 ********************************************************************/
3051 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
3053 prs_switch_type(&src
->prs
, MARSHALL
);
3054 if(!prs_set_offset(&src
->prs
, 0))
3056 prs_force_dynamic(&src
->prs
);
3057 prs_mem_clear(&src
->prs
);
3061 /*******************************************************************
3062 Get the size of a BUFFER struct.
3063 ********************************************************************/
3065 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
3067 return (buffer
->size
);
3070 /*******************************************************************
3071 Parse a DRIVER_DIRECTORY_1 structure.
3072 ********************************************************************/
3074 BOOL
smb_io_driverdir_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
3076 prs_struct
*ps
=&buffer
->prs
;
3078 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
3081 buffer
->struct_start
=prs_offset(ps
);
3083 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
3089 /*******************************************************************
3090 Parse a PORT_INFO_1 structure.
3091 ********************************************************************/
3093 BOOL
smb_io_port_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
3095 prs_struct
*ps
=&buffer
->prs
;
3097 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
3100 buffer
->struct_start
=prs_offset(ps
);
3102 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3108 /*******************************************************************
3109 Parse a PORT_INFO_2 structure.
3110 ********************************************************************/
3112 BOOL
smb_io_port_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
3114 prs_struct
*ps
=&buffer
->prs
;
3116 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
3119 buffer
->struct_start
=prs_offset(ps
);
3121 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3123 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
3125 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
3127 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
3129 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
3135 /*******************************************************************
3136 ********************************************************************/
3138 BOOL
smb_io_printprocessor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
3140 prs_struct
*ps
=&buffer
->prs
;
3142 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
3145 buffer
->struct_start
=prs_offset(ps
);
3147 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3153 /*******************************************************************
3154 ********************************************************************/
3156 BOOL
smb_io_printprocdatatype_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
3158 prs_struct
*ps
=&buffer
->prs
;
3160 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
3163 buffer
->struct_start
=prs_offset(ps
);
3165 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3171 /*******************************************************************
3172 ********************************************************************/
3174 BOOL
smb_io_printmonitor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
3176 prs_struct
*ps
=&buffer
->prs
;
3178 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
3181 buffer
->struct_start
=prs_offset(ps
);
3183 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3189 /*******************************************************************
3190 ********************************************************************/
3192 BOOL
smb_io_printmonitor_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
3194 prs_struct
*ps
=&buffer
->prs
;
3196 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
3199 buffer
->struct_start
=prs_offset(ps
);
3201 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3203 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
3205 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
3211 /*******************************************************************
3212 return the size required by a struct in the stream
3213 ********************************************************************/
3215 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
3219 size
+=size_of_relative_string( &info
->printername
);
3220 size
+=size_of_relative_string( &info
->servername
);
3222 size
+=size_of_uint32( &info
->cjobs
);
3223 size
+=size_of_uint32( &info
->total_jobs
);
3224 size
+=size_of_uint32( &info
->total_bytes
);
3226 size
+=size_of_uint16( &info
->year
);
3227 size
+=size_of_uint16( &info
->month
);
3228 size
+=size_of_uint16( &info
->dayofweek
);
3229 size
+=size_of_uint16( &info
->day
);
3230 size
+=size_of_uint16( &info
->hour
);
3231 size
+=size_of_uint16( &info
->minute
);
3232 size
+=size_of_uint16( &info
->second
);
3233 size
+=size_of_uint16( &info
->milliseconds
);
3235 size
+=size_of_uint32( &info
->global_counter
);
3236 size
+=size_of_uint32( &info
->total_pages
);
3238 size
+=size_of_uint16( &info
->major_version
);
3239 size
+=size_of_uint16( &info
->build_version
);
3241 size
+=size_of_uint32( &info
->unknown7
);
3242 size
+=size_of_uint32( &info
->unknown8
);
3243 size
+=size_of_uint32( &info
->unknown9
);
3244 size
+=size_of_uint32( &info
->session_counter
);
3245 size
+=size_of_uint32( &info
->unknown11
);
3246 size
+=size_of_uint32( &info
->printer_errors
);
3247 size
+=size_of_uint32( &info
->unknown13
);
3248 size
+=size_of_uint32( &info
->unknown14
);
3249 size
+=size_of_uint32( &info
->unknown15
);
3250 size
+=size_of_uint32( &info
->unknown16
);
3251 size
+=size_of_uint32( &info
->change_id
);
3252 size
+=size_of_uint32( &info
->unknown18
);
3253 size
+=size_of_uint32( &info
->status
);
3254 size
+=size_of_uint32( &info
->unknown20
);
3255 size
+=size_of_uint32( &info
->c_setprinter
);
3257 size
+=size_of_uint16( &info
->unknown22
);
3258 size
+=size_of_uint16( &info
->unknown23
);
3259 size
+=size_of_uint16( &info
->unknown24
);
3260 size
+=size_of_uint16( &info
->unknown25
);
3261 size
+=size_of_uint16( &info
->unknown26
);
3262 size
+=size_of_uint16( &info
->unknown27
);
3263 size
+=size_of_uint16( &info
->unknown28
);
3264 size
+=size_of_uint16( &info
->unknown29
);
3269 /*******************************************************************
3270 return the size required by a struct in the stream
3271 ********************************************************************/
3273 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3277 size
+=size_of_uint32( &info
->flags
);
3278 size
+=size_of_relative_string( &info
->description
);
3279 size
+=size_of_relative_string( &info
->name
);
3280 size
+=size_of_relative_string( &info
->comment
);
3285 /*******************************************************************
3286 return the size required by a struct in the stream
3287 ********************************************************************/
3289 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3295 size
+= sec_desc_size( info
->secdesc
);
3297 size
+=size_of_device_mode( info
->devmode
);
3299 size
+=size_of_relative_string( &info
->servername
);
3300 size
+=size_of_relative_string( &info
->printername
);
3301 size
+=size_of_relative_string( &info
->sharename
);
3302 size
+=size_of_relative_string( &info
->portname
);
3303 size
+=size_of_relative_string( &info
->drivername
);
3304 size
+=size_of_relative_string( &info
->comment
);
3305 size
+=size_of_relative_string( &info
->location
);
3307 size
+=size_of_relative_string( &info
->sepfile
);
3308 size
+=size_of_relative_string( &info
->printprocessor
);
3309 size
+=size_of_relative_string( &info
->datatype
);
3310 size
+=size_of_relative_string( &info
->parameters
);
3312 size
+=size_of_uint32( &info
->attributes
);
3313 size
+=size_of_uint32( &info
->priority
);
3314 size
+=size_of_uint32( &info
->defaultpriority
);
3315 size
+=size_of_uint32( &info
->starttime
);
3316 size
+=size_of_uint32( &info
->untiltime
);
3317 size
+=size_of_uint32( &info
->status
);
3318 size
+=size_of_uint32( &info
->cjobs
);
3319 size
+=size_of_uint32( &info
->averageppm
);
3322 * add any adjustments for alignment. This is
3323 * not optimal since we could be calling this
3324 * function from a loop (e.g. enumprinters), but
3325 * it is easier to maintain the calculation here and
3326 * not place the burden on the caller to remember. --jerry
3333 /*******************************************************************
3334 return the size required by a struct in the stream
3335 ********************************************************************/
3337 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3341 size
+=size_of_relative_string( &info
->printername
);
3342 size
+=size_of_relative_string( &info
->servername
);
3344 size
+=size_of_uint32( &info
->attributes
);
3348 /*******************************************************************
3349 return the size required by a struct in the stream
3350 ********************************************************************/
3352 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3356 size
+=size_of_relative_string( &info
->printername
);
3357 size
+=size_of_relative_string( &info
->portname
);
3359 size
+=size_of_uint32( &info
->attributes
);
3360 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3361 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3366 /*******************************************************************
3367 return the size required by a struct in the stream
3368 ********************************************************************/
3370 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3372 /* The 4 is for the self relative pointer.. */
3373 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3374 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3377 /*******************************************************************
3378 return the size required by a struct in the stream
3379 ********************************************************************/
3381 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3384 size
+=size_of_relative_string( &info
->name
);
3389 /*******************************************************************
3390 return the size required by a struct in the stream
3391 ********************************************************************/
3393 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3396 size
+=size_of_uint32( &info
->version
);
3397 size
+=size_of_relative_string( &info
->name
);
3398 size
+=size_of_relative_string( &info
->architecture
);
3399 size
+=size_of_relative_string( &info
->driverpath
);
3400 size
+=size_of_relative_string( &info
->datafile
);
3401 size
+=size_of_relative_string( &info
->configfile
);
3406 /*******************************************************************
3407 return the size required by a string array.
3408 ********************************************************************/
3410 uint32
spoolss_size_string_array(uint16
*string
)
3415 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3417 i
=i
+2; /* to count all chars including the leading zero */
3418 i
=2*i
; /* because we need the value in bytes */
3419 i
=i
+4; /* the offset pointer size */
3424 /*******************************************************************
3425 return the size required by a struct in the stream
3426 ********************************************************************/
3428 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3432 size
+=size_of_uint32( &info
->version
);
3433 size
+=size_of_relative_string( &info
->name
);
3434 size
+=size_of_relative_string( &info
->architecture
);
3435 size
+=size_of_relative_string( &info
->driverpath
);
3436 size
+=size_of_relative_string( &info
->datafile
);
3437 size
+=size_of_relative_string( &info
->configfile
);
3438 size
+=size_of_relative_string( &info
->helpfile
);
3439 size
+=size_of_relative_string( &info
->monitorname
);
3440 size
+=size_of_relative_string( &info
->defaultdatatype
);
3442 size
+=spoolss_size_string_array(info
->dependentfiles
);
3447 /*******************************************************************
3448 return the size required by a struct in the stream
3449 ********************************************************************/
3451 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3455 size
+=size_of_uint32( &info
->version
);
3456 size
+=size_of_relative_string( &info
->name
);
3457 size
+=size_of_relative_string( &info
->architecture
);
3458 size
+=size_of_relative_string( &info
->driverpath
);
3459 size
+=size_of_relative_string( &info
->datafile
);
3460 size
+=size_of_relative_string( &info
->configfile
);
3461 size
+=size_of_relative_string( &info
->helpfile
);
3463 size
+=spoolss_size_string_array(info
->dependentfiles
);
3465 size
+=size_of_relative_string( &info
->monitorname
);
3466 size
+=size_of_relative_string( &info
->defaultdatatype
);
3468 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3470 size
+=size_of_nttime(&info
->driver_date
);
3471 size
+=size_of_uint32( &info
->padding
);
3472 size
+=size_of_uint32( &info
->driver_version_low
);
3473 size
+=size_of_uint32( &info
->driver_version_high
);
3474 size
+=size_of_relative_string( &info
->mfgname
);
3475 size
+=size_of_relative_string( &info
->oem_url
);
3476 size
+=size_of_relative_string( &info
->hardware_id
);
3477 size
+=size_of_relative_string( &info
->provider
);
3482 /*******************************************************************
3483 return the size required by a struct in the stream
3484 ********************************************************************/
3486 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3489 size
+=size_of_uint32( &info
->jobid
);
3490 size
+=size_of_relative_string( &info
->printername
);
3491 size
+=size_of_relative_string( &info
->machinename
);
3492 size
+=size_of_relative_string( &info
->username
);
3493 size
+=size_of_relative_string( &info
->document
);
3494 size
+=size_of_relative_string( &info
->datatype
);
3495 size
+=size_of_relative_string( &info
->text_status
);
3496 size
+=size_of_uint32( &info
->status
);
3497 size
+=size_of_uint32( &info
->priority
);
3498 size
+=size_of_uint32( &info
->position
);
3499 size
+=size_of_uint32( &info
->totalpages
);
3500 size
+=size_of_uint32( &info
->pagesprinted
);
3501 size
+=size_of_systemtime( &info
->submitted
);
3506 /*******************************************************************
3507 return the size required by a struct in the stream
3508 ********************************************************************/
3510 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3514 size
+=4; /* size of sec desc ptr */
3516 size
+=size_of_uint32( &info
->jobid
);
3517 size
+=size_of_relative_string( &info
->printername
);
3518 size
+=size_of_relative_string( &info
->machinename
);
3519 size
+=size_of_relative_string( &info
->username
);
3520 size
+=size_of_relative_string( &info
->document
);
3521 size
+=size_of_relative_string( &info
->notifyname
);
3522 size
+=size_of_relative_string( &info
->datatype
);
3523 size
+=size_of_relative_string( &info
->printprocessor
);
3524 size
+=size_of_relative_string( &info
->parameters
);
3525 size
+=size_of_relative_string( &info
->drivername
);
3526 size
+=size_of_device_mode( info
->devmode
);
3527 size
+=size_of_relative_string( &info
->text_status
);
3528 /* SEC_DESC sec_desc;*/
3529 size
+=size_of_uint32( &info
->status
);
3530 size
+=size_of_uint32( &info
->priority
);
3531 size
+=size_of_uint32( &info
->position
);
3532 size
+=size_of_uint32( &info
->starttime
);
3533 size
+=size_of_uint32( &info
->untiltime
);
3534 size
+=size_of_uint32( &info
->totalpages
);
3535 size
+=size_of_uint32( &info
->size
);
3536 size
+=size_of_systemtime( &info
->submitted
);
3537 size
+=size_of_uint32( &info
->timeelapsed
);
3538 size
+=size_of_uint32( &info
->pagesprinted
);
3543 /*******************************************************************
3544 return the size required by a struct in the stream
3545 ********************************************************************/
3547 uint32
spoolss_size_form_1(FORM_1
*info
)
3551 size
+=size_of_uint32( &info
->flag
);
3552 size
+=size_of_relative_string( &info
->name
);
3553 size
+=size_of_uint32( &info
->width
);
3554 size
+=size_of_uint32( &info
->length
);
3555 size
+=size_of_uint32( &info
->left
);
3556 size
+=size_of_uint32( &info
->top
);
3557 size
+=size_of_uint32( &info
->right
);
3558 size
+=size_of_uint32( &info
->bottom
);
3563 /*******************************************************************
3564 return the size required by a struct in the stream
3565 ********************************************************************/
3567 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3571 size
+=size_of_relative_string( &info
->port_name
);
3576 /*******************************************************************
3577 return the size required by a struct in the stream
3578 ********************************************************************/
3580 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3584 size
=str_len_uni(&info
->name
); /* the string length */
3585 size
=size
+1; /* add the leading zero */
3586 size
=size
*2; /* convert in char */
3591 /*******************************************************************
3592 return the size required by a struct in the stream
3593 ********************************************************************/
3595 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3599 size
=str_len_uni(&info
->name
); /* the string length */
3600 size
=size
+1; /* add the leading zero */
3601 size
=size
*2; /* convert in char */
3606 /*******************************************************************
3607 return the size required by a struct in the stream
3608 ********************************************************************/
3610 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3614 size
+=size_of_relative_string( &info
->port_name
);
3615 size
+=size_of_relative_string( &info
->monitor_name
);
3616 size
+=size_of_relative_string( &info
->description
);
3618 size
+=size_of_uint32( &info
->port_type
);
3619 size
+=size_of_uint32( &info
->reserved
);
3624 /*******************************************************************
3625 return the size required by a struct in the stream
3626 ********************************************************************/
3628 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3631 size
+=size_of_relative_string( &info
->name
);
3636 /*******************************************************************
3637 return the size required by a struct in the stream
3638 ********************************************************************/
3640 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3643 size
+=size_of_relative_string( &info
->name
);
3648 /*******************************************************************
3649 return the size required by a struct in the stream
3650 ********************************************************************/
3651 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3658 /* uint32(offset) + uint32(length) + length) */
3659 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3660 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
;
3662 size
+= size_of_uint32(&p
->type
);
3667 /*******************************************************************
3668 return the size required by a struct in the stream
3669 ********************************************************************/
3671 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3674 size
+=size_of_relative_string( &info
->name
);
3679 /*******************************************************************
3680 return the size required by a struct in the stream
3681 ********************************************************************/
3683 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3686 size
+=size_of_relative_string( &info
->name
);
3687 size
+=size_of_relative_string( &info
->environment
);
3688 size
+=size_of_relative_string( &info
->dll_name
);
3693 /*******************************************************************
3695 ********************************************************************/
3697 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3698 const POLICY_HND
*hnd
,
3699 const fstring architecture
,
3700 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3701 NEW_BUFFER
*buffer
, uint32 offered
)
3706 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3708 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3711 q_u
->clientmajorversion
=clientmajor
;
3712 q_u
->clientminorversion
=clientminor
;
3715 q_u
->offered
=offered
;
3720 /*******************************************************************
3722 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3723 ********************************************************************/
3725 BOOL
spoolss_io_q_getprinterdriver2(char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3727 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3733 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3735 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3737 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3742 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3745 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3751 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3754 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3756 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3762 /*******************************************************************
3764 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3765 ********************************************************************/
3767 BOOL
spoolss_io_r_getprinterdriver2(char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3769 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3775 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3780 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3782 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3784 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3786 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3792 /*******************************************************************
3794 ********************************************************************/
3796 BOOL
make_spoolss_q_enumprinters(
3797 SPOOL_Q_ENUMPRINTERS
*q_u
,
3807 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3808 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3812 q_u
->offered
=offered
;
3817 /*******************************************************************
3819 ********************************************************************/
3821 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3822 fstring servername
, uint32 level
,
3823 NEW_BUFFER
*buffer
, uint32 offered
)
3825 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3826 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3830 q_u
->offered
=offered
;
3835 /*******************************************************************
3837 * called from spoolss_enumprinters (srv_spoolss.c)
3838 ********************************************************************/
3840 BOOL
spoolss_io_q_enumprinters(char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3842 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3848 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3850 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3853 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3858 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3861 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3866 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3872 /*******************************************************************
3873 Parse a SPOOL_R_ENUMPRINTERS structure.
3874 ********************************************************************/
3876 BOOL
spoolss_io_r_enumprinters(char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3878 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3884 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3890 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3893 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3896 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3902 /*******************************************************************
3903 * write a structure.
3904 * called from spoolss_r_enum_printers (srv_spoolss.c)
3906 ********************************************************************/
3908 BOOL
spoolss_io_r_getprinter(char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3910 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3916 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3922 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3925 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3931 /*******************************************************************
3933 * called from spoolss_getprinter (srv_spoolss.c)
3934 ********************************************************************/
3936 BOOL
spoolss_io_q_getprinter(char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3938 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3944 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3946 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3949 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3954 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3960 /*******************************************************************
3962 ********************************************************************/
3964 BOOL
make_spoolss_q_getprinter(
3965 TALLOC_CTX
*mem_ctx
,
3966 SPOOL_Q_GETPRINTER
*q_u
,
3967 const POLICY_HND
*hnd
,
3977 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3981 q_u
->offered
=offered
;
3986 /*******************************************************************
3988 ********************************************************************/
3989 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
3990 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
3994 DEVICEMODE
*devmode
;
3999 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4002 q_u
->info
.level
= level
;
4003 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
4006 /* There's no such thing as a setprinter level 1 */
4009 secdesc
= info
->printers_2
->secdesc
;
4010 devmode
= info
->printers_2
->devmode
;
4012 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
4013 #if 1 /* JERRY TEST */
4014 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
4015 if (!q_u
->secdesc_ctr
)
4017 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
4018 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4019 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4020 q_u
->secdesc_ctr
->sec
= secdesc
;
4022 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
4023 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
4024 q_u
->devmode_ctr
.devmode
= devmode
;
4026 q_u
->secdesc_ctr
= NULL
;
4028 q_u
->devmode_ctr
.devmode_ptr
= 0;
4029 q_u
->devmode_ctr
.size
= 0;
4030 q_u
->devmode_ctr
.devmode
= NULL
;
4034 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
4039 q_u
->command
= command
;
4045 /*******************************************************************
4046 ********************************************************************/
4048 BOOL
spoolss_io_r_setprinter(char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
4050 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
4056 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4062 /*******************************************************************
4063 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
4064 ********************************************************************/
4066 BOOL
spoolss_io_q_setprinter(char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4068 uint32 ptr_sec_desc
= 0;
4070 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
4076 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
4078 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4081 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4084 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4094 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4099 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4105 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4110 /* Parse a NULL security descriptor. This should really
4111 happen inside the sec_io_desc_buf() function. */
4113 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4114 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4116 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
4120 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4126 /*******************************************************************
4127 ********************************************************************/
4129 BOOL
spoolss_io_r_fcpn(char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
4131 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
4137 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4143 /*******************************************************************
4144 ********************************************************************/
4146 BOOL
spoolss_io_q_fcpn(char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
4149 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
4155 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4162 /*******************************************************************
4163 ********************************************************************/
4165 BOOL
spoolss_io_r_addjob(char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
4167 prs_debug(ps
, depth
, desc
, "");
4173 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4179 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4182 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4188 /*******************************************************************
4189 ********************************************************************/
4191 BOOL
spoolss_io_q_addjob(char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
4193 prs_debug(ps
, depth
, desc
, "");
4199 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4201 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4204 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4210 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4216 /*******************************************************************
4217 ********************************************************************/
4219 BOOL
spoolss_io_r_enumjobs(char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
4221 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
4227 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4233 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4236 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4239 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4245 /*******************************************************************
4246 ********************************************************************/
4248 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4259 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4260 q_u
->firstjob
= firstjob
;
4261 q_u
->numofjobs
= numofjobs
;
4263 q_u
->buffer
= buffer
;
4264 q_u
->offered
= offered
;
4268 /*******************************************************************
4269 ********************************************************************/
4271 BOOL
spoolss_io_q_enumjobs(char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4273 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4279 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4282 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4284 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
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_r_schedulejob(char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4306 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4312 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4318 /*******************************************************************
4319 ********************************************************************/
4321 BOOL
spoolss_io_q_schedulejob(char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4323 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4329 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4331 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4337 /*******************************************************************
4338 ********************************************************************/
4340 BOOL
spoolss_io_r_setjob(char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4342 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4348 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4354 /*******************************************************************
4355 ********************************************************************/
4357 BOOL
spoolss_io_q_setjob(char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4359 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4365 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4367 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4370 * level is usually 0. If (level!=0) then I'm in trouble !
4371 * I will try to generate setjob command with level!=0, one day.
4373 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4375 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4381 /*******************************************************************
4382 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4383 ********************************************************************/
4385 BOOL
spoolss_io_r_enumprinterdrivers(char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4387 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4393 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4399 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4402 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4405 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4411 /*******************************************************************
4413 ********************************************************************/
4415 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4417 const char *environment
,
4419 NEW_BUFFER
*buffer
, uint32 offered
)
4421 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4422 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4426 q_u
->offered
=offered
;
4431 /*******************************************************************
4432 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4433 ********************************************************************/
4435 BOOL
spoolss_io_q_enumprinterdrivers(char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4438 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4444 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4446 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4451 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4453 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4458 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4461 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4467 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4473 /*******************************************************************
4474 ********************************************************************/
4476 BOOL
spoolss_io_q_enumforms(char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4479 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4484 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4486 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4489 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4494 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4500 /*******************************************************************
4501 ********************************************************************/
4503 BOOL
spoolss_io_r_enumforms(char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4505 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4511 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4517 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4520 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4523 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4529 /*******************************************************************
4530 ********************************************************************/
4532 BOOL
spoolss_io_q_getform(char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4535 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4540 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4542 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4548 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4551 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4556 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4562 /*******************************************************************
4563 ********************************************************************/
4565 BOOL
spoolss_io_r_getform(char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4567 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4573 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4579 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4582 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4588 /*******************************************************************
4589 Parse a SPOOL_R_ENUMPORTS structure.
4590 ********************************************************************/
4592 BOOL
spoolss_io_r_enumports(char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4594 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4600 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4606 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4609 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4612 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4618 /*******************************************************************
4619 ********************************************************************/
4621 BOOL
spoolss_io_q_enumports(char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4623 prs_debug(ps
, depth
, desc
, "");
4629 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4631 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4636 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4639 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4644 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4650 /*******************************************************************
4651 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4652 ********************************************************************/
4654 BOOL
spool_io_printer_info_level_1(char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4656 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4662 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4664 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4666 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4668 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4671 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4673 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4675 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4681 /*******************************************************************
4682 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4683 ********************************************************************/
4685 BOOL
spool_io_printer_info_level_3(char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4687 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4693 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4699 /*******************************************************************
4700 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4701 ********************************************************************/
4703 BOOL
spool_io_printer_info_level_2(char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4705 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4711 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4713 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4715 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4717 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4720 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4722 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4724 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4726 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4728 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4730 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4732 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4734 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4736 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4739 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4741 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4743 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4745 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4747 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4749 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4751 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4753 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4756 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4758 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4760 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4762 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4764 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4766 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4768 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4770 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4772 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4774 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4776 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4782 /*******************************************************************
4783 ********************************************************************/
4785 BOOL
spool_io_printer_info_level(char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4787 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4792 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4794 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4797 /* if no struct inside just return */
4798 if (il
->info_ptr
==0) {
4799 if (UNMARSHALLING(ps
)) {
4806 switch (il
->level
) {
4808 * level 0 is used by setprinter when managing the queue
4809 * (hold, stop, start a queue)
4813 /* DOCUMENT ME!!! What is level 1 used for? */
4816 if (UNMARSHALLING(ps
)) {
4817 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4820 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4825 * level 2 is used by addprinter
4826 * and by setprinter when updating printer's info
4829 if (UNMARSHALLING(ps
)) {
4830 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4833 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4836 /* DOCUMENT ME!!! What is level 3 used for? */
4839 if (UNMARSHALLING(ps
)) {
4840 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4843 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4852 /*******************************************************************
4853 ********************************************************************/
4855 BOOL
spoolss_io_q_addprinterex(char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4857 uint32 ptr_sec_desc
= 0;
4859 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4864 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4866 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4872 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4875 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4878 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4884 switch (q_u
->level
) {
4886 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4889 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4893 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4898 /* Parse a NULL security descriptor. This should really
4899 happen inside the sec_io_desc_buf() function. */
4901 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4902 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4904 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
4908 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4910 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4916 /*******************************************************************
4917 ********************************************************************/
4919 BOOL
spoolss_io_r_addprinterex(char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4920 prs_struct
*ps
, int depth
)
4922 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4925 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4928 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4934 /*******************************************************************
4935 ********************************************************************/
4937 BOOL
spool_io_printer_driver_info_level_3(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4938 prs_struct
*ps
, int depth
)
4940 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4942 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4946 if (UNMARSHALLING(ps
)) {
4947 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4959 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4961 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4963 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4965 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4967 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4969 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4971 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4973 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4975 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4977 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4979 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4985 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4987 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4989 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4991 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4993 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4995 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4997 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4999 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5005 if (il
->dependentfiles_ptr
)
5006 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
5011 /*******************************************************************
5012 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
5013 ********************************************************************/
5015 BOOL
spool_io_printer_driver_info_level_6(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
5016 prs_struct
*ps
, int depth
)
5018 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
5020 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
5024 if (UNMARSHALLING(ps
)) {
5025 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
5038 /* parse the main elements the packet */
5040 if(!prs_uint32("version", ps
, depth
, &il
->version
))
5043 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
5046 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
5047 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
5048 * from W2K CDROM (which uses unidriver). JohnR 010205
5050 if (!il
->name_ptr
) {
5051 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
5052 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
5056 if(!prs_uint32("environment_ptr", ps
, depth
, &il
->environment_ptr
))
5058 if(!prs_uint32("driverpath_ptr", ps
, depth
, &il
->driverpath_ptr
))
5060 if(!prs_uint32("datafile_ptr", ps
, depth
, &il
->datafile_ptr
))
5062 if(!prs_uint32("configfile_ptr", ps
, depth
, &il
->configfile_ptr
))
5064 if(!prs_uint32("helpfile_ptr", ps
, depth
, &il
->helpfile_ptr
))
5066 if(!prs_uint32("monitorname_ptr", ps
, depth
, &il
->monitorname_ptr
))
5068 if(!prs_uint32("defaultdatatype_ptr", ps
, depth
, &il
->defaultdatatype_ptr
))
5070 if(!prs_uint32("dependentfiles_len", ps
, depth
, &il
->dependentfiles_len
))
5072 if(!prs_uint32("dependentfiles_ptr", ps
, depth
, &il
->dependentfiles_ptr
))
5074 if(!prs_uint32("previousnames_len", ps
, depth
, &il
->previousnames_len
))
5076 if(!prs_uint32("previousnames_ptr", ps
, depth
, &il
->previousnames_ptr
))
5078 if(!smb_io_time("driverdate", &il
->driverdate
, ps
, depth
))
5080 if(!prs_uint32("dummy4", ps
, depth
, &il
->dummy4
))
5082 if(!prs_uint64("driverversion", ps
, depth
, &il
->driverversion
))
5084 if(!prs_uint32("mfgname_ptr", ps
, depth
, &il
->mfgname_ptr
))
5086 if(!prs_uint32("oemurl_ptr", ps
, depth
, &il
->oemurl_ptr
))
5088 if(!prs_uint32("hardwareid_ptr", ps
, depth
, &il
->hardwareid_ptr
))
5090 if(!prs_uint32("provider_ptr", ps
, depth
, &il
->provider_ptr
))
5093 /* parse the structures in the packet */
5095 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5100 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5105 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5110 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5115 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5120 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5125 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5130 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5134 if (il
->dependentfiles_ptr
) {
5135 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
5140 if (il
->previousnames_ptr
) {
5141 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
5146 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
5150 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
5154 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
5158 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
5164 /*******************************************************************
5165 convert a buffer of UNICODE strings null terminated
5166 the buffer is terminated by a NULL
5168 convert to an dos codepage array (null terminated)
5170 dynamically allocate memory
5172 ********************************************************************/
5173 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
5182 src
= (char *)buf5
->buffer
;
5185 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
5186 rpcstr_pull(f
, src
, sizeof(f
)-1, -1, 0);
5187 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
5188 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
5193 fstrcpy((*ar
)[n
], f
);
5196 fstrcpy((*ar
)[n
], "");
5204 /*******************************************************************
5205 read a UNICODE array with null terminated strings
5206 and null terminated array
5207 and size of array at beginning
5208 ********************************************************************/
5210 BOOL
smb_io_unibuffer(char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
5212 if (buffer
==NULL
) return False
;
5215 buffer
->uni_str_len
=buffer
->uni_max_len
;
5217 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
5220 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
5226 /*******************************************************************
5227 ********************************************************************/
5229 BOOL
spool_io_printer_driver_info_level(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
5231 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
5236 if(!prs_uint32("level", ps
, depth
, &il
->level
))
5238 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
5244 switch (il
->level
) {
5246 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
5250 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5260 /*******************************************************************
5261 init a SPOOL_Q_ADDPRINTERDRIVER struct
5262 ******************************************************************/
5264 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5265 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5266 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5268 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5270 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
5271 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
5275 q_u
->info
.level
= level
;
5276 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
5279 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5281 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5285 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5292 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5293 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5294 DRIVER_INFO_3
*info3
)
5297 uint16
*ptr
= info3
->dependentfiles
;
5299 BOOL null_char
= False
;
5300 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5302 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
5305 inf
->cversion
= info3
->version
;
5306 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5307 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5308 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5309 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5310 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5311 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5312 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5313 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5315 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5316 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5317 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5318 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5319 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5320 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5321 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5322 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5329 /* the null_char BOOL is used to help locate
5330 two '\0's back to back */
5345 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5346 inf
->dependentfilessize
= len
;
5347 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5353 *spool_drv_info
= inf
;
5358 /*******************************************************************
5359 make a BUFFER5 struct from a uint16*
5360 ******************************************************************/
5361 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5364 buf5
->buf_len
= len
;
5365 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5367 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5374 /*******************************************************************
5375 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5376 ********************************************************************/
5378 BOOL
spoolss_io_q_addprinterdriver(char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5380 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5386 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5388 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5393 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5396 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5402 /*******************************************************************
5403 ********************************************************************/
5405 BOOL
spoolss_io_r_addprinterdriver(char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5407 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5410 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5416 /*******************************************************************
5417 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5418 ********************************************************************/
5420 BOOL
spoolss_io_q_addprinterdriverex(char *desc
, SPOOL_Q_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5422 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriverex");
5428 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5430 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5435 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5438 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5443 if(!prs_uint32("copy flags", ps
, depth
, &q_u
->copy_flags
))
5449 /*******************************************************************
5450 ********************************************************************/
5452 BOOL
spoolss_io_r_addprinterdriverex(char *desc
, SPOOL_R_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5454 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriverex");
5457 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5463 /*******************************************************************
5464 ********************************************************************/
5466 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5467 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5469 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5471 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5475 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5483 d
->cversion
=uni
->cversion
;
5485 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5486 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5487 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5488 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5489 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5490 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5491 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5492 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5494 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5495 DEBUGADD(8,( "name: %s\n", d
->name
));
5496 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5497 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5498 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5499 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5500 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5501 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5502 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5504 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5511 /*******************************************************************
5512 ********************************************************************/
5513 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5514 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5516 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5518 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5522 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5530 d
->version
=uni
->version
;
5532 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5533 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5534 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5535 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5536 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5537 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5538 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5539 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5541 DEBUGADD(8,( "version: %d\n", d
->version
));
5542 DEBUGADD(8,( "name: %s\n", d
->name
));
5543 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5544 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5545 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5546 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5547 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5548 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5549 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5551 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5553 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5563 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5564 NT_PRINTER_INFO_LEVEL_2
**asc
)
5566 NT_PRINTER_INFO_LEVEL_2
*d
;
5569 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5570 time_unix
=time(NULL
);
5573 DEBUGADD(8,("allocating memory\n"));
5575 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5580 /* we allocate memory iff called from
5581 * addprinter(ex) so we can do one time stuff here.
5583 (*asc
)->setuptime
=time_unix
;
5586 DEBUGADD(8,("start converting\n"));
5590 d
->attributes
=uni
->attributes
;
5591 d
->priority
=uni
->priority
;
5592 d
->default_priority
=uni
->default_priority
;
5593 d
->starttime
=uni
->starttime
;
5594 d
->untiltime
=uni
->untiltime
;
5595 d
->status
=uni
->status
;
5596 d
->cjobs
=uni
->cjobs
;
5598 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5599 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5600 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5601 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5602 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5603 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5604 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5605 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5606 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5607 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5608 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5613 /*******************************************************************
5615 ********************************************************************/
5617 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5618 fstring servername
, fstring env_name
, uint32 level
,
5619 NEW_BUFFER
*buffer
, uint32 offered
)
5621 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5622 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5626 q_u
->offered
=offered
;
5631 /*******************************************************************
5632 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5633 ********************************************************************/
5635 BOOL
spoolss_io_q_getprinterdriverdir(char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5637 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5642 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5644 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5650 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5652 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5658 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5661 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5667 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5673 /*******************************************************************
5674 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5675 ********************************************************************/
5677 BOOL
spoolss_io_r_getprinterdriverdir(char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5679 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5685 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5691 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5694 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5700 /*******************************************************************
5701 ********************************************************************/
5703 BOOL
spoolss_io_r_enumprintprocessors(char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5705 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5711 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5717 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5720 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5723 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5729 /*******************************************************************
5730 ********************************************************************/
5732 BOOL
spoolss_io_q_enumprintprocessors(char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5734 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5740 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5742 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5748 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5750 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5756 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5759 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5765 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5771 /*******************************************************************
5772 ********************************************************************/
5774 BOOL
spoolss_io_q_addprintprocessor(char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5776 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5782 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5784 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5789 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5794 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5799 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5805 /*******************************************************************
5806 ********************************************************************/
5808 BOOL
spoolss_io_r_addprintprocessor(char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5810 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5816 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5822 /*******************************************************************
5823 ********************************************************************/
5825 BOOL
spoolss_io_r_enumprintprocdatatypes(char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5827 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5833 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5839 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5842 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5845 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5851 /*******************************************************************
5852 ********************************************************************/
5854 BOOL
spoolss_io_q_enumprintprocdatatypes(char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5856 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5862 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5864 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5870 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5872 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5878 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5881 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5887 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5893 /*******************************************************************
5894 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5895 ********************************************************************/
5897 BOOL
spoolss_io_q_enumprintmonitors(char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5899 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5905 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5907 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5913 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5916 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5922 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5928 /*******************************************************************
5929 ********************************************************************/
5931 BOOL
spoolss_io_r_enumprintmonitors(char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5933 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5939 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5945 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5948 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5951 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5957 /*******************************************************************
5958 ********************************************************************/
5960 BOOL
spoolss_io_r_enumprinterdata(char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5962 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5967 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5970 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
5971 r_u
->value
= (uint16
*)prs_alloc_mem(ps
, r_u
->valuesize
* 2);
5973 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
5978 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5984 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5987 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5990 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5993 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
5994 r_u
->data
= (uint8
*)prs_alloc_mem(ps
, r_u
->datasize
);
5996 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
6001 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
6006 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
6008 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6014 /*******************************************************************
6015 ********************************************************************/
6017 BOOL
spoolss_io_q_enumprinterdata(char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6019 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
6024 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6026 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
6028 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
6030 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
6036 /*******************************************************************
6037 ********************************************************************/
6039 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
6040 const POLICY_HND
*hnd
,
6041 uint32 idx
, uint32 valuelen
, uint32 datalen
)
6043 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6045 q_u
->valuesize
=valuelen
;
6046 q_u
->datasize
=datalen
;
6051 /*******************************************************************
6052 ********************************************************************/
6053 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, const POLICY_HND
*hnd
,
6054 char* value
, char* data
, uint32 data_size
)
6056 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6058 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
6060 q_u
->max_len
= q_u
->real_len
= data_size
;
6065 /*******************************************************************
6066 ********************************************************************/
6068 BOOL
spoolss_io_q_setprinterdata(char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6070 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
6075 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6077 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6083 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6086 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6096 if (UNMARSHALLING(ps
))
6097 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6098 if(q_u
->data
== NULL
)
6100 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6108 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6114 /*******************************************************************
6115 ********************************************************************/
6117 BOOL
spoolss_io_r_setprinterdata(char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6119 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
6124 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6130 /*******************************************************************
6131 ********************************************************************/
6132 BOOL
spoolss_io_q_resetprinter(char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6134 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
6139 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6142 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
6145 if (q_u
->datatype_ptr
) {
6146 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
6150 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
6157 /*******************************************************************
6158 ********************************************************************/
6159 BOOL
spoolss_io_r_resetprinter(char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6161 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
6166 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6172 /*******************************************************************
6173 ********************************************************************/
6174 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
6175 uint32 type
, const uint8
*data
, uint32 len
)
6177 DEBUG(5,("converting a specific param struct\n"));
6181 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
6184 memset((char *)*param
, '\0', sizeof(NT_PRINTER_PARAM
));
6185 DEBUGADD(6,("Allocated a new PARAM struct\n"));
6187 unistr2_to_ascii((*param
)->value
, value
, sizeof((*param
)->value
)-1);
6188 (*param
)->type
= type
;
6190 /* le champ data n'est pas NULL termine */
6191 /* on stocke donc la longueur */
6193 (*param
)->data_len
=len
;
6196 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
6197 if((*param
)->data
== NULL
)
6199 memcpy((*param
)->data
, data
, len
);
6202 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
6203 dump_data(10, (char *)(*param
)->data
, (*param
)->data_len
);
6208 /*******************************************************************
6209 ********************************************************************/
6211 static BOOL
spoolss_io_addform(char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
6213 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
6220 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
6222 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
6224 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
6226 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
6228 if(!prs_uint32("left", ps
, depth
, &f
->left
))
6230 if(!prs_uint32("top", ps
, depth
, &f
->top
))
6232 if(!prs_uint32("right", ps
, depth
, &f
->right
))
6234 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
6237 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
6244 /*******************************************************************
6245 ********************************************************************/
6247 BOOL
spoolss_io_q_deleteform(char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
6249 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
6254 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6256 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
6262 /*******************************************************************
6263 ********************************************************************/
6265 BOOL
spoolss_io_r_deleteform(char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
6267 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
6272 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6278 /*******************************************************************
6279 ********************************************************************/
6281 BOOL
spoolss_io_q_addform(char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
6283 uint32 useless_ptr
=1;
6284 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
6289 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6291 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6293 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6298 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6300 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6307 /*******************************************************************
6308 ********************************************************************/
6310 BOOL
spoolss_io_r_addform(char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6312 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6317 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6323 /*******************************************************************
6324 ********************************************************************/
6326 BOOL
spoolss_io_q_setform(char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6328 uint32 useless_ptr
=1;
6329 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6334 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6336 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6342 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6344 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6349 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6351 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6358 /*******************************************************************
6359 ********************************************************************/
6361 BOOL
spoolss_io_r_setform(char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6363 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6368 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6374 /*******************************************************************
6375 Parse a SPOOL_R_GETJOB structure.
6376 ********************************************************************/
6378 BOOL
spoolss_io_r_getjob(char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6380 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6386 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6392 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6395 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6401 /*******************************************************************
6402 Parse a SPOOL_Q_GETJOB structure.
6403 ********************************************************************/
6405 BOOL
spoolss_io_q_getjob(char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6407 prs_debug(ps
, depth
, desc
, "");
6413 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6415 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6417 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6420 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6426 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6432 void free_devmode(DEVICEMODE
*devmode
)
6434 if (devmode
!=NULL
) {
6435 SAFE_FREE(devmode
->private);
6440 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6445 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6447 if (printer
!=NULL
) {
6448 free_devmode(printer
->devmode
);
6449 printer
->devmode
= NULL
;
6454 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6459 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6464 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6469 void free_job_info_2(JOB_INFO_2
*job
)
6472 free_devmode(job
->devmode
);
6475 /*******************************************************************
6477 ********************************************************************/
6479 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6480 const fstring string
, uint32 printer
, uint32 type
)
6485 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
6487 q_u
->printer
=printer
;
6496 /*******************************************************************
6497 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6498 ********************************************************************/
6500 BOOL
spoolss_io_q_replyopenprinter(char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6502 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6508 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6514 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6516 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6519 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6521 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6527 /*******************************************************************
6528 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6529 ********************************************************************/
6531 BOOL
spoolss_io_r_replyopenprinter(char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6533 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6539 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6542 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6548 /*******************************************************************
6550 ********************************************************************/
6551 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6552 uint32 condition
, uint32 change_id
)
6555 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6557 q_u
->condition
= condition
;
6558 q_u
->change_id
= change_id
;
6561 q_u
->unknown1
= 0x1;
6562 memset(q_u
->unknown2
, 0x0, 5);
6563 q_u
->unknown2
[0] = 0x1;
6568 /*******************************************************************
6569 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6570 ********************************************************************/
6571 BOOL
spoolss_io_q_routerreplyprinter (char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6574 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6580 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6583 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6586 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6589 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6592 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6598 /*******************************************************************
6599 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6600 ********************************************************************/
6601 BOOL
spoolss_io_r_routerreplyprinter (char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6603 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6609 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6615 /*******************************************************************
6617 ********************************************************************/
6619 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6624 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6629 /*******************************************************************
6630 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6631 ********************************************************************/
6633 BOOL
spoolss_io_q_replycloseprinter(char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6635 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6641 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6647 /*******************************************************************
6648 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6649 ********************************************************************/
6651 BOOL
spoolss_io_r_replycloseprinter(char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6653 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6659 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6662 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6668 #if 0 /* JERRY - not currently used but could be :-) */
6670 /*******************************************************************
6671 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6672 ******************************************************************/
6673 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6674 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6678 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6680 for (i
=0; i
<n
; i
++) {
6684 if (src
->size
!= POINTER
)
6686 len
= src
->notify_data
.data
.length
;
6687 s
= malloc(sizeof(uint16
)*len
);
6689 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6693 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6694 dst
->notify_data
.data
.string
= s
;
6700 /*******************************************************************
6701 Deep copy a SPOOL_NOTIFY_INFO structure
6702 ******************************************************************/
6703 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6706 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6710 dst
->version
= src
->version
;
6711 dst
->flags
= src
->flags
;
6712 dst
->count
= src
->count
;
6716 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6718 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6721 if (dst
->data
== NULL
) {
6722 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6727 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6734 /*******************************************************************
6736 ********************************************************************/
6738 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6739 uint32 change_low
, uint32 change_high
,
6740 SPOOL_NOTIFY_INFO
*info
)
6745 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6747 q_u
->change_low
=change_low
;
6748 q_u
->change_high
=change_high
;
6753 q_u
->info_ptr
=0xaddee11e;
6755 q_u
->info
.version
=2;
6758 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6760 q_u
->info
.version
= info
->version
;
6761 q_u
->info
.flags
= info
->flags
;
6762 q_u
->info
.count
= info
->count
;
6763 /* pointer field - be careful! */
6764 q_u
->info
.data
= info
->data
;
6767 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6774 /*******************************************************************
6775 Parse a SPOOL_Q_REPLY_RRPCN structure.
6776 ********************************************************************/
6778 BOOL
spoolss_io_q_reply_rrpcn(char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6780 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6786 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6789 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6792 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6795 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6798 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6801 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6804 if(q_u
->info_ptr
!=0)
6805 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6811 /*******************************************************************
6812 Parse a SPOOL_R_REPLY_RRPCN structure.
6813 ********************************************************************/
6815 BOOL
spoolss_io_r_reply_rrpcn(char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6817 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6823 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6826 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6832 /*******************************************************************
6834 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6835 ********************************************************************/
6837 BOOL
spoolss_io_q_getprinterdataex(char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6842 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6847 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6851 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6855 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6859 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6865 /*******************************************************************
6866 * write a structure.
6867 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6868 ********************************************************************/
6870 BOOL
spoolss_io_r_getprinterdataex(char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6875 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6880 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6882 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6885 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
6891 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6893 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6899 /*******************************************************************
6901 ********************************************************************/
6903 BOOL
spoolss_io_q_setprinterdataex(char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6905 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
6910 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6912 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6918 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6924 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6927 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6937 if (UNMARSHALLING(ps
))
6938 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6939 if(q_u
->data
== NULL
)
6941 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6949 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6955 /*******************************************************************
6956 * write a structure.
6957 ********************************************************************/
6959 BOOL
spoolss_io_r_setprinterdataex(char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6961 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
6966 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6973 /*******************************************************************
6975 ********************************************************************/
6977 BOOL
spoolss_io_q_enumprinterkey(char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
6979 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
6984 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6987 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6993 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6999 /*******************************************************************
7000 * write a structure.
7001 ********************************************************************/
7003 BOOL
spoolss_io_r_enumprinterkey(char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7005 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
7011 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
7017 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7020 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7026 /*******************************************************************
7028 ********************************************************************/
7030 BOOL
spoolss_io_q_deleteprinterkey(char *desc
, SPOOL_Q_DELETEPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7032 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterkey");
7037 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7040 if(!smb_io_unistr2("", &q_u
->keyname
, True
, ps
, depth
))
7046 /*******************************************************************
7047 * write a structure.
7048 ********************************************************************/
7050 BOOL
spoolss_io_r_deleteprinterkey(char *desc
, SPOOL_R_DELETEPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7052 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterkey");
7058 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7065 /*******************************************************************
7067 ********************************************************************/
7069 BOOL
spoolss_io_q_enumprinterdataex(char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7071 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
7076 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7079 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7085 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7091 /*******************************************************************
7092 ********************************************************************/
7093 static BOOL
spoolss_io_printer_enum_values_ctr(char *desc
, prs_struct
*ps
,
7094 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
7097 uint32 valuename_offset
,
7100 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
7102 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
7105 if (!prs_uint32("size", ps
, depth
, &ctr
->size
))
7108 /* offset data begins at 20 bytes per structure * size_of_array.
7109 Don't forget the uint32 at the beginning */
7111 current_offset
= basic_unit
* ctr
->size_of_array
;
7113 /* first loop to write basic enum_value information */
7115 for (i
=0; i
<ctr
->size_of_array
; i
++)
7117 valuename_offset
= current_offset
;
7118 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
7121 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
7124 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
7127 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
7128 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
7131 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
7134 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
7137 /* loop #2 for writing the dynamically size objects
7138 while viewing conversations between Win2k -> Win2k,
7139 4-byte alignment does not seem to matter here --jerry */
7141 for (i
=0; i
<ctr
->size_of_array
; i
++)
7144 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
7147 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
7157 /*******************************************************************
7158 * write a structure.
7159 ********************************************************************/
7161 BOOL
spoolss_io_r_enumprinterdataex(char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7163 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
7169 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
7175 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7178 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
7181 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7188 /*******************************************************************
7189 * write a structure.
7190 ********************************************************************/
7193 uint32 GetPrintProcessorDirectory(
7195 [in] unistr2 *environment,
7197 [in,out] NEW_BUFFER buffer,
7198 [in] uint32 offered,
7199 [out] uint32 needed,
7200 [out] uint32 returned
7205 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, NEW_BUFFER
*buffer
, uint32 offered
)
7207 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
7209 init_unistr2(&q_u
->name
, name
, strlen(name
)+1);
7210 init_unistr2(&q_u
->environment
, environment
, strlen(environment
)+1);
7214 q_u
->buffer
= buffer
;
7215 q_u
->offered
= offered
;
7220 BOOL
spoolss_io_q_getprintprocessordirectory(char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
7224 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
7230 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7234 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
7241 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7245 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
7253 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7256 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
7262 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
7268 /*******************************************************************
7269 * write a structure.
7270 ********************************************************************/
7272 BOOL
spoolss_io_r_getprintprocessordirectory(char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
7274 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
7280 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
7286 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7289 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7295 BOOL
smb_io_printprocessordirectory_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
7297 prs_struct
*ps
=&buffer
->prs
;
7299 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
7302 buffer
->struct_start
=prs_offset(ps
);
7304 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
7310 /*******************************************************************
7312 ********************************************************************/
7314 BOOL
make_spoolss_q_addform(SPOOL_Q_ADDFORM
*q_u
, POLICY_HND
*handle
,
7315 int level
, FORM
*form
)
7317 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7319 q_u
->level2
= level
;
7320 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7325 /*******************************************************************
7327 ********************************************************************/
7329 BOOL
make_spoolss_q_setform(SPOOL_Q_SETFORM
*q_u
, POLICY_HND
*handle
,
7330 int level
, char *form_name
, FORM
*form
)
7332 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7334 q_u
->level2
= level
;
7335 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7336 init_unistr2(&q_u
->name
, form_name
, strlen(form_name
) + 1);
7341 /*******************************************************************
7343 ********************************************************************/
7345 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
, char *form
)
7347 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7348 init_unistr2(&q_u
->name
, form
, strlen(form
) + 1);
7352 /*******************************************************************
7354 ********************************************************************/
7356 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7357 char *formname
, uint32 level
, NEW_BUFFER
*buffer
,
7360 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7362 init_unistr2(&q_u
->formname
, formname
, strlen(formname
) + 1);
7364 q_u
->offered
=offered
;
7369 /*******************************************************************
7371 ********************************************************************/
7373 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7374 uint32 level
, NEW_BUFFER
*buffer
,
7377 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7380 q_u
->offered
=offered
;
7385 /*******************************************************************
7387 ********************************************************************/
7389 BOOL
make_spoolss_q_setjob(SPOOL_Q_SETJOB
*q_u
, POLICY_HND
*handle
,
7390 uint32 jobid
, uint32 level
, uint32 command
)
7392 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7396 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7397 the server side code has it marked as unused. */
7399 q_u
->command
= command
;
7404 /*******************************************************************
7406 ********************************************************************/
7408 BOOL
make_spoolss_q_getjob(SPOOL_Q_GETJOB
*q_u
, POLICY_HND
*handle
,
7409 uint32 jobid
, uint32 level
, NEW_BUFFER
*buffer
,
7412 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7415 q_u
->buffer
= buffer
;
7416 q_u
->offered
= offered
;
7421 /*******************************************************************
7423 ********************************************************************/
7425 BOOL
make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER
*q_u
,
7428 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7433 /*******************************************************************
7435 ********************************************************************/
7437 BOOL
make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER
*q_u
,
7440 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7445 /*******************************************************************
7447 ********************************************************************/
7449 BOOL
make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER
*q_u
,
7450 POLICY_HND
*handle
, uint32 level
,
7451 char *docname
, char *outputfile
,
7454 DOC_INFO_CONTAINER
*ctr
= &q_u
->doc_info_container
;
7456 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7462 ctr
->docinfo
.switch_value
= level
;
7464 ctr
->docinfo
.doc_info_1
.p_docname
= docname
? 1 : 0;
7465 ctr
->docinfo
.doc_info_1
.p_outputfile
= outputfile
? 1 : 0;
7466 ctr
->docinfo
.doc_info_1
.p_datatype
= datatype
? 1 : 0;
7469 init_unistr2(&ctr
->docinfo
.doc_info_1
.docname
, docname
,
7470 strlen(docname
) + 1);
7473 init_unistr2(&ctr
->docinfo
.doc_info_1
.outputfile
, outputfile
,
7474 strlen(outputfile
) + 1);
7477 init_unistr2(&ctr
->docinfo
.doc_info_1
.datatype
, datatype
,
7478 strlen(datatype
) + 1);
7482 /* DOC_INFO_2 is only used by Windows 9x and since it
7483 doesn't do printing over RPC we don't have to worry
7486 DEBUG(3, ("unsupported info level %d\n", level
));
7493 /*******************************************************************
7495 ********************************************************************/
7497 BOOL
make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER
*q_u
,
7500 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7505 /*******************************************************************
7507 ********************************************************************/
7509 BOOL
make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER
*q_u
,
7510 POLICY_HND
*handle
, uint32 data_size
,
7513 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7514 q_u
->buffer_size
= q_u
->buffer_size2
= data_size
;
7519 /*******************************************************************
7521 ********************************************************************/
7523 BOOL
make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA
*q_u
,
7524 POLICY_HND
*handle
, char *valuename
)
7526 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7527 init_unistr2(&q_u
->valuename
, valuename
, strlen(valuename
) + 1);