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
);
1057 /*******************************************************************
1059 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1060 ********************************************************************/
1062 BOOL
spoolss_io_q_open_printer(const char *desc
, SPOOL_Q_OPEN_PRINTER
*q_u
, prs_struct
*ps
, int depth
)
1067 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer");
1073 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
1075 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
1081 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1087 /*******************************************************************
1088 * write a structure.
1089 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1090 * called from spoolss_open_printer_ex (cli_spoolss.c)
1091 ********************************************************************/
1093 BOOL
spoolss_io_r_open_printer(const char *desc
, SPOOL_R_OPEN_PRINTER
*r_u
, prs_struct
*ps
, int depth
)
1095 if (r_u
== NULL
) return False
;
1097 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer");
1103 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1106 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1113 /*******************************************************************
1115 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1116 ********************************************************************/
1118 BOOL
spoolss_io_q_open_printer_ex(const char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
1123 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
1129 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
1131 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
1137 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1140 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
1142 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
1148 /*******************************************************************
1149 * write a structure.
1150 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1151 * called from spoolss_open_printer_ex (cli_spoolss.c)
1152 ********************************************************************/
1154 BOOL
spoolss_io_r_open_printer_ex(const char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
1156 if (r_u
== NULL
) return False
;
1158 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
1164 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1167 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1173 /*******************************************************************
1175 ********************************************************************/
1176 BOOL
make_spoolss_q_deleteprinterdriver(
1177 TALLOC_CTX
*mem_ctx
,
1178 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
1184 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1186 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1188 /* these must be NULL terminated or else NT4 will
1189 complain about invalid parameters --jerry */
1190 init_unistr2(&q_u
->server
, server
, UNI_STR_TERMINATE
);
1191 init_unistr2(&q_u
->arch
, arch
, UNI_STR_TERMINATE
);
1192 init_unistr2(&q_u
->driver
, driver
, UNI_STR_TERMINATE
);
1197 /*******************************************************************
1199 ********************************************************************/
1201 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
1202 const POLICY_HND
*handle
,
1203 const char *valuename
, uint32 size
)
1205 if (q_u
== NULL
) return False
;
1207 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1209 q_u
->handle
= *handle
;
1210 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
1216 /*******************************************************************
1218 ********************************************************************/
1220 BOOL
make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX
*q_u
,
1221 const POLICY_HND
*handle
,
1222 const char *keyname
,
1223 const char *valuename
, uint32 size
)
1225 if (q_u
== NULL
) return False
;
1227 DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
1229 q_u
->handle
= *handle
;
1230 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
1231 init_unistr2(&q_u
->keyname
, keyname
, UNI_STR_TERMINATE
);
1237 /*******************************************************************
1239 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1240 ********************************************************************/
1242 BOOL
spoolss_io_q_getprinterdata(const char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1247 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1252 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1256 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1260 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1266 /*******************************************************************
1268 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1269 ********************************************************************/
1271 BOOL
spoolss_io_q_deleteprinterdata(const char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1276 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1281 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1285 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1291 /*******************************************************************
1292 * write a structure.
1293 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1294 ********************************************************************/
1296 BOOL
spoolss_io_r_deleteprinterdata(const char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1298 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1300 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1306 /*******************************************************************
1308 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1309 ********************************************************************/
1311 BOOL
spoolss_io_q_deleteprinterdataex(const char *desc
, SPOOL_Q_DELETEPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
1316 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdataex");
1321 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1324 if (!smb_io_unistr2("keyname ", &q_u
->keyname
, True
, ps
, depth
))
1326 if (!smb_io_unistr2("valuename", &q_u
->valuename
, True
, ps
, depth
))
1332 /*******************************************************************
1333 * write a structure.
1334 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1335 ********************************************************************/
1337 BOOL
spoolss_io_r_deleteprinterdataex(const char *desc
, SPOOL_R_DELETEPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
1339 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdataex");
1342 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1348 /*******************************************************************
1349 * write a structure.
1350 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1351 ********************************************************************/
1353 BOOL
spoolss_io_r_getprinterdata(const char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1358 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1363 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1365 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1368 if (UNMARSHALLING(ps
) && r_u
->size
) {
1369 r_u
->data
= (unsigned char *)prs_alloc_mem(ps
, r_u
->size
);
1374 if (!prs_uint8s( False
, "data", ps
, depth
, r_u
->data
, r_u
->size
))
1380 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1382 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1388 /*******************************************************************
1390 ********************************************************************/
1392 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1394 if (q_u
== NULL
) return False
;
1396 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1398 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1403 /*******************************************************************
1405 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1406 * called from spoolss_abortprinter (cli_spoolss.c)
1407 ********************************************************************/
1409 BOOL
spoolss_io_q_abortprinter(const char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1411 if (q_u
== NULL
) return False
;
1413 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1419 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1425 /*******************************************************************
1426 * write a structure.
1427 * called from spoolss_r_abortprinter (srv_spoolss.c)
1428 ********************************************************************/
1430 BOOL
spoolss_io_r_abortprinter(const char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1432 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1434 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1440 /*******************************************************************
1442 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1443 * called from spoolss_deleteprinter (cli_spoolss.c)
1444 ********************************************************************/
1446 BOOL
spoolss_io_q_deleteprinter(const char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1448 if (q_u
== NULL
) return False
;
1450 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1456 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1462 /*******************************************************************
1463 * write a structure.
1464 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1465 * called from spoolss_deleteprinter (cli_spoolss.c)
1466 ********************************************************************/
1468 BOOL
spoolss_io_r_deleteprinter(const char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1470 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1476 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1478 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1485 /*******************************************************************
1487 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1488 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1489 ********************************************************************/
1491 BOOL
spoolss_io_q_deleteprinterdriver(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1493 if (q_u
== NULL
) return False
;
1495 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1501 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1503 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1505 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1507 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1515 /*******************************************************************
1516 * write a structure.
1517 ********************************************************************/
1518 BOOL
spoolss_io_r_deleteprinterdriver(const char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1520 if (r_u
== NULL
) return False
;
1522 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1528 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1535 /*******************************************************************
1537 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1538 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1539 ********************************************************************/
1541 BOOL
spoolss_io_q_deleteprinterdriverex(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
1543 if (q_u
== NULL
) return False
;
1545 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriverex");
1551 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1553 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1555 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1557 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1563 if(!prs_uint32("delete_flags ", ps
, depth
, &q_u
->delete_flags
))
1565 if(!prs_uint32("version ", ps
, depth
, &q_u
->version
))
1573 /*******************************************************************
1574 * write a structure.
1575 ********************************************************************/
1576 BOOL
spoolss_io_r_deleteprinterdriverex(const char *desc
, SPOOL_R_DELETEPRINTERDRIVEREX
*r_u
, prs_struct
*ps
, int depth
)
1578 if (r_u
== NULL
) return False
;
1580 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriverex");
1586 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1594 /*******************************************************************
1596 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1597 * called from spoolss_closeprinter (cli_spoolss.c)
1598 ********************************************************************/
1600 BOOL
spoolss_io_q_closeprinter(const char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1602 if (q_u
== NULL
) return False
;
1604 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1610 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1616 /*******************************************************************
1617 * write a structure.
1618 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1619 * called from spoolss_closeprinter (cli_spoolss.c)
1620 ********************************************************************/
1622 BOOL
spoolss_io_r_closeprinter(const char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1624 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1630 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1632 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1638 /*******************************************************************
1640 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1641 ********************************************************************/
1643 BOOL
spoolss_io_q_startdocprinter(const char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1645 if (q_u
== NULL
) return False
;
1647 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1653 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1656 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1662 /*******************************************************************
1663 * write a structure.
1664 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1665 ********************************************************************/
1667 BOOL
spoolss_io_r_startdocprinter(const char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1669 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1671 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1673 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1679 /*******************************************************************
1681 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1682 ********************************************************************/
1684 BOOL
spoolss_io_q_enddocprinter(const char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1686 if (q_u
== NULL
) return False
;
1688 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1694 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1700 /*******************************************************************
1701 * write a structure.
1702 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1703 ********************************************************************/
1705 BOOL
spoolss_io_r_enddocprinter(const char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1707 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1709 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1715 /*******************************************************************
1717 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1718 ********************************************************************/
1720 BOOL
spoolss_io_q_startpageprinter(const char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1722 if (q_u
== NULL
) return False
;
1724 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1730 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1736 /*******************************************************************
1737 * write a structure.
1738 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1739 ********************************************************************/
1741 BOOL
spoolss_io_r_startpageprinter(const char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1743 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1745 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1751 /*******************************************************************
1753 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1754 ********************************************************************/
1756 BOOL
spoolss_io_q_endpageprinter(const char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1758 if (q_u
== NULL
) return False
;
1760 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1766 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1772 /*******************************************************************
1773 * write a structure.
1774 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1775 ********************************************************************/
1777 BOOL
spoolss_io_r_endpageprinter(const char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1779 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1781 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1787 /*******************************************************************
1789 * called from spoolss_q_writeprinter (srv_spoolss.c)
1790 ********************************************************************/
1792 BOOL
spoolss_io_q_writeprinter(const char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1794 if (q_u
== NULL
) return False
;
1796 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1802 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1804 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1807 if (q_u
->buffer_size
!=0)
1809 if (UNMARSHALLING(ps
))
1810 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1811 if(q_u
->buffer
== NULL
)
1813 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1818 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1824 /*******************************************************************
1825 * write a structure.
1826 * called from spoolss_r_writeprinter (srv_spoolss.c)
1827 ********************************************************************/
1829 BOOL
spoolss_io_r_writeprinter(const char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1831 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1833 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1835 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1841 /*******************************************************************
1843 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1844 ********************************************************************/
1846 BOOL
spoolss_io_q_rffpcnex(const char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1848 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1854 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1856 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1858 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1860 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1862 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1868 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1871 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1874 if (q_u
->option_ptr
!=0) {
1876 if (UNMARSHALLING(ps
))
1877 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1880 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1887 /*******************************************************************
1888 * write a structure.
1889 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1890 ********************************************************************/
1892 BOOL
spoolss_io_r_rffpcnex(const char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1894 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1897 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1903 /*******************************************************************
1905 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1906 ********************************************************************/
1908 BOOL
spoolss_io_q_rfnpcnex(const char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1910 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1916 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1919 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1922 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1925 if (q_u
->option_ptr
!=0) {
1927 if (UNMARSHALLING(ps
))
1928 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1931 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1938 /*******************************************************************
1939 * write a structure.
1940 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1941 ********************************************************************/
1943 BOOL
spoolss_io_r_rfnpcnex(const char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1945 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1951 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1954 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1959 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1965 /*******************************************************************
1966 * return the length of a uint16 (obvious, but the code is clean)
1967 ********************************************************************/
1969 static uint32
size_of_uint16(uint16
*value
)
1971 return (sizeof(*value
));
1974 /*******************************************************************
1975 * return the length of a uint32 (obvious, but the code is clean)
1976 ********************************************************************/
1978 static uint32
size_of_uint32(uint32
*value
)
1980 return (sizeof(*value
));
1983 /*******************************************************************
1984 * return the length of a NTTIME (obvious, but the code is clean)
1985 ********************************************************************/
1987 static uint32
size_of_nttime(NTTIME
*value
)
1989 return (sizeof(*value
));
1992 /*******************************************************************
1993 * return the length of a UNICODE string in number of char, includes:
1994 * - the leading zero
1995 * - the relative pointer size
1996 ********************************************************************/
1998 static uint32
size_of_relative_string(UNISTR
*string
)
2002 size
=str_len_uni(string
); /* the string length */
2003 size
=size
+1; /* add the trailing zero */
2004 size
=size
*2; /* convert in char */
2005 size
=size
+4; /* add the size of the ptr */
2009 * Do not include alignment as Win2k does not align relative
2010 * strings within a buffer --jerry
2012 /* Ensure size is 4 byte multiple (prs_align is being called...). */
2013 /* size += ((4 - (size & 3)) & 3); */
2019 /*******************************************************************
2020 * return the length of a uint32 (obvious, but the code is clean)
2021 ********************************************************************/
2023 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
2028 return (4+devmode
->size
+devmode
->driverextra
);
2031 /*******************************************************************
2032 * return the length of a uint32 (obvious, but the code is clean)
2033 ********************************************************************/
2035 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
2040 return (sizeof(SYSTEMTIME
) +4);
2043 /*******************************************************************
2044 * write a UNICODE string and its relative pointer.
2045 * used by all the RPC structs passing a buffer
2047 * As I'm a nice guy, I'm forcing myself to explain this code.
2048 * MS did a good job in the overall spoolss code except in some
2049 * functions where they are passing the API buffer directly in the
2050 * RPC request/reply. That's to maintain compatiility at the API level.
2051 * They could have done it the good way the first time.
2053 * So what happen is: the strings are written at the buffer's end,
2054 * in the reverse order of the original structure. Some pointers to
2055 * the strings are also in the buffer. Those are relative to the
2058 * If you don't understand or want to change that function,
2059 * first get in touch with me: jfm@samba.org
2061 ********************************************************************/
2063 static BOOL
smb_io_relstr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
2065 prs_struct
*ps
=&buffer
->prs
;
2067 if (MARSHALLING(ps
)) {
2068 uint32 struct_offset
= prs_offset(ps
);
2069 uint32 relative_offset
;
2071 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
2072 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2076 * Win2k does not align strings in a buffer
2077 * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry
2082 buffer
->string_at_end
= prs_offset(ps
);
2084 /* write the string */
2085 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2088 if(!prs_set_offset(ps
, struct_offset
))
2091 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2092 /* write its offset */
2093 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2099 /* read the offset */
2100 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
2103 if (buffer
->string_at_end
== 0)
2106 old_offset
= prs_offset(ps
);
2107 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
2110 /* read the string */
2111 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2114 if(!prs_set_offset(ps
, old_offset
))
2120 /*******************************************************************
2121 * write a array of UNICODE strings and its relative pointer.
2122 * used by 2 RPC structs
2123 ********************************************************************/
2125 static BOOL
smb_io_relarraystr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
2129 prs_struct
*ps
=&buffer
->prs
;
2131 if (MARSHALLING(ps
)) {
2132 uint32 struct_offset
= prs_offset(ps
);
2133 uint32 relative_offset
;
2140 /* first write the last 0 */
2141 buffer
->string_at_end
-= 2;
2142 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2145 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
2148 while (p
&& (*p
!=0)) {
2152 /* Yes this should be malloc not talloc. Don't change. */
2154 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
2155 if (chaine
.buffer
== NULL
)
2158 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
2160 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
2162 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
2163 SAFE_FREE(chaine
.buffer
);
2167 /* write the string */
2168 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
2169 SAFE_FREE(chaine
.buffer
);
2175 SAFE_FREE(chaine
.buffer
);
2178 if(!prs_set_offset(ps
, struct_offset
))
2181 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2182 /* write its offset */
2183 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2191 uint16
*chaine2
=NULL
;
2194 size_t realloc_size
= 0;
2198 /* read the offset */
2199 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2202 old_offset
= prs_offset(ps
);
2203 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2207 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
))
2210 l_chaine
=str_len_uni(&chaine
);
2212 /* we're going to add two more bytes here in case this
2213 is the last string in the array and we need to add
2214 an extra NULL for termination */
2219 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
2221 /* Yes this should be realloc - it's freed below. JRA */
2223 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
2228 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
2229 l_chaine2
+=l_chaine
+1;
2232 } while(l_chaine
!=0);
2234 /* the end should be bould NULL terminated so add
2235 the second one here */
2238 chaine2
[l_chaine2
] = '\0';
2239 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
2243 if(!prs_set_offset(ps
, old_offset
))
2249 /*******************************************************************
2250 Parse a DEVMODE structure and its relative pointer.
2251 ********************************************************************/
2253 static BOOL
smb_io_relsecdesc(const char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
2255 prs_struct
*ps
= &buffer
->prs
;
2257 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
2260 if (MARSHALLING(ps
)) {
2261 uint32 struct_offset
= prs_offset(ps
);
2262 uint32 relative_offset
;
2265 relative_offset
= 0;
2266 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2271 if (*secdesc
!= NULL
) {
2272 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
2274 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2276 /* write the secdesc */
2277 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2280 if(!prs_set_offset(ps
, struct_offset
))
2284 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2285 /* write its offset */
2287 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2292 /* read the offset */
2293 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2296 old_offset
= prs_offset(ps
);
2297 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2301 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2304 if(!prs_set_offset(ps
, old_offset
))
2310 /*******************************************************************
2311 Parse a DEVMODE structure and its relative pointer.
2312 ********************************************************************/
2314 static BOOL
smb_io_reldevmode(const char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2316 prs_struct
*ps
=&buffer
->prs
;
2318 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2321 if (MARSHALLING(ps
)) {
2322 uint32 struct_offset
= prs_offset(ps
);
2323 uint32 relative_offset
;
2325 if (*devmode
== NULL
) {
2327 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2329 DEBUG(8, ("boing, the devmode was NULL\n"));
2334 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2336 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2339 /* write the DEVMODE */
2340 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2343 if(!prs_set_offset(ps
, struct_offset
))
2346 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2347 /* write its offset */
2348 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2354 /* read the offset */
2355 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2357 if (buffer
->string_at_end
== 0) {
2362 old_offset
= prs_offset(ps
);
2363 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2366 /* read the string */
2367 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2369 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2372 if(!prs_set_offset(ps
, old_offset
))
2378 /*******************************************************************
2379 Parse a PRINTER_INFO_0 structure.
2380 ********************************************************************/
2382 BOOL
smb_io_printer_info_0(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2384 prs_struct
*ps
=&buffer
->prs
;
2386 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2389 buffer
->struct_start
=prs_offset(ps
);
2391 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2393 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2396 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2398 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2400 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2403 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2405 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2407 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2409 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2411 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2413 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2415 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2417 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2420 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2422 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2425 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2427 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2429 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2431 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2433 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2435 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2437 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2439 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2441 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2443 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2445 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2447 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2449 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2451 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2453 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2455 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2457 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2459 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2461 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2463 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2465 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2467 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2469 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2471 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2473 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2479 /*******************************************************************
2480 Parse a PRINTER_INFO_1 structure.
2481 ********************************************************************/
2483 BOOL
smb_io_printer_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2485 prs_struct
*ps
=&buffer
->prs
;
2487 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2490 buffer
->struct_start
=prs_offset(ps
);
2492 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2494 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2496 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2498 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2504 /*******************************************************************
2505 Parse a PRINTER_INFO_2 structure.
2506 ********************************************************************/
2508 BOOL
smb_io_printer_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2510 prs_struct
*ps
=&buffer
->prs
;
2511 uint32 dm_offset
, sd_offset
, current_offset
;
2512 uint32 dummy_value
= 0, has_secdesc
= 0;
2514 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2517 buffer
->struct_start
=prs_offset(ps
);
2519 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2521 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2523 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2525 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2527 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2529 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2531 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2534 /* save current offset and wind forwared by a uint32 */
2535 dm_offset
= prs_offset(ps
);
2536 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
2539 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2541 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2543 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2545 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2548 /* save current offset for the sec_desc */
2549 sd_offset
= prs_offset(ps
);
2550 if (!prs_uint32("sec_desc", ps
, depth
, &has_secdesc
))
2554 /* save current location so we can pick back up here */
2555 current_offset
= prs_offset(ps
);
2557 /* parse the devmode */
2558 if (!prs_set_offset(ps
, dm_offset
))
2560 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2563 /* parse the sec_desc */
2564 if (info
->secdesc
) {
2565 if (!prs_set_offset(ps
, sd_offset
))
2567 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2571 /* pick up where we left off */
2572 if (!prs_set_offset(ps
, current_offset
))
2575 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2577 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2579 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2581 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2583 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2585 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2587 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2589 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2595 /*******************************************************************
2596 Parse a PRINTER_INFO_3 structure.
2597 ********************************************************************/
2599 BOOL
smb_io_printer_info_3(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2601 prs_struct
*ps
=&buffer
->prs
;
2603 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2606 buffer
->struct_start
=prs_offset(ps
);
2608 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2610 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2616 /*******************************************************************
2617 Parse a PRINTER_INFO_4 structure.
2618 ********************************************************************/
2620 BOOL
smb_io_printer_info_4(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2622 prs_struct
*ps
=&buffer
->prs
;
2624 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2627 buffer
->struct_start
=prs_offset(ps
);
2629 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2631 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2633 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2638 /*******************************************************************
2639 Parse a PRINTER_INFO_5 structure.
2640 ********************************************************************/
2642 BOOL
smb_io_printer_info_5(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2644 prs_struct
*ps
=&buffer
->prs
;
2646 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2649 buffer
->struct_start
=prs_offset(ps
);
2651 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2653 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2655 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2657 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2659 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2664 /*******************************************************************
2665 Parse a PRINTER_INFO_7 structure.
2666 ********************************************************************/
2668 BOOL
smb_io_printer_info_7(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_7
*info
, int depth
)
2670 prs_struct
*ps
=&buffer
->prs
;
2672 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_7");
2675 buffer
->struct_start
=prs_offset(ps
);
2677 if (!smb_io_relstr("guid", buffer
, depth
, &info
->guid
))
2679 if (!prs_uint32("action", ps
, depth
, &info
->action
))
2684 /*******************************************************************
2685 Parse a PORT_INFO_1 structure.
2686 ********************************************************************/
2688 BOOL
smb_io_port_info_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2690 prs_struct
*ps
=&buffer
->prs
;
2692 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2695 buffer
->struct_start
=prs_offset(ps
);
2697 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2703 /*******************************************************************
2704 Parse a PORT_INFO_2 structure.
2705 ********************************************************************/
2707 BOOL
smb_io_port_info_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2709 prs_struct
*ps
=&buffer
->prs
;
2711 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2714 buffer
->struct_start
=prs_offset(ps
);
2716 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2718 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2720 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2722 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2724 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2730 /*******************************************************************
2731 Parse a DRIVER_INFO_1 structure.
2732 ********************************************************************/
2734 BOOL
smb_io_printer_driver_info_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2736 prs_struct
*ps
=&buffer
->prs
;
2738 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2741 buffer
->struct_start
=prs_offset(ps
);
2743 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2749 /*******************************************************************
2750 Parse a DRIVER_INFO_2 structure.
2751 ********************************************************************/
2753 BOOL
smb_io_printer_driver_info_2(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2755 prs_struct
*ps
=&buffer
->prs
;
2757 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2760 buffer
->struct_start
=prs_offset(ps
);
2762 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2764 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2766 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2768 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2770 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2772 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2778 /*******************************************************************
2779 Parse a DRIVER_INFO_3 structure.
2780 ********************************************************************/
2782 BOOL
smb_io_printer_driver_info_3(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2784 prs_struct
*ps
=&buffer
->prs
;
2786 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2789 buffer
->struct_start
=prs_offset(ps
);
2791 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2793 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2795 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2797 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2799 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2801 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2803 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2806 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2809 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2811 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2817 /*******************************************************************
2818 Parse a DRIVER_INFO_6 structure.
2819 ********************************************************************/
2821 BOOL
smb_io_printer_driver_info_6(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2823 prs_struct
*ps
=&buffer
->prs
;
2825 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2828 buffer
->struct_start
=prs_offset(ps
);
2830 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2832 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2834 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2836 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2838 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2840 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2842 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2845 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2848 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2850 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2853 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2856 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2858 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2861 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2864 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2867 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2870 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2872 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2874 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2876 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2882 /*******************************************************************
2883 Parse a JOB_INFO_1 structure.
2884 ********************************************************************/
2886 BOOL
smb_io_job_info_1(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2888 prs_struct
*ps
=&buffer
->prs
;
2890 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2893 buffer
->struct_start
=prs_offset(ps
);
2895 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2897 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2899 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2901 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2903 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2905 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2907 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2909 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2911 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2913 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2915 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2917 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2919 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2925 /*******************************************************************
2926 Parse a JOB_INFO_2 structure.
2927 ********************************************************************/
2929 BOOL
smb_io_job_info_2(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2932 prs_struct
*ps
=&buffer
->prs
;
2934 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2937 buffer
->struct_start
=prs_offset(ps
);
2939 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2941 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2943 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2945 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2947 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2949 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2951 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2954 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2956 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2958 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2960 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2962 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2965 /* SEC_DESC sec_desc;*/
2966 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2969 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2971 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2973 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2975 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2977 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2979 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2981 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2983 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2985 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2987 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2993 /*******************************************************************
2994 ********************************************************************/
2996 BOOL
smb_io_form_1(const char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2998 prs_struct
*ps
=&buffer
->prs
;
3000 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
3003 buffer
->struct_start
=prs_offset(ps
);
3005 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
3008 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3011 if (!prs_uint32("width", ps
, depth
, &info
->width
))
3013 if (!prs_uint32("length", ps
, depth
, &info
->length
))
3015 if (!prs_uint32("left", ps
, depth
, &info
->left
))
3017 if (!prs_uint32("top", ps
, depth
, &info
->top
))
3019 if (!prs_uint32("right", ps
, depth
, &info
->right
))
3021 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
3027 /*******************************************************************
3028 Read/write a BUFFER struct.
3029 ********************************************************************/
3031 static BOOL
spoolss_io_buffer(const char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
3033 NEW_BUFFER
*buffer
= *pp_buffer
;
3035 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
3038 if (UNMARSHALLING(ps
))
3039 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
3044 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
3048 if (UNMARSHALLING(ps
)) {
3050 buffer
->string_at_end
=0;
3052 if (buffer
->ptr
==0) {
3054 * JRA. I'm not sure if the data in here is in big-endian format if
3055 * the client is big-endian. Leave as default (little endian) for now.
3058 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
3063 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3067 * JRA. I'm not sure if the data in here is in big-endian format if
3068 * the client is big-endian. Leave as default (little endian) for now.
3071 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
3074 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
3077 if (!prs_set_offset(&buffer
->prs
, 0))
3080 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
3083 buffer
->string_at_end
=buffer
->size
;
3091 if (buffer
->ptr
==0) {
3092 /* We have finished with the data in buffer->prs - free it. */
3093 prs_mem_free(&buffer
->prs
);
3097 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3100 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
3106 /* We have finished with the data in buffer->prs - free it. */
3107 prs_mem_free(&buffer
->prs
);
3113 /*******************************************************************
3114 move a BUFFER from the query to the reply.
3115 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
3116 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
3117 Clears the memory to zero also.
3118 ********************************************************************/
3120 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
3122 prs_switch_type(&src
->prs
, MARSHALL
);
3123 if(!prs_set_offset(&src
->prs
, 0))
3125 prs_force_dynamic(&src
->prs
);
3126 prs_mem_clear(&src
->prs
);
3130 /*******************************************************************
3131 Get the size of a BUFFER struct.
3132 ********************************************************************/
3134 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
3136 return (buffer
->size
);
3139 /*******************************************************************
3140 Parse a DRIVER_DIRECTORY_1 structure.
3141 ********************************************************************/
3143 BOOL
smb_io_driverdir_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
3145 prs_struct
*ps
=&buffer
->prs
;
3147 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
3150 buffer
->struct_start
=prs_offset(ps
);
3152 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
3158 /*******************************************************************
3159 Parse a PORT_INFO_1 structure.
3160 ********************************************************************/
3162 BOOL
smb_io_port_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
3164 prs_struct
*ps
=&buffer
->prs
;
3166 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
3169 buffer
->struct_start
=prs_offset(ps
);
3171 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3177 /*******************************************************************
3178 Parse a PORT_INFO_2 structure.
3179 ********************************************************************/
3181 BOOL
smb_io_port_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
3183 prs_struct
*ps
=&buffer
->prs
;
3185 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
3188 buffer
->struct_start
=prs_offset(ps
);
3190 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3192 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
3194 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
3196 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
3198 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
3204 /*******************************************************************
3205 ********************************************************************/
3207 BOOL
smb_io_printprocessor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
3209 prs_struct
*ps
=&buffer
->prs
;
3211 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
3214 buffer
->struct_start
=prs_offset(ps
);
3216 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3222 /*******************************************************************
3223 ********************************************************************/
3225 BOOL
smb_io_printprocdatatype_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
3227 prs_struct
*ps
=&buffer
->prs
;
3229 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
3232 buffer
->struct_start
=prs_offset(ps
);
3234 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3240 /*******************************************************************
3241 ********************************************************************/
3243 BOOL
smb_io_printmonitor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
3245 prs_struct
*ps
=&buffer
->prs
;
3247 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
3250 buffer
->struct_start
=prs_offset(ps
);
3252 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3258 /*******************************************************************
3259 ********************************************************************/
3261 BOOL
smb_io_printmonitor_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
3263 prs_struct
*ps
=&buffer
->prs
;
3265 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
3268 buffer
->struct_start
=prs_offset(ps
);
3270 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3272 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
3274 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
3280 /*******************************************************************
3281 return the size required by a struct in the stream
3282 ********************************************************************/
3284 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
3288 size
+=size_of_relative_string( &info
->printername
);
3289 size
+=size_of_relative_string( &info
->servername
);
3291 size
+=size_of_uint32( &info
->cjobs
);
3292 size
+=size_of_uint32( &info
->total_jobs
);
3293 size
+=size_of_uint32( &info
->total_bytes
);
3295 size
+=size_of_uint16( &info
->year
);
3296 size
+=size_of_uint16( &info
->month
);
3297 size
+=size_of_uint16( &info
->dayofweek
);
3298 size
+=size_of_uint16( &info
->day
);
3299 size
+=size_of_uint16( &info
->hour
);
3300 size
+=size_of_uint16( &info
->minute
);
3301 size
+=size_of_uint16( &info
->second
);
3302 size
+=size_of_uint16( &info
->milliseconds
);
3304 size
+=size_of_uint32( &info
->global_counter
);
3305 size
+=size_of_uint32( &info
->total_pages
);
3307 size
+=size_of_uint16( &info
->major_version
);
3308 size
+=size_of_uint16( &info
->build_version
);
3310 size
+=size_of_uint32( &info
->unknown7
);
3311 size
+=size_of_uint32( &info
->unknown8
);
3312 size
+=size_of_uint32( &info
->unknown9
);
3313 size
+=size_of_uint32( &info
->session_counter
);
3314 size
+=size_of_uint32( &info
->unknown11
);
3315 size
+=size_of_uint32( &info
->printer_errors
);
3316 size
+=size_of_uint32( &info
->unknown13
);
3317 size
+=size_of_uint32( &info
->unknown14
);
3318 size
+=size_of_uint32( &info
->unknown15
);
3319 size
+=size_of_uint32( &info
->unknown16
);
3320 size
+=size_of_uint32( &info
->change_id
);
3321 size
+=size_of_uint32( &info
->unknown18
);
3322 size
+=size_of_uint32( &info
->status
);
3323 size
+=size_of_uint32( &info
->unknown20
);
3324 size
+=size_of_uint32( &info
->c_setprinter
);
3326 size
+=size_of_uint16( &info
->unknown22
);
3327 size
+=size_of_uint16( &info
->unknown23
);
3328 size
+=size_of_uint16( &info
->unknown24
);
3329 size
+=size_of_uint16( &info
->unknown25
);
3330 size
+=size_of_uint16( &info
->unknown26
);
3331 size
+=size_of_uint16( &info
->unknown27
);
3332 size
+=size_of_uint16( &info
->unknown28
);
3333 size
+=size_of_uint16( &info
->unknown29
);
3338 /*******************************************************************
3339 return the size required by a struct in the stream
3340 ********************************************************************/
3342 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3346 size
+=size_of_uint32( &info
->flags
);
3347 size
+=size_of_relative_string( &info
->description
);
3348 size
+=size_of_relative_string( &info
->name
);
3349 size
+=size_of_relative_string( &info
->comment
);
3354 /*******************************************************************
3355 return the size required by a struct in the stream
3356 ********************************************************************/
3358 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3364 size
+= sec_desc_size( info
->secdesc
);
3366 size
+=size_of_device_mode( info
->devmode
);
3368 size
+=size_of_relative_string( &info
->servername
);
3369 size
+=size_of_relative_string( &info
->printername
);
3370 size
+=size_of_relative_string( &info
->sharename
);
3371 size
+=size_of_relative_string( &info
->portname
);
3372 size
+=size_of_relative_string( &info
->drivername
);
3373 size
+=size_of_relative_string( &info
->comment
);
3374 size
+=size_of_relative_string( &info
->location
);
3376 size
+=size_of_relative_string( &info
->sepfile
);
3377 size
+=size_of_relative_string( &info
->printprocessor
);
3378 size
+=size_of_relative_string( &info
->datatype
);
3379 size
+=size_of_relative_string( &info
->parameters
);
3381 size
+=size_of_uint32( &info
->attributes
);
3382 size
+=size_of_uint32( &info
->priority
);
3383 size
+=size_of_uint32( &info
->defaultpriority
);
3384 size
+=size_of_uint32( &info
->starttime
);
3385 size
+=size_of_uint32( &info
->untiltime
);
3386 size
+=size_of_uint32( &info
->status
);
3387 size
+=size_of_uint32( &info
->cjobs
);
3388 size
+=size_of_uint32( &info
->averageppm
);
3391 * add any adjustments for alignment. This is
3392 * not optimal since we could be calling this
3393 * function from a loop (e.g. enumprinters), but
3394 * it is easier to maintain the calculation here and
3395 * not place the burden on the caller to remember. --jerry
3397 if ((size
% 4) != 0)
3398 size
+= 4 - (size
% 4);
3403 /*******************************************************************
3404 return the size required by a struct in the stream
3405 ********************************************************************/
3407 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3411 size
+=size_of_relative_string( &info
->printername
);
3412 size
+=size_of_relative_string( &info
->servername
);
3414 size
+=size_of_uint32( &info
->attributes
);
3418 /*******************************************************************
3419 return the size required by a struct in the stream
3420 ********************************************************************/
3422 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3426 size
+=size_of_relative_string( &info
->printername
);
3427 size
+=size_of_relative_string( &info
->portname
);
3429 size
+=size_of_uint32( &info
->attributes
);
3430 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3431 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3436 /*******************************************************************
3437 return the size required by a struct in the stream
3438 ********************************************************************/
3440 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3442 /* The 4 is for the self relative pointer.. */
3443 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3444 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3447 /*******************************************************************
3448 return the size required by a struct in the stream
3449 ********************************************************************/
3451 uint32
spoolss_size_printer_info_7(PRINTER_INFO_7
*info
)
3455 size
+=size_of_relative_string( &info
->guid
);
3456 size
+=size_of_uint32( &info
->action
);
3460 /*******************************************************************
3461 return the size required by a struct in the stream
3462 ********************************************************************/
3464 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3467 size
+=size_of_relative_string( &info
->name
);
3472 /*******************************************************************
3473 return the size required by a struct in the stream
3474 ********************************************************************/
3476 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3479 size
+=size_of_uint32( &info
->version
);
3480 size
+=size_of_relative_string( &info
->name
);
3481 size
+=size_of_relative_string( &info
->architecture
);
3482 size
+=size_of_relative_string( &info
->driverpath
);
3483 size
+=size_of_relative_string( &info
->datafile
);
3484 size
+=size_of_relative_string( &info
->configfile
);
3489 /*******************************************************************
3490 return the size required by a string array.
3491 ********************************************************************/
3493 uint32
spoolss_size_string_array(uint16
*string
)
3498 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3500 i
=i
+2; /* to count all chars including the leading zero */
3501 i
=2*i
; /* because we need the value in bytes */
3502 i
=i
+4; /* the offset pointer size */
3507 /*******************************************************************
3508 return the size required by a struct in the stream
3509 ********************************************************************/
3511 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3515 size
+=size_of_uint32( &info
->version
);
3516 size
+=size_of_relative_string( &info
->name
);
3517 size
+=size_of_relative_string( &info
->architecture
);
3518 size
+=size_of_relative_string( &info
->driverpath
);
3519 size
+=size_of_relative_string( &info
->datafile
);
3520 size
+=size_of_relative_string( &info
->configfile
);
3521 size
+=size_of_relative_string( &info
->helpfile
);
3522 size
+=size_of_relative_string( &info
->monitorname
);
3523 size
+=size_of_relative_string( &info
->defaultdatatype
);
3525 size
+=spoolss_size_string_array(info
->dependentfiles
);
3530 /*******************************************************************
3531 return the size required by a struct in the stream
3532 ********************************************************************/
3534 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3538 size
+=size_of_uint32( &info
->version
);
3539 size
+=size_of_relative_string( &info
->name
);
3540 size
+=size_of_relative_string( &info
->architecture
);
3541 size
+=size_of_relative_string( &info
->driverpath
);
3542 size
+=size_of_relative_string( &info
->datafile
);
3543 size
+=size_of_relative_string( &info
->configfile
);
3544 size
+=size_of_relative_string( &info
->helpfile
);
3546 size
+=spoolss_size_string_array(info
->dependentfiles
);
3548 size
+=size_of_relative_string( &info
->monitorname
);
3549 size
+=size_of_relative_string( &info
->defaultdatatype
);
3551 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3553 size
+=size_of_nttime(&info
->driver_date
);
3554 size
+=size_of_uint32( &info
->padding
);
3555 size
+=size_of_uint32( &info
->driver_version_low
);
3556 size
+=size_of_uint32( &info
->driver_version_high
);
3557 size
+=size_of_relative_string( &info
->mfgname
);
3558 size
+=size_of_relative_string( &info
->oem_url
);
3559 size
+=size_of_relative_string( &info
->hardware_id
);
3560 size
+=size_of_relative_string( &info
->provider
);
3565 /*******************************************************************
3566 return the size required by a struct in the stream
3567 ********************************************************************/
3569 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3572 size
+=size_of_uint32( &info
->jobid
);
3573 size
+=size_of_relative_string( &info
->printername
);
3574 size
+=size_of_relative_string( &info
->machinename
);
3575 size
+=size_of_relative_string( &info
->username
);
3576 size
+=size_of_relative_string( &info
->document
);
3577 size
+=size_of_relative_string( &info
->datatype
);
3578 size
+=size_of_relative_string( &info
->text_status
);
3579 size
+=size_of_uint32( &info
->status
);
3580 size
+=size_of_uint32( &info
->priority
);
3581 size
+=size_of_uint32( &info
->position
);
3582 size
+=size_of_uint32( &info
->totalpages
);
3583 size
+=size_of_uint32( &info
->pagesprinted
);
3584 size
+=size_of_systemtime( &info
->submitted
);
3589 /*******************************************************************
3590 return the size required by a struct in the stream
3591 ********************************************************************/
3593 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3597 size
+=4; /* size of sec desc ptr */
3599 size
+=size_of_uint32( &info
->jobid
);
3600 size
+=size_of_relative_string( &info
->printername
);
3601 size
+=size_of_relative_string( &info
->machinename
);
3602 size
+=size_of_relative_string( &info
->username
);
3603 size
+=size_of_relative_string( &info
->document
);
3604 size
+=size_of_relative_string( &info
->notifyname
);
3605 size
+=size_of_relative_string( &info
->datatype
);
3606 size
+=size_of_relative_string( &info
->printprocessor
);
3607 size
+=size_of_relative_string( &info
->parameters
);
3608 size
+=size_of_relative_string( &info
->drivername
);
3609 size
+=size_of_device_mode( info
->devmode
);
3610 size
+=size_of_relative_string( &info
->text_status
);
3611 /* SEC_DESC sec_desc;*/
3612 size
+=size_of_uint32( &info
->status
);
3613 size
+=size_of_uint32( &info
->priority
);
3614 size
+=size_of_uint32( &info
->position
);
3615 size
+=size_of_uint32( &info
->starttime
);
3616 size
+=size_of_uint32( &info
->untiltime
);
3617 size
+=size_of_uint32( &info
->totalpages
);
3618 size
+=size_of_uint32( &info
->size
);
3619 size
+=size_of_systemtime( &info
->submitted
);
3620 size
+=size_of_uint32( &info
->timeelapsed
);
3621 size
+=size_of_uint32( &info
->pagesprinted
);
3626 /*******************************************************************
3627 return the size required by a struct in the stream
3628 ********************************************************************/
3630 uint32
spoolss_size_form_1(FORM_1
*info
)
3634 size
+=size_of_uint32( &info
->flag
);
3635 size
+=size_of_relative_string( &info
->name
);
3636 size
+=size_of_uint32( &info
->width
);
3637 size
+=size_of_uint32( &info
->length
);
3638 size
+=size_of_uint32( &info
->left
);
3639 size
+=size_of_uint32( &info
->top
);
3640 size
+=size_of_uint32( &info
->right
);
3641 size
+=size_of_uint32( &info
->bottom
);
3646 /*******************************************************************
3647 return the size required by a struct in the stream
3648 ********************************************************************/
3650 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3654 size
+=size_of_relative_string( &info
->port_name
);
3659 /*******************************************************************
3660 return the size required by a struct in the stream
3661 ********************************************************************/
3663 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3667 size
=str_len_uni(&info
->name
); /* the string length */
3668 size
=size
+1; /* add the leading zero */
3669 size
=size
*2; /* convert in char */
3674 /*******************************************************************
3675 return the size required by a struct in the stream
3676 ********************************************************************/
3678 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3682 size
=str_len_uni(&info
->name
); /* the string length */
3683 size
=size
+1; /* add the leading zero */
3684 size
=size
*2; /* convert in char */
3689 /*******************************************************************
3690 return the size required by a struct in the stream
3691 ********************************************************************/
3693 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3697 size
+=size_of_relative_string( &info
->port_name
);
3698 size
+=size_of_relative_string( &info
->monitor_name
);
3699 size
+=size_of_relative_string( &info
->description
);
3701 size
+=size_of_uint32( &info
->port_type
);
3702 size
+=size_of_uint32( &info
->reserved
);
3707 /*******************************************************************
3708 return the size required by a struct in the stream
3709 ********************************************************************/
3711 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3714 size
+=size_of_relative_string( &info
->name
);
3719 /*******************************************************************
3720 return the size required by a struct in the stream
3721 ********************************************************************/
3723 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3726 size
+=size_of_relative_string( &info
->name
);
3731 /*******************************************************************
3732 return the size required by a struct in the stream
3733 ********************************************************************/
3734 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3741 /* uint32(offset) + uint32(length) + length) */
3742 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3743 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
+ (p
->data_len
%2) ;
3745 size
+= size_of_uint32(&p
->type
);
3750 /*******************************************************************
3751 return the size required by a struct in the stream
3752 ********************************************************************/
3754 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3757 size
+=size_of_relative_string( &info
->name
);
3762 /*******************************************************************
3763 return the size required by a struct in the stream
3764 ********************************************************************/
3766 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3769 size
+=size_of_relative_string( &info
->name
);
3770 size
+=size_of_relative_string( &info
->environment
);
3771 size
+=size_of_relative_string( &info
->dll_name
);
3776 /*******************************************************************
3778 ********************************************************************/
3780 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3781 const POLICY_HND
*hnd
,
3782 const fstring architecture
,
3783 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3784 NEW_BUFFER
*buffer
, uint32 offered
)
3789 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3791 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3794 q_u
->clientmajorversion
=clientmajor
;
3795 q_u
->clientminorversion
=clientminor
;
3798 q_u
->offered
=offered
;
3803 /*******************************************************************
3805 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3806 ********************************************************************/
3808 BOOL
spoolss_io_q_getprinterdriver2(const char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3810 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3816 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3818 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3820 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3825 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3828 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3834 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3837 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3839 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3845 /*******************************************************************
3847 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3848 ********************************************************************/
3850 BOOL
spoolss_io_r_getprinterdriver2(const char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3852 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3858 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3863 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3865 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3867 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3869 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3875 /*******************************************************************
3877 ********************************************************************/
3879 BOOL
make_spoolss_q_enumprinters(
3880 SPOOL_Q_ENUMPRINTERS
*q_u
,
3890 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3891 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3895 q_u
->offered
=offered
;
3900 /*******************************************************************
3902 ********************************************************************/
3904 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3905 fstring servername
, uint32 level
,
3906 NEW_BUFFER
*buffer
, uint32 offered
)
3908 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3909 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3913 q_u
->offered
=offered
;
3918 /*******************************************************************
3920 * called from spoolss_enumprinters (srv_spoolss.c)
3921 ********************************************************************/
3923 BOOL
spoolss_io_q_enumprinters(const char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3925 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3931 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3933 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3936 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3941 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3944 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3949 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3955 /*******************************************************************
3956 Parse a SPOOL_R_ENUMPRINTERS structure.
3957 ********************************************************************/
3959 BOOL
spoolss_io_r_enumprinters(const char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3961 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3967 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3973 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3976 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3979 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3985 /*******************************************************************
3986 * write a structure.
3987 * called from spoolss_r_enum_printers (srv_spoolss.c)
3989 ********************************************************************/
3991 BOOL
spoolss_io_r_getprinter(const char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3993 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3999 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4005 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4008 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4014 /*******************************************************************
4016 * called from spoolss_getprinter (srv_spoolss.c)
4017 ********************************************************************/
4019 BOOL
spoolss_io_q_getprinter(const char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4021 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
4027 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4029 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4032 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4037 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4043 /*******************************************************************
4045 ********************************************************************/
4047 BOOL
make_spoolss_q_getprinter(
4048 TALLOC_CTX
*mem_ctx
,
4049 SPOOL_Q_GETPRINTER
*q_u
,
4050 const POLICY_HND
*hnd
,
4060 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4064 q_u
->offered
=offered
;
4069 /*******************************************************************
4071 ********************************************************************/
4072 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
4073 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
4077 DEVICEMODE
*devmode
;
4082 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4085 q_u
->info
.level
= level
;
4086 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
4089 /* There's no such thing as a setprinter level 1 */
4092 secdesc
= info
->printers_2
->secdesc
;
4093 devmode
= info
->printers_2
->devmode
;
4095 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
4096 #if 1 /* JERRY TEST */
4097 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
4098 if (!q_u
->secdesc_ctr
)
4100 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
4101 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4102 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4103 q_u
->secdesc_ctr
->sec
= secdesc
;
4105 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
4106 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
4107 q_u
->devmode_ctr
.devmode
= devmode
;
4109 q_u
->secdesc_ctr
= NULL
;
4111 q_u
->devmode_ctr
.devmode_ptr
= 0;
4112 q_u
->devmode_ctr
.size
= 0;
4113 q_u
->devmode_ctr
.devmode
= NULL
;
4117 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
4122 q_u
->command
= command
;
4128 /*******************************************************************
4129 ********************************************************************/
4131 BOOL
spoolss_io_r_setprinter(const char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
4133 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
4139 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4145 /*******************************************************************
4146 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
4147 ********************************************************************/
4149 BOOL
spoolss_io_q_setprinter(const char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4151 uint32 ptr_sec_desc
= 0;
4153 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
4159 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
4161 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4164 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4167 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4177 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4182 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4188 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4193 /* Parse a NULL security descriptor. This should really
4194 happen inside the sec_io_desc_buf() function. */
4196 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4197 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4199 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
4203 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4209 /*******************************************************************
4210 ********************************************************************/
4212 BOOL
spoolss_io_r_fcpn(const char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
4214 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
4220 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4226 /*******************************************************************
4227 ********************************************************************/
4229 BOOL
spoolss_io_q_fcpn(const char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
4232 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
4238 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4245 /*******************************************************************
4246 ********************************************************************/
4248 BOOL
spoolss_io_r_addjob(const char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
4250 prs_debug(ps
, depth
, desc
, "");
4256 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4262 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4265 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4271 /*******************************************************************
4272 ********************************************************************/
4274 BOOL
spoolss_io_q_addjob(const char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
4276 prs_debug(ps
, depth
, desc
, "");
4282 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4284 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4287 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4293 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4299 /*******************************************************************
4300 ********************************************************************/
4302 BOOL
spoolss_io_r_enumjobs(const char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
4304 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
4310 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4316 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4319 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4322 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4328 /*******************************************************************
4329 ********************************************************************/
4331 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4342 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4343 q_u
->firstjob
= firstjob
;
4344 q_u
->numofjobs
= numofjobs
;
4346 q_u
->buffer
= buffer
;
4347 q_u
->offered
= offered
;
4351 /*******************************************************************
4352 ********************************************************************/
4354 BOOL
spoolss_io_q_enumjobs(const char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4356 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4362 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4365 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4367 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
4369 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4372 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4378 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4384 /*******************************************************************
4385 ********************************************************************/
4387 BOOL
spoolss_io_r_schedulejob(const char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4389 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4395 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4401 /*******************************************************************
4402 ********************************************************************/
4404 BOOL
spoolss_io_q_schedulejob(const char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4406 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4412 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4414 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4420 /*******************************************************************
4421 ********************************************************************/
4423 BOOL
spoolss_io_r_setjob(const char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4425 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4431 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4437 /*******************************************************************
4438 ********************************************************************/
4440 BOOL
spoolss_io_q_setjob(const char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4442 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4448 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4450 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4453 * level is usually 0. If (level!=0) then I'm in trouble !
4454 * I will try to generate setjob command with level!=0, one day.
4456 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4458 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4464 /*******************************************************************
4465 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4466 ********************************************************************/
4468 BOOL
spoolss_io_r_enumprinterdrivers(const char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4470 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4476 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4482 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4485 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4488 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4494 /*******************************************************************
4496 ********************************************************************/
4498 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4500 const char *environment
,
4502 NEW_BUFFER
*buffer
, uint32 offered
)
4504 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4505 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4509 q_u
->offered
=offered
;
4514 /*******************************************************************
4515 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4516 ********************************************************************/
4518 BOOL
spoolss_io_q_enumprinterdrivers(const char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4521 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4527 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4529 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4534 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4536 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4541 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4544 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4550 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4556 /*******************************************************************
4557 ********************************************************************/
4559 BOOL
spoolss_io_q_enumforms(const char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4562 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4567 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4569 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4572 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4577 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4583 /*******************************************************************
4584 ********************************************************************/
4586 BOOL
spoolss_io_r_enumforms(const char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4588 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4594 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4600 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4603 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4606 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4612 /*******************************************************************
4613 ********************************************************************/
4615 BOOL
spoolss_io_q_getform(const char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4618 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4623 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4625 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4631 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4634 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4639 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4645 /*******************************************************************
4646 ********************************************************************/
4648 BOOL
spoolss_io_r_getform(const char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4650 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4656 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4662 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4665 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4671 /*******************************************************************
4672 Parse a SPOOL_R_ENUMPORTS structure.
4673 ********************************************************************/
4675 BOOL
spoolss_io_r_enumports(const char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4677 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4683 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4689 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4692 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4695 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4701 /*******************************************************************
4702 ********************************************************************/
4704 BOOL
spoolss_io_q_enumports(const char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4706 prs_debug(ps
, depth
, desc
, "");
4712 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4714 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4719 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4722 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4727 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4733 /*******************************************************************
4734 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4735 ********************************************************************/
4737 BOOL
spool_io_printer_info_level_1(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4739 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4745 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4747 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4749 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4751 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4754 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4756 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4758 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4764 /*******************************************************************
4765 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4766 ********************************************************************/
4768 BOOL
spool_io_printer_info_level_3(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4770 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4776 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4782 /*******************************************************************
4783 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4784 ********************************************************************/
4786 BOOL
spool_io_printer_info_level_2(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4788 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4794 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4796 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4798 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4800 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4803 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4805 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4807 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4809 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4811 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4813 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4815 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4817 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4819 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4822 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4824 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4826 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4828 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4830 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4832 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4834 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4836 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4839 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4841 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4843 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4845 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4847 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4849 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4851 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4853 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4855 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4857 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4859 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4865 BOOL
spool_io_printer_info_level_7(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_7
*il
, prs_struct
*ps
, int depth
)
4867 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_7");
4873 if(!prs_uint32("guid_ptr", ps
, depth
, &il
->guid_ptr
))
4875 if(!prs_uint32("action", ps
, depth
, &il
->action
))
4878 if(!smb_io_unistr2("servername", &il
->guid
, il
->guid_ptr
, ps
, depth
))
4883 /*******************************************************************
4884 ********************************************************************/
4886 BOOL
spool_io_printer_info_level(const char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4888 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4893 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4895 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4898 /* if no struct inside just return */
4899 if (il
->info_ptr
==0) {
4900 if (UNMARSHALLING(ps
)) {
4907 switch (il
->level
) {
4909 * level 0 is used by setprinter when managing the queue
4910 * (hold, stop, start a queue)
4914 /* DOCUMENT ME!!! What is level 1 used for? */
4917 if (UNMARSHALLING(ps
)) {
4918 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4921 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4926 * level 2 is used by addprinter
4927 * and by setprinter when updating printer's info
4930 if (UNMARSHALLING(ps
)) {
4931 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4934 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4937 /* DOCUMENT ME!!! What is level 3 used for? */
4940 if (UNMARSHALLING(ps
)) {
4941 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4944 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4949 if (UNMARSHALLING(ps
))
4950 if ((il
->info_7
=(SPOOL_PRINTER_INFO_LEVEL_7
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_7
))) == NULL
)
4952 if (!spool_io_printer_info_level_7("", il
->info_7
, ps
, depth
))
4960 /*******************************************************************
4961 ********************************************************************/
4963 BOOL
spoolss_io_q_addprinterex(const char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4965 uint32 ptr_sec_desc
= 0;
4967 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4972 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4974 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4980 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4983 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4986 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4992 switch (q_u
->level
) {
4994 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4997 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
5001 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
5006 /* Parse a NULL security descriptor. This should really
5007 happen inside the sec_io_desc_buf() function. */
5009 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
5010 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
5012 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
5016 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
5018 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
5024 /*******************************************************************
5025 ********************************************************************/
5027 BOOL
spoolss_io_r_addprinterex(const char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
5028 prs_struct
*ps
, int depth
)
5030 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
5033 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5036 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5042 /*******************************************************************
5043 ********************************************************************/
5045 BOOL
spool_io_printer_driver_info_level_3(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
5046 prs_struct
*ps
, int depth
)
5048 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
5050 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
5054 if (UNMARSHALLING(ps
)) {
5055 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
5067 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
5069 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
5071 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
5073 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
5075 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
5077 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
5079 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
5081 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
5083 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5085 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
5087 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
5093 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5095 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5097 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5099 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5101 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5103 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5105 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5107 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5113 if (il
->dependentfiles_ptr
)
5114 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
5119 /*******************************************************************
5120 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
5121 ********************************************************************/
5123 BOOL
spool_io_printer_driver_info_level_6(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
5124 prs_struct
*ps
, int depth
)
5126 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
5128 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
5132 if (UNMARSHALLING(ps
)) {
5133 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
5146 * I know this seems weird, but I have no other explanation.
5147 * This is observed behavior on both NT4 and 2K servers.
5151 if (!prs_align_uint64(ps
))
5154 /* parse the main elements the packet */
5156 if(!prs_uint32("cversion ", ps
, depth
, &il
->version
))
5158 if(!prs_uint32("name ", ps
, depth
, &il
->name_ptr
))
5160 if(!prs_uint32("environment ", ps
, depth
, &il
->environment_ptr
))
5162 if(!prs_uint32("driverpath ", ps
, depth
, &il
->driverpath_ptr
))
5164 if(!prs_uint32("datafile ", ps
, depth
, &il
->datafile_ptr
))
5166 if(!prs_uint32("configfile ", ps
, depth
, &il
->configfile_ptr
))
5168 if(!prs_uint32("helpfile ", ps
, depth
, &il
->helpfile_ptr
))
5170 if(!prs_uint32("monitorname ", ps
, depth
, &il
->monitorname_ptr
))
5172 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5174 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_len
))
5176 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_ptr
))
5178 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_len
))
5180 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_ptr
))
5182 if(!smb_io_time("driverdate ", &il
->driverdate
, ps
, depth
))
5184 if(!prs_uint32("dummy4 ", ps
, depth
, &il
->dummy4
))
5186 if(!prs_uint64("driverversion ", ps
, depth
, &il
->driverversion
))
5188 if(!prs_uint32("mfgname ", ps
, depth
, &il
->mfgname_ptr
))
5190 if(!prs_uint32("oemurl ", ps
, depth
, &il
->oemurl_ptr
))
5192 if(!prs_uint32("hardwareid ", ps
, depth
, &il
->hardwareid_ptr
))
5194 if(!prs_uint32("provider ", ps
, depth
, &il
->provider_ptr
))
5197 /* parse the structures in the packet */
5199 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5204 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5209 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5214 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5219 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5224 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5229 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5234 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5238 if (il
->dependentfiles_ptr
) {
5239 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
5244 if (il
->previousnames_ptr
) {
5245 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
5250 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
5254 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
5258 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
5262 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
5268 /*******************************************************************
5269 convert a buffer of UNICODE strings null terminated
5270 the buffer is terminated by a NULL
5272 convert to an dos codepage array (null terminated)
5274 dynamically allocate memory
5276 ********************************************************************/
5277 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
5286 src
= (char *)buf5
->buffer
;
5289 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
5290 rpcstr_pull(f
, src
, sizeof(f
)-1, -1, STR_TERMINATE
);
5291 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
5292 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
5297 fstrcpy((*ar
)[n
], f
);
5300 fstrcpy((*ar
)[n
], "");
5308 /*******************************************************************
5309 read a UNICODE array with null terminated strings
5310 and null terminated array
5311 and size of array at beginning
5312 ********************************************************************/
5314 BOOL
smb_io_unibuffer(const char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
5316 if (buffer
==NULL
) return False
;
5319 buffer
->uni_str_len
=buffer
->uni_max_len
;
5321 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
5324 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
5330 /*******************************************************************
5331 ********************************************************************/
5333 BOOL
spool_io_printer_driver_info_level(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
5335 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
5340 if(!prs_uint32("level", ps
, depth
, &il
->level
))
5342 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
5348 switch (il
->level
) {
5350 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
5354 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5364 /*******************************************************************
5365 init a SPOOL_Q_ADDPRINTERDRIVER struct
5366 ******************************************************************/
5368 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5369 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5370 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5372 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5374 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
5375 init_unistr2(&q_u
->server_name
, srv_name
, UNI_STR_TERMINATE
);
5379 q_u
->info
.level
= level
;
5380 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
5383 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5385 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5389 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5396 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5397 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5398 DRIVER_INFO_3
*info3
)
5401 uint16
*ptr
= info3
->dependentfiles
;
5403 BOOL null_char
= False
;
5404 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5406 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
5409 inf
->cversion
= info3
->version
;
5410 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5411 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5412 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5413 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5414 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5415 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5416 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5417 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5419 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5420 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5421 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5422 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5423 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5424 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5425 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5426 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5433 /* the null_char BOOL is used to help locate
5434 two '\0's back to back */
5449 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5450 inf
->dependentfilessize
= len
;
5451 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5457 *spool_drv_info
= inf
;
5462 /*******************************************************************
5463 make a BUFFER5 struct from a uint16*
5464 ******************************************************************/
5465 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5468 buf5
->buf_len
= len
;
5469 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5471 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5478 /*******************************************************************
5479 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5480 ********************************************************************/
5482 BOOL
spoolss_io_q_addprinterdriver(const char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5484 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5490 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5492 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5497 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5500 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5506 /*******************************************************************
5507 ********************************************************************/
5509 BOOL
spoolss_io_r_addprinterdriver(const char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5511 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5514 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5520 /*******************************************************************
5521 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5522 ********************************************************************/
5524 BOOL
spoolss_io_q_addprinterdriverex(const char *desc
, SPOOL_Q_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5526 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriverex");
5532 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5534 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5539 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5542 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5547 if(!prs_uint32("copy flags", ps
, depth
, &q_u
->copy_flags
))
5553 /*******************************************************************
5554 ********************************************************************/
5556 BOOL
spoolss_io_r_addprinterdriverex(const char *desc
, SPOOL_R_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5558 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriverex");
5561 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5567 /*******************************************************************
5568 ********************************************************************/
5570 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5571 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5573 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5575 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5579 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5587 d
->cversion
=uni
->cversion
;
5589 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5590 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5591 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5592 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5593 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5594 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5595 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5596 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5598 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5599 DEBUGADD(8,( "name: %s\n", d
->name
));
5600 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5601 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5602 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5603 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5604 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5605 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5606 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5608 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5615 /*******************************************************************
5616 ********************************************************************/
5617 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5618 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5620 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5622 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5626 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5634 d
->version
=uni
->version
;
5636 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5637 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5638 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5639 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5640 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5641 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5642 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5643 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5645 DEBUGADD(8,( "version: %d\n", d
->version
));
5646 DEBUGADD(8,( "name: %s\n", d
->name
));
5647 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5648 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5649 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5650 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5651 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5652 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5653 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5655 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5657 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5667 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5668 NT_PRINTER_INFO_LEVEL_2
**asc
)
5670 NT_PRINTER_INFO_LEVEL_2
*d
;
5673 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5674 time_unix
=time(NULL
);
5677 DEBUGADD(8,("allocating memory\n"));
5679 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5684 /* we allocate memory iff called from
5685 * addprinter(ex) so we can do one time stuff here.
5687 (*asc
)->setuptime
=time_unix
;
5690 DEBUGADD(8,("start converting\n"));
5694 d
->attributes
=uni
->attributes
;
5695 d
->priority
=uni
->priority
;
5696 d
->default_priority
=uni
->default_priority
;
5697 d
->starttime
=uni
->starttime
;
5698 d
->untiltime
=uni
->untiltime
;
5699 d
->status
=uni
->status
;
5700 d
->cjobs
=uni
->cjobs
;
5702 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5703 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5704 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5705 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5706 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5707 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5708 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5709 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5710 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5711 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5712 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5717 /*******************************************************************
5719 ********************************************************************/
5721 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5722 fstring servername
, fstring env_name
, uint32 level
,
5723 NEW_BUFFER
*buffer
, uint32 offered
)
5725 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5726 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5730 q_u
->offered
=offered
;
5735 /*******************************************************************
5736 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5737 ********************************************************************/
5739 BOOL
spoolss_io_q_getprinterdriverdir(const char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5741 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5746 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5748 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5754 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5756 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5762 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5765 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5771 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5777 /*******************************************************************
5778 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5779 ********************************************************************/
5781 BOOL
spoolss_io_r_getprinterdriverdir(const char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5783 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5789 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5795 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5798 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5804 /*******************************************************************
5805 ********************************************************************/
5807 BOOL
spoolss_io_r_enumprintprocessors(const char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5809 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5815 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5821 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5824 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5827 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5833 /*******************************************************************
5834 ********************************************************************/
5836 BOOL
spoolss_io_q_enumprintprocessors(const char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5838 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5844 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5846 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5852 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5854 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5860 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5863 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5869 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5875 /*******************************************************************
5876 ********************************************************************/
5878 BOOL
spoolss_io_q_addprintprocessor(const char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5880 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5886 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5888 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5893 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5898 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5903 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5909 /*******************************************************************
5910 ********************************************************************/
5912 BOOL
spoolss_io_r_addprintprocessor(const char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5914 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5920 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5926 /*******************************************************************
5927 ********************************************************************/
5929 BOOL
spoolss_io_r_enumprintprocdatatypes(const char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5931 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5937 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5943 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5946 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5949 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5955 /*******************************************************************
5956 ********************************************************************/
5958 BOOL
spoolss_io_q_enumprintprocdatatypes(const char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5960 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5966 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5968 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5974 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5976 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5982 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5985 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5991 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5997 /*******************************************************************
5998 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5999 ********************************************************************/
6001 BOOL
spoolss_io_q_enumprintmonitors(const char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
6003 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
6009 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
6011 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6017 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
6020 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6026 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6032 /*******************************************************************
6033 ********************************************************************/
6035 BOOL
spoolss_io_r_enumprintmonitors(const char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
6037 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
6043 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6049 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6052 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6055 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6061 /*******************************************************************
6062 ********************************************************************/
6064 BOOL
spoolss_io_r_enumprinterdata(const char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6066 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
6071 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
6074 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
6075 r_u
->value
= (uint16
*)prs_alloc_mem(ps
, r_u
->valuesize
* 2);
6077 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
6082 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
6088 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
6091 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
6094 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
6097 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
6098 r_u
->data
= (uint8
*)prs_alloc_mem(ps
, r_u
->datasize
);
6100 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
6105 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
6110 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
6112 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6118 /*******************************************************************
6119 ********************************************************************/
6121 BOOL
spoolss_io_q_enumprinterdata(const char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6123 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
6128 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6130 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
6132 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
6134 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
6140 /*******************************************************************
6141 ********************************************************************/
6143 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
6144 const POLICY_HND
*hnd
,
6145 uint32 idx
, uint32 valuelen
, uint32 datalen
)
6147 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6149 q_u
->valuesize
=valuelen
;
6150 q_u
->datasize
=datalen
;
6155 /*******************************************************************
6156 ********************************************************************/
6158 BOOL
make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX
*q_u
,
6159 const POLICY_HND
*hnd
, const char *key
,
6162 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6163 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
6169 /*******************************************************************
6170 ********************************************************************/
6171 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, const POLICY_HND
*hnd
,
6172 char* value
, uint32 data_type
, char* data
, uint32 data_size
)
6174 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6175 q_u
->type
= data_type
;
6176 init_unistr2(&q_u
->value
, value
, UNI_STR_TERMINATE
);
6178 q_u
->max_len
= q_u
->real_len
= data_size
;
6179 q_u
->data
= (unsigned char *)data
;
6184 /*******************************************************************
6185 ********************************************************************/
6186 BOOL
make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX
*q_u
, const POLICY_HND
*hnd
,
6187 char *key
, char* value
, uint32 data_type
, char* data
,
6190 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6191 q_u
->type
= data_type
;
6192 init_unistr2(&q_u
->value
, value
, UNI_STR_TERMINATE
);
6193 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
6195 q_u
->max_len
= q_u
->real_len
= data_size
;
6196 q_u
->data
= (unsigned char *)data
;
6201 /*******************************************************************
6202 ********************************************************************/
6204 BOOL
spoolss_io_q_setprinterdata(const char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6206 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
6211 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6213 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6219 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6222 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6232 if (UNMARSHALLING(ps
))
6233 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6234 if(q_u
->data
== NULL
)
6236 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6244 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6250 /*******************************************************************
6251 ********************************************************************/
6253 BOOL
spoolss_io_r_setprinterdata(const char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6255 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
6260 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6266 /*******************************************************************
6267 ********************************************************************/
6268 BOOL
spoolss_io_q_resetprinter(const char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6270 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
6275 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6278 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
6281 if (q_u
->datatype_ptr
) {
6282 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
6286 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
6293 /*******************************************************************
6294 ********************************************************************/
6295 BOOL
spoolss_io_r_resetprinter(const char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6297 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
6302 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6308 /*******************************************************************
6309 ********************************************************************/
6311 static BOOL
spoolss_io_addform(const char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
6313 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
6320 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
6322 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
6324 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
6326 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
6328 if(!prs_uint32("left", ps
, depth
, &f
->left
))
6330 if(!prs_uint32("top", ps
, depth
, &f
->top
))
6332 if(!prs_uint32("right", ps
, depth
, &f
->right
))
6334 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
6337 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
6344 /*******************************************************************
6345 ********************************************************************/
6347 BOOL
spoolss_io_q_deleteform(const char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
6349 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
6354 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6356 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
6362 /*******************************************************************
6363 ********************************************************************/
6365 BOOL
spoolss_io_r_deleteform(const char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
6367 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
6372 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6378 /*******************************************************************
6379 ********************************************************************/
6381 BOOL
spoolss_io_q_addform(const char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
6383 uint32 useless_ptr
=1;
6384 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
6389 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6391 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6393 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6398 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6400 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6407 /*******************************************************************
6408 ********************************************************************/
6410 BOOL
spoolss_io_r_addform(const char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6412 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6417 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6423 /*******************************************************************
6424 ********************************************************************/
6426 BOOL
spoolss_io_q_setform(const char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6428 uint32 useless_ptr
=1;
6429 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6434 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6436 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6442 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6444 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6449 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6451 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6458 /*******************************************************************
6459 ********************************************************************/
6461 BOOL
spoolss_io_r_setform(const char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6463 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6468 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6474 /*******************************************************************
6475 Parse a SPOOL_R_GETJOB structure.
6476 ********************************************************************/
6478 BOOL
spoolss_io_r_getjob(const char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6480 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6486 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6492 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6495 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6501 /*******************************************************************
6502 Parse a SPOOL_Q_GETJOB structure.
6503 ********************************************************************/
6505 BOOL
spoolss_io_q_getjob(const char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6507 prs_debug(ps
, depth
, desc
, "");
6513 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6515 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6517 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6520 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6526 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6532 void free_devmode(DEVICEMODE
*devmode
)
6534 if (devmode
!=NULL
) {
6535 SAFE_FREE(devmode
->private);
6540 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6545 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6547 if (printer
!=NULL
) {
6548 free_devmode(printer
->devmode
);
6549 printer
->devmode
= NULL
;
6554 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6559 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6564 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6569 void free_printer_info_7(PRINTER_INFO_7
*printer
)
6574 void free_job_info_2(JOB_INFO_2
*job
)
6577 free_devmode(job
->devmode
);
6580 /*******************************************************************
6582 ********************************************************************/
6584 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6585 const fstring string
, uint32 printer
, uint32 type
)
6590 init_unistr2(&q_u
->string
, string
, UNI_STR_TERMINATE
);
6592 q_u
->printer
=printer
;
6601 /*******************************************************************
6602 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6603 ********************************************************************/
6605 BOOL
spoolss_io_q_replyopenprinter(const char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6607 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6613 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6619 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6621 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6624 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6626 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6632 /*******************************************************************
6633 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6634 ********************************************************************/
6636 BOOL
spoolss_io_r_replyopenprinter(const char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6638 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6644 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6647 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6653 /*******************************************************************
6655 ********************************************************************/
6656 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6657 uint32 condition
, uint32 change_id
)
6660 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6662 q_u
->condition
= condition
;
6663 q_u
->change_id
= change_id
;
6666 q_u
->unknown1
= 0x1;
6667 memset(q_u
->unknown2
, 0x0, 5);
6668 q_u
->unknown2
[0] = 0x1;
6673 /*******************************************************************
6674 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6675 ********************************************************************/
6676 BOOL
spoolss_io_q_routerreplyprinter (const char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6679 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6685 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6688 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6691 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6694 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6697 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6703 /*******************************************************************
6704 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6705 ********************************************************************/
6706 BOOL
spoolss_io_r_routerreplyprinter (const char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6708 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6714 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6720 /*******************************************************************
6722 ********************************************************************/
6724 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6729 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6734 /*******************************************************************
6735 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6736 ********************************************************************/
6738 BOOL
spoolss_io_q_replycloseprinter(const char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6740 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6746 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6752 /*******************************************************************
6753 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6754 ********************************************************************/
6756 BOOL
spoolss_io_r_replycloseprinter(const char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6758 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6764 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6767 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6773 #if 0 /* JERRY - not currently used but could be :-) */
6775 /*******************************************************************
6776 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6777 ******************************************************************/
6778 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6779 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6783 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6785 for (i
=0; i
<n
; i
++) {
6789 if (src
->size
!= POINTER
)
6791 len
= src
->notify_data
.data
.length
;
6792 s
= malloc(sizeof(uint16
)*len
);
6794 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6798 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6799 dst
->notify_data
.data
.string
= s
;
6805 /*******************************************************************
6806 Deep copy a SPOOL_NOTIFY_INFO structure
6807 ******************************************************************/
6808 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6811 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6815 dst
->version
= src
->version
;
6816 dst
->flags
= src
->flags
;
6817 dst
->count
= src
->count
;
6821 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6823 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6826 if (dst
->data
== NULL
) {
6827 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6832 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6839 /*******************************************************************
6841 ********************************************************************/
6843 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6844 uint32 change_low
, uint32 change_high
,
6845 SPOOL_NOTIFY_INFO
*info
)
6850 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6852 q_u
->change_low
=change_low
;
6853 q_u
->change_high
=change_high
;
6858 q_u
->info_ptr
=0x0FF0ADDE;
6860 q_u
->info
.version
=2;
6863 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6865 q_u
->info
.version
= info
->version
;
6866 q_u
->info
.flags
= info
->flags
;
6867 q_u
->info
.count
= info
->count
;
6868 /* pointer field - be careful! */
6869 q_u
->info
.data
= info
->data
;
6872 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6879 /*******************************************************************
6880 Parse a SPOOL_Q_REPLY_RRPCN structure.
6881 ********************************************************************/
6883 BOOL
spoolss_io_q_reply_rrpcn(const char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6885 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6891 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6894 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6897 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6900 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6903 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6906 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6909 if(q_u
->info_ptr
!=0)
6910 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6916 /*******************************************************************
6917 Parse a SPOOL_R_REPLY_RRPCN structure.
6918 ********************************************************************/
6920 BOOL
spoolss_io_r_reply_rrpcn(const char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6922 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6928 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6931 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6937 /*******************************************************************
6939 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6940 ********************************************************************/
6942 BOOL
spoolss_io_q_getprinterdataex(const char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6947 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6952 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6956 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6960 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6964 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6970 /*******************************************************************
6971 * write a structure.
6972 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6973 ********************************************************************/
6975 BOOL
spoolss_io_r_getprinterdataex(const char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6980 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6985 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6987 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6990 if (UNMARSHALLING(ps
) && r_u
->size
) {
6991 r_u
->data
= (unsigned char *)prs_alloc_mem(ps
, r_u
->size
);
6996 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
7002 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7004 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
7010 /*******************************************************************
7012 ********************************************************************/
7014 BOOL
spoolss_io_q_setprinterdataex(const char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7016 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
7021 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7023 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7029 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
7035 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
7038 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
7048 if (UNMARSHALLING(ps
))
7049 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
7050 if(q_u
->data
== NULL
)
7052 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
7060 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
7066 /*******************************************************************
7067 * write a structure.
7068 ********************************************************************/
7070 BOOL
spoolss_io_r_setprinterdataex(const char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7072 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
7077 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7083 /*******************************************************************
7085 ********************************************************************/
7086 BOOL
make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY
*q_u
,
7087 POLICY_HND
*hnd
, const char *key
,
7090 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
7092 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7093 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
7099 /*******************************************************************
7101 ********************************************************************/
7103 BOOL
spoolss_io_q_enumprinterkey(const char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7105 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
7110 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7113 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7119 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7125 /*******************************************************************
7126 * write a structure.
7127 ********************************************************************/
7129 BOOL
spoolss_io_r_enumprinterkey(const char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7131 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
7137 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
7143 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7146 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7152 /*******************************************************************
7154 ********************************************************************/
7156 BOOL
make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY
*q_u
,
7157 POLICY_HND
*hnd
, char *keyname
)
7159 DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
7161 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7162 init_unistr2(&q_u
->keyname
, keyname
, UNI_STR_TERMINATE
);
7167 /*******************************************************************
7169 ********************************************************************/
7171 BOOL
spoolss_io_q_deleteprinterkey(const char *desc
, SPOOL_Q_DELETEPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7173 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterkey");
7178 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7181 if(!smb_io_unistr2("", &q_u
->keyname
, True
, ps
, depth
))
7187 /*******************************************************************
7188 * write a structure.
7189 ********************************************************************/
7191 BOOL
spoolss_io_r_deleteprinterkey(const char *desc
, SPOOL_R_DELETEPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7193 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterkey");
7199 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7206 /*******************************************************************
7208 ********************************************************************/
7210 BOOL
spoolss_io_q_enumprinterdataex(const char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7212 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
7217 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7220 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7226 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7232 /*******************************************************************
7233 ********************************************************************/
7235 static BOOL
spoolss_io_printer_enum_values_ctr(const char *desc
, prs_struct
*ps
,
7236 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
7239 uint32 valuename_offset
,
7242 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
7244 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
7248 * offset data begins at 20 bytes per structure * size_of_array.
7249 * Don't forget the uint32 at the beginning
7252 current_offset
= basic_unit
* ctr
->size_of_array
;
7254 /* first loop to write basic enum_value information */
7256 if (UNMARSHALLING(ps
)) {
7257 ctr
->values
= (PRINTER_ENUM_VALUES
*)prs_alloc_mem(
7258 ps
, ctr
->size_of_array
* sizeof(PRINTER_ENUM_VALUES
));
7263 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7264 valuename_offset
= current_offset
;
7265 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
7268 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
7271 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
7274 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
7276 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
7279 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
7282 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
7283 /* account for 2 byte alignment */
7284 current_offset
+= (current_offset
% 2);
7288 * loop #2 for writing the dynamically size objects; pay
7289 * attention to 2-byte alignment here....
7292 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7294 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
7297 if ( ctr
->values
[i
].data_len
) {
7298 if ( UNMARSHALLING(ps
) ) {
7299 ctr
->values
[i
].data
= (uint8
*)prs_alloc_mem(
7300 ps
, ctr
->values
[i
].data_len
);
7301 if (!ctr
->values
[i
].data
)
7304 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
7308 if ( !prs_align_uint16(ps
) )
7315 /*******************************************************************
7316 * write a structure.
7317 ********************************************************************/
7319 BOOL
spoolss_io_r_enumprinterdataex(const char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7321 uint32 data_offset
, end_offset
;
7322 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
7328 if (!prs_uint32("size", ps
, depth
, &r_u
->ctr
.size
))
7331 data_offset
= prs_offset(ps
);
7333 if (!prs_set_offset(ps
, data_offset
+ r_u
->ctr
.size
))
7339 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7342 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
7345 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7348 r_u
->ctr
.size_of_array
= r_u
->returned
;
7350 end_offset
= prs_offset(ps
);
7352 if (!prs_set_offset(ps
, data_offset
))
7356 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
7359 if (!prs_set_offset(ps
, end_offset
))
7364 /*******************************************************************
7365 * write a structure.
7366 ********************************************************************/
7369 uint32 GetPrintProcessorDirectory(
7371 [in] unistr2 *environment,
7373 [in,out] NEW_BUFFER buffer,
7374 [in] uint32 offered,
7375 [out] uint32 needed,
7376 [out] uint32 returned
7381 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, NEW_BUFFER
*buffer
, uint32 offered
)
7383 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
7385 init_unistr2(&q_u
->name
, name
, UNI_STR_TERMINATE
);
7386 init_unistr2(&q_u
->environment
, environment
, UNI_STR_TERMINATE
);
7390 q_u
->buffer
= buffer
;
7391 q_u
->offered
= offered
;
7396 BOOL
spoolss_io_q_getprintprocessordirectory(const char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
7400 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
7406 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7410 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
7417 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7421 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
7429 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7432 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
7438 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
7444 /*******************************************************************
7445 * write a structure.
7446 ********************************************************************/
7448 BOOL
spoolss_io_r_getprintprocessordirectory(const char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
7450 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
7456 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
7462 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7465 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7471 BOOL
smb_io_printprocessordirectory_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
7473 prs_struct
*ps
=&buffer
->prs
;
7475 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
7478 buffer
->struct_start
=prs_offset(ps
);
7480 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
7486 /*******************************************************************
7488 ********************************************************************/
7490 BOOL
make_spoolss_q_addform(SPOOL_Q_ADDFORM
*q_u
, POLICY_HND
*handle
,
7491 int level
, FORM
*form
)
7493 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7495 q_u
->level2
= level
;
7496 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7501 /*******************************************************************
7503 ********************************************************************/
7505 BOOL
make_spoolss_q_setform(SPOOL_Q_SETFORM
*q_u
, POLICY_HND
*handle
,
7506 int level
, const char *form_name
, FORM
*form
)
7508 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7510 q_u
->level2
= level
;
7511 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7512 init_unistr2(&q_u
->name
, form_name
, UNI_STR_TERMINATE
);
7517 /*******************************************************************
7519 ********************************************************************/
7521 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
,
7524 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7525 init_unistr2(&q_u
->name
, form
, UNI_STR_TERMINATE
);
7529 /*******************************************************************
7531 ********************************************************************/
7533 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7534 const char *formname
, uint32 level
,
7535 NEW_BUFFER
*buffer
, uint32 offered
)
7537 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7539 init_unistr2(&q_u
->formname
, formname
, UNI_STR_TERMINATE
);
7541 q_u
->offered
=offered
;
7546 /*******************************************************************
7548 ********************************************************************/
7550 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7551 uint32 level
, NEW_BUFFER
*buffer
,
7554 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7557 q_u
->offered
=offered
;
7562 /*******************************************************************
7564 ********************************************************************/
7566 BOOL
make_spoolss_q_setjob(SPOOL_Q_SETJOB
*q_u
, POLICY_HND
*handle
,
7567 uint32 jobid
, uint32 level
, uint32 command
)
7569 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7573 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7574 the server side code has it marked as unused. */
7576 q_u
->command
= command
;
7581 /*******************************************************************
7583 ********************************************************************/
7585 BOOL
make_spoolss_q_getjob(SPOOL_Q_GETJOB
*q_u
, POLICY_HND
*handle
,
7586 uint32 jobid
, uint32 level
, NEW_BUFFER
*buffer
,
7589 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7592 q_u
->buffer
= buffer
;
7593 q_u
->offered
= offered
;
7598 /*******************************************************************
7600 ********************************************************************/
7602 BOOL
make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER
*q_u
,
7605 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7610 /*******************************************************************
7612 ********************************************************************/
7614 BOOL
make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER
*q_u
,
7617 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7622 /*******************************************************************
7624 ********************************************************************/
7626 BOOL
make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER
*q_u
,
7627 POLICY_HND
*handle
, uint32 level
,
7628 char *docname
, char *outputfile
,
7631 DOC_INFO_CONTAINER
*ctr
= &q_u
->doc_info_container
;
7633 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7639 ctr
->docinfo
.switch_value
= level
;
7641 ctr
->docinfo
.doc_info_1
.p_docname
= docname
? 1 : 0;
7642 ctr
->docinfo
.doc_info_1
.p_outputfile
= outputfile
? 1 : 0;
7643 ctr
->docinfo
.doc_info_1
.p_datatype
= datatype
? 1 : 0;
7645 init_unistr2(&ctr
->docinfo
.doc_info_1
.docname
, docname
, UNI_STR_TERMINATE
);
7646 init_unistr2(&ctr
->docinfo
.doc_info_1
.outputfile
, outputfile
, UNI_STR_TERMINATE
);
7647 init_unistr2(&ctr
->docinfo
.doc_info_1
.datatype
, datatype
, UNI_STR_TERMINATE
);
7651 /* DOC_INFO_2 is only used by Windows 9x and since it
7652 doesn't do printing over RPC we don't have to worry
7655 DEBUG(3, ("unsupported info level %d\n", level
));
7662 /*******************************************************************
7664 ********************************************************************/
7666 BOOL
make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER
*q_u
,
7669 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7674 /*******************************************************************
7676 ********************************************************************/
7678 BOOL
make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER
*q_u
,
7679 POLICY_HND
*handle
, uint32 data_size
,
7682 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7683 q_u
->buffer_size
= q_u
->buffer_size2
= data_size
;
7684 q_u
->buffer
= (unsigned char *)data
;
7688 /*******************************************************************
7690 ********************************************************************/
7692 BOOL
make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA
*q_u
,
7693 POLICY_HND
*handle
, char *valuename
)
7695 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7696 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
7701 /*******************************************************************
7703 ********************************************************************/
7705 BOOL
make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX
*q_u
,
7706 POLICY_HND
*handle
, char *key
,
7709 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7710 init_unistr2(&q_u
->valuename
, value
, UNI_STR_TERMINATE
);
7711 init_unistr2(&q_u
->keyname
, key
, UNI_STR_TERMINATE
);
7716 /*******************************************************************
7718 ********************************************************************/
7720 BOOL
make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX
*q_u
, POLICY_HND
*handle
,
7721 uint32 flags
, uint32 options
, const char *localmachine
,
7722 uint32 printerlocal
, SPOOL_NOTIFY_OPTION
*option
)
7724 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7727 q_u
->options
= options
;
7729 q_u
->localmachine_ptr
= 1;
7731 init_unistr2(&q_u
->localmachine
, localmachine
, UNI_STR_TERMINATE
);
7733 q_u
->printerlocal
= printerlocal
;
7736 q_u
->option_ptr
= 1;
7738 q_u
->option
= option
;