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 uint32 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
, 32))
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(10, ("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
, strlen(printername
)+1);
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, strlen(datatype));
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
, strlen(clientname
)+1);
941 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
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
, strlen(srv_name
));
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
, strlen(clientname
)+1);
995 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
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
, strlen(server
)+1);
1191 init_unistr2(&q_u
->arch
, arch
, strlen(arch
)+1);
1192 init_unistr2(&q_u
->driver
, driver
, strlen(driver
)+1);
1199 /*******************************************************************
1201 ********************************************************************/
1203 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
1204 const POLICY_HND
*handle
,
1205 char *valuename
, uint32 size
)
1207 if (q_u
== NULL
) return False
;
1209 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1211 q_u
->handle
= *handle
;
1212 init_unistr2(&q_u
->valuename
, valuename
, strlen(valuename
) + 1);
1218 /*******************************************************************
1220 ********************************************************************/
1222 BOOL
make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX
*q_u
,
1223 const POLICY_HND
*handle
,
1224 char *keyname
, char *valuename
, uint32 size
)
1226 if (q_u
== NULL
) return False
;
1228 DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
1230 q_u
->handle
= *handle
;
1231 init_unistr2(&q_u
->valuename
, valuename
, strlen(valuename
) + 1);
1232 init_unistr2(&q_u
->keyname
, keyname
, strlen(keyname
) + 1);
1238 /*******************************************************************
1240 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1241 ********************************************************************/
1243 BOOL
spoolss_io_q_getprinterdata(const char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1248 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1253 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1257 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1261 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1267 /*******************************************************************
1269 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1270 ********************************************************************/
1272 BOOL
spoolss_io_q_deleteprinterdata(const char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1277 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1282 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1286 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1292 /*******************************************************************
1293 * write a structure.
1294 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1295 ********************************************************************/
1297 BOOL
spoolss_io_r_deleteprinterdata(const char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1299 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1301 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1307 /*******************************************************************
1309 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1310 ********************************************************************/
1312 BOOL
spoolss_io_q_deleteprinterdataex(const char *desc
, SPOOL_Q_DELETEPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
1317 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdataex");
1322 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1325 if (!smb_io_unistr2("keyname ", &q_u
->keyname
, True
, ps
, depth
))
1327 if (!smb_io_unistr2("valuename", &q_u
->valuename
, True
, ps
, depth
))
1333 /*******************************************************************
1334 * write a structure.
1335 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1336 ********************************************************************/
1338 BOOL
spoolss_io_r_deleteprinterdataex(const char *desc
, SPOOL_R_DELETEPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
1340 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdataex");
1343 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1349 /*******************************************************************
1350 * write a structure.
1351 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1352 ********************************************************************/
1354 BOOL
spoolss_io_r_getprinterdata(const char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1359 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1364 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1366 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1369 if (UNMARSHALLING(ps
) && r_u
->size
) {
1370 r_u
->data
= prs_alloc_mem(ps
, r_u
->size
);
1375 if (!prs_uint8s( False
, "data", ps
, depth
, r_u
->data
, r_u
->size
))
1381 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1383 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1389 /*******************************************************************
1391 ********************************************************************/
1393 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1395 if (q_u
== NULL
) return False
;
1397 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1399 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1404 /*******************************************************************
1406 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1407 * called from spoolss_abortprinter (cli_spoolss.c)
1408 ********************************************************************/
1410 BOOL
spoolss_io_q_abortprinter(const char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1412 if (q_u
== NULL
) return False
;
1414 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1420 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1426 /*******************************************************************
1427 * write a structure.
1428 * called from spoolss_r_abortprinter (srv_spoolss.c)
1429 ********************************************************************/
1431 BOOL
spoolss_io_r_abortprinter(const char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1433 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1435 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1441 /*******************************************************************
1443 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1444 * called from spoolss_deleteprinter (cli_spoolss.c)
1445 ********************************************************************/
1447 BOOL
spoolss_io_q_deleteprinter(const char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1449 if (q_u
== NULL
) return False
;
1451 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1457 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1463 /*******************************************************************
1464 * write a structure.
1465 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1466 * called from spoolss_deleteprinter (cli_spoolss.c)
1467 ********************************************************************/
1469 BOOL
spoolss_io_r_deleteprinter(const char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1471 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1477 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1479 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1486 /*******************************************************************
1488 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1489 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1490 ********************************************************************/
1492 BOOL
spoolss_io_q_deleteprinterdriver(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1494 if (q_u
== NULL
) return False
;
1496 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1502 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1504 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1506 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1508 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1516 /*******************************************************************
1517 * write a structure.
1518 ********************************************************************/
1519 BOOL
spoolss_io_r_deleteprinterdriver(const char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1521 if (r_u
== NULL
) return False
;
1523 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1529 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1536 /*******************************************************************
1538 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1539 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1540 ********************************************************************/
1542 BOOL
spoolss_io_q_deleteprinterdriverex(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
1544 if (q_u
== NULL
) return False
;
1546 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriverex");
1552 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1554 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1556 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1558 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1564 if(!prs_uint32("delete_flags ", ps
, depth
, &q_u
->delete_flags
))
1566 if(!prs_uint32("version ", ps
, depth
, &q_u
->version
))
1574 /*******************************************************************
1575 * write a structure.
1576 ********************************************************************/
1577 BOOL
spoolss_io_r_deleteprinterdriverex(const char *desc
, SPOOL_R_DELETEPRINTERDRIVEREX
*r_u
, prs_struct
*ps
, int depth
)
1579 if (r_u
== NULL
) return False
;
1581 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriverex");
1587 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1595 /*******************************************************************
1597 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1598 * called from spoolss_closeprinter (cli_spoolss.c)
1599 ********************************************************************/
1601 BOOL
spoolss_io_q_closeprinter(const char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1603 if (q_u
== NULL
) return False
;
1605 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1611 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1617 /*******************************************************************
1618 * write a structure.
1619 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1620 * called from spoolss_closeprinter (cli_spoolss.c)
1621 ********************************************************************/
1623 BOOL
spoolss_io_r_closeprinter(const char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1625 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1631 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1633 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1639 /*******************************************************************
1641 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1642 ********************************************************************/
1644 BOOL
spoolss_io_q_startdocprinter(const char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1646 if (q_u
== NULL
) return False
;
1648 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1654 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1657 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1663 /*******************************************************************
1664 * write a structure.
1665 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1666 ********************************************************************/
1668 BOOL
spoolss_io_r_startdocprinter(const char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1670 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1672 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1674 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1680 /*******************************************************************
1682 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1683 ********************************************************************/
1685 BOOL
spoolss_io_q_enddocprinter(const char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1687 if (q_u
== NULL
) return False
;
1689 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1695 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1701 /*******************************************************************
1702 * write a structure.
1703 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1704 ********************************************************************/
1706 BOOL
spoolss_io_r_enddocprinter(const char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1708 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1710 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1716 /*******************************************************************
1718 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1719 ********************************************************************/
1721 BOOL
spoolss_io_q_startpageprinter(const char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1723 if (q_u
== NULL
) return False
;
1725 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1731 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1737 /*******************************************************************
1738 * write a structure.
1739 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1740 ********************************************************************/
1742 BOOL
spoolss_io_r_startpageprinter(const char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1744 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1746 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1752 /*******************************************************************
1754 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1755 ********************************************************************/
1757 BOOL
spoolss_io_q_endpageprinter(const char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1759 if (q_u
== NULL
) return False
;
1761 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1767 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1773 /*******************************************************************
1774 * write a structure.
1775 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1776 ********************************************************************/
1778 BOOL
spoolss_io_r_endpageprinter(const char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1780 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1782 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1788 /*******************************************************************
1790 * called from spoolss_q_writeprinter (srv_spoolss.c)
1791 ********************************************************************/
1793 BOOL
spoolss_io_q_writeprinter(const char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1795 if (q_u
== NULL
) return False
;
1797 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1803 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1805 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1808 if (q_u
->buffer_size
!=0)
1810 if (UNMARSHALLING(ps
))
1811 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1812 if(q_u
->buffer
== NULL
)
1814 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1819 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1825 /*******************************************************************
1826 * write a structure.
1827 * called from spoolss_r_writeprinter (srv_spoolss.c)
1828 ********************************************************************/
1830 BOOL
spoolss_io_r_writeprinter(const char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1832 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1834 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1836 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1842 /*******************************************************************
1844 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1845 ********************************************************************/
1847 BOOL
spoolss_io_q_rffpcnex(const char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1849 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1855 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1857 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1859 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1861 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1863 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1869 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1872 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1875 if (q_u
->option_ptr
!=0) {
1877 if (UNMARSHALLING(ps
))
1878 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1881 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1888 /*******************************************************************
1889 * write a structure.
1890 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1891 ********************************************************************/
1893 BOOL
spoolss_io_r_rffpcnex(const char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1895 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1898 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1904 /*******************************************************************
1906 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1907 ********************************************************************/
1909 BOOL
spoolss_io_q_rfnpcnex(const char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1911 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1917 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1920 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1923 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1926 if (q_u
->option_ptr
!=0) {
1928 if (UNMARSHALLING(ps
))
1929 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1932 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1939 /*******************************************************************
1940 * write a structure.
1941 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1942 ********************************************************************/
1944 BOOL
spoolss_io_r_rfnpcnex(const char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1946 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1952 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1955 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1960 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1966 /*******************************************************************
1967 * return the length of a uint16 (obvious, but the code is clean)
1968 ********************************************************************/
1970 static uint32
size_of_uint16(uint16
*value
)
1972 return (sizeof(*value
));
1975 /*******************************************************************
1976 * return the length of a uint32 (obvious, but the code is clean)
1977 ********************************************************************/
1979 static uint32
size_of_uint32(uint32
*value
)
1981 return (sizeof(*value
));
1984 /*******************************************************************
1985 * return the length of a NTTIME (obvious, but the code is clean)
1986 ********************************************************************/
1988 static uint32
size_of_nttime(NTTIME
*value
)
1990 return (sizeof(*value
));
1993 /*******************************************************************
1994 * return the length of a UNICODE string in number of char, includes:
1995 * - the leading zero
1996 * - the relative pointer size
1997 ********************************************************************/
1999 static uint32
size_of_relative_string(UNISTR
*string
)
2003 size
=str_len_uni(string
); /* the string length */
2004 size
=size
+1; /* add the trailing zero */
2005 size
=size
*2; /* convert in char */
2006 size
=size
+4; /* add the size of the ptr */
2010 * Do not include alignment as Win2k does not align relative
2011 * strings within a buffer --jerry
2013 /* Ensure size is 4 byte multiple (prs_align is being called...). */
2014 /* size += ((4 - (size & 3)) & 3); */
2020 /*******************************************************************
2021 * return the length of a uint32 (obvious, but the code is clean)
2022 ********************************************************************/
2024 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
2029 return (4+devmode
->size
+devmode
->driverextra
);
2032 /*******************************************************************
2033 * return the length of a uint32 (obvious, but the code is clean)
2034 ********************************************************************/
2036 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
2041 return (sizeof(SYSTEMTIME
) +4);
2044 /*******************************************************************
2045 * write a UNICODE string and its relative pointer.
2046 * used by all the RPC structs passing a buffer
2048 * As I'm a nice guy, I'm forcing myself to explain this code.
2049 * MS did a good job in the overall spoolss code except in some
2050 * functions where they are passing the API buffer directly in the
2051 * RPC request/reply. That's to maintain compatiility at the API level.
2052 * They could have done it the good way the first time.
2054 * So what happen is: the strings are written at the buffer's end,
2055 * in the reverse order of the original structure. Some pointers to
2056 * the strings are also in the buffer. Those are relative to the
2059 * If you don't understand or want to change that function,
2060 * first get in touch with me: jfm@samba.org
2062 ********************************************************************/
2064 static BOOL
smb_io_relstr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
2066 prs_struct
*ps
=&buffer
->prs
;
2068 if (MARSHALLING(ps
)) {
2069 uint32 struct_offset
= prs_offset(ps
);
2070 uint32 relative_offset
;
2072 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
2073 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2077 * Win2k does not align strings in a buffer
2078 * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry
2083 buffer
->string_at_end
= prs_offset(ps
);
2085 /* write the string */
2086 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2089 if(!prs_set_offset(ps
, struct_offset
))
2092 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2093 /* write its offset */
2094 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2100 /* read the offset */
2101 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
2104 if (buffer
->string_at_end
== 0)
2107 old_offset
= prs_offset(ps
);
2108 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
2111 /* read the string */
2112 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2115 if(!prs_set_offset(ps
, old_offset
))
2121 /*******************************************************************
2122 * write a array of UNICODE strings and its relative pointer.
2123 * used by 2 RPC structs
2124 ********************************************************************/
2126 static BOOL
smb_io_relarraystr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
2130 prs_struct
*ps
=&buffer
->prs
;
2132 if (MARSHALLING(ps
)) {
2133 uint32 struct_offset
= prs_offset(ps
);
2134 uint32 relative_offset
;
2141 /* first write the last 0 */
2142 buffer
->string_at_end
-= 2;
2143 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2146 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
2149 while (p
&& (*p
!=0)) {
2153 /* Yes this should be malloc not talloc. Don't change. */
2155 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
2156 if (chaine
.buffer
== NULL
)
2159 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
2161 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
2163 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
2164 SAFE_FREE(chaine
.buffer
);
2168 /* write the string */
2169 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
2170 SAFE_FREE(chaine
.buffer
);
2176 SAFE_FREE(chaine
.buffer
);
2179 if(!prs_set_offset(ps
, struct_offset
))
2182 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2183 /* write its offset */
2184 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2192 uint16
*chaine2
=NULL
;
2195 size_t realloc_size
= 0;
2199 /* read the offset */
2200 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2203 old_offset
= prs_offset(ps
);
2204 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2208 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
))
2211 l_chaine
=str_len_uni(&chaine
);
2213 /* we're going to add two more bytes here in case this
2214 is the last string in the array and we need to add
2215 an extra NULL for termination */
2220 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
2222 /* Yes this should be realloc - it's freed below. JRA */
2224 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
2229 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
2230 l_chaine2
+=l_chaine
+1;
2233 } while(l_chaine
!=0);
2235 /* the end should be bould NULL terminated so add
2236 the second one here */
2239 chaine2
[l_chaine2
] = '\0';
2240 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
2244 if(!prs_set_offset(ps
, old_offset
))
2250 /*******************************************************************
2251 Parse a DEVMODE structure and its relative pointer.
2252 ********************************************************************/
2254 static BOOL
smb_io_relsecdesc(const char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
2256 prs_struct
*ps
= &buffer
->prs
;
2258 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
2261 if (MARSHALLING(ps
)) {
2262 uint32 struct_offset
= prs_offset(ps
);
2263 uint32 relative_offset
;
2266 relative_offset
= 0;
2267 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2272 if (*secdesc
!= NULL
) {
2273 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
2275 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2277 /* write the secdesc */
2278 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2281 if(!prs_set_offset(ps
, struct_offset
))
2285 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2286 /* write its offset */
2288 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2293 /* read the offset */
2294 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2297 old_offset
= prs_offset(ps
);
2298 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2302 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2305 if(!prs_set_offset(ps
, old_offset
))
2311 /*******************************************************************
2312 Parse a DEVMODE structure and its relative pointer.
2313 ********************************************************************/
2315 static BOOL
smb_io_reldevmode(const char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2317 prs_struct
*ps
=&buffer
->prs
;
2319 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2322 if (MARSHALLING(ps
)) {
2323 uint32 struct_offset
= prs_offset(ps
);
2324 uint32 relative_offset
;
2326 if (*devmode
== NULL
) {
2328 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2330 DEBUG(8, ("boing, the devmode was NULL\n"));
2335 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2337 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2340 /* write the DEVMODE */
2341 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2344 if(!prs_set_offset(ps
, struct_offset
))
2347 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2348 /* write its offset */
2349 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2355 /* read the offset */
2356 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2358 if (buffer
->string_at_end
== 0) {
2363 old_offset
= prs_offset(ps
);
2364 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2367 /* read the string */
2368 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2370 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2373 if(!prs_set_offset(ps
, old_offset
))
2379 /*******************************************************************
2380 Parse a PRINTER_INFO_0 structure.
2381 ********************************************************************/
2383 BOOL
smb_io_printer_info_0(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2385 prs_struct
*ps
=&buffer
->prs
;
2387 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2390 buffer
->struct_start
=prs_offset(ps
);
2392 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2394 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2397 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2399 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2401 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2404 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2406 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2408 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2410 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2412 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2414 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2416 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2418 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2421 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2423 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2426 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2428 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2430 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2432 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2434 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2436 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2438 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2440 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2442 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2444 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2446 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2448 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2450 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2452 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2454 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2456 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2458 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2460 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2462 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2464 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2466 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2468 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2470 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2472 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2474 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2480 /*******************************************************************
2481 Parse a PRINTER_INFO_1 structure.
2482 ********************************************************************/
2484 BOOL
smb_io_printer_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2486 prs_struct
*ps
=&buffer
->prs
;
2488 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2491 buffer
->struct_start
=prs_offset(ps
);
2493 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2495 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2497 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2499 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2505 /*******************************************************************
2506 Parse a PRINTER_INFO_2 structure.
2507 ********************************************************************/
2509 BOOL
smb_io_printer_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2511 prs_struct
*ps
=&buffer
->prs
;
2512 uint32 dm_offset
, sd_offset
, current_offset
;
2513 uint32 dummy_value
= 0, has_secdesc
= 0;
2515 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2518 buffer
->struct_start
=prs_offset(ps
);
2520 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2522 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2524 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2526 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2528 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2530 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2532 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2535 /* save current offset and wind forwared by a uint32 */
2536 dm_offset
= prs_offset(ps
);
2537 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
2540 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2542 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2544 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2546 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2549 /* save current offset for the sec_desc */
2550 sd_offset
= prs_offset(ps
);
2551 if (!prs_uint32("sec_desc", ps
, depth
, &has_secdesc
))
2555 /* save current location so we can pick back up here */
2556 current_offset
= prs_offset(ps
);
2558 /* parse the devmode */
2559 if (!prs_set_offset(ps
, dm_offset
))
2561 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2564 /* parse the sec_desc */
2566 if (!prs_set_offset(ps
, sd_offset
))
2568 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2572 /* pick up where we left off */
2573 if (!prs_set_offset(ps
, current_offset
))
2576 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2578 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2580 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2582 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2584 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2586 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2588 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2590 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2596 /*******************************************************************
2597 Parse a PRINTER_INFO_3 structure.
2598 ********************************************************************/
2600 BOOL
smb_io_printer_info_3(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2602 prs_struct
*ps
=&buffer
->prs
;
2604 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2607 buffer
->struct_start
=prs_offset(ps
);
2609 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2611 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2617 /*******************************************************************
2618 Parse a PRINTER_INFO_4 structure.
2619 ********************************************************************/
2621 BOOL
smb_io_printer_info_4(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2623 prs_struct
*ps
=&buffer
->prs
;
2625 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2628 buffer
->struct_start
=prs_offset(ps
);
2630 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2632 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2634 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2639 /*******************************************************************
2640 Parse a PRINTER_INFO_5 structure.
2641 ********************************************************************/
2643 BOOL
smb_io_printer_info_5(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2645 prs_struct
*ps
=&buffer
->prs
;
2647 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2650 buffer
->struct_start
=prs_offset(ps
);
2652 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2654 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2656 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2658 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2660 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2665 /*******************************************************************
2666 Parse a PRINTER_INFO_7 structure.
2667 ********************************************************************/
2669 BOOL
smb_io_printer_info_7(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_7
*info
, int depth
)
2671 prs_struct
*ps
=&buffer
->prs
;
2673 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_7");
2676 buffer
->struct_start
=prs_offset(ps
);
2678 if (!smb_io_relstr("guid", buffer
, depth
, &info
->guid
))
2680 if (!prs_uint32("action", ps
, depth
, &info
->action
))
2685 /*******************************************************************
2686 Parse a PORT_INFO_1 structure.
2687 ********************************************************************/
2689 BOOL
smb_io_port_info_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2691 prs_struct
*ps
=&buffer
->prs
;
2693 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2696 buffer
->struct_start
=prs_offset(ps
);
2698 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2704 /*******************************************************************
2705 Parse a PORT_INFO_2 structure.
2706 ********************************************************************/
2708 BOOL
smb_io_port_info_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2710 prs_struct
*ps
=&buffer
->prs
;
2712 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2715 buffer
->struct_start
=prs_offset(ps
);
2717 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2719 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2721 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2723 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2725 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2731 /*******************************************************************
2732 Parse a DRIVER_INFO_1 structure.
2733 ********************************************************************/
2735 BOOL
smb_io_printer_driver_info_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2737 prs_struct
*ps
=&buffer
->prs
;
2739 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2742 buffer
->struct_start
=prs_offset(ps
);
2744 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2750 /*******************************************************************
2751 Parse a DRIVER_INFO_2 structure.
2752 ********************************************************************/
2754 BOOL
smb_io_printer_driver_info_2(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2756 prs_struct
*ps
=&buffer
->prs
;
2758 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2761 buffer
->struct_start
=prs_offset(ps
);
2763 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2765 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2767 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2769 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2771 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2773 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2779 /*******************************************************************
2780 Parse a DRIVER_INFO_3 structure.
2781 ********************************************************************/
2783 BOOL
smb_io_printer_driver_info_3(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2785 prs_struct
*ps
=&buffer
->prs
;
2787 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2790 buffer
->struct_start
=prs_offset(ps
);
2792 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2794 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2796 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2798 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2800 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2802 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2804 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2807 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2810 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2812 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2818 /*******************************************************************
2819 Parse a DRIVER_INFO_6 structure.
2820 ********************************************************************/
2822 BOOL
smb_io_printer_driver_info_6(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2824 prs_struct
*ps
=&buffer
->prs
;
2826 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2829 buffer
->struct_start
=prs_offset(ps
);
2831 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2833 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2835 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2837 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2839 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2841 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2843 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2846 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2849 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2851 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2854 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2857 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2859 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2862 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2865 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2868 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2871 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2873 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2875 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2877 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2883 /*******************************************************************
2884 Parse a JOB_INFO_1 structure.
2885 ********************************************************************/
2887 BOOL
smb_io_job_info_1(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2889 prs_struct
*ps
=&buffer
->prs
;
2891 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2894 buffer
->struct_start
=prs_offset(ps
);
2896 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2898 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2900 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2902 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2904 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2906 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2908 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2910 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2912 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2914 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2916 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2918 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2920 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2926 /*******************************************************************
2927 Parse a JOB_INFO_2 structure.
2928 ********************************************************************/
2930 BOOL
smb_io_job_info_2(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2933 prs_struct
*ps
=&buffer
->prs
;
2935 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2938 buffer
->struct_start
=prs_offset(ps
);
2940 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2942 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2944 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2946 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2948 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2950 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2952 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2955 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2957 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2959 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2961 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2963 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2966 /* SEC_DESC sec_desc;*/
2967 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2970 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2972 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2974 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2976 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2978 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2980 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2982 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2984 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2986 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2988 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2994 /*******************************************************************
2995 ********************************************************************/
2997 BOOL
smb_io_form_1(const char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2999 prs_struct
*ps
=&buffer
->prs
;
3001 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
3004 buffer
->struct_start
=prs_offset(ps
);
3006 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
3009 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3012 if (!prs_uint32("width", ps
, depth
, &info
->width
))
3014 if (!prs_uint32("length", ps
, depth
, &info
->length
))
3016 if (!prs_uint32("left", ps
, depth
, &info
->left
))
3018 if (!prs_uint32("top", ps
, depth
, &info
->top
))
3020 if (!prs_uint32("right", ps
, depth
, &info
->right
))
3022 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
3028 /*******************************************************************
3029 Read/write a BUFFER struct.
3030 ********************************************************************/
3032 static BOOL
spoolss_io_buffer(const char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
3034 NEW_BUFFER
*buffer
= *pp_buffer
;
3036 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
3039 if (UNMARSHALLING(ps
))
3040 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
3045 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
3049 if (UNMARSHALLING(ps
)) {
3051 buffer
->string_at_end
=0;
3053 if (buffer
->ptr
==0) {
3055 * JRA. I'm not sure if the data in here is in big-endian format if
3056 * the client is big-endian. Leave as default (little endian) for now.
3059 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
3064 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3068 * JRA. I'm not sure if the data in here is in big-endian format if
3069 * the client is big-endian. Leave as default (little endian) for now.
3072 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
3075 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
3078 if (!prs_set_offset(&buffer
->prs
, 0))
3081 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
3084 buffer
->string_at_end
=buffer
->size
;
3092 if (buffer
->ptr
==0) {
3093 /* We have finished with the data in buffer->prs - free it. */
3094 prs_mem_free(&buffer
->prs
);
3098 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3101 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
3107 /* We have finished with the data in buffer->prs - free it. */
3108 prs_mem_free(&buffer
->prs
);
3114 /*******************************************************************
3115 move a BUFFER from the query to the reply.
3116 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
3117 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
3118 Clears the memory to zero also.
3119 ********************************************************************/
3121 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
3123 prs_switch_type(&src
->prs
, MARSHALL
);
3124 if(!prs_set_offset(&src
->prs
, 0))
3126 prs_force_dynamic(&src
->prs
);
3127 prs_mem_clear(&src
->prs
);
3131 /*******************************************************************
3132 Get the size of a BUFFER struct.
3133 ********************************************************************/
3135 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
3137 return (buffer
->size
);
3140 /*******************************************************************
3141 Parse a DRIVER_DIRECTORY_1 structure.
3142 ********************************************************************/
3144 BOOL
smb_io_driverdir_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
3146 prs_struct
*ps
=&buffer
->prs
;
3148 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
3151 buffer
->struct_start
=prs_offset(ps
);
3153 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
3159 /*******************************************************************
3160 Parse a PORT_INFO_1 structure.
3161 ********************************************************************/
3163 BOOL
smb_io_port_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
3165 prs_struct
*ps
=&buffer
->prs
;
3167 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
3170 buffer
->struct_start
=prs_offset(ps
);
3172 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3178 /*******************************************************************
3179 Parse a PORT_INFO_2 structure.
3180 ********************************************************************/
3182 BOOL
smb_io_port_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
3184 prs_struct
*ps
=&buffer
->prs
;
3186 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
3189 buffer
->struct_start
=prs_offset(ps
);
3191 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3193 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
3195 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
3197 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
3199 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
3205 /*******************************************************************
3206 ********************************************************************/
3208 BOOL
smb_io_printprocessor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
3210 prs_struct
*ps
=&buffer
->prs
;
3212 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
3215 buffer
->struct_start
=prs_offset(ps
);
3217 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3223 /*******************************************************************
3224 ********************************************************************/
3226 BOOL
smb_io_printprocdatatype_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
3228 prs_struct
*ps
=&buffer
->prs
;
3230 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
3233 buffer
->struct_start
=prs_offset(ps
);
3235 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3241 /*******************************************************************
3242 ********************************************************************/
3244 BOOL
smb_io_printmonitor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
3246 prs_struct
*ps
=&buffer
->prs
;
3248 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
3251 buffer
->struct_start
=prs_offset(ps
);
3253 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3259 /*******************************************************************
3260 ********************************************************************/
3262 BOOL
smb_io_printmonitor_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
3264 prs_struct
*ps
=&buffer
->prs
;
3266 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
3269 buffer
->struct_start
=prs_offset(ps
);
3271 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3273 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
3275 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
3281 /*******************************************************************
3282 return the size required by a struct in the stream
3283 ********************************************************************/
3285 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
3289 size
+=size_of_relative_string( &info
->printername
);
3290 size
+=size_of_relative_string( &info
->servername
);
3292 size
+=size_of_uint32( &info
->cjobs
);
3293 size
+=size_of_uint32( &info
->total_jobs
);
3294 size
+=size_of_uint32( &info
->total_bytes
);
3296 size
+=size_of_uint16( &info
->year
);
3297 size
+=size_of_uint16( &info
->month
);
3298 size
+=size_of_uint16( &info
->dayofweek
);
3299 size
+=size_of_uint16( &info
->day
);
3300 size
+=size_of_uint16( &info
->hour
);
3301 size
+=size_of_uint16( &info
->minute
);
3302 size
+=size_of_uint16( &info
->second
);
3303 size
+=size_of_uint16( &info
->milliseconds
);
3305 size
+=size_of_uint32( &info
->global_counter
);
3306 size
+=size_of_uint32( &info
->total_pages
);
3308 size
+=size_of_uint16( &info
->major_version
);
3309 size
+=size_of_uint16( &info
->build_version
);
3311 size
+=size_of_uint32( &info
->unknown7
);
3312 size
+=size_of_uint32( &info
->unknown8
);
3313 size
+=size_of_uint32( &info
->unknown9
);
3314 size
+=size_of_uint32( &info
->session_counter
);
3315 size
+=size_of_uint32( &info
->unknown11
);
3316 size
+=size_of_uint32( &info
->printer_errors
);
3317 size
+=size_of_uint32( &info
->unknown13
);
3318 size
+=size_of_uint32( &info
->unknown14
);
3319 size
+=size_of_uint32( &info
->unknown15
);
3320 size
+=size_of_uint32( &info
->unknown16
);
3321 size
+=size_of_uint32( &info
->change_id
);
3322 size
+=size_of_uint32( &info
->unknown18
);
3323 size
+=size_of_uint32( &info
->status
);
3324 size
+=size_of_uint32( &info
->unknown20
);
3325 size
+=size_of_uint32( &info
->c_setprinter
);
3327 size
+=size_of_uint16( &info
->unknown22
);
3328 size
+=size_of_uint16( &info
->unknown23
);
3329 size
+=size_of_uint16( &info
->unknown24
);
3330 size
+=size_of_uint16( &info
->unknown25
);
3331 size
+=size_of_uint16( &info
->unknown26
);
3332 size
+=size_of_uint16( &info
->unknown27
);
3333 size
+=size_of_uint16( &info
->unknown28
);
3334 size
+=size_of_uint16( &info
->unknown29
);
3339 /*******************************************************************
3340 return the size required by a struct in the stream
3341 ********************************************************************/
3343 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3347 size
+=size_of_uint32( &info
->flags
);
3348 size
+=size_of_relative_string( &info
->description
);
3349 size
+=size_of_relative_string( &info
->name
);
3350 size
+=size_of_relative_string( &info
->comment
);
3355 /*******************************************************************
3356 return the size required by a struct in the stream
3357 ********************************************************************/
3359 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3365 size
+= sec_desc_size( info
->secdesc
);
3367 size
+=size_of_device_mode( info
->devmode
);
3369 size
+=size_of_relative_string( &info
->servername
);
3370 size
+=size_of_relative_string( &info
->printername
);
3371 size
+=size_of_relative_string( &info
->sharename
);
3372 size
+=size_of_relative_string( &info
->portname
);
3373 size
+=size_of_relative_string( &info
->drivername
);
3374 size
+=size_of_relative_string( &info
->comment
);
3375 size
+=size_of_relative_string( &info
->location
);
3377 size
+=size_of_relative_string( &info
->sepfile
);
3378 size
+=size_of_relative_string( &info
->printprocessor
);
3379 size
+=size_of_relative_string( &info
->datatype
);
3380 size
+=size_of_relative_string( &info
->parameters
);
3382 size
+=size_of_uint32( &info
->attributes
);
3383 size
+=size_of_uint32( &info
->priority
);
3384 size
+=size_of_uint32( &info
->defaultpriority
);
3385 size
+=size_of_uint32( &info
->starttime
);
3386 size
+=size_of_uint32( &info
->untiltime
);
3387 size
+=size_of_uint32( &info
->status
);
3388 size
+=size_of_uint32( &info
->cjobs
);
3389 size
+=size_of_uint32( &info
->averageppm
);
3392 * add any adjustments for alignment. This is
3393 * not optimal since we could be calling this
3394 * function from a loop (e.g. enumprinters), but
3395 * it is easier to maintain the calculation here and
3396 * not place the burden on the caller to remember. --jerry
3398 if ((size
% 4) != 0)
3399 size
+= 4 - (size
% 4);
3404 /*******************************************************************
3405 return the size required by a struct in the stream
3406 ********************************************************************/
3408 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3412 size
+=size_of_relative_string( &info
->printername
);
3413 size
+=size_of_relative_string( &info
->servername
);
3415 size
+=size_of_uint32( &info
->attributes
);
3419 /*******************************************************************
3420 return the size required by a struct in the stream
3421 ********************************************************************/
3423 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3427 size
+=size_of_relative_string( &info
->printername
);
3428 size
+=size_of_relative_string( &info
->portname
);
3430 size
+=size_of_uint32( &info
->attributes
);
3431 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3432 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3437 /*******************************************************************
3438 return the size required by a struct in the stream
3439 ********************************************************************/
3441 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3443 /* The 4 is for the self relative pointer.. */
3444 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3445 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3448 /*******************************************************************
3449 return the size required by a struct in the stream
3450 ********************************************************************/
3452 uint32
spoolss_size_printer_info_7(PRINTER_INFO_7
*info
)
3456 size
+=size_of_relative_string( &info
->guid
);
3457 size
+=size_of_uint32( &info
->action
);
3461 /*******************************************************************
3462 return the size required by a struct in the stream
3463 ********************************************************************/
3465 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3468 size
+=size_of_relative_string( &info
->name
);
3473 /*******************************************************************
3474 return the size required by a struct in the stream
3475 ********************************************************************/
3477 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3480 size
+=size_of_uint32( &info
->version
);
3481 size
+=size_of_relative_string( &info
->name
);
3482 size
+=size_of_relative_string( &info
->architecture
);
3483 size
+=size_of_relative_string( &info
->driverpath
);
3484 size
+=size_of_relative_string( &info
->datafile
);
3485 size
+=size_of_relative_string( &info
->configfile
);
3490 /*******************************************************************
3491 return the size required by a string array.
3492 ********************************************************************/
3494 uint32
spoolss_size_string_array(uint16
*string
)
3499 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3501 i
=i
+2; /* to count all chars including the leading zero */
3502 i
=2*i
; /* because we need the value in bytes */
3503 i
=i
+4; /* the offset pointer size */
3508 /*******************************************************************
3509 return the size required by a struct in the stream
3510 ********************************************************************/
3512 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3516 size
+=size_of_uint32( &info
->version
);
3517 size
+=size_of_relative_string( &info
->name
);
3518 size
+=size_of_relative_string( &info
->architecture
);
3519 size
+=size_of_relative_string( &info
->driverpath
);
3520 size
+=size_of_relative_string( &info
->datafile
);
3521 size
+=size_of_relative_string( &info
->configfile
);
3522 size
+=size_of_relative_string( &info
->helpfile
);
3523 size
+=size_of_relative_string( &info
->monitorname
);
3524 size
+=size_of_relative_string( &info
->defaultdatatype
);
3526 size
+=spoolss_size_string_array(info
->dependentfiles
);
3531 /*******************************************************************
3532 return the size required by a struct in the stream
3533 ********************************************************************/
3535 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3539 size
+=size_of_uint32( &info
->version
);
3540 size
+=size_of_relative_string( &info
->name
);
3541 size
+=size_of_relative_string( &info
->architecture
);
3542 size
+=size_of_relative_string( &info
->driverpath
);
3543 size
+=size_of_relative_string( &info
->datafile
);
3544 size
+=size_of_relative_string( &info
->configfile
);
3545 size
+=size_of_relative_string( &info
->helpfile
);
3547 size
+=spoolss_size_string_array(info
->dependentfiles
);
3549 size
+=size_of_relative_string( &info
->monitorname
);
3550 size
+=size_of_relative_string( &info
->defaultdatatype
);
3552 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3554 size
+=size_of_nttime(&info
->driver_date
);
3555 size
+=size_of_uint32( &info
->padding
);
3556 size
+=size_of_uint32( &info
->driver_version_low
);
3557 size
+=size_of_uint32( &info
->driver_version_high
);
3558 size
+=size_of_relative_string( &info
->mfgname
);
3559 size
+=size_of_relative_string( &info
->oem_url
);
3560 size
+=size_of_relative_string( &info
->hardware_id
);
3561 size
+=size_of_relative_string( &info
->provider
);
3566 /*******************************************************************
3567 return the size required by a struct in the stream
3568 ********************************************************************/
3570 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3573 size
+=size_of_uint32( &info
->jobid
);
3574 size
+=size_of_relative_string( &info
->printername
);
3575 size
+=size_of_relative_string( &info
->machinename
);
3576 size
+=size_of_relative_string( &info
->username
);
3577 size
+=size_of_relative_string( &info
->document
);
3578 size
+=size_of_relative_string( &info
->datatype
);
3579 size
+=size_of_relative_string( &info
->text_status
);
3580 size
+=size_of_uint32( &info
->status
);
3581 size
+=size_of_uint32( &info
->priority
);
3582 size
+=size_of_uint32( &info
->position
);
3583 size
+=size_of_uint32( &info
->totalpages
);
3584 size
+=size_of_uint32( &info
->pagesprinted
);
3585 size
+=size_of_systemtime( &info
->submitted
);
3590 /*******************************************************************
3591 return the size required by a struct in the stream
3592 ********************************************************************/
3594 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3598 size
+=4; /* size of sec desc ptr */
3600 size
+=size_of_uint32( &info
->jobid
);
3601 size
+=size_of_relative_string( &info
->printername
);
3602 size
+=size_of_relative_string( &info
->machinename
);
3603 size
+=size_of_relative_string( &info
->username
);
3604 size
+=size_of_relative_string( &info
->document
);
3605 size
+=size_of_relative_string( &info
->notifyname
);
3606 size
+=size_of_relative_string( &info
->datatype
);
3607 size
+=size_of_relative_string( &info
->printprocessor
);
3608 size
+=size_of_relative_string( &info
->parameters
);
3609 size
+=size_of_relative_string( &info
->drivername
);
3610 size
+=size_of_device_mode( info
->devmode
);
3611 size
+=size_of_relative_string( &info
->text_status
);
3612 /* SEC_DESC sec_desc;*/
3613 size
+=size_of_uint32( &info
->status
);
3614 size
+=size_of_uint32( &info
->priority
);
3615 size
+=size_of_uint32( &info
->position
);
3616 size
+=size_of_uint32( &info
->starttime
);
3617 size
+=size_of_uint32( &info
->untiltime
);
3618 size
+=size_of_uint32( &info
->totalpages
);
3619 size
+=size_of_uint32( &info
->size
);
3620 size
+=size_of_systemtime( &info
->submitted
);
3621 size
+=size_of_uint32( &info
->timeelapsed
);
3622 size
+=size_of_uint32( &info
->pagesprinted
);
3627 /*******************************************************************
3628 return the size required by a struct in the stream
3629 ********************************************************************/
3631 uint32
spoolss_size_form_1(FORM_1
*info
)
3635 size
+=size_of_uint32( &info
->flag
);
3636 size
+=size_of_relative_string( &info
->name
);
3637 size
+=size_of_uint32( &info
->width
);
3638 size
+=size_of_uint32( &info
->length
);
3639 size
+=size_of_uint32( &info
->left
);
3640 size
+=size_of_uint32( &info
->top
);
3641 size
+=size_of_uint32( &info
->right
);
3642 size
+=size_of_uint32( &info
->bottom
);
3647 /*******************************************************************
3648 return the size required by a struct in the stream
3649 ********************************************************************/
3651 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3655 size
+=size_of_relative_string( &info
->port_name
);
3660 /*******************************************************************
3661 return the size required by a struct in the stream
3662 ********************************************************************/
3664 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3668 size
=str_len_uni(&info
->name
); /* the string length */
3669 size
=size
+1; /* add the leading zero */
3670 size
=size
*2; /* convert in char */
3675 /*******************************************************************
3676 return the size required by a struct in the stream
3677 ********************************************************************/
3679 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3683 size
=str_len_uni(&info
->name
); /* the string length */
3684 size
=size
+1; /* add the leading zero */
3685 size
=size
*2; /* convert in char */
3690 /*******************************************************************
3691 return the size required by a struct in the stream
3692 ********************************************************************/
3694 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3698 size
+=size_of_relative_string( &info
->port_name
);
3699 size
+=size_of_relative_string( &info
->monitor_name
);
3700 size
+=size_of_relative_string( &info
->description
);
3702 size
+=size_of_uint32( &info
->port_type
);
3703 size
+=size_of_uint32( &info
->reserved
);
3708 /*******************************************************************
3709 return the size required by a struct in the stream
3710 ********************************************************************/
3712 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3715 size
+=size_of_relative_string( &info
->name
);
3720 /*******************************************************************
3721 return the size required by a struct in the stream
3722 ********************************************************************/
3724 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3727 size
+=size_of_relative_string( &info
->name
);
3732 /*******************************************************************
3733 return the size required by a struct in the stream
3734 ********************************************************************/
3735 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3742 /* uint32(offset) + uint32(length) + length) */
3743 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3744 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
+ (p
->data_len
%2) ;
3746 size
+= size_of_uint32(&p
->type
);
3751 /*******************************************************************
3752 return the size required by a struct in the stream
3753 ********************************************************************/
3755 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3758 size
+=size_of_relative_string( &info
->name
);
3763 /*******************************************************************
3764 return the size required by a struct in the stream
3765 ********************************************************************/
3767 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3770 size
+=size_of_relative_string( &info
->name
);
3771 size
+=size_of_relative_string( &info
->environment
);
3772 size
+=size_of_relative_string( &info
->dll_name
);
3777 /*******************************************************************
3779 ********************************************************************/
3781 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3782 const POLICY_HND
*hnd
,
3783 const fstring architecture
,
3784 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3785 NEW_BUFFER
*buffer
, uint32 offered
)
3790 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3792 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3795 q_u
->clientmajorversion
=clientmajor
;
3796 q_u
->clientminorversion
=clientminor
;
3799 q_u
->offered
=offered
;
3804 /*******************************************************************
3806 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3807 ********************************************************************/
3809 BOOL
spoolss_io_q_getprinterdriver2(const char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3811 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3817 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3819 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3821 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3826 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3829 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3835 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3838 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3840 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3846 /*******************************************************************
3848 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3849 ********************************************************************/
3851 BOOL
spoolss_io_r_getprinterdriver2(const char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3853 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3859 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3864 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3866 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3868 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3870 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3876 /*******************************************************************
3878 ********************************************************************/
3880 BOOL
make_spoolss_q_enumprinters(
3881 SPOOL_Q_ENUMPRINTERS
*q_u
,
3891 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3892 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3896 q_u
->offered
=offered
;
3901 /*******************************************************************
3903 ********************************************************************/
3905 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3906 fstring servername
, uint32 level
,
3907 NEW_BUFFER
*buffer
, uint32 offered
)
3909 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3910 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3914 q_u
->offered
=offered
;
3919 /*******************************************************************
3921 * called from spoolss_enumprinters (srv_spoolss.c)
3922 ********************************************************************/
3924 BOOL
spoolss_io_q_enumprinters(const char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3926 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3932 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3934 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3937 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3942 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3945 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3950 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3956 /*******************************************************************
3957 Parse a SPOOL_R_ENUMPRINTERS structure.
3958 ********************************************************************/
3960 BOOL
spoolss_io_r_enumprinters(const char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3962 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3968 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3974 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3977 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3980 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3986 /*******************************************************************
3987 * write a structure.
3988 * called from spoolss_r_enum_printers (srv_spoolss.c)
3990 ********************************************************************/
3992 BOOL
spoolss_io_r_getprinter(const char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3994 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
4000 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4006 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4009 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4015 /*******************************************************************
4017 * called from spoolss_getprinter (srv_spoolss.c)
4018 ********************************************************************/
4020 BOOL
spoolss_io_q_getprinter(const char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4022 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
4028 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4030 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4033 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4038 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4044 /*******************************************************************
4046 ********************************************************************/
4048 BOOL
make_spoolss_q_getprinter(
4049 TALLOC_CTX
*mem_ctx
,
4050 SPOOL_Q_GETPRINTER
*q_u
,
4051 const POLICY_HND
*hnd
,
4061 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4065 q_u
->offered
=offered
;
4070 /*******************************************************************
4072 ********************************************************************/
4073 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
4074 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
4078 DEVICEMODE
*devmode
;
4083 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4086 q_u
->info
.level
= level
;
4087 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
4090 /* There's no such thing as a setprinter level 1 */
4093 secdesc
= info
->printers_2
->secdesc
;
4094 devmode
= info
->printers_2
->devmode
;
4096 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
4097 #if 1 /* JERRY TEST */
4098 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
4099 if (!q_u
->secdesc_ctr
)
4101 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
4102 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4103 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4104 q_u
->secdesc_ctr
->sec
= secdesc
;
4106 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
4107 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
4108 q_u
->devmode_ctr
.devmode
= devmode
;
4110 q_u
->secdesc_ctr
= NULL
;
4112 q_u
->devmode_ctr
.devmode_ptr
= 0;
4113 q_u
->devmode_ctr
.size
= 0;
4114 q_u
->devmode_ctr
.devmode
= NULL
;
4118 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
4123 q_u
->command
= command
;
4129 /*******************************************************************
4130 ********************************************************************/
4132 BOOL
spoolss_io_r_setprinter(const char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
4134 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
4140 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4146 /*******************************************************************
4147 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
4148 ********************************************************************/
4150 BOOL
spoolss_io_q_setprinter(const char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4152 uint32 ptr_sec_desc
= 0;
4154 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
4160 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
4162 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4165 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4168 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4178 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4183 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4189 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4194 /* Parse a NULL security descriptor. This should really
4195 happen inside the sec_io_desc_buf() function. */
4197 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4198 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4200 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
4204 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4210 /*******************************************************************
4211 ********************************************************************/
4213 BOOL
spoolss_io_r_fcpn(const char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
4215 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
4221 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4227 /*******************************************************************
4228 ********************************************************************/
4230 BOOL
spoolss_io_q_fcpn(const char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
4233 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
4239 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4246 /*******************************************************************
4247 ********************************************************************/
4249 BOOL
spoolss_io_r_addjob(const char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
4251 prs_debug(ps
, depth
, desc
, "");
4257 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4263 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4266 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4272 /*******************************************************************
4273 ********************************************************************/
4275 BOOL
spoolss_io_q_addjob(const char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
4277 prs_debug(ps
, depth
, desc
, "");
4283 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4285 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4288 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4294 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4300 /*******************************************************************
4301 ********************************************************************/
4303 BOOL
spoolss_io_r_enumjobs(const char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
4305 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
4311 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4317 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4320 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4323 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4329 /*******************************************************************
4330 ********************************************************************/
4332 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4343 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4344 q_u
->firstjob
= firstjob
;
4345 q_u
->numofjobs
= numofjobs
;
4347 q_u
->buffer
= buffer
;
4348 q_u
->offered
= offered
;
4352 /*******************************************************************
4353 ********************************************************************/
4355 BOOL
spoolss_io_q_enumjobs(const char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4357 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4363 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4366 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4368 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
4370 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4373 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4379 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4385 /*******************************************************************
4386 ********************************************************************/
4388 BOOL
spoolss_io_r_schedulejob(const char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4390 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4396 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4402 /*******************************************************************
4403 ********************************************************************/
4405 BOOL
spoolss_io_q_schedulejob(const char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4407 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4413 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4415 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4421 /*******************************************************************
4422 ********************************************************************/
4424 BOOL
spoolss_io_r_setjob(const char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4426 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4432 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4438 /*******************************************************************
4439 ********************************************************************/
4441 BOOL
spoolss_io_q_setjob(const char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4443 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4449 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4451 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4454 * level is usually 0. If (level!=0) then I'm in trouble !
4455 * I will try to generate setjob command with level!=0, one day.
4457 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4459 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4465 /*******************************************************************
4466 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4467 ********************************************************************/
4469 BOOL
spoolss_io_r_enumprinterdrivers(const char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4471 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4477 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4483 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4486 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4489 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4495 /*******************************************************************
4497 ********************************************************************/
4499 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4501 const char *environment
,
4503 NEW_BUFFER
*buffer
, uint32 offered
)
4505 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4506 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4510 q_u
->offered
=offered
;
4515 /*******************************************************************
4516 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4517 ********************************************************************/
4519 BOOL
spoolss_io_q_enumprinterdrivers(const char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4522 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4528 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4530 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4535 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4537 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4542 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4545 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4551 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4557 /*******************************************************************
4558 ********************************************************************/
4560 BOOL
spoolss_io_q_enumforms(const char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4563 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4568 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4570 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4573 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4578 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4584 /*******************************************************************
4585 ********************************************************************/
4587 BOOL
spoolss_io_r_enumforms(const char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4589 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4595 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4601 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4604 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4607 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4613 /*******************************************************************
4614 ********************************************************************/
4616 BOOL
spoolss_io_q_getform(const char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4619 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4624 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4626 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4632 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4635 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4640 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4646 /*******************************************************************
4647 ********************************************************************/
4649 BOOL
spoolss_io_r_getform(const char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4651 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4657 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4663 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4666 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4672 /*******************************************************************
4673 Parse a SPOOL_R_ENUMPORTS structure.
4674 ********************************************************************/
4676 BOOL
spoolss_io_r_enumports(const char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4678 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4684 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4690 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4693 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4696 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4702 /*******************************************************************
4703 ********************************************************************/
4705 BOOL
spoolss_io_q_enumports(const char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4707 prs_debug(ps
, depth
, desc
, "");
4713 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4715 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4720 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4723 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4728 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4734 /*******************************************************************
4735 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4736 ********************************************************************/
4738 BOOL
spool_io_printer_info_level_1(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4740 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4746 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4748 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4750 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4752 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4755 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4757 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4759 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4765 /*******************************************************************
4766 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4767 ********************************************************************/
4769 BOOL
spool_io_printer_info_level_3(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4771 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4777 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4783 /*******************************************************************
4784 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4785 ********************************************************************/
4787 BOOL
spool_io_printer_info_level_2(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4789 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4795 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4797 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4799 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4801 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4804 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4806 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4808 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4810 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4812 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4814 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4816 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4818 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4820 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4823 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4825 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4827 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4829 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4831 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4833 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4835 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4837 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4840 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4842 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4844 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4846 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4848 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4850 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4852 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4854 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4856 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4858 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4860 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4866 BOOL
spool_io_printer_info_level_7(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_7
*il
, prs_struct
*ps
, int depth
)
4868 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_7");
4874 if(!prs_uint32("guid_ptr", ps
, depth
, &il
->guid_ptr
))
4876 if(!prs_uint32("action", ps
, depth
, &il
->action
))
4879 if(!smb_io_unistr2("servername", &il
->guid
, il
->guid_ptr
, ps
, depth
))
4884 /*******************************************************************
4885 ********************************************************************/
4887 BOOL
spool_io_printer_info_level(const char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4889 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4894 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4896 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4899 /* if no struct inside just return */
4900 if (il
->info_ptr
==0) {
4901 if (UNMARSHALLING(ps
)) {
4908 switch (il
->level
) {
4910 * level 0 is used by setprinter when managing the queue
4911 * (hold, stop, start a queue)
4915 /* DOCUMENT ME!!! What is level 1 used for? */
4918 if (UNMARSHALLING(ps
)) {
4919 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4922 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4927 * level 2 is used by addprinter
4928 * and by setprinter when updating printer's info
4931 if (UNMARSHALLING(ps
)) {
4932 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4935 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4938 /* DOCUMENT ME!!! What is level 3 used for? */
4941 if (UNMARSHALLING(ps
)) {
4942 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4945 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4950 if (UNMARSHALLING(ps
))
4951 if ((il
->info_7
=(SPOOL_PRINTER_INFO_LEVEL_7
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_7
))) == NULL
)
4953 if (!spool_io_printer_info_level_7("", il
->info_7
, ps
, depth
))
4961 /*******************************************************************
4962 ********************************************************************/
4964 BOOL
spoolss_io_q_addprinterex(const char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4966 uint32 ptr_sec_desc
= 0;
4968 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4973 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4975 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4981 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4984 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4987 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4993 switch (q_u
->level
) {
4995 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4998 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
5002 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
5007 /* Parse a NULL security descriptor. This should really
5008 happen inside the sec_io_desc_buf() function. */
5010 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
5011 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
5013 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
5017 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
5019 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
5025 /*******************************************************************
5026 ********************************************************************/
5028 BOOL
spoolss_io_r_addprinterex(const char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
5029 prs_struct
*ps
, int depth
)
5031 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
5034 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5037 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5043 /*******************************************************************
5044 ********************************************************************/
5046 BOOL
spool_io_printer_driver_info_level_3(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
5047 prs_struct
*ps
, int depth
)
5049 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
5051 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
5055 if (UNMARSHALLING(ps
)) {
5056 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
5068 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
5070 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
5072 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
5074 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
5076 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
5078 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
5080 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
5082 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
5084 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5086 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
5088 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
5094 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5096 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5098 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5100 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5102 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5104 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5106 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5108 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5114 if (il
->dependentfiles_ptr
)
5115 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
5120 /*******************************************************************
5121 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
5122 ********************************************************************/
5124 BOOL
spool_io_printer_driver_info_level_6(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
5125 prs_struct
*ps
, int depth
)
5127 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
5129 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
5133 if (UNMARSHALLING(ps
)) {
5134 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
5147 * I know this seems weird, but I have no other explanation.
5148 * This is observed behavior on both NT4 and 2K servers.
5152 if (!prs_align_uint64(ps
))
5155 /* parse the main elements the packet */
5157 if(!prs_uint32("cversion ", ps
, depth
, &il
->version
))
5159 if(!prs_uint32("name ", ps
, depth
, &il
->name_ptr
))
5161 if(!prs_uint32("environment ", ps
, depth
, &il
->environment_ptr
))
5163 if(!prs_uint32("driverpath ", ps
, depth
, &il
->driverpath_ptr
))
5165 if(!prs_uint32("datafile ", ps
, depth
, &il
->datafile_ptr
))
5167 if(!prs_uint32("configfile ", ps
, depth
, &il
->configfile_ptr
))
5169 if(!prs_uint32("helpfile ", ps
, depth
, &il
->helpfile_ptr
))
5171 if(!prs_uint32("monitorname ", ps
, depth
, &il
->monitorname_ptr
))
5173 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5175 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_len
))
5177 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_ptr
))
5179 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_len
))
5181 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_ptr
))
5183 if(!smb_io_time("driverdate ", &il
->driverdate
, ps
, depth
))
5185 if(!prs_uint32("dummy4 ", ps
, depth
, &il
->dummy4
))
5187 if(!prs_uint64("driverversion ", ps
, depth
, &il
->driverversion
))
5189 if(!prs_uint32("mfgname ", ps
, depth
, &il
->mfgname_ptr
))
5191 if(!prs_uint32("oemurl ", ps
, depth
, &il
->oemurl_ptr
))
5193 if(!prs_uint32("hardwareid ", ps
, depth
, &il
->hardwareid_ptr
))
5195 if(!prs_uint32("provider ", ps
, depth
, &il
->provider_ptr
))
5198 /* parse the structures in the packet */
5200 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5205 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5210 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5215 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5220 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5225 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5230 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5235 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5239 if (il
->dependentfiles_ptr
) {
5240 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
5245 if (il
->previousnames_ptr
) {
5246 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
5251 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
5255 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
5259 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
5263 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
5269 /*******************************************************************
5270 convert a buffer of UNICODE strings null terminated
5271 the buffer is terminated by a NULL
5273 convert to an dos codepage array (null terminated)
5275 dynamically allocate memory
5277 ********************************************************************/
5278 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
5287 src
= (char *)buf5
->buffer
;
5290 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
5291 rpcstr_pull(f
, src
, sizeof(f
)-1, -1, STR_TERMINATE
);
5292 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
5293 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
5298 fstrcpy((*ar
)[n
], f
);
5301 fstrcpy((*ar
)[n
], "");
5309 /*******************************************************************
5310 read a UNICODE array with null terminated strings
5311 and null terminated array
5312 and size of array at beginning
5313 ********************************************************************/
5315 BOOL
smb_io_unibuffer(const char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
5317 if (buffer
==NULL
) return False
;
5320 buffer
->uni_str_len
=buffer
->uni_max_len
;
5322 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
5325 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
5331 /*******************************************************************
5332 ********************************************************************/
5334 BOOL
spool_io_printer_driver_info_level(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
5336 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
5341 if(!prs_uint32("level", ps
, depth
, &il
->level
))
5343 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
5349 switch (il
->level
) {
5351 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
5355 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5365 /*******************************************************************
5366 init a SPOOL_Q_ADDPRINTERDRIVER struct
5367 ******************************************************************/
5369 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5370 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5371 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5373 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5375 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
5376 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
5380 q_u
->info
.level
= level
;
5381 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
5384 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5386 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5390 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5397 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5398 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5399 DRIVER_INFO_3
*info3
)
5402 uint16
*ptr
= info3
->dependentfiles
;
5404 BOOL null_char
= False
;
5405 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5407 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
5410 inf
->cversion
= info3
->version
;
5411 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5412 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5413 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5414 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5415 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5416 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5417 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5418 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5420 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5421 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5422 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5423 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5424 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5425 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5426 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5427 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5434 /* the null_char BOOL is used to help locate
5435 two '\0's back to back */
5450 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5451 inf
->dependentfilessize
= len
;
5452 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5458 *spool_drv_info
= inf
;
5463 /*******************************************************************
5464 make a BUFFER5 struct from a uint16*
5465 ******************************************************************/
5466 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5469 buf5
->buf_len
= len
;
5470 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5472 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5479 /*******************************************************************
5480 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5481 ********************************************************************/
5483 BOOL
spoolss_io_q_addprinterdriver(const char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5485 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5491 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5493 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5498 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5501 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5507 /*******************************************************************
5508 ********************************************************************/
5510 BOOL
spoolss_io_r_addprinterdriver(const char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5512 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5515 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5521 /*******************************************************************
5522 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5523 ********************************************************************/
5525 BOOL
spoolss_io_q_addprinterdriverex(const char *desc
, SPOOL_Q_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5527 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriverex");
5533 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5535 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5540 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5543 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5548 if(!prs_uint32("copy flags", ps
, depth
, &q_u
->copy_flags
))
5554 /*******************************************************************
5555 ********************************************************************/
5557 BOOL
spoolss_io_r_addprinterdriverex(const char *desc
, SPOOL_R_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5559 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriverex");
5562 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5568 /*******************************************************************
5569 ********************************************************************/
5571 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5572 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5574 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5576 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5580 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5588 d
->cversion
=uni
->cversion
;
5590 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5591 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5592 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5593 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5594 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5595 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5596 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5597 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5599 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5600 DEBUGADD(8,( "name: %s\n", d
->name
));
5601 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5602 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5603 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5604 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5605 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5606 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5607 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5609 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5616 /*******************************************************************
5617 ********************************************************************/
5618 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5619 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5621 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5623 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5627 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5635 d
->version
=uni
->version
;
5637 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5638 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5639 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5640 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5641 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5642 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5643 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5644 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5646 DEBUGADD(8,( "version: %d\n", d
->version
));
5647 DEBUGADD(8,( "name: %s\n", d
->name
));
5648 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5649 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5650 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5651 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5652 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5653 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5654 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5656 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5658 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5668 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5669 NT_PRINTER_INFO_LEVEL_2
**asc
)
5671 NT_PRINTER_INFO_LEVEL_2
*d
;
5674 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5675 time_unix
=time(NULL
);
5678 DEBUGADD(8,("allocating memory\n"));
5680 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5685 /* we allocate memory iff called from
5686 * addprinter(ex) so we can do one time stuff here.
5688 (*asc
)->setuptime
=time_unix
;
5691 DEBUGADD(8,("start converting\n"));
5695 d
->attributes
=uni
->attributes
;
5696 d
->priority
=uni
->priority
;
5697 d
->default_priority
=uni
->default_priority
;
5698 d
->starttime
=uni
->starttime
;
5699 d
->untiltime
=uni
->untiltime
;
5700 d
->status
=uni
->status
;
5701 d
->cjobs
=uni
->cjobs
;
5703 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5704 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5705 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5706 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5707 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5708 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5709 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5710 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5711 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5712 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5713 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5718 /*******************************************************************
5720 ********************************************************************/
5722 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5723 fstring servername
, fstring env_name
, uint32 level
,
5724 NEW_BUFFER
*buffer
, uint32 offered
)
5726 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5727 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5731 q_u
->offered
=offered
;
5736 /*******************************************************************
5737 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5738 ********************************************************************/
5740 BOOL
spoolss_io_q_getprinterdriverdir(const char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5742 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5747 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5749 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5755 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5757 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5763 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5766 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5772 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5778 /*******************************************************************
5779 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5780 ********************************************************************/
5782 BOOL
spoolss_io_r_getprinterdriverdir(const char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5784 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5790 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5796 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5799 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5805 /*******************************************************************
5806 ********************************************************************/
5808 BOOL
spoolss_io_r_enumprintprocessors(const char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5810 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5816 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5822 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5825 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5828 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5834 /*******************************************************************
5835 ********************************************************************/
5837 BOOL
spoolss_io_q_enumprintprocessors(const char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5839 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5845 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5847 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5853 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5855 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5861 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5864 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5870 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5876 /*******************************************************************
5877 ********************************************************************/
5879 BOOL
spoolss_io_q_addprintprocessor(const char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5881 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5887 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5889 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5894 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5899 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5904 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5910 /*******************************************************************
5911 ********************************************************************/
5913 BOOL
spoolss_io_r_addprintprocessor(const char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5915 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5921 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5927 /*******************************************************************
5928 ********************************************************************/
5930 BOOL
spoolss_io_r_enumprintprocdatatypes(const char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5932 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5938 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5944 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5947 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5950 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5956 /*******************************************************************
5957 ********************************************************************/
5959 BOOL
spoolss_io_q_enumprintprocdatatypes(const char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5961 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5967 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5969 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5975 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5977 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5983 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5986 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5992 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5998 /*******************************************************************
5999 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
6000 ********************************************************************/
6002 BOOL
spoolss_io_q_enumprintmonitors(const char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
6004 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
6010 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
6012 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6018 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
6021 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6027 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6033 /*******************************************************************
6034 ********************************************************************/
6036 BOOL
spoolss_io_r_enumprintmonitors(const char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
6038 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
6044 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6050 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6053 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6056 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6062 /*******************************************************************
6063 ********************************************************************/
6065 BOOL
spoolss_io_r_enumprinterdata(const char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6067 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
6072 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
6075 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
6076 r_u
->value
= (uint16
*)prs_alloc_mem(ps
, r_u
->valuesize
* 2);
6078 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
6083 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
6089 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
6092 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
6095 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
6098 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
6099 r_u
->data
= (uint8
*)prs_alloc_mem(ps
, r_u
->datasize
);
6101 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
6106 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
6111 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
6113 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6119 /*******************************************************************
6120 ********************************************************************/
6122 BOOL
spoolss_io_q_enumprinterdata(const char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6124 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
6129 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6131 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
6133 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
6135 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
6141 /*******************************************************************
6142 ********************************************************************/
6144 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
6145 const POLICY_HND
*hnd
,
6146 uint32 idx
, uint32 valuelen
, uint32 datalen
)
6148 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6150 q_u
->valuesize
=valuelen
;
6151 q_u
->datasize
=datalen
;
6156 /*******************************************************************
6157 ********************************************************************/
6159 BOOL
make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX
*q_u
,
6160 const POLICY_HND
*hnd
, const char *key
,
6163 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6164 init_unistr2(&q_u
->key
, key
, strlen(key
)+1);
6170 /*******************************************************************
6171 ********************************************************************/
6172 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, const POLICY_HND
*hnd
,
6173 char* value
, uint32 data_type
, char* data
, uint32 data_size
)
6175 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6176 q_u
->type
= data_type
;
6177 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
6179 q_u
->max_len
= q_u
->real_len
= data_size
;
6185 /*******************************************************************
6186 ********************************************************************/
6187 BOOL
make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX
*q_u
, const POLICY_HND
*hnd
,
6188 char *key
, char* value
, uint32 data_type
, char* data
,
6191 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6192 q_u
->type
= data_type
;
6193 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
6194 init_unistr2(&q_u
->key
, key
, strlen(key
)+1);
6196 q_u
->max_len
= q_u
->real_len
= data_size
;
6202 /*******************************************************************
6203 ********************************************************************/
6205 BOOL
spoolss_io_q_setprinterdata(const char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6207 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
6212 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6214 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6220 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6223 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6233 if (UNMARSHALLING(ps
))
6234 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6235 if(q_u
->data
== NULL
)
6237 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6245 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6251 /*******************************************************************
6252 ********************************************************************/
6254 BOOL
spoolss_io_r_setprinterdata(const char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6256 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
6261 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6267 /*******************************************************************
6268 ********************************************************************/
6269 BOOL
spoolss_io_q_resetprinter(const char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6271 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
6276 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6279 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
6282 if (q_u
->datatype_ptr
) {
6283 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
6287 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
6294 /*******************************************************************
6295 ********************************************************************/
6296 BOOL
spoolss_io_r_resetprinter(const char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6298 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
6303 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6309 /*******************************************************************
6310 ********************************************************************/
6312 static BOOL
spoolss_io_addform(const char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
6314 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
6321 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
6323 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
6325 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
6327 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
6329 if(!prs_uint32("left", ps
, depth
, &f
->left
))
6331 if(!prs_uint32("top", ps
, depth
, &f
->top
))
6333 if(!prs_uint32("right", ps
, depth
, &f
->right
))
6335 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
6338 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
6345 /*******************************************************************
6346 ********************************************************************/
6348 BOOL
spoolss_io_q_deleteform(const char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
6350 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
6355 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6357 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
6363 /*******************************************************************
6364 ********************************************************************/
6366 BOOL
spoolss_io_r_deleteform(const char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
6368 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
6373 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6379 /*******************************************************************
6380 ********************************************************************/
6382 BOOL
spoolss_io_q_addform(const char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
6384 uint32 useless_ptr
=1;
6385 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
6390 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6392 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6394 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6399 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6401 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6408 /*******************************************************************
6409 ********************************************************************/
6411 BOOL
spoolss_io_r_addform(const char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6413 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6418 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6424 /*******************************************************************
6425 ********************************************************************/
6427 BOOL
spoolss_io_q_setform(const char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6429 uint32 useless_ptr
=1;
6430 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6435 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6437 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6443 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6445 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6450 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6452 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6459 /*******************************************************************
6460 ********************************************************************/
6462 BOOL
spoolss_io_r_setform(const char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6464 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6469 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6475 /*******************************************************************
6476 Parse a SPOOL_R_GETJOB structure.
6477 ********************************************************************/
6479 BOOL
spoolss_io_r_getjob(const char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6481 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6487 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6493 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6496 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6502 /*******************************************************************
6503 Parse a SPOOL_Q_GETJOB structure.
6504 ********************************************************************/
6506 BOOL
spoolss_io_q_getjob(const char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6508 prs_debug(ps
, depth
, desc
, "");
6514 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6516 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6518 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6521 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6527 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6533 void free_devmode(DEVICEMODE
*devmode
)
6535 if (devmode
!=NULL
) {
6536 SAFE_FREE(devmode
->private);
6541 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6546 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6548 if (printer
!=NULL
) {
6549 free_devmode(printer
->devmode
);
6550 printer
->devmode
= NULL
;
6555 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6560 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6565 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6570 void free_printer_info_7(PRINTER_INFO_7
*printer
)
6575 void free_job_info_2(JOB_INFO_2
*job
)
6578 free_devmode(job
->devmode
);
6581 /*******************************************************************
6583 ********************************************************************/
6585 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6586 const fstring string
, uint32 printer
, uint32 type
)
6591 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
6593 q_u
->printer
=printer
;
6602 /*******************************************************************
6603 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6604 ********************************************************************/
6606 BOOL
spoolss_io_q_replyopenprinter(const char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6608 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6614 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6620 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6622 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6625 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6627 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6633 /*******************************************************************
6634 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6635 ********************************************************************/
6637 BOOL
spoolss_io_r_replyopenprinter(const char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6639 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6645 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6648 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6654 /*******************************************************************
6656 ********************************************************************/
6657 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6658 uint32 condition
, uint32 change_id
)
6661 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6663 q_u
->condition
= condition
;
6664 q_u
->change_id
= change_id
;
6667 q_u
->unknown1
= 0x1;
6668 memset(q_u
->unknown2
, 0x0, 5);
6669 q_u
->unknown2
[0] = 0x1;
6674 /*******************************************************************
6675 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6676 ********************************************************************/
6677 BOOL
spoolss_io_q_routerreplyprinter (const char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6680 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6686 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6689 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6692 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6695 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6698 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6704 /*******************************************************************
6705 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6706 ********************************************************************/
6707 BOOL
spoolss_io_r_routerreplyprinter (const char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6709 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6715 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6721 /*******************************************************************
6723 ********************************************************************/
6725 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6730 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6735 /*******************************************************************
6736 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6737 ********************************************************************/
6739 BOOL
spoolss_io_q_replycloseprinter(const char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6741 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6747 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6753 /*******************************************************************
6754 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6755 ********************************************************************/
6757 BOOL
spoolss_io_r_replycloseprinter(const char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6759 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6765 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6768 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6774 #if 0 /* JERRY - not currently used but could be :-) */
6776 /*******************************************************************
6777 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6778 ******************************************************************/
6779 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6780 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6784 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6786 for (i
=0; i
<n
; i
++) {
6790 if (src
->size
!= POINTER
)
6792 len
= src
->notify_data
.data
.length
;
6793 s
= malloc(sizeof(uint16
)*len
);
6795 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6799 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6800 dst
->notify_data
.data
.string
= s
;
6806 /*******************************************************************
6807 Deep copy a SPOOL_NOTIFY_INFO structure
6808 ******************************************************************/
6809 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6812 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6816 dst
->version
= src
->version
;
6817 dst
->flags
= src
->flags
;
6818 dst
->count
= src
->count
;
6822 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6824 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6827 if (dst
->data
== NULL
) {
6828 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6833 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6840 /*******************************************************************
6842 ********************************************************************/
6844 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6845 uint32 change_low
, uint32 change_high
,
6846 SPOOL_NOTIFY_INFO
*info
)
6851 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6853 q_u
->change_low
=change_low
;
6854 q_u
->change_high
=change_high
;
6859 q_u
->info_ptr
=0x0FF0ADDE;
6861 q_u
->info
.version
=2;
6864 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6866 q_u
->info
.version
= info
->version
;
6867 q_u
->info
.flags
= info
->flags
;
6868 q_u
->info
.count
= info
->count
;
6869 /* pointer field - be careful! */
6870 q_u
->info
.data
= info
->data
;
6873 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6880 /*******************************************************************
6881 Parse a SPOOL_Q_REPLY_RRPCN structure.
6882 ********************************************************************/
6884 BOOL
spoolss_io_q_reply_rrpcn(const char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6886 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6892 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6895 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6898 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6901 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6904 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6907 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6910 if(q_u
->info_ptr
!=0)
6911 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6917 /*******************************************************************
6918 Parse a SPOOL_R_REPLY_RRPCN structure.
6919 ********************************************************************/
6921 BOOL
spoolss_io_r_reply_rrpcn(const char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6923 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6929 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6932 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6938 /*******************************************************************
6940 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6941 ********************************************************************/
6943 BOOL
spoolss_io_q_getprinterdataex(const char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6948 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6953 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6957 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6961 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6965 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6971 /*******************************************************************
6972 * write a structure.
6973 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6974 ********************************************************************/
6976 BOOL
spoolss_io_r_getprinterdataex(const char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6981 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6986 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6988 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6991 if (UNMARSHALLING(ps
) && r_u
->size
) {
6992 r_u
->data
= prs_alloc_mem(ps
, r_u
->size
);
6997 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
7003 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7005 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
7011 /*******************************************************************
7013 ********************************************************************/
7015 BOOL
spoolss_io_q_setprinterdataex(const char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7017 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
7022 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7024 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7030 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
7036 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
7039 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
7049 if (UNMARSHALLING(ps
))
7050 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
7051 if(q_u
->data
== NULL
)
7053 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
7061 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
7067 /*******************************************************************
7068 * write a structure.
7069 ********************************************************************/
7071 BOOL
spoolss_io_r_setprinterdataex(const char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7073 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
7078 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7084 /*******************************************************************
7086 ********************************************************************/
7087 BOOL
make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY
*q_u
,
7088 POLICY_HND
*hnd
, const char *key
,
7091 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
7093 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7094 init_unistr2(&q_u
->key
, key
, strlen(key
)+1);
7100 /*******************************************************************
7102 ********************************************************************/
7104 BOOL
spoolss_io_q_enumprinterkey(const char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7106 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
7111 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7114 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7120 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7126 /*******************************************************************
7127 * write a structure.
7128 ********************************************************************/
7130 BOOL
spoolss_io_r_enumprinterkey(const char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7132 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
7138 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
7144 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7147 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7153 /*******************************************************************
7155 ********************************************************************/
7157 BOOL
make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY
*q_u
,
7158 POLICY_HND
*hnd
, char *keyname
)
7160 DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
7162 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7163 init_unistr2(&q_u
->keyname
, keyname
, strlen(keyname
)+1);
7168 /*******************************************************************
7170 ********************************************************************/
7172 BOOL
spoolss_io_q_deleteprinterkey(const char *desc
, SPOOL_Q_DELETEPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7174 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterkey");
7179 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7182 if(!smb_io_unistr2("", &q_u
->keyname
, True
, ps
, depth
))
7188 /*******************************************************************
7189 * write a structure.
7190 ********************************************************************/
7192 BOOL
spoolss_io_r_deleteprinterkey(const char *desc
, SPOOL_R_DELETEPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7194 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterkey");
7200 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7207 /*******************************************************************
7209 ********************************************************************/
7211 BOOL
spoolss_io_q_enumprinterdataex(const char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7213 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
7218 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7221 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7227 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7233 /*******************************************************************
7234 ********************************************************************/
7236 static BOOL
spoolss_io_printer_enum_values_ctr(const char *desc
, prs_struct
*ps
,
7237 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
7240 uint32 valuename_offset
,
7243 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
7245 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
7249 * offset data begins at 20 bytes per structure * size_of_array.
7250 * Don't forget the uint32 at the beginning
7253 current_offset
= basic_unit
* ctr
->size_of_array
;
7255 /* first loop to write basic enum_value information */
7257 if (UNMARSHALLING(ps
)) {
7258 ctr
->values
= (PRINTER_ENUM_VALUES
*)prs_alloc_mem(
7259 ps
, ctr
->size_of_array
* sizeof(PRINTER_ENUM_VALUES
));
7264 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7265 valuename_offset
= current_offset
;
7266 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
7269 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
7272 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
7275 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
7277 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
7280 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
7283 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
7284 /* account for 2 byte alignment */
7285 current_offset
+= (current_offset
% 2);
7289 * loop #2 for writing the dynamically size objects; pay
7290 * attention to 2-byte alignment here....
7293 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7295 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
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
)
7305 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
, strlen(name
)+1);
7386 init_unistr2(&q_u
->environment
, environment
, strlen(environment
)+1);
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
, 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
, strlen(form_name
) + 1);
7517 /*******************************************************************
7519 ********************************************************************/
7521 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
, char *form
)
7523 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7524 init_unistr2(&q_u
->name
, form
, strlen(form
) + 1);
7528 /*******************************************************************
7530 ********************************************************************/
7532 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7533 char *formname
, uint32 level
, NEW_BUFFER
*buffer
,
7536 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7538 init_unistr2(&q_u
->formname
, formname
, strlen(formname
) + 1);
7540 q_u
->offered
=offered
;
7545 /*******************************************************************
7547 ********************************************************************/
7549 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7550 uint32 level
, NEW_BUFFER
*buffer
,
7553 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7556 q_u
->offered
=offered
;
7561 /*******************************************************************
7563 ********************************************************************/
7565 BOOL
make_spoolss_q_setjob(SPOOL_Q_SETJOB
*q_u
, POLICY_HND
*handle
,
7566 uint32 jobid
, uint32 level
, uint32 command
)
7568 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7572 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7573 the server side code has it marked as unused. */
7575 q_u
->command
= command
;
7580 /*******************************************************************
7582 ********************************************************************/
7584 BOOL
make_spoolss_q_getjob(SPOOL_Q_GETJOB
*q_u
, POLICY_HND
*handle
,
7585 uint32 jobid
, uint32 level
, NEW_BUFFER
*buffer
,
7588 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7591 q_u
->buffer
= buffer
;
7592 q_u
->offered
= offered
;
7597 /*******************************************************************
7599 ********************************************************************/
7601 BOOL
make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER
*q_u
,
7604 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7609 /*******************************************************************
7611 ********************************************************************/
7613 BOOL
make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER
*q_u
,
7616 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7621 /*******************************************************************
7623 ********************************************************************/
7625 BOOL
make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER
*q_u
,
7626 POLICY_HND
*handle
, uint32 level
,
7627 char *docname
, char *outputfile
,
7630 DOC_INFO_CONTAINER
*ctr
= &q_u
->doc_info_container
;
7632 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7638 ctr
->docinfo
.switch_value
= level
;
7640 ctr
->docinfo
.doc_info_1
.p_docname
= docname
? 1 : 0;
7641 ctr
->docinfo
.doc_info_1
.p_outputfile
= outputfile
? 1 : 0;
7642 ctr
->docinfo
.doc_info_1
.p_datatype
= datatype
? 1 : 0;
7645 init_unistr2(&ctr
->docinfo
.doc_info_1
.docname
, docname
,
7646 strlen(docname
) + 1);
7649 init_unistr2(&ctr
->docinfo
.doc_info_1
.outputfile
, outputfile
,
7650 strlen(outputfile
) + 1);
7653 init_unistr2(&ctr
->docinfo
.doc_info_1
.datatype
, datatype
,
7654 strlen(datatype
) + 1);
7658 /* DOC_INFO_2 is only used by Windows 9x and since it
7659 doesn't do printing over RPC we don't have to worry
7662 DEBUG(3, ("unsupported info level %d\n", level
));
7669 /*******************************************************************
7671 ********************************************************************/
7673 BOOL
make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER
*q_u
,
7676 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7681 /*******************************************************************
7683 ********************************************************************/
7685 BOOL
make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER
*q_u
,
7686 POLICY_HND
*handle
, uint32 data_size
,
7689 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7690 q_u
->buffer_size
= q_u
->buffer_size2
= data_size
;
7695 /*******************************************************************
7697 ********************************************************************/
7699 BOOL
make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA
*q_u
,
7700 POLICY_HND
*handle
, char *valuename
)
7702 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7703 init_unistr2(&q_u
->valuename
, valuename
, strlen(valuename
) + 1);
7708 /*******************************************************************
7710 ********************************************************************/
7712 BOOL
make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX
*q_u
,
7713 POLICY_HND
*handle
, char *key
,
7716 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7717 init_unistr2(&q_u
->valuename
, value
, strlen(value
) + 1);
7718 init_unistr2(&q_u
->keyname
, key
, strlen(key
) + 1);
7723 /*******************************************************************
7725 ********************************************************************/
7727 BOOL
make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX
*q_u
, POLICY_HND
*handle
,
7728 uint32 flags
, uint32 options
, const char *localmachine
,
7729 uint32 printerlocal
, SPOOL_NOTIFY_OPTION
*option
)
7731 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7734 q_u
->options
= options
;
7736 q_u
->localmachine_ptr
= 1;
7738 init_unistr2(&q_u
->localmachine
, localmachine
,
7739 strlen(localmachine
) + 1);
7741 q_u
->printerlocal
= printerlocal
;
7744 q_u
->option_ptr
= 1;
7746 q_u
->option
= option
;