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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
325 uint32 useless_ptr
=0x0FF0ADDE;
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 if( !prs_uint32( "sd size", ps
, depth
, &data
->notify_data
.sd
.size
) )
384 if( !prs_uint32( "pointer", ps
, depth
, &useless_ptr
) )
390 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data\n",
398 /*******************************************************************
399 reads or writes an NOTIFY INFO DATA structure.
400 ********************************************************************/
402 BOOL
smb_io_notify_info_data_strings(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
403 prs_struct
*ps
, int depth
)
405 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
411 switch(data
->enc_type
) {
413 /* No data for values */
415 case NOTIFY_ONE_VALUE
:
416 case NOTIFY_TWO_VALUE
:
420 /* Strings start with a length in uint16s */
424 if (UNMARSHALLING(ps
)) {
425 data
->notify_data
.data
.string
=
426 (uint16
*)prs_alloc_mem(ps
, data
->notify_data
.data
.length
);
428 if (!data
->notify_data
.data
.string
)
433 data
->notify_data
.data
.length
/= 2;
435 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
438 if (!prs_uint16uni(True
, "string", ps
, depth
, data
->notify_data
.data
.string
,
439 data
->notify_data
.data
.length
))
443 data
->notify_data
.data
.length
*= 2;
449 if (UNMARSHALLING(ps
)) {
450 data
->notify_data
.data
.string
=
451 (uint16
*)prs_alloc_mem(ps
, data
->notify_data
.data
.length
);
453 if (!data
->notify_data
.data
.string
)
457 if(!prs_uint8s(True
,"buffer",ps
,depth
,(uint8
*)data
->notify_data
.data
.string
,data
->notify_data
.data
.length
))
463 if( !prs_uint32("secdesc size ", ps
, depth
, &data
->notify_data
.sd
.size
) )
465 if ( !sec_io_desc( "sec_desc", &data
->notify_data
.sd
.desc
, ps
, depth
) )
470 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data_strings\n",
476 if (isvalue
==False
) {
478 /* length of string in unicode include \0 */
479 x
=data
->notify_data
.data
.length
+1;
481 if (data
->field
!= 16)
482 if(!prs_uint32("string length", ps
, depth
, &x
))
485 if (MARSHALLING(ps
)) {
486 /* These are already in little endian format. Don't byte swap. */
489 /* No memory allocated for this string
490 therefore following the data.string
491 pointer is a bad idea. Use a pointer to
492 the uint32 length union member to
493 provide a source for a unicode NULL */
495 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
499 if (data
->field
== 16)
502 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
507 /* Tallocate memory for string */
509 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
510 if (!data
->notify_data
.data
.string
)
513 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
521 /* Win2k does not seem to put this parse align here */
529 /*******************************************************************
530 reads or writes an NOTIFY INFO structure.
531 ********************************************************************/
533 static BOOL
smb_io_notify_info(const char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
537 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
543 if(!prs_uint32("count", ps
, depth
, &info
->count
))
545 if(!prs_uint32("version", ps
, depth
, &info
->version
))
547 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
549 if(!prs_uint32("count", ps
, depth
, &info
->count
))
552 for (i
=0;i
<info
->count
;i
++) {
553 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
557 /* now do the strings at the end of the stream */
558 for (i
=0;i
<info
->count
;i
++) {
559 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
566 /*******************************************************************
567 ********************************************************************/
569 static BOOL
spool_io_user_level_1(const char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
571 prs_debug(ps
, depth
, desc
, "");
575 if (UNMARSHALLING(ps
))
580 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
582 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
584 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
586 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
588 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
590 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
592 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
595 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
599 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
605 /*******************************************************************
606 ********************************************************************/
608 static BOOL
spool_io_user_level(const char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
613 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
619 /* From looking at many captures in ethereal, it looks like
620 the level and ptr fields should be transposed. -tpot */
622 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
624 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
627 switch (q_u
->level
) {
629 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
639 /*******************************************************************
640 * read or write a DEVICEMODE struct.
641 * on reading allocate memory for the private member
642 ********************************************************************/
644 #define DM_NUM_OPTIONAL_FIELDS 8
646 BOOL
spoolss_io_devmode(const char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
648 int available_space
; /* size of the device mode left to parse */
649 /* only important on unmarshalling */
652 struct optional_fields
{
655 } opt_fields
[DM_NUM_OPTIONAL_FIELDS
] = {
656 { "icmmethod", NULL
},
657 { "icmintent", NULL
},
658 { "mediatype", NULL
},
659 { "dithertype", NULL
},
660 { "reserved1", NULL
},
661 { "reserved2", NULL
},
662 { "panningwidth", NULL
},
663 { "panningheight", NULL
}
666 /* assign at run time to keep non-gcc compilers happy */
668 opt_fields
[0].field
= &devmode
->icmmethod
;
669 opt_fields
[1].field
= &devmode
->icmintent
;
670 opt_fields
[2].field
= &devmode
->mediatype
;
671 opt_fields
[3].field
= &devmode
->dithertype
;
672 opt_fields
[4].field
= &devmode
->reserved1
;
673 opt_fields
[5].field
= &devmode
->reserved2
;
674 opt_fields
[6].field
= &devmode
->panningwidth
;
675 opt_fields
[7].field
= &devmode
->panningheight
;
678 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
681 if (UNMARSHALLING(ps
)) {
682 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
683 if (devmode
->devicename
.buffer
== NULL
)
687 if (!prs_uint16uni(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, MAXDEVICENAME
))
690 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
693 /* Sanity Check - look for unknown specversions, but don't fail if we see one.
694 Let the size determine that */
696 switch (devmode
->specversion
) {
697 /* list of observed spec version's */
705 DEBUG(0,("spoolss_io_devmode: Unknown specversion in devicemode [0x%x]\n",
706 devmode
->specversion
));
707 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
712 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
714 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
716 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
718 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
720 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
722 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
724 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
726 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
728 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
730 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
732 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
734 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
736 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
738 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
740 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
742 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
744 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
747 if (UNMARSHALLING(ps
)) {
748 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
749 if (devmode
->formname
.buffer
== NULL
)
753 if (!prs_uint16uni(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
755 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
757 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
759 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
761 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
763 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
765 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
768 * every device mode I've ever seen on the wire at least has up
769 * to the displayfrequency field. --jerry (05-09-2002)
772 /* add uint32's + uint16's + two UNICODE strings */
774 available_space
= devmode
->size
- (sizeof(uint32
)*6 + sizeof(uint16
)*18 + sizeof(uint16
)*64);
776 /* Sanity check - we only have uint32's left tp parse */
778 if ( available_space
&& ((available_space
% sizeof(uint32
)) != 0) ) {
779 DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n",
780 available_space
, devmode
->size
));
781 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
786 * Conditional parsing. Assume that the DeviceMode has been
787 * zero'd by the caller.
790 while ((available_space
> 0) && (i
< DM_NUM_OPTIONAL_FIELDS
))
792 DEBUG(11, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space
));
793 if (!prs_uint32(opt_fields
[i
].name
, ps
, depth
, opt_fields
[i
].field
))
795 available_space
-= sizeof(uint32
);
799 /* Sanity Check - we should no available space at this point unless
800 MS changes the device mode structure */
802 if (available_space
) {
803 DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n"));
804 DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n",
805 available_space
, devmode
->size
));
806 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
811 if (devmode
->driverextra
!=0) {
812 if (UNMARSHALLING(ps
)) {
813 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
814 if(devmode
->private == NULL
)
816 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
819 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
820 if (!prs_uint8s(False
, "private", ps
, depth
,
821 devmode
->private, devmode
->driverextra
))
828 /*******************************************************************
829 Read or write a DEVICEMODE container
830 ********************************************************************/
832 static BOOL
spoolss_io_devmode_cont(const char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
837 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
843 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
846 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
849 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
850 if (UNMARSHALLING(ps
))
851 /* if while reading there is no DEVMODE ... */
856 /* so we have a DEVICEMODE to follow */
857 if (UNMARSHALLING(ps
)) {
858 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
859 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
860 if(dm_c
->devmode
== NULL
)
864 /* this is bad code, shouldn't be there */
865 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
868 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
874 /*******************************************************************
875 ********************************************************************/
877 static BOOL
spoolss_io_printer_default(const char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
882 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
885 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
888 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
894 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
900 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
906 /*******************************************************************
908 ********************************************************************/
910 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
911 const fstring printername
,
912 const fstring datatype
,
913 uint32 access_required
,
914 const fstring clientname
,
915 const fstring user_name
)
917 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
918 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
919 init_unistr2(&q_u
->printername
, printername
, UNI_STR_TERMINATE
);
921 q_u
->printer_default
.datatype_ptr
= 0;
923 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
924 init_unistr2(&q_u->printer_default.datatype, datatype, UNI_FLAGS_NONE);
926 q_u
->printer_default
.devmode_cont
.size
=0;
927 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
928 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
929 q_u
->printer_default
.access_required
=access_required
;
931 q_u
->user_ctr
.level
=1;
933 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
934 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
935 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
936 q_u
->user_ctr
.user1
.build
=1381;
937 q_u
->user_ctr
.user1
.major
=2;
938 q_u
->user_ctr
.user1
.minor
=0;
939 q_u
->user_ctr
.user1
.processor
=0;
940 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, UNI_STR_TERMINATE
);
941 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, UNI_STR_TERMINATE
);
946 /*******************************************************************
948 ********************************************************************/
950 BOOL
make_spoolss_q_addprinterex(
952 SPOOL_Q_ADDPRINTEREX
*q_u
,
953 const char *srv_name
,
954 const char* clientname
,
955 const char* user_name
,
957 PRINTER_INFO_CTR
*ctr
)
959 DEBUG(5,("make_spoolss_q_addprinterex\n"));
961 if (!ctr
) return False
;
965 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
966 init_unistr2(&q_u
->server_name
, srv_name
, UNI_FLAGS_NONE
);
970 q_u
->info
.level
= level
;
971 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
974 /* init q_u->info.info2 from *info */
975 if (!make_spoolss_printer_info_2(mem_ctx
, &q_u
->info
.info_2
, ctr
->printers_2
)) {
976 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
986 q_u
->user_ctr
.level
=1;
988 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
989 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
990 q_u
->user_ctr
.user1
.build
=1381;
991 q_u
->user_ctr
.user1
.major
=2;
992 q_u
->user_ctr
.user1
.minor
=0;
993 q_u
->user_ctr
.user1
.processor
=0;
994 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, UNI_STR_TERMINATE
);
995 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, UNI_STR_TERMINATE
);
996 q_u
->user_ctr
.user1
.size
=q_u
->user_ctr
.user1
.user_name
.uni_str_len
+
997 q_u
->user_ctr
.user1
.client_name
.uni_str_len
+ 2;
1002 /*******************************************************************
1003 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
1004 *******************************************************************/
1006 BOOL
make_spoolss_printer_info_2(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
1007 PRINTER_INFO_2
*info
)
1010 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
1012 /* allocate the necessary memory */
1013 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_2
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_2
)))) {
1014 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
1018 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
1019 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
1020 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
1021 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
1022 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
1023 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
1024 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
1025 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
1026 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
1027 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
1028 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
1029 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
1030 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
1031 inf
->attributes
= info
->attributes
;
1032 inf
->priority
= info
->priority
;
1033 inf
->default_priority
= info
->defaultpriority
;
1034 inf
->starttime
= info
->starttime
;
1035 inf
->untiltime
= info
->untiltime
;
1036 inf
->cjobs
= info
->cjobs
;
1037 inf
->averageppm
= info
->averageppm
;
1038 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
1039 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
1040 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
1041 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
1042 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
1043 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
1044 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
1045 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
1046 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
1047 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
1048 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
1049 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
1056 /*******************************************************************
1057 create a SPOOL_PRINTER_INFO_3 struct from a PRINTER_INFO_3 struct
1058 *******************************************************************/
1060 BOOL
make_spoolss_printer_info_3(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_3
**spool_info3
,
1061 PRINTER_INFO_3
*info
)
1064 SPOOL_PRINTER_INFO_LEVEL_3
*inf
;
1066 /* allocate the necessary memory */
1067 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_3
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_3
)))) {
1068 DEBUG(0,("make_spoolss_printer_info_3: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_3 sruct!\n"));
1072 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
1079 /*******************************************************************
1080 create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
1081 *******************************************************************/
1083 BOOL
make_spoolss_printer_info_7(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_7
**spool_info7
,
1084 PRINTER_INFO_7
*info
)
1087 SPOOL_PRINTER_INFO_LEVEL_7
*inf
;
1089 /* allocate the necessary memory */
1090 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_7
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_7
)))) {
1091 DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
1095 inf
->guid_ptr
= (info
->guid
.buffer
!=NULL
)?1:0;
1096 inf
->action
= info
->action
;
1097 init_unistr2_from_unistr(&inf
->guid
, &info
->guid
);
1105 /*******************************************************************
1107 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1108 ********************************************************************/
1110 BOOL
spoolss_io_q_open_printer(const char *desc
, SPOOL_Q_OPEN_PRINTER
*q_u
, prs_struct
*ps
, int depth
)
1115 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer");
1121 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
1123 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
1129 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1135 /*******************************************************************
1136 * write a structure.
1137 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1138 * called from spoolss_open_printer_ex (cli_spoolss.c)
1139 ********************************************************************/
1141 BOOL
spoolss_io_r_open_printer(const char *desc
, SPOOL_R_OPEN_PRINTER
*r_u
, prs_struct
*ps
, int depth
)
1143 if (r_u
== NULL
) return False
;
1145 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer");
1151 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1154 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1161 /*******************************************************************
1163 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1164 ********************************************************************/
1166 BOOL
spoolss_io_q_open_printer_ex(const char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
1171 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
1177 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
1179 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
1185 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1188 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
1190 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
1196 /*******************************************************************
1197 * write a structure.
1198 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1199 * called from spoolss_open_printer_ex (cli_spoolss.c)
1200 ********************************************************************/
1202 BOOL
spoolss_io_r_open_printer_ex(const char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
1204 if (r_u
== NULL
) return False
;
1206 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
1212 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1215 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1221 /*******************************************************************
1223 ********************************************************************/
1224 BOOL
make_spoolss_q_deleteprinterdriverex( TALLOC_CTX
*mem_ctx
,
1225 SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
,
1231 DEBUG(5,("make_spoolss_q_deleteprinterdriverex\n"));
1233 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1234 q_u
->delete_flags
= DPD_DELETE_UNUSED_FILES
;
1236 /* these must be NULL terminated or else NT4 will
1237 complain about invalid parameters --jerry */
1238 init_unistr2(&q_u
->server
, server
, UNI_STR_TERMINATE
);
1239 init_unistr2(&q_u
->arch
, arch
, UNI_STR_TERMINATE
);
1240 init_unistr2(&q_u
->driver
, driver
, UNI_STR_TERMINATE
);
1243 q_u
->delete_flags
|= DPD_DELETE_SPECIFIC_VERSION
;
1244 q_u
->version
= version
;
1251 /*******************************************************************
1253 ********************************************************************/
1254 BOOL
make_spoolss_q_deleteprinterdriver(
1255 TALLOC_CTX
*mem_ctx
,
1256 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
1262 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1264 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1266 /* these must be NULL terminated or else NT4 will
1267 complain about invalid parameters --jerry */
1268 init_unistr2(&q_u
->server
, server
, UNI_STR_TERMINATE
);
1269 init_unistr2(&q_u
->arch
, arch
, UNI_STR_TERMINATE
);
1270 init_unistr2(&q_u
->driver
, driver
, UNI_STR_TERMINATE
);
1275 /*******************************************************************
1277 ********************************************************************/
1279 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
1280 const POLICY_HND
*handle
,
1281 const char *valuename
, uint32 size
)
1283 if (q_u
== NULL
) return False
;
1285 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1287 q_u
->handle
= *handle
;
1288 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
1294 /*******************************************************************
1296 ********************************************************************/
1298 BOOL
make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX
*q_u
,
1299 const POLICY_HND
*handle
,
1300 const char *keyname
,
1301 const char *valuename
, uint32 size
)
1303 if (q_u
== NULL
) return False
;
1305 DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
1307 q_u
->handle
= *handle
;
1308 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
1309 init_unistr2(&q_u
->keyname
, keyname
, UNI_STR_TERMINATE
);
1315 /*******************************************************************
1317 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1318 ********************************************************************/
1320 BOOL
spoolss_io_q_getprinterdata(const char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1325 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1330 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1334 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1338 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1344 /*******************************************************************
1346 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1347 ********************************************************************/
1349 BOOL
spoolss_io_q_deleteprinterdata(const char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1354 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1359 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1363 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1369 /*******************************************************************
1370 * write a structure.
1371 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1372 ********************************************************************/
1374 BOOL
spoolss_io_r_deleteprinterdata(const char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1376 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1378 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1384 /*******************************************************************
1386 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1387 ********************************************************************/
1389 BOOL
spoolss_io_q_deleteprinterdataex(const char *desc
, SPOOL_Q_DELETEPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
1394 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdataex");
1399 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1402 if (!smb_io_unistr2("keyname ", &q_u
->keyname
, True
, ps
, depth
))
1404 if (!smb_io_unistr2("valuename", &q_u
->valuename
, True
, ps
, depth
))
1410 /*******************************************************************
1411 * write a structure.
1412 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1413 ********************************************************************/
1415 BOOL
spoolss_io_r_deleteprinterdataex(const char *desc
, SPOOL_R_DELETEPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
1417 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdataex");
1420 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1426 /*******************************************************************
1427 * write a structure.
1428 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1429 ********************************************************************/
1431 BOOL
spoolss_io_r_getprinterdata(const char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1436 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1441 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1443 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1446 if (UNMARSHALLING(ps
) && r_u
->size
) {
1447 r_u
->data
= (unsigned char *)prs_alloc_mem(ps
, r_u
->size
);
1452 if (!prs_uint8s( False
, "data", ps
, depth
, r_u
->data
, r_u
->size
))
1458 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1460 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1466 /*******************************************************************
1468 ********************************************************************/
1470 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1472 if (q_u
== NULL
) return False
;
1474 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1476 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1481 /*******************************************************************
1483 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1484 * called from spoolss_abortprinter (cli_spoolss.c)
1485 ********************************************************************/
1487 BOOL
spoolss_io_q_abortprinter(const char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1489 if (q_u
== NULL
) return False
;
1491 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1497 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1503 /*******************************************************************
1504 * write a structure.
1505 * called from spoolss_r_abortprinter (srv_spoolss.c)
1506 ********************************************************************/
1508 BOOL
spoolss_io_r_abortprinter(const char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1510 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1512 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1518 /*******************************************************************
1520 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1521 * called from spoolss_deleteprinter (cli_spoolss.c)
1522 ********************************************************************/
1524 BOOL
spoolss_io_q_deleteprinter(const char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1526 if (q_u
== NULL
) return False
;
1528 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1534 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1540 /*******************************************************************
1541 * write a structure.
1542 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1543 * called from spoolss_deleteprinter (cli_spoolss.c)
1544 ********************************************************************/
1546 BOOL
spoolss_io_r_deleteprinter(const char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1548 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1554 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1556 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1563 /*******************************************************************
1565 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1566 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1567 ********************************************************************/
1569 BOOL
spoolss_io_q_deleteprinterdriver(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1571 if (q_u
== NULL
) return False
;
1573 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1579 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1581 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1583 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1585 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1593 /*******************************************************************
1594 * write a structure.
1595 ********************************************************************/
1596 BOOL
spoolss_io_r_deleteprinterdriver(const char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1598 if (r_u
== NULL
) return False
;
1600 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1606 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1613 /*******************************************************************
1615 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1616 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1617 ********************************************************************/
1619 BOOL
spoolss_io_q_deleteprinterdriverex(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
1621 if (q_u
== NULL
) return False
;
1623 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriverex");
1629 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1631 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1633 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1635 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1641 if(!prs_uint32("delete_flags ", ps
, depth
, &q_u
->delete_flags
))
1643 if(!prs_uint32("version ", ps
, depth
, &q_u
->version
))
1651 /*******************************************************************
1652 * write a structure.
1653 ********************************************************************/
1654 BOOL
spoolss_io_r_deleteprinterdriverex(const char *desc
, SPOOL_R_DELETEPRINTERDRIVEREX
*r_u
, prs_struct
*ps
, int depth
)
1656 if (r_u
== NULL
) return False
;
1658 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriverex");
1664 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1672 /*******************************************************************
1674 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1675 * called from spoolss_closeprinter (cli_spoolss.c)
1676 ********************************************************************/
1678 BOOL
spoolss_io_q_closeprinter(const char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1680 if (q_u
== NULL
) return False
;
1682 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1688 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1694 /*******************************************************************
1695 * write a structure.
1696 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1697 * called from spoolss_closeprinter (cli_spoolss.c)
1698 ********************************************************************/
1700 BOOL
spoolss_io_r_closeprinter(const char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1702 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1708 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1710 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1716 /*******************************************************************
1718 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1719 ********************************************************************/
1721 BOOL
spoolss_io_q_startdocprinter(const char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1723 if (q_u
== NULL
) return False
;
1725 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1731 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1734 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1740 /*******************************************************************
1741 * write a structure.
1742 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1743 ********************************************************************/
1745 BOOL
spoolss_io_r_startdocprinter(const char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1747 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1749 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1751 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1757 /*******************************************************************
1759 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1760 ********************************************************************/
1762 BOOL
spoolss_io_q_enddocprinter(const char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1764 if (q_u
== NULL
) return False
;
1766 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1772 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1778 /*******************************************************************
1779 * write a structure.
1780 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1781 ********************************************************************/
1783 BOOL
spoolss_io_r_enddocprinter(const char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1785 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1787 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1793 /*******************************************************************
1795 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1796 ********************************************************************/
1798 BOOL
spoolss_io_q_startpageprinter(const char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1800 if (q_u
== NULL
) return False
;
1802 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1808 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1814 /*******************************************************************
1815 * write a structure.
1816 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1817 ********************************************************************/
1819 BOOL
spoolss_io_r_startpageprinter(const char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1821 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1823 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1829 /*******************************************************************
1831 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1832 ********************************************************************/
1834 BOOL
spoolss_io_q_endpageprinter(const char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1836 if (q_u
== NULL
) return False
;
1838 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1844 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1850 /*******************************************************************
1851 * write a structure.
1852 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1853 ********************************************************************/
1855 BOOL
spoolss_io_r_endpageprinter(const char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1857 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1859 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1865 /*******************************************************************
1867 * called from spoolss_q_writeprinter (srv_spoolss.c)
1868 ********************************************************************/
1870 BOOL
spoolss_io_q_writeprinter(const char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1872 if (q_u
== NULL
) return False
;
1874 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1880 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1882 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1885 if (q_u
->buffer_size
!=0)
1887 if (UNMARSHALLING(ps
))
1888 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1889 if(q_u
->buffer
== NULL
)
1891 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1896 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1902 /*******************************************************************
1903 * write a structure.
1904 * called from spoolss_r_writeprinter (srv_spoolss.c)
1905 ********************************************************************/
1907 BOOL
spoolss_io_r_writeprinter(const char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1909 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1911 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1913 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1919 /*******************************************************************
1921 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1922 ********************************************************************/
1924 BOOL
spoolss_io_q_rffpcnex(const char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1926 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1932 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1934 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1936 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1938 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1940 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1946 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1949 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1952 if (q_u
->option_ptr
!=0) {
1954 if (UNMARSHALLING(ps
))
1955 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1958 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1965 /*******************************************************************
1966 * write a structure.
1967 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1968 ********************************************************************/
1970 BOOL
spoolss_io_r_rffpcnex(const char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1972 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1975 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1981 /*******************************************************************
1983 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1984 ********************************************************************/
1986 BOOL
spoolss_io_q_rfnpcnex(const char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1988 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1994 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1997 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
2000 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
2003 if (q_u
->option_ptr
!=0) {
2005 if (UNMARSHALLING(ps
))
2006 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
2009 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
2016 /*******************************************************************
2017 * write a structure.
2018 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
2019 ********************************************************************/
2021 BOOL
spoolss_io_r_rfnpcnex(const char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
2023 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
2029 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
2032 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
2037 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
2043 /*******************************************************************
2044 * return the length of a uint16 (obvious, but the code is clean)
2045 ********************************************************************/
2047 static uint32
size_of_uint16(uint16
*value
)
2049 return (sizeof(*value
));
2052 /*******************************************************************
2053 * return the length of a uint32 (obvious, but the code is clean)
2054 ********************************************************************/
2056 static uint32
size_of_uint32(uint32
*value
)
2058 return (sizeof(*value
));
2061 /*******************************************************************
2062 * return the length of a NTTIME (obvious, but the code is clean)
2063 ********************************************************************/
2065 static uint32
size_of_nttime(NTTIME
*value
)
2067 return (sizeof(*value
));
2070 /*******************************************************************
2071 * return the length of a UNICODE string in number of char, includes:
2072 * - the leading zero
2073 * - the relative pointer size
2074 ********************************************************************/
2076 static uint32
size_of_relative_string(UNISTR
*string
)
2080 size
=str_len_uni(string
); /* the string length */
2081 size
=size
+1; /* add the trailing zero */
2082 size
=size
*2; /* convert in char */
2083 size
=size
+4; /* add the size of the ptr */
2087 * Do not include alignment as Win2k does not align relative
2088 * strings within a buffer --jerry
2090 /* Ensure size is 4 byte multiple (prs_align is being called...). */
2091 /* size += ((4 - (size & 3)) & 3); */
2097 /*******************************************************************
2098 * return the length of a uint32 (obvious, but the code is clean)
2099 ********************************************************************/
2101 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
2106 return (4+devmode
->size
+devmode
->driverextra
);
2109 /*******************************************************************
2110 * return the length of a uint32 (obvious, but the code is clean)
2111 ********************************************************************/
2113 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
2118 return (sizeof(SYSTEMTIME
) +4);
2121 /*******************************************************************
2122 * write a UNICODE string and its relative pointer.
2123 * used by all the RPC structs passing a buffer
2125 * As I'm a nice guy, I'm forcing myself to explain this code.
2126 * MS did a good job in the overall spoolss code except in some
2127 * functions where they are passing the API buffer directly in the
2128 * RPC request/reply. That's to maintain compatiility at the API level.
2129 * They could have done it the good way the first time.
2131 * So what happen is: the strings are written at the buffer's end,
2132 * in the reverse order of the original structure. Some pointers to
2133 * the strings are also in the buffer. Those are relative to the
2136 * If you don't understand or want to change that function,
2137 * first get in touch with me: jfm@samba.org
2139 ********************************************************************/
2141 static BOOL
smb_io_relstr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
2143 prs_struct
*ps
=&buffer
->prs
;
2145 if (MARSHALLING(ps
)) {
2146 uint32 struct_offset
= prs_offset(ps
);
2147 uint32 relative_offset
;
2149 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
2150 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2154 * Win2k does not align strings in a buffer
2155 * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry
2160 buffer
->string_at_end
= prs_offset(ps
);
2162 /* write the string */
2163 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2166 if(!prs_set_offset(ps
, struct_offset
))
2169 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2170 /* write its offset */
2171 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2177 /* read the offset */
2178 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
2181 if (buffer
->string_at_end
== 0)
2184 old_offset
= prs_offset(ps
);
2185 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
2188 /* read the string */
2189 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2192 if(!prs_set_offset(ps
, old_offset
))
2198 /*******************************************************************
2199 * write a array of UNICODE strings and its relative pointer.
2200 * used by 2 RPC structs
2201 ********************************************************************/
2203 static BOOL
smb_io_relarraystr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
2207 prs_struct
*ps
=&buffer
->prs
;
2209 if (MARSHALLING(ps
)) {
2210 uint32 struct_offset
= prs_offset(ps
);
2211 uint32 relative_offset
;
2218 /* first write the last 0 */
2219 buffer
->string_at_end
-= 2;
2220 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2223 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
2226 while (p
&& (*p
!=0)) {
2230 /* Yes this should be malloc not talloc. Don't change. */
2232 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
2233 if (chaine
.buffer
== NULL
)
2236 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
2238 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
2240 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
2241 SAFE_FREE(chaine
.buffer
);
2245 /* write the string */
2246 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
2247 SAFE_FREE(chaine
.buffer
);
2253 SAFE_FREE(chaine
.buffer
);
2256 if(!prs_set_offset(ps
, struct_offset
))
2259 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2260 /* write its offset */
2261 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2269 uint16
*chaine2
=NULL
;
2272 size_t realloc_size
= 0;
2276 /* read the offset */
2277 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2280 old_offset
= prs_offset(ps
);
2281 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2285 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
))
2288 l_chaine
=str_len_uni(&chaine
);
2290 /* we're going to add two more bytes here in case this
2291 is the last string in the array and we need to add
2292 an extra NULL for termination */
2297 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
2299 /* Yes this should be realloc - it's freed below. JRA */
2301 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
2306 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
2307 l_chaine2
+=l_chaine
+1;
2310 } while(l_chaine
!=0);
2312 /* the end should be bould NULL terminated so add
2313 the second one here */
2316 chaine2
[l_chaine2
] = '\0';
2317 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
2321 if(!prs_set_offset(ps
, old_offset
))
2327 /*******************************************************************
2328 Parse a DEVMODE structure and its relative pointer.
2329 ********************************************************************/
2331 static BOOL
smb_io_relsecdesc(const char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
2333 prs_struct
*ps
= &buffer
->prs
;
2335 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
2338 if (MARSHALLING(ps
)) {
2339 uint32 struct_offset
= prs_offset(ps
);
2340 uint32 relative_offset
;
2343 relative_offset
= 0;
2344 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2349 if (*secdesc
!= NULL
) {
2350 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
2352 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2354 /* write the secdesc */
2355 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2358 if(!prs_set_offset(ps
, struct_offset
))
2362 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2363 /* write its offset */
2365 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2370 /* read the offset */
2371 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2374 old_offset
= prs_offset(ps
);
2375 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2379 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2382 if(!prs_set_offset(ps
, old_offset
))
2388 /*******************************************************************
2389 Parse a DEVMODE structure and its relative pointer.
2390 ********************************************************************/
2392 static BOOL
smb_io_reldevmode(const char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2394 prs_struct
*ps
=&buffer
->prs
;
2396 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2399 if (MARSHALLING(ps
)) {
2400 uint32 struct_offset
= prs_offset(ps
);
2401 uint32 relative_offset
;
2403 if (*devmode
== NULL
) {
2405 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2407 DEBUG(8, ("boing, the devmode was NULL\n"));
2412 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2414 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2417 /* write the DEVMODE */
2418 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2421 if(!prs_set_offset(ps
, struct_offset
))
2424 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2425 /* write its offset */
2426 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2432 /* read the offset */
2433 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2435 if (buffer
->string_at_end
== 0) {
2440 old_offset
= prs_offset(ps
);
2441 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2444 /* read the string */
2445 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2447 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2450 if(!prs_set_offset(ps
, old_offset
))
2456 /*******************************************************************
2457 Parse a PRINTER_INFO_0 structure.
2458 ********************************************************************/
2460 BOOL
smb_io_printer_info_0(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2462 prs_struct
*ps
=&buffer
->prs
;
2464 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2467 buffer
->struct_start
=prs_offset(ps
);
2469 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2471 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2474 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2476 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2478 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2481 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2483 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2485 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2487 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2489 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2491 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2493 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2495 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2498 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2500 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2503 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2505 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2507 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2509 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2511 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2513 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2515 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2517 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2519 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2521 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2523 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2525 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2527 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2529 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2531 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2533 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2535 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2537 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2539 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2541 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2543 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2545 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2547 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2549 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2551 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2557 /*******************************************************************
2558 Parse a PRINTER_INFO_1 structure.
2559 ********************************************************************/
2561 BOOL
smb_io_printer_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2563 prs_struct
*ps
=&buffer
->prs
;
2565 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2568 buffer
->struct_start
=prs_offset(ps
);
2570 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2572 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2574 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2576 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2582 /*******************************************************************
2583 Parse a PRINTER_INFO_2 structure.
2584 ********************************************************************/
2586 BOOL
smb_io_printer_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2588 prs_struct
*ps
=&buffer
->prs
;
2589 uint32 dm_offset
, sd_offset
, current_offset
;
2590 uint32 dummy_value
= 0, has_secdesc
= 0;
2592 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2595 buffer
->struct_start
=prs_offset(ps
);
2597 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2599 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2601 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2603 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2605 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2607 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2609 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2612 /* save current offset and wind forwared by a uint32 */
2613 dm_offset
= prs_offset(ps
);
2614 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
2617 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2619 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2621 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2623 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2626 /* save current offset for the sec_desc */
2627 sd_offset
= prs_offset(ps
);
2628 if (!prs_uint32("sec_desc", ps
, depth
, &has_secdesc
))
2632 /* save current location so we can pick back up here */
2633 current_offset
= prs_offset(ps
);
2635 /* parse the devmode */
2636 if (!prs_set_offset(ps
, dm_offset
))
2638 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2641 /* parse the sec_desc */
2642 if (info
->secdesc
) {
2643 if (!prs_set_offset(ps
, sd_offset
))
2645 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2649 /* pick up where we left off */
2650 if (!prs_set_offset(ps
, current_offset
))
2653 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2655 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2657 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2659 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2661 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2663 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2665 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2667 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2673 /*******************************************************************
2674 Parse a PRINTER_INFO_3 structure.
2675 ********************************************************************/
2677 BOOL
smb_io_printer_info_3(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2679 prs_struct
*ps
=&buffer
->prs
;
2681 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2684 buffer
->struct_start
=prs_offset(ps
);
2686 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2688 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2694 /*******************************************************************
2695 Parse a PRINTER_INFO_4 structure.
2696 ********************************************************************/
2698 BOOL
smb_io_printer_info_4(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2700 prs_struct
*ps
=&buffer
->prs
;
2702 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2705 buffer
->struct_start
=prs_offset(ps
);
2707 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2709 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2711 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2716 /*******************************************************************
2717 Parse a PRINTER_INFO_5 structure.
2718 ********************************************************************/
2720 BOOL
smb_io_printer_info_5(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2722 prs_struct
*ps
=&buffer
->prs
;
2724 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2727 buffer
->struct_start
=prs_offset(ps
);
2729 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2731 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2733 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2735 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2737 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2742 /*******************************************************************
2743 Parse a PRINTER_INFO_7 structure.
2744 ********************************************************************/
2746 BOOL
smb_io_printer_info_7(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_7
*info
, int depth
)
2748 prs_struct
*ps
=&buffer
->prs
;
2750 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_7");
2753 buffer
->struct_start
=prs_offset(ps
);
2755 if (!smb_io_relstr("guid", buffer
, depth
, &info
->guid
))
2757 if (!prs_uint32("action", ps
, depth
, &info
->action
))
2762 /*******************************************************************
2763 Parse a PORT_INFO_1 structure.
2764 ********************************************************************/
2766 BOOL
smb_io_port_info_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2768 prs_struct
*ps
=&buffer
->prs
;
2770 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2773 buffer
->struct_start
=prs_offset(ps
);
2775 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2781 /*******************************************************************
2782 Parse a PORT_INFO_2 structure.
2783 ********************************************************************/
2785 BOOL
smb_io_port_info_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2787 prs_struct
*ps
=&buffer
->prs
;
2789 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2792 buffer
->struct_start
=prs_offset(ps
);
2794 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2796 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2798 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2800 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2802 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2808 /*******************************************************************
2809 Parse a DRIVER_INFO_1 structure.
2810 ********************************************************************/
2812 BOOL
smb_io_printer_driver_info_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2814 prs_struct
*ps
=&buffer
->prs
;
2816 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2819 buffer
->struct_start
=prs_offset(ps
);
2821 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2827 /*******************************************************************
2828 Parse a DRIVER_INFO_2 structure.
2829 ********************************************************************/
2831 BOOL
smb_io_printer_driver_info_2(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2833 prs_struct
*ps
=&buffer
->prs
;
2835 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2838 buffer
->struct_start
=prs_offset(ps
);
2840 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2842 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2844 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2846 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2848 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2850 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2856 /*******************************************************************
2857 Parse a DRIVER_INFO_3 structure.
2858 ********************************************************************/
2860 BOOL
smb_io_printer_driver_info_3(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2862 prs_struct
*ps
=&buffer
->prs
;
2864 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2867 buffer
->struct_start
=prs_offset(ps
);
2869 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2871 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2873 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2875 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2877 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2879 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2881 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2884 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2887 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2889 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2895 /*******************************************************************
2896 Parse a DRIVER_INFO_6 structure.
2897 ********************************************************************/
2899 BOOL
smb_io_printer_driver_info_6(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2901 prs_struct
*ps
=&buffer
->prs
;
2903 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2906 buffer
->struct_start
=prs_offset(ps
);
2908 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2910 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2912 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2914 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2916 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2918 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2920 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2923 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2926 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2928 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2931 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2934 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2936 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2939 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2942 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2945 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2948 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2950 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2952 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2954 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2960 /*******************************************************************
2961 Parse a JOB_INFO_1 structure.
2962 ********************************************************************/
2964 BOOL
smb_io_job_info_1(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2966 prs_struct
*ps
=&buffer
->prs
;
2968 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2971 buffer
->struct_start
=prs_offset(ps
);
2973 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2975 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2977 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2979 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2981 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2983 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2985 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2987 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2989 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2991 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2993 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2995 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2997 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
3003 /*******************************************************************
3004 Parse a JOB_INFO_2 structure.
3005 ********************************************************************/
3007 BOOL
smb_io_job_info_2(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
3010 prs_struct
*ps
=&buffer
->prs
;
3012 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
3015 buffer
->struct_start
=prs_offset(ps
);
3017 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
3019 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
3021 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
3023 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
3025 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
3027 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
3029 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
3032 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
3034 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
3036 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
3038 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
3040 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
3043 /* SEC_DESC sec_desc;*/
3044 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
3047 if (!prs_uint32("status",ps
, depth
, &info
->status
))
3049 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
3051 if (!prs_uint32("position",ps
, depth
, &info
->position
))
3053 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
3055 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
3057 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
3059 if (!prs_uint32("size",ps
, depth
, &info
->size
))
3061 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
3063 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
3065 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
3071 /*******************************************************************
3072 ********************************************************************/
3074 BOOL
smb_io_form_1(const char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
3076 prs_struct
*ps
=&buffer
->prs
;
3078 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
3081 buffer
->struct_start
=prs_offset(ps
);
3083 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
3086 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3089 if (!prs_uint32("width", ps
, depth
, &info
->width
))
3091 if (!prs_uint32("length", ps
, depth
, &info
->length
))
3093 if (!prs_uint32("left", ps
, depth
, &info
->left
))
3095 if (!prs_uint32("top", ps
, depth
, &info
->top
))
3097 if (!prs_uint32("right", ps
, depth
, &info
->right
))
3099 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
3105 /*******************************************************************
3106 Read/write a BUFFER struct.
3107 ********************************************************************/
3109 static BOOL
spoolss_io_buffer(const char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
3111 NEW_BUFFER
*buffer
= *pp_buffer
;
3113 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
3116 if (UNMARSHALLING(ps
))
3117 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
3122 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
3126 if (UNMARSHALLING(ps
)) {
3128 buffer
->string_at_end
=0;
3130 if (buffer
->ptr
==0) {
3132 * JRA. I'm not sure if the data in here is in big-endian format if
3133 * the client is big-endian. Leave as default (little endian) for now.
3136 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
3141 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3145 * JRA. I'm not sure if the data in here is in big-endian format if
3146 * the client is big-endian. Leave as default (little endian) for now.
3149 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
3152 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
3155 if (!prs_set_offset(&buffer
->prs
, 0))
3158 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
3161 buffer
->string_at_end
=buffer
->size
;
3169 if (buffer
->ptr
==0) {
3170 /* We have finished with the data in buffer->prs - free it. */
3171 prs_mem_free(&buffer
->prs
);
3175 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3178 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
3184 /* We have finished with the data in buffer->prs - free it. */
3185 prs_mem_free(&buffer
->prs
);
3191 /*******************************************************************
3192 move a BUFFER from the query to the reply.
3193 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
3194 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
3195 Clears the memory to zero also.
3196 ********************************************************************/
3198 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
3200 prs_switch_type(&src
->prs
, MARSHALL
);
3201 if(!prs_set_offset(&src
->prs
, 0))
3203 prs_force_dynamic(&src
->prs
);
3204 prs_mem_clear(&src
->prs
);
3208 /*******************************************************************
3209 Get the size of a BUFFER struct.
3210 ********************************************************************/
3212 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
3214 return (buffer
->size
);
3217 /*******************************************************************
3218 Parse a DRIVER_DIRECTORY_1 structure.
3219 ********************************************************************/
3221 BOOL
smb_io_driverdir_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
3223 prs_struct
*ps
=&buffer
->prs
;
3225 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
3228 buffer
->struct_start
=prs_offset(ps
);
3230 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
3236 /*******************************************************************
3237 Parse a PORT_INFO_1 structure.
3238 ********************************************************************/
3240 BOOL
smb_io_port_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
3242 prs_struct
*ps
=&buffer
->prs
;
3244 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
3247 buffer
->struct_start
=prs_offset(ps
);
3249 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3255 /*******************************************************************
3256 Parse a PORT_INFO_2 structure.
3257 ********************************************************************/
3259 BOOL
smb_io_port_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
3261 prs_struct
*ps
=&buffer
->prs
;
3263 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
3266 buffer
->struct_start
=prs_offset(ps
);
3268 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3270 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
3272 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
3274 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
3276 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
3282 /*******************************************************************
3283 ********************************************************************/
3285 BOOL
smb_io_printprocessor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
3287 prs_struct
*ps
=&buffer
->prs
;
3289 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
3292 buffer
->struct_start
=prs_offset(ps
);
3294 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3300 /*******************************************************************
3301 ********************************************************************/
3303 BOOL
smb_io_printprocdatatype_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
3305 prs_struct
*ps
=&buffer
->prs
;
3307 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
3310 buffer
->struct_start
=prs_offset(ps
);
3312 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3318 /*******************************************************************
3319 ********************************************************************/
3321 BOOL
smb_io_printmonitor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
3323 prs_struct
*ps
=&buffer
->prs
;
3325 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
3328 buffer
->struct_start
=prs_offset(ps
);
3330 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3336 /*******************************************************************
3337 ********************************************************************/
3339 BOOL
smb_io_printmonitor_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
3341 prs_struct
*ps
=&buffer
->prs
;
3343 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
3346 buffer
->struct_start
=prs_offset(ps
);
3348 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3350 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
3352 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
3358 /*******************************************************************
3359 return the size required by a struct in the stream
3360 ********************************************************************/
3362 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
3366 size
+=size_of_relative_string( &info
->printername
);
3367 size
+=size_of_relative_string( &info
->servername
);
3369 size
+=size_of_uint32( &info
->cjobs
);
3370 size
+=size_of_uint32( &info
->total_jobs
);
3371 size
+=size_of_uint32( &info
->total_bytes
);
3373 size
+=size_of_uint16( &info
->year
);
3374 size
+=size_of_uint16( &info
->month
);
3375 size
+=size_of_uint16( &info
->dayofweek
);
3376 size
+=size_of_uint16( &info
->day
);
3377 size
+=size_of_uint16( &info
->hour
);
3378 size
+=size_of_uint16( &info
->minute
);
3379 size
+=size_of_uint16( &info
->second
);
3380 size
+=size_of_uint16( &info
->milliseconds
);
3382 size
+=size_of_uint32( &info
->global_counter
);
3383 size
+=size_of_uint32( &info
->total_pages
);
3385 size
+=size_of_uint16( &info
->major_version
);
3386 size
+=size_of_uint16( &info
->build_version
);
3388 size
+=size_of_uint32( &info
->unknown7
);
3389 size
+=size_of_uint32( &info
->unknown8
);
3390 size
+=size_of_uint32( &info
->unknown9
);
3391 size
+=size_of_uint32( &info
->session_counter
);
3392 size
+=size_of_uint32( &info
->unknown11
);
3393 size
+=size_of_uint32( &info
->printer_errors
);
3394 size
+=size_of_uint32( &info
->unknown13
);
3395 size
+=size_of_uint32( &info
->unknown14
);
3396 size
+=size_of_uint32( &info
->unknown15
);
3397 size
+=size_of_uint32( &info
->unknown16
);
3398 size
+=size_of_uint32( &info
->change_id
);
3399 size
+=size_of_uint32( &info
->unknown18
);
3400 size
+=size_of_uint32( &info
->status
);
3401 size
+=size_of_uint32( &info
->unknown20
);
3402 size
+=size_of_uint32( &info
->c_setprinter
);
3404 size
+=size_of_uint16( &info
->unknown22
);
3405 size
+=size_of_uint16( &info
->unknown23
);
3406 size
+=size_of_uint16( &info
->unknown24
);
3407 size
+=size_of_uint16( &info
->unknown25
);
3408 size
+=size_of_uint16( &info
->unknown26
);
3409 size
+=size_of_uint16( &info
->unknown27
);
3410 size
+=size_of_uint16( &info
->unknown28
);
3411 size
+=size_of_uint16( &info
->unknown29
);
3416 /*******************************************************************
3417 return the size required by a struct in the stream
3418 ********************************************************************/
3420 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3424 size
+=size_of_uint32( &info
->flags
);
3425 size
+=size_of_relative_string( &info
->description
);
3426 size
+=size_of_relative_string( &info
->name
);
3427 size
+=size_of_relative_string( &info
->comment
);
3432 /*******************************************************************
3433 return the size required by a struct in the stream
3434 ********************************************************************/
3436 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3442 size
+= sec_desc_size( info
->secdesc
);
3444 size
+=size_of_device_mode( info
->devmode
);
3446 size
+=size_of_relative_string( &info
->servername
);
3447 size
+=size_of_relative_string( &info
->printername
);
3448 size
+=size_of_relative_string( &info
->sharename
);
3449 size
+=size_of_relative_string( &info
->portname
);
3450 size
+=size_of_relative_string( &info
->drivername
);
3451 size
+=size_of_relative_string( &info
->comment
);
3452 size
+=size_of_relative_string( &info
->location
);
3454 size
+=size_of_relative_string( &info
->sepfile
);
3455 size
+=size_of_relative_string( &info
->printprocessor
);
3456 size
+=size_of_relative_string( &info
->datatype
);
3457 size
+=size_of_relative_string( &info
->parameters
);
3459 size
+=size_of_uint32( &info
->attributes
);
3460 size
+=size_of_uint32( &info
->priority
);
3461 size
+=size_of_uint32( &info
->defaultpriority
);
3462 size
+=size_of_uint32( &info
->starttime
);
3463 size
+=size_of_uint32( &info
->untiltime
);
3464 size
+=size_of_uint32( &info
->status
);
3465 size
+=size_of_uint32( &info
->cjobs
);
3466 size
+=size_of_uint32( &info
->averageppm
);
3469 * add any adjustments for alignment. This is
3470 * not optimal since we could be calling this
3471 * function from a loop (e.g. enumprinters), but
3472 * it is easier to maintain the calculation here and
3473 * not place the burden on the caller to remember. --jerry
3475 if ((size
% 4) != 0)
3476 size
+= 4 - (size
% 4);
3481 /*******************************************************************
3482 return the size required by a struct in the stream
3483 ********************************************************************/
3485 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3489 size
+=size_of_relative_string( &info
->printername
);
3490 size
+=size_of_relative_string( &info
->servername
);
3492 size
+=size_of_uint32( &info
->attributes
);
3496 /*******************************************************************
3497 return the size required by a struct in the stream
3498 ********************************************************************/
3500 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3504 size
+=size_of_relative_string( &info
->printername
);
3505 size
+=size_of_relative_string( &info
->portname
);
3507 size
+=size_of_uint32( &info
->attributes
);
3508 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3509 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3514 /*******************************************************************
3515 return the size required by a struct in the stream
3516 ********************************************************************/
3518 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3520 /* The 4 is for the self relative pointer.. */
3521 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3522 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3525 /*******************************************************************
3526 return the size required by a struct in the stream
3527 ********************************************************************/
3529 uint32
spoolss_size_printer_info_7(PRINTER_INFO_7
*info
)
3533 size
+=size_of_relative_string( &info
->guid
);
3534 size
+=size_of_uint32( &info
->action
);
3538 /*******************************************************************
3539 return the size required by a struct in the stream
3540 ********************************************************************/
3542 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3545 size
+=size_of_relative_string( &info
->name
);
3550 /*******************************************************************
3551 return the size required by a struct in the stream
3552 ********************************************************************/
3554 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3557 size
+=size_of_uint32( &info
->version
);
3558 size
+=size_of_relative_string( &info
->name
);
3559 size
+=size_of_relative_string( &info
->architecture
);
3560 size
+=size_of_relative_string( &info
->driverpath
);
3561 size
+=size_of_relative_string( &info
->datafile
);
3562 size
+=size_of_relative_string( &info
->configfile
);
3567 /*******************************************************************
3568 return the size required by a string array.
3569 ********************************************************************/
3571 uint32
spoolss_size_string_array(uint16
*string
)
3576 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3578 i
=i
+2; /* to count all chars including the leading zero */
3579 i
=2*i
; /* because we need the value in bytes */
3580 i
=i
+4; /* the offset pointer size */
3585 /*******************************************************************
3586 return the size required by a struct in the stream
3587 ********************************************************************/
3589 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3593 size
+=size_of_uint32( &info
->version
);
3594 size
+=size_of_relative_string( &info
->name
);
3595 size
+=size_of_relative_string( &info
->architecture
);
3596 size
+=size_of_relative_string( &info
->driverpath
);
3597 size
+=size_of_relative_string( &info
->datafile
);
3598 size
+=size_of_relative_string( &info
->configfile
);
3599 size
+=size_of_relative_string( &info
->helpfile
);
3600 size
+=size_of_relative_string( &info
->monitorname
);
3601 size
+=size_of_relative_string( &info
->defaultdatatype
);
3603 size
+=spoolss_size_string_array(info
->dependentfiles
);
3608 /*******************************************************************
3609 return the size required by a struct in the stream
3610 ********************************************************************/
3612 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3616 size
+=size_of_uint32( &info
->version
);
3617 size
+=size_of_relative_string( &info
->name
);
3618 size
+=size_of_relative_string( &info
->architecture
);
3619 size
+=size_of_relative_string( &info
->driverpath
);
3620 size
+=size_of_relative_string( &info
->datafile
);
3621 size
+=size_of_relative_string( &info
->configfile
);
3622 size
+=size_of_relative_string( &info
->helpfile
);
3624 size
+=spoolss_size_string_array(info
->dependentfiles
);
3626 size
+=size_of_relative_string( &info
->monitorname
);
3627 size
+=size_of_relative_string( &info
->defaultdatatype
);
3629 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3631 size
+=size_of_nttime(&info
->driver_date
);
3632 size
+=size_of_uint32( &info
->padding
);
3633 size
+=size_of_uint32( &info
->driver_version_low
);
3634 size
+=size_of_uint32( &info
->driver_version_high
);
3635 size
+=size_of_relative_string( &info
->mfgname
);
3636 size
+=size_of_relative_string( &info
->oem_url
);
3637 size
+=size_of_relative_string( &info
->hardware_id
);
3638 size
+=size_of_relative_string( &info
->provider
);
3643 /*******************************************************************
3644 return the size required by a struct in the stream
3645 ********************************************************************/
3647 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3650 size
+=size_of_uint32( &info
->jobid
);
3651 size
+=size_of_relative_string( &info
->printername
);
3652 size
+=size_of_relative_string( &info
->machinename
);
3653 size
+=size_of_relative_string( &info
->username
);
3654 size
+=size_of_relative_string( &info
->document
);
3655 size
+=size_of_relative_string( &info
->datatype
);
3656 size
+=size_of_relative_string( &info
->text_status
);
3657 size
+=size_of_uint32( &info
->status
);
3658 size
+=size_of_uint32( &info
->priority
);
3659 size
+=size_of_uint32( &info
->position
);
3660 size
+=size_of_uint32( &info
->totalpages
);
3661 size
+=size_of_uint32( &info
->pagesprinted
);
3662 size
+=size_of_systemtime( &info
->submitted
);
3667 /*******************************************************************
3668 return the size required by a struct in the stream
3669 ********************************************************************/
3671 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3675 size
+=4; /* size of sec desc ptr */
3677 size
+=size_of_uint32( &info
->jobid
);
3678 size
+=size_of_relative_string( &info
->printername
);
3679 size
+=size_of_relative_string( &info
->machinename
);
3680 size
+=size_of_relative_string( &info
->username
);
3681 size
+=size_of_relative_string( &info
->document
);
3682 size
+=size_of_relative_string( &info
->notifyname
);
3683 size
+=size_of_relative_string( &info
->datatype
);
3684 size
+=size_of_relative_string( &info
->printprocessor
);
3685 size
+=size_of_relative_string( &info
->parameters
);
3686 size
+=size_of_relative_string( &info
->drivername
);
3687 size
+=size_of_device_mode( info
->devmode
);
3688 size
+=size_of_relative_string( &info
->text_status
);
3689 /* SEC_DESC sec_desc;*/
3690 size
+=size_of_uint32( &info
->status
);
3691 size
+=size_of_uint32( &info
->priority
);
3692 size
+=size_of_uint32( &info
->position
);
3693 size
+=size_of_uint32( &info
->starttime
);
3694 size
+=size_of_uint32( &info
->untiltime
);
3695 size
+=size_of_uint32( &info
->totalpages
);
3696 size
+=size_of_uint32( &info
->size
);
3697 size
+=size_of_systemtime( &info
->submitted
);
3698 size
+=size_of_uint32( &info
->timeelapsed
);
3699 size
+=size_of_uint32( &info
->pagesprinted
);
3704 /*******************************************************************
3705 return the size required by a struct in the stream
3706 ********************************************************************/
3708 uint32
spoolss_size_form_1(FORM_1
*info
)
3712 size
+=size_of_uint32( &info
->flag
);
3713 size
+=size_of_relative_string( &info
->name
);
3714 size
+=size_of_uint32( &info
->width
);
3715 size
+=size_of_uint32( &info
->length
);
3716 size
+=size_of_uint32( &info
->left
);
3717 size
+=size_of_uint32( &info
->top
);
3718 size
+=size_of_uint32( &info
->right
);
3719 size
+=size_of_uint32( &info
->bottom
);
3724 /*******************************************************************
3725 return the size required by a struct in the stream
3726 ********************************************************************/
3728 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3732 size
+=size_of_relative_string( &info
->port_name
);
3737 /*******************************************************************
3738 return the size required by a struct in the stream
3739 ********************************************************************/
3741 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3745 size
=str_len_uni(&info
->name
); /* the string length */
3746 size
=size
+1; /* add the leading zero */
3747 size
=size
*2; /* convert in char */
3752 /*******************************************************************
3753 return the size required by a struct in the stream
3754 ********************************************************************/
3756 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3760 size
=str_len_uni(&info
->name
); /* the string length */
3761 size
=size
+1; /* add the leading zero */
3762 size
=size
*2; /* convert in char */
3767 /*******************************************************************
3768 return the size required by a struct in the stream
3769 ********************************************************************/
3771 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3775 size
+=size_of_relative_string( &info
->port_name
);
3776 size
+=size_of_relative_string( &info
->monitor_name
);
3777 size
+=size_of_relative_string( &info
->description
);
3779 size
+=size_of_uint32( &info
->port_type
);
3780 size
+=size_of_uint32( &info
->reserved
);
3785 /*******************************************************************
3786 return the size required by a struct in the stream
3787 ********************************************************************/
3789 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3792 size
+=size_of_relative_string( &info
->name
);
3797 /*******************************************************************
3798 return the size required by a struct in the stream
3799 ********************************************************************/
3801 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3804 size
+=size_of_relative_string( &info
->name
);
3809 /*******************************************************************
3810 return the size required by a struct in the stream
3811 ********************************************************************/
3812 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3819 /* uint32(offset) + uint32(length) + length) */
3820 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3821 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
+ (p
->data_len
%2) ;
3823 size
+= size_of_uint32(&p
->type
);
3828 /*******************************************************************
3829 return the size required by a struct in the stream
3830 ********************************************************************/
3832 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3835 size
+=size_of_relative_string( &info
->name
);
3840 /*******************************************************************
3841 return the size required by a struct in the stream
3842 ********************************************************************/
3844 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3847 size
+=size_of_relative_string( &info
->name
);
3848 size
+=size_of_relative_string( &info
->environment
);
3849 size
+=size_of_relative_string( &info
->dll_name
);
3854 /*******************************************************************
3856 ********************************************************************/
3858 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3859 const POLICY_HND
*hnd
,
3860 const fstring architecture
,
3861 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3862 NEW_BUFFER
*buffer
, uint32 offered
)
3867 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3869 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3872 q_u
->clientmajorversion
=clientmajor
;
3873 q_u
->clientminorversion
=clientminor
;
3876 q_u
->offered
=offered
;
3881 /*******************************************************************
3883 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3884 ********************************************************************/
3886 BOOL
spoolss_io_q_getprinterdriver2(const char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3888 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3894 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3896 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3898 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3903 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3906 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3912 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3915 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3917 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3923 /*******************************************************************
3925 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3926 ********************************************************************/
3928 BOOL
spoolss_io_r_getprinterdriver2(const char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3930 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3936 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3941 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3943 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3945 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3947 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3953 /*******************************************************************
3955 ********************************************************************/
3957 BOOL
make_spoolss_q_enumprinters(
3958 SPOOL_Q_ENUMPRINTERS
*q_u
,
3968 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3969 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3973 q_u
->offered
=offered
;
3978 /*******************************************************************
3980 ********************************************************************/
3982 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3983 fstring servername
, uint32 level
,
3984 NEW_BUFFER
*buffer
, uint32 offered
)
3986 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3987 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3991 q_u
->offered
=offered
;
3996 /*******************************************************************
3998 * called from spoolss_enumprinters (srv_spoolss.c)
3999 ********************************************************************/
4001 BOOL
spoolss_io_q_enumprinters(const char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
4003 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
4009 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
4011 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
4014 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
4019 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4022 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4027 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4033 /*******************************************************************
4034 Parse a SPOOL_R_ENUMPRINTERS structure.
4035 ********************************************************************/
4037 BOOL
spoolss_io_r_enumprinters(const char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
4039 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
4045 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4051 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4054 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4057 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4063 /*******************************************************************
4064 * write a structure.
4065 * called from spoolss_r_enum_printers (srv_spoolss.c)
4067 ********************************************************************/
4069 BOOL
spoolss_io_r_getprinter(const char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
4071 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
4077 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4083 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4086 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4092 /*******************************************************************
4094 * called from spoolss_getprinter (srv_spoolss.c)
4095 ********************************************************************/
4097 BOOL
spoolss_io_q_getprinter(const char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4099 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
4105 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4107 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4110 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4115 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4121 /*******************************************************************
4123 ********************************************************************/
4125 BOOL
make_spoolss_q_getprinter(
4126 TALLOC_CTX
*mem_ctx
,
4127 SPOOL_Q_GETPRINTER
*q_u
,
4128 const POLICY_HND
*hnd
,
4138 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4142 q_u
->offered
=offered
;
4147 /*******************************************************************
4149 ********************************************************************/
4150 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
4151 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
4155 DEVICEMODE
*devmode
;
4160 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4163 q_u
->info
.level
= level
;
4164 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
4167 /* There's no such thing as a setprinter level 1 */
4170 secdesc
= info
->printers_2
->secdesc
;
4171 devmode
= info
->printers_2
->devmode
;
4173 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
4174 #if 1 /* JERRY TEST */
4175 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
4176 if (!q_u
->secdesc_ctr
)
4178 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
4179 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4180 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4181 q_u
->secdesc_ctr
->sec
= secdesc
;
4183 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
4184 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
4185 q_u
->devmode_ctr
.devmode
= devmode
;
4187 q_u
->secdesc_ctr
= NULL
;
4189 q_u
->devmode_ctr
.devmode_ptr
= 0;
4190 q_u
->devmode_ctr
.size
= 0;
4191 q_u
->devmode_ctr
.devmode
= NULL
;
4195 secdesc
= info
->printers_3
->secdesc
;
4197 make_spoolss_printer_info_3 (mem_ctx
, &q_u
->info
.info_3
, info
->printers_3
);
4199 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
4200 if (!q_u
->secdesc_ctr
)
4202 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
4203 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4204 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4205 q_u
->secdesc_ctr
->sec
= secdesc
;
4209 make_spoolss_printer_info_7 (mem_ctx
, &q_u
->info
.info_7
, info
->printers_7
);
4213 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
4218 q_u
->command
= command
;
4224 /*******************************************************************
4225 ********************************************************************/
4227 BOOL
spoolss_io_r_setprinter(const char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
4229 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
4235 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4241 /*******************************************************************
4242 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
4243 ********************************************************************/
4245 BOOL
spoolss_io_q_setprinter(const char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4247 uint32 ptr_sec_desc
= 0;
4249 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
4255 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
4257 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4260 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4263 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4273 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4278 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4284 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4289 /* Parse a NULL security descriptor. This should really
4290 happen inside the sec_io_desc_buf() function. */
4292 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4293 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4295 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
4299 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4305 /*******************************************************************
4306 ********************************************************************/
4308 BOOL
spoolss_io_r_fcpn(const char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
4310 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
4316 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4322 /*******************************************************************
4323 ********************************************************************/
4325 BOOL
spoolss_io_q_fcpn(const char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
4328 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
4334 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4341 /*******************************************************************
4342 ********************************************************************/
4344 BOOL
spoolss_io_r_addjob(const char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
4346 prs_debug(ps
, depth
, desc
, "");
4352 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4358 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4361 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4367 /*******************************************************************
4368 ********************************************************************/
4370 BOOL
spoolss_io_q_addjob(const char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
4372 prs_debug(ps
, depth
, desc
, "");
4378 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4380 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4383 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4389 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4395 /*******************************************************************
4396 ********************************************************************/
4398 BOOL
spoolss_io_r_enumjobs(const char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
4400 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
4406 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4412 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4415 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4418 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4424 /*******************************************************************
4425 ********************************************************************/
4427 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4438 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4439 q_u
->firstjob
= firstjob
;
4440 q_u
->numofjobs
= numofjobs
;
4442 q_u
->buffer
= buffer
;
4443 q_u
->offered
= offered
;
4447 /*******************************************************************
4448 ********************************************************************/
4450 BOOL
spoolss_io_q_enumjobs(const char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4452 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4458 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4461 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4463 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
4465 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4468 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4474 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4480 /*******************************************************************
4481 ********************************************************************/
4483 BOOL
spoolss_io_r_schedulejob(const char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4485 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4491 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4497 /*******************************************************************
4498 ********************************************************************/
4500 BOOL
spoolss_io_q_schedulejob(const char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4502 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4508 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4510 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4516 /*******************************************************************
4517 ********************************************************************/
4519 BOOL
spoolss_io_r_setjob(const char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4521 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4527 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4533 /*******************************************************************
4534 ********************************************************************/
4536 BOOL
spoolss_io_q_setjob(const char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4538 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4544 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4546 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4549 * level is usually 0. If (level!=0) then I'm in trouble !
4550 * I will try to generate setjob command with level!=0, one day.
4552 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4554 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4560 /*******************************************************************
4561 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4562 ********************************************************************/
4564 BOOL
spoolss_io_r_enumprinterdrivers(const char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4566 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4572 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4578 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4581 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4584 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4590 /*******************************************************************
4592 ********************************************************************/
4594 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4596 const char *environment
,
4598 NEW_BUFFER
*buffer
, uint32 offered
)
4600 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4601 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4605 q_u
->offered
=offered
;
4610 /*******************************************************************
4611 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4612 ********************************************************************/
4614 BOOL
spoolss_io_q_enumprinterdrivers(const char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4617 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4623 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4625 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4630 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4632 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4637 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4640 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4646 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4652 /*******************************************************************
4653 ********************************************************************/
4655 BOOL
spoolss_io_q_enumforms(const char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4658 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4663 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4665 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4668 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4673 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4679 /*******************************************************************
4680 ********************************************************************/
4682 BOOL
spoolss_io_r_enumforms(const char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4684 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4690 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4696 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4699 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4702 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4708 /*******************************************************************
4709 ********************************************************************/
4711 BOOL
spoolss_io_q_getform(const char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4714 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4719 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4721 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4727 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4730 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4735 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4741 /*******************************************************************
4742 ********************************************************************/
4744 BOOL
spoolss_io_r_getform(const char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4746 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4752 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4758 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4761 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4767 /*******************************************************************
4768 Parse a SPOOL_R_ENUMPORTS structure.
4769 ********************************************************************/
4771 BOOL
spoolss_io_r_enumports(const char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4773 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4779 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4785 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4788 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4791 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4797 /*******************************************************************
4798 ********************************************************************/
4800 BOOL
spoolss_io_q_enumports(const char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4802 prs_debug(ps
, depth
, desc
, "");
4808 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4810 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4815 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4818 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4823 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4829 /*******************************************************************
4830 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4831 ********************************************************************/
4833 BOOL
spool_io_printer_info_level_1(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4835 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4841 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4843 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4845 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4847 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4850 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4852 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4854 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4860 /*******************************************************************
4861 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4862 ********************************************************************/
4864 BOOL
spool_io_printer_info_level_3(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4866 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4872 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4878 /*******************************************************************
4879 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4880 ********************************************************************/
4882 BOOL
spool_io_printer_info_level_2(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4884 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4890 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4892 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4894 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4896 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4899 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4901 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4903 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4905 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4907 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4909 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4911 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4913 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4915 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4918 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4920 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4922 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4924 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4926 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4928 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4930 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4932 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4935 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4937 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4939 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4941 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4943 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4945 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4947 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4949 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4951 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4953 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4955 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4961 BOOL
spool_io_printer_info_level_7(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_7
*il
, prs_struct
*ps
, int depth
)
4963 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_7");
4969 if(!prs_uint32("guid_ptr", ps
, depth
, &il
->guid_ptr
))
4971 if(!prs_uint32("action", ps
, depth
, &il
->action
))
4974 if(!smb_io_unistr2("servername", &il
->guid
, il
->guid_ptr
, ps
, depth
))
4979 /*******************************************************************
4980 ********************************************************************/
4982 BOOL
spool_io_printer_info_level(const char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4984 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4989 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4991 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4994 /* if no struct inside just return */
4995 if (il
->info_ptr
==0) {
4996 if (UNMARSHALLING(ps
)) {
5003 switch (il
->level
) {
5005 * level 0 is used by setprinter when managing the queue
5006 * (hold, stop, start a queue)
5010 /* DOCUMENT ME!!! What is level 1 used for? */
5013 if (UNMARSHALLING(ps
)) {
5014 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
5017 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
5022 * level 2 is used by addprinter
5023 * and by setprinter when updating printer's info
5026 if (UNMARSHALLING(ps
)) {
5027 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
5030 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
5033 /* DOCUMENT ME!!! What is level 3 used for? */
5036 if (UNMARSHALLING(ps
)) {
5037 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
5040 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
5045 if (UNMARSHALLING(ps
))
5046 if ((il
->info_7
=(SPOOL_PRINTER_INFO_LEVEL_7
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_7
))) == NULL
)
5048 if (!spool_io_printer_info_level_7("", il
->info_7
, ps
, depth
))
5056 /*******************************************************************
5057 ********************************************************************/
5059 BOOL
spoolss_io_q_addprinterex(const char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
5061 uint32 ptr_sec_desc
= 0;
5063 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
5068 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
5070 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5076 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5079 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
5082 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
5088 switch (q_u
->level
) {
5090 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
5093 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
5097 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
5102 /* Parse a NULL security descriptor. This should really
5103 happen inside the sec_io_desc_buf() function. */
5105 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
5106 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
5108 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
5112 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
5114 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
5120 /*******************************************************************
5121 ********************************************************************/
5123 BOOL
spoolss_io_r_addprinterex(const char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
5124 prs_struct
*ps
, int depth
)
5126 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
5129 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5132 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5138 /*******************************************************************
5139 ********************************************************************/
5141 BOOL
spool_io_printer_driver_info_level_3(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
5142 prs_struct
*ps
, int depth
)
5144 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
5146 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
5150 if (UNMARSHALLING(ps
)) {
5151 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
5163 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
5165 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
5167 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
5169 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
5171 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
5173 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
5175 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
5177 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
5179 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5181 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
5183 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
5189 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5191 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5193 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5195 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5197 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5199 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5201 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5203 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5209 if (il
->dependentfiles_ptr
)
5210 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
5215 /*******************************************************************
5216 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
5217 ********************************************************************/
5219 BOOL
spool_io_printer_driver_info_level_6(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
5220 prs_struct
*ps
, int depth
)
5222 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
5224 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
5228 if (UNMARSHALLING(ps
)) {
5229 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
5242 * I know this seems weird, but I have no other explanation.
5243 * This is observed behavior on both NT4 and 2K servers.
5247 if (!prs_align_uint64(ps
))
5250 /* parse the main elements the packet */
5252 if(!prs_uint32("cversion ", ps
, depth
, &il
->version
))
5254 if(!prs_uint32("name ", ps
, depth
, &il
->name_ptr
))
5256 if(!prs_uint32("environment ", ps
, depth
, &il
->environment_ptr
))
5258 if(!prs_uint32("driverpath ", ps
, depth
, &il
->driverpath_ptr
))
5260 if(!prs_uint32("datafile ", ps
, depth
, &il
->datafile_ptr
))
5262 if(!prs_uint32("configfile ", ps
, depth
, &il
->configfile_ptr
))
5264 if(!prs_uint32("helpfile ", ps
, depth
, &il
->helpfile_ptr
))
5266 if(!prs_uint32("monitorname ", ps
, depth
, &il
->monitorname_ptr
))
5268 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5270 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_len
))
5272 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_ptr
))
5274 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_len
))
5276 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_ptr
))
5278 if(!smb_io_time("driverdate ", &il
->driverdate
, ps
, depth
))
5280 if(!prs_uint32("dummy4 ", ps
, depth
, &il
->dummy4
))
5282 if(!prs_uint64("driverversion ", ps
, depth
, &il
->driverversion
))
5284 if(!prs_uint32("mfgname ", ps
, depth
, &il
->mfgname_ptr
))
5286 if(!prs_uint32("oemurl ", ps
, depth
, &il
->oemurl_ptr
))
5288 if(!prs_uint32("hardwareid ", ps
, depth
, &il
->hardwareid_ptr
))
5290 if(!prs_uint32("provider ", ps
, depth
, &il
->provider_ptr
))
5293 /* parse the structures in the packet */
5295 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5300 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5305 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5310 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5315 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5320 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5325 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5330 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5334 if (il
->dependentfiles_ptr
) {
5335 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
5340 if (il
->previousnames_ptr
) {
5341 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
5346 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
5350 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
5354 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
5358 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
5364 /*******************************************************************
5365 convert a buffer of UNICODE strings null terminated
5366 the buffer is terminated by a NULL
5368 convert to an dos codepage array (null terminated)
5370 dynamically allocate memory
5372 ********************************************************************/
5373 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
5382 src
= (char *)buf5
->buffer
;
5385 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
5386 rpcstr_pull(f
, src
, sizeof(f
)-1, -1, STR_TERMINATE
);
5387 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
5388 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
5393 fstrcpy((*ar
)[n
], f
);
5396 fstrcpy((*ar
)[n
], "");
5404 /*******************************************************************
5405 read a UNICODE array with null terminated strings
5406 and null terminated array
5407 and size of array at beginning
5408 ********************************************************************/
5410 BOOL
smb_io_unibuffer(const char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
5412 if (buffer
==NULL
) return False
;
5415 buffer
->uni_str_len
=buffer
->uni_max_len
;
5417 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
5420 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
5426 /*******************************************************************
5427 ********************************************************************/
5429 BOOL
spool_io_printer_driver_info_level(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
5431 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
5436 if(!prs_uint32("level", ps
, depth
, &il
->level
))
5438 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
5444 switch (il
->level
) {
5446 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
5450 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5460 /*******************************************************************
5461 init a SPOOL_Q_ADDPRINTERDRIVER struct
5462 ******************************************************************/
5464 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5465 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5466 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5468 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5470 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
5471 init_unistr2(&q_u
->server_name
, srv_name
, UNI_STR_TERMINATE
);
5475 q_u
->info
.level
= level
;
5476 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
5479 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5481 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5485 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5492 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5493 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5494 DRIVER_INFO_3
*info3
)
5497 uint16
*ptr
= info3
->dependentfiles
;
5499 BOOL null_char
= False
;
5500 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5502 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
5505 inf
->cversion
= info3
->version
;
5506 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5507 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5508 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5509 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5510 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5511 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5512 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5513 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5515 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5516 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5517 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5518 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5519 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5520 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5521 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5522 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5529 /* the null_char BOOL is used to help locate
5530 two '\0's back to back */
5545 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5546 inf
->dependentfilessize
= len
;
5547 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5553 *spool_drv_info
= inf
;
5558 /*******************************************************************
5559 make a BUFFER5 struct from a uint16*
5560 ******************************************************************/
5561 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5564 buf5
->buf_len
= len
;
5565 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5567 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5574 /*******************************************************************
5575 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5576 ********************************************************************/
5578 BOOL
spoolss_io_q_addprinterdriver(const char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5580 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5586 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5588 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5593 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5596 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5602 /*******************************************************************
5603 ********************************************************************/
5605 BOOL
spoolss_io_r_addprinterdriver(const char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5607 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5610 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5616 /*******************************************************************
5617 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5618 ********************************************************************/
5620 BOOL
spoolss_io_q_addprinterdriverex(const char *desc
, SPOOL_Q_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5622 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriverex");
5628 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5630 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5635 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5638 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5643 if(!prs_uint32("copy flags", ps
, depth
, &q_u
->copy_flags
))
5649 /*******************************************************************
5650 ********************************************************************/
5652 BOOL
spoolss_io_r_addprinterdriverex(const char *desc
, SPOOL_R_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5654 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriverex");
5657 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5663 /*******************************************************************
5664 ********************************************************************/
5666 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5667 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5669 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5671 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5675 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5683 d
->cversion
=uni
->cversion
;
5685 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5686 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5687 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5688 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5689 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5690 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5691 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5692 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5694 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5695 DEBUGADD(8,( "name: %s\n", d
->name
));
5696 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5697 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5698 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5699 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5700 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5701 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5702 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5704 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5711 /*******************************************************************
5712 ********************************************************************/
5713 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5714 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5716 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5718 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5722 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5730 d
->version
=uni
->version
;
5732 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5733 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5734 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5735 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5736 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5737 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5738 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5739 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5741 DEBUGADD(8,( "version: %d\n", d
->version
));
5742 DEBUGADD(8,( "name: %s\n", d
->name
));
5743 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5744 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5745 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5746 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5747 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5748 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5749 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5751 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5753 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5763 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5764 NT_PRINTER_INFO_LEVEL_2
**asc
)
5766 NT_PRINTER_INFO_LEVEL_2
*d
;
5769 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5770 time_unix
=time(NULL
);
5773 DEBUGADD(8,("allocating memory\n"));
5775 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5780 /* we allocate memory iff called from
5781 * addprinter(ex) so we can do one time stuff here.
5783 (*asc
)->setuptime
=time_unix
;
5786 DEBUGADD(8,("start converting\n"));
5790 d
->attributes
=uni
->attributes
;
5791 d
->priority
=uni
->priority
;
5792 d
->default_priority
=uni
->default_priority
;
5793 d
->starttime
=uni
->starttime
;
5794 d
->untiltime
=uni
->untiltime
;
5795 d
->status
=uni
->status
;
5796 d
->cjobs
=uni
->cjobs
;
5798 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5799 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5800 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5801 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5802 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5803 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5804 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5805 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5806 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5807 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5808 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5813 /*******************************************************************
5815 ********************************************************************/
5817 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5818 fstring servername
, fstring env_name
, uint32 level
,
5819 NEW_BUFFER
*buffer
, uint32 offered
)
5821 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5822 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5826 q_u
->offered
=offered
;
5831 /*******************************************************************
5832 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5833 ********************************************************************/
5835 BOOL
spoolss_io_q_getprinterdriverdir(const char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5837 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5842 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5844 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5850 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5852 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5858 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5861 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5867 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5873 /*******************************************************************
5874 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5875 ********************************************************************/
5877 BOOL
spoolss_io_r_getprinterdriverdir(const char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5879 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5885 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5891 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5894 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5900 /*******************************************************************
5901 ********************************************************************/
5903 BOOL
spoolss_io_r_enumprintprocessors(const char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5905 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5911 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5917 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5920 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5923 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5929 /*******************************************************************
5930 ********************************************************************/
5932 BOOL
spoolss_io_q_enumprintprocessors(const char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5934 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5940 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5942 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5948 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5950 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5956 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5959 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5965 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5971 /*******************************************************************
5972 ********************************************************************/
5974 BOOL
spoolss_io_q_addprintprocessor(const char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5976 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5982 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5984 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5989 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5994 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5999 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6005 /*******************************************************************
6006 ********************************************************************/
6008 BOOL
spoolss_io_r_addprintprocessor(const char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
6010 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
6016 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6022 /*******************************************************************
6023 ********************************************************************/
6025 BOOL
spoolss_io_r_enumprintprocdatatypes(const char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
6027 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
6033 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6039 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6042 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6045 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6051 /*******************************************************************
6052 ********************************************************************/
6054 BOOL
spoolss_io_q_enumprintprocdatatypes(const char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
6056 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
6062 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
6064 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6070 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
6072 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
6078 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
6081 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
6087 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6093 /*******************************************************************
6094 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
6095 ********************************************************************/
6097 BOOL
spoolss_io_q_enumprintmonitors(const char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
6099 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
6105 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
6107 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6113 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
6116 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6122 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6128 /*******************************************************************
6129 ********************************************************************/
6131 BOOL
spoolss_io_r_enumprintmonitors(const char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
6133 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
6139 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6145 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6148 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6151 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6157 /*******************************************************************
6158 ********************************************************************/
6160 BOOL
spoolss_io_r_enumprinterdata(const char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6162 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
6167 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
6170 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
6171 r_u
->value
= (uint16
*)prs_alloc_mem(ps
, r_u
->valuesize
* 2);
6173 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
6178 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
6184 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
6187 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
6190 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
6193 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
6194 r_u
->data
= (uint8
*)prs_alloc_mem(ps
, r_u
->datasize
);
6196 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
6201 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
6206 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
6208 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6214 /*******************************************************************
6215 ********************************************************************/
6217 BOOL
spoolss_io_q_enumprinterdata(const char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6219 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
6224 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6226 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
6228 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
6230 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
6236 /*******************************************************************
6237 ********************************************************************/
6239 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
6240 const POLICY_HND
*hnd
,
6241 uint32 idx
, uint32 valuelen
, uint32 datalen
)
6243 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6245 q_u
->valuesize
=valuelen
;
6246 q_u
->datasize
=datalen
;
6251 /*******************************************************************
6252 ********************************************************************/
6254 BOOL
make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX
*q_u
,
6255 const POLICY_HND
*hnd
, const char *key
,
6258 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6259 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
6265 /*******************************************************************
6266 ********************************************************************/
6267 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, const POLICY_HND
*hnd
,
6268 char* value
, uint32 data_type
, char* data
, uint32 data_size
)
6270 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6271 q_u
->type
= data_type
;
6272 init_unistr2(&q_u
->value
, value
, UNI_STR_TERMINATE
);
6274 q_u
->max_len
= q_u
->real_len
= data_size
;
6275 q_u
->data
= (unsigned char *)data
;
6280 /*******************************************************************
6281 ********************************************************************/
6282 BOOL
make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX
*q_u
, const POLICY_HND
*hnd
,
6283 char *key
, char* value
, uint32 data_type
, char* data
,
6286 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6287 q_u
->type
= data_type
;
6288 init_unistr2(&q_u
->value
, value
, UNI_STR_TERMINATE
);
6289 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
6291 q_u
->max_len
= q_u
->real_len
= data_size
;
6292 q_u
->data
= (unsigned char *)data
;
6297 /*******************************************************************
6298 ********************************************************************/
6300 BOOL
spoolss_io_q_setprinterdata(const char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6302 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
6307 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6309 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6315 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6318 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6328 if (UNMARSHALLING(ps
))
6329 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6330 if(q_u
->data
== NULL
)
6332 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6340 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6346 /*******************************************************************
6347 ********************************************************************/
6349 BOOL
spoolss_io_r_setprinterdata(const char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6351 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
6356 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6362 /*******************************************************************
6363 ********************************************************************/
6364 BOOL
spoolss_io_q_resetprinter(const char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6366 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
6371 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6374 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
6377 if (q_u
->datatype_ptr
) {
6378 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
6382 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
6389 /*******************************************************************
6390 ********************************************************************/
6391 BOOL
spoolss_io_r_resetprinter(const char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6393 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
6398 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6404 /*******************************************************************
6405 ********************************************************************/
6407 static BOOL
spoolss_io_addform(const char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
6409 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
6416 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
6418 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
6420 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
6422 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
6424 if(!prs_uint32("left", ps
, depth
, &f
->left
))
6426 if(!prs_uint32("top", ps
, depth
, &f
->top
))
6428 if(!prs_uint32("right", ps
, depth
, &f
->right
))
6430 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
6433 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
6440 /*******************************************************************
6441 ********************************************************************/
6443 BOOL
spoolss_io_q_deleteform(const char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
6445 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
6450 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6452 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
6458 /*******************************************************************
6459 ********************************************************************/
6461 BOOL
spoolss_io_r_deleteform(const char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
6463 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
6468 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6474 /*******************************************************************
6475 ********************************************************************/
6477 BOOL
spoolss_io_q_addform(const char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
6479 uint32 useless_ptr
=1;
6480 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
6485 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6487 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6489 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6494 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6496 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6503 /*******************************************************************
6504 ********************************************************************/
6506 BOOL
spoolss_io_r_addform(const char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6508 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6513 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6519 /*******************************************************************
6520 ********************************************************************/
6522 BOOL
spoolss_io_q_setform(const char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6524 uint32 useless_ptr
=1;
6525 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6530 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6532 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6538 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6540 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6545 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6547 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6554 /*******************************************************************
6555 ********************************************************************/
6557 BOOL
spoolss_io_r_setform(const char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6559 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6564 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6570 /*******************************************************************
6571 Parse a SPOOL_R_GETJOB structure.
6572 ********************************************************************/
6574 BOOL
spoolss_io_r_getjob(const char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6576 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6582 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6588 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6591 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6597 /*******************************************************************
6598 Parse a SPOOL_Q_GETJOB structure.
6599 ********************************************************************/
6601 BOOL
spoolss_io_q_getjob(const char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6603 prs_debug(ps
, depth
, desc
, "");
6609 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6611 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6613 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6616 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6622 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6628 void free_devmode(DEVICEMODE
*devmode
)
6630 if (devmode
!=NULL
) {
6631 SAFE_FREE(devmode
->private);
6636 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6641 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6643 if (printer
!=NULL
) {
6644 free_devmode(printer
->devmode
);
6645 printer
->devmode
= NULL
;
6650 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6655 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6660 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6665 void free_printer_info_7(PRINTER_INFO_7
*printer
)
6670 void free_job_info_2(JOB_INFO_2
*job
)
6673 free_devmode(job
->devmode
);
6676 /*******************************************************************
6678 ********************************************************************/
6680 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6681 const fstring string
, uint32 printer
, uint32 type
)
6686 init_unistr2(&q_u
->string
, string
, UNI_STR_TERMINATE
);
6688 q_u
->printer
=printer
;
6697 /*******************************************************************
6698 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6699 ********************************************************************/
6701 BOOL
spoolss_io_q_replyopenprinter(const char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6703 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6709 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6715 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6717 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6720 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6722 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6728 /*******************************************************************
6729 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6730 ********************************************************************/
6732 BOOL
spoolss_io_r_replyopenprinter(const char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6734 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6740 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6743 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6749 /*******************************************************************
6751 ********************************************************************/
6752 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6753 uint32 condition
, uint32 change_id
)
6756 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6758 q_u
->condition
= condition
;
6759 q_u
->change_id
= change_id
;
6762 q_u
->unknown1
= 0x1;
6763 memset(q_u
->unknown2
, 0x0, 5);
6764 q_u
->unknown2
[0] = 0x1;
6769 /*******************************************************************
6770 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6771 ********************************************************************/
6772 BOOL
spoolss_io_q_routerreplyprinter (const char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6775 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6781 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6784 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6787 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6790 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6793 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6799 /*******************************************************************
6800 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6801 ********************************************************************/
6802 BOOL
spoolss_io_r_routerreplyprinter (const char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6804 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6810 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6816 /*******************************************************************
6818 ********************************************************************/
6820 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6825 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6830 /*******************************************************************
6831 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6832 ********************************************************************/
6834 BOOL
spoolss_io_q_replycloseprinter(const char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6836 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6842 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6848 /*******************************************************************
6849 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6850 ********************************************************************/
6852 BOOL
spoolss_io_r_replycloseprinter(const char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6854 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6860 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6863 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6869 #if 0 /* JERRY - not currently used but could be :-) */
6871 /*******************************************************************
6872 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6873 ******************************************************************/
6874 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6875 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6879 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6881 for (i
=0; i
<n
; i
++) {
6885 if (src
->size
!= POINTER
)
6887 len
= src
->notify_data
.data
.length
;
6888 s
= malloc(sizeof(uint16
)*len
);
6890 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6894 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6895 dst
->notify_data
.data
.string
= s
;
6901 /*******************************************************************
6902 Deep copy a SPOOL_NOTIFY_INFO structure
6903 ******************************************************************/
6904 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6907 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6911 dst
->version
= src
->version
;
6912 dst
->flags
= src
->flags
;
6913 dst
->count
= src
->count
;
6917 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6919 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6922 if (dst
->data
== NULL
) {
6923 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6928 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6935 /*******************************************************************
6937 ********************************************************************/
6939 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6940 uint32 change_low
, uint32 change_high
,
6941 SPOOL_NOTIFY_INFO
*info
)
6946 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6948 q_u
->change_low
=change_low
;
6949 q_u
->change_high
=change_high
;
6954 q_u
->info_ptr
=0x0FF0ADDE;
6956 q_u
->info
.version
=2;
6959 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6961 q_u
->info
.version
= info
->version
;
6962 q_u
->info
.flags
= info
->flags
;
6963 q_u
->info
.count
= info
->count
;
6964 /* pointer field - be careful! */
6965 q_u
->info
.data
= info
->data
;
6968 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6975 /*******************************************************************
6976 Parse a SPOOL_Q_REPLY_RRPCN structure.
6977 ********************************************************************/
6979 BOOL
spoolss_io_q_reply_rrpcn(const char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6981 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6987 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6990 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6993 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6996 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6999 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
7002 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
7005 if(q_u
->info_ptr
!=0)
7006 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
7012 /*******************************************************************
7013 Parse a SPOOL_R_REPLY_RRPCN structure.
7014 ********************************************************************/
7016 BOOL
spoolss_io_r_reply_rrpcn(const char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
7018 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
7024 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
7027 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
7033 /*******************************************************************
7035 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
7036 ********************************************************************/
7038 BOOL
spoolss_io_q_getprinterdataex(const char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7043 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
7048 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
7052 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
7056 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
7060 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
7066 /*******************************************************************
7067 * write a structure.
7068 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
7069 ********************************************************************/
7071 BOOL
spoolss_io_r_getprinterdataex(const char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7076 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
7081 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
7083 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
7086 if (UNMARSHALLING(ps
) && r_u
->size
) {
7087 r_u
->data
= (unsigned char *)prs_alloc_mem(ps
, r_u
->size
);
7092 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
7098 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7100 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
7106 /*******************************************************************
7108 ********************************************************************/
7110 BOOL
spoolss_io_q_setprinterdataex(const char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7112 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
7117 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7119 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7125 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
7131 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
7134 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
7144 if (UNMARSHALLING(ps
))
7145 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
7146 if(q_u
->data
== NULL
)
7148 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
7156 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
7162 /*******************************************************************
7163 * write a structure.
7164 ********************************************************************/
7166 BOOL
spoolss_io_r_setprinterdataex(const char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7168 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
7173 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7179 /*******************************************************************
7181 ********************************************************************/
7182 BOOL
make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY
*q_u
,
7183 POLICY_HND
*hnd
, const char *key
,
7186 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
7188 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7189 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
7195 /*******************************************************************
7197 ********************************************************************/
7199 BOOL
spoolss_io_q_enumprinterkey(const char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7201 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
7206 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7209 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7215 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7221 /*******************************************************************
7222 * write a structure.
7223 ********************************************************************/
7225 BOOL
spoolss_io_r_enumprinterkey(const char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7227 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
7233 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
7239 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7242 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7248 /*******************************************************************
7250 ********************************************************************/
7252 BOOL
make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY
*q_u
,
7253 POLICY_HND
*hnd
, char *keyname
)
7255 DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
7257 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7258 init_unistr2(&q_u
->keyname
, keyname
, UNI_STR_TERMINATE
);
7263 /*******************************************************************
7265 ********************************************************************/
7267 BOOL
spoolss_io_q_deleteprinterkey(const char *desc
, SPOOL_Q_DELETEPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7269 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterkey");
7274 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7277 if(!smb_io_unistr2("", &q_u
->keyname
, True
, ps
, depth
))
7283 /*******************************************************************
7284 * write a structure.
7285 ********************************************************************/
7287 BOOL
spoolss_io_r_deleteprinterkey(const char *desc
, SPOOL_R_DELETEPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7289 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterkey");
7295 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7302 /*******************************************************************
7304 ********************************************************************/
7306 BOOL
spoolss_io_q_enumprinterdataex(const char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7308 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
7313 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7316 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7322 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7328 /*******************************************************************
7329 ********************************************************************/
7331 static BOOL
spoolss_io_printer_enum_values_ctr(const char *desc
, prs_struct
*ps
,
7332 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
7335 uint32 valuename_offset
,
7338 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
7340 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
7344 * offset data begins at 20 bytes per structure * size_of_array.
7345 * Don't forget the uint32 at the beginning
7348 current_offset
= basic_unit
* ctr
->size_of_array
;
7350 /* first loop to write basic enum_value information */
7352 if (UNMARSHALLING(ps
)) {
7353 ctr
->values
= (PRINTER_ENUM_VALUES
*)prs_alloc_mem(
7354 ps
, ctr
->size_of_array
* sizeof(PRINTER_ENUM_VALUES
));
7359 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7360 valuename_offset
= current_offset
;
7361 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
7364 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
7367 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
7370 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
7372 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
7375 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
7378 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
7379 /* account for 2 byte alignment */
7380 current_offset
+= (current_offset
% 2);
7384 * loop #2 for writing the dynamically size objects; pay
7385 * attention to 2-byte alignment here....
7388 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7390 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
7393 if ( ctr
->values
[i
].data_len
) {
7394 if ( UNMARSHALLING(ps
) ) {
7395 ctr
->values
[i
].data
= (uint8
*)prs_alloc_mem(
7396 ps
, ctr
->values
[i
].data_len
);
7397 if (!ctr
->values
[i
].data
)
7400 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
7404 if ( !prs_align_uint16(ps
) )
7411 /*******************************************************************
7412 * write a structure.
7413 ********************************************************************/
7415 BOOL
spoolss_io_r_enumprinterdataex(const char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7417 uint32 data_offset
, end_offset
;
7418 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
7424 if (!prs_uint32("size", ps
, depth
, &r_u
->ctr
.size
))
7427 data_offset
= prs_offset(ps
);
7429 if (!prs_set_offset(ps
, data_offset
+ r_u
->ctr
.size
))
7435 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7438 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
7441 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7444 r_u
->ctr
.size_of_array
= r_u
->returned
;
7446 end_offset
= prs_offset(ps
);
7448 if (!prs_set_offset(ps
, data_offset
))
7452 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
7455 if (!prs_set_offset(ps
, end_offset
))
7460 /*******************************************************************
7461 * write a structure.
7462 ********************************************************************/
7465 uint32 GetPrintProcessorDirectory(
7467 [in] unistr2 *environment,
7469 [in,out] NEW_BUFFER buffer,
7470 [in] uint32 offered,
7471 [out] uint32 needed,
7472 [out] uint32 returned
7477 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, NEW_BUFFER
*buffer
, uint32 offered
)
7479 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
7481 init_unistr2(&q_u
->name
, name
, UNI_STR_TERMINATE
);
7482 init_unistr2(&q_u
->environment
, environment
, UNI_STR_TERMINATE
);
7486 q_u
->buffer
= buffer
;
7487 q_u
->offered
= offered
;
7492 BOOL
spoolss_io_q_getprintprocessordirectory(const char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
7496 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
7502 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7506 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
7513 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7517 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
7525 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7528 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
7534 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
7540 /*******************************************************************
7541 * write a structure.
7542 ********************************************************************/
7544 BOOL
spoolss_io_r_getprintprocessordirectory(const char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
7546 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
7552 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
7558 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7561 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7567 BOOL
smb_io_printprocessordirectory_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
7569 prs_struct
*ps
=&buffer
->prs
;
7571 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
7574 buffer
->struct_start
=prs_offset(ps
);
7576 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
7582 /*******************************************************************
7584 ********************************************************************/
7586 BOOL
make_spoolss_q_addform(SPOOL_Q_ADDFORM
*q_u
, POLICY_HND
*handle
,
7587 int level
, FORM
*form
)
7589 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7591 q_u
->level2
= level
;
7592 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7597 /*******************************************************************
7599 ********************************************************************/
7601 BOOL
make_spoolss_q_setform(SPOOL_Q_SETFORM
*q_u
, POLICY_HND
*handle
,
7602 int level
, const char *form_name
, FORM
*form
)
7604 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7606 q_u
->level2
= level
;
7607 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7608 init_unistr2(&q_u
->name
, form_name
, UNI_STR_TERMINATE
);
7613 /*******************************************************************
7615 ********************************************************************/
7617 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
,
7620 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7621 init_unistr2(&q_u
->name
, form
, UNI_STR_TERMINATE
);
7625 /*******************************************************************
7627 ********************************************************************/
7629 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7630 const char *formname
, uint32 level
,
7631 NEW_BUFFER
*buffer
, uint32 offered
)
7633 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7635 init_unistr2(&q_u
->formname
, formname
, UNI_STR_TERMINATE
);
7637 q_u
->offered
=offered
;
7642 /*******************************************************************
7644 ********************************************************************/
7646 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7647 uint32 level
, NEW_BUFFER
*buffer
,
7650 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7653 q_u
->offered
=offered
;
7658 /*******************************************************************
7660 ********************************************************************/
7662 BOOL
make_spoolss_q_setjob(SPOOL_Q_SETJOB
*q_u
, POLICY_HND
*handle
,
7663 uint32 jobid
, uint32 level
, uint32 command
)
7665 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7669 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7670 the server side code has it marked as unused. */
7672 q_u
->command
= command
;
7677 /*******************************************************************
7679 ********************************************************************/
7681 BOOL
make_spoolss_q_getjob(SPOOL_Q_GETJOB
*q_u
, POLICY_HND
*handle
,
7682 uint32 jobid
, uint32 level
, NEW_BUFFER
*buffer
,
7685 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7688 q_u
->buffer
= buffer
;
7689 q_u
->offered
= offered
;
7694 /*******************************************************************
7696 ********************************************************************/
7698 BOOL
make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER
*q_u
,
7701 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7706 /*******************************************************************
7708 ********************************************************************/
7710 BOOL
make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER
*q_u
,
7713 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7718 /*******************************************************************
7720 ********************************************************************/
7722 BOOL
make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER
*q_u
,
7723 POLICY_HND
*handle
, uint32 level
,
7724 char *docname
, char *outputfile
,
7727 DOC_INFO_CONTAINER
*ctr
= &q_u
->doc_info_container
;
7729 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7735 ctr
->docinfo
.switch_value
= level
;
7737 ctr
->docinfo
.doc_info_1
.p_docname
= docname
? 1 : 0;
7738 ctr
->docinfo
.doc_info_1
.p_outputfile
= outputfile
? 1 : 0;
7739 ctr
->docinfo
.doc_info_1
.p_datatype
= datatype
? 1 : 0;
7741 init_unistr2(&ctr
->docinfo
.doc_info_1
.docname
, docname
, UNI_STR_TERMINATE
);
7742 init_unistr2(&ctr
->docinfo
.doc_info_1
.outputfile
, outputfile
, UNI_STR_TERMINATE
);
7743 init_unistr2(&ctr
->docinfo
.doc_info_1
.datatype
, datatype
, UNI_STR_TERMINATE
);
7747 /* DOC_INFO_2 is only used by Windows 9x and since it
7748 doesn't do printing over RPC we don't have to worry
7751 DEBUG(3, ("unsupported info level %d\n", level
));
7758 /*******************************************************************
7760 ********************************************************************/
7762 BOOL
make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER
*q_u
,
7765 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7770 /*******************************************************************
7772 ********************************************************************/
7774 BOOL
make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER
*q_u
,
7775 POLICY_HND
*handle
, uint32 data_size
,
7778 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7779 q_u
->buffer_size
= q_u
->buffer_size2
= data_size
;
7780 q_u
->buffer
= (unsigned char *)data
;
7784 /*******************************************************************
7786 ********************************************************************/
7788 BOOL
make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA
*q_u
,
7789 POLICY_HND
*handle
, char *valuename
)
7791 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7792 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
7797 /*******************************************************************
7799 ********************************************************************/
7801 BOOL
make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX
*q_u
,
7802 POLICY_HND
*handle
, char *key
,
7805 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7806 init_unistr2(&q_u
->valuename
, value
, UNI_STR_TERMINATE
);
7807 init_unistr2(&q_u
->keyname
, key
, UNI_STR_TERMINATE
);
7812 /*******************************************************************
7814 ********************************************************************/
7816 BOOL
make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX
*q_u
, POLICY_HND
*handle
,
7817 uint32 flags
, uint32 options
, const char *localmachine
,
7818 uint32 printerlocal
, SPOOL_NOTIFY_OPTION
*option
)
7820 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7823 q_u
->options
= options
;
7825 q_u
->localmachine_ptr
= 1;
7827 init_unistr2(&q_u
->localmachine
, localmachine
, UNI_STR_TERMINATE
);
7829 q_u
->printerlocal
= printerlocal
;
7832 q_u
->option_ptr
= 1;
7834 q_u
->option
= option
;