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 const 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 const char *keyname
,
1225 const char *valuename
, uint32 size
)
1227 if (q_u
== NULL
) return False
;
1229 DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
1231 q_u
->handle
= *handle
;
1232 init_unistr2(&q_u
->valuename
, valuename
, strlen(valuename
) + 1);
1233 init_unistr2(&q_u
->keyname
, keyname
, strlen(keyname
) + 1);
1239 /*******************************************************************
1241 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1242 ********************************************************************/
1244 BOOL
spoolss_io_q_getprinterdata(const char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1249 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1254 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1258 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1262 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1268 /*******************************************************************
1270 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1271 ********************************************************************/
1273 BOOL
spoolss_io_q_deleteprinterdata(const char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1278 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1283 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1287 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1293 /*******************************************************************
1294 * write a structure.
1295 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1296 ********************************************************************/
1298 BOOL
spoolss_io_r_deleteprinterdata(const char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1300 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1302 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1308 /*******************************************************************
1310 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1311 ********************************************************************/
1313 BOOL
spoolss_io_q_deleteprinterdataex(const char *desc
, SPOOL_Q_DELETEPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
1318 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdataex");
1323 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1326 if (!smb_io_unistr2("keyname ", &q_u
->keyname
, True
, ps
, depth
))
1328 if (!smb_io_unistr2("valuename", &q_u
->valuename
, True
, ps
, depth
))
1334 /*******************************************************************
1335 * write a structure.
1336 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1337 ********************************************************************/
1339 BOOL
spoolss_io_r_deleteprinterdataex(const char *desc
, SPOOL_R_DELETEPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
1341 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdataex");
1344 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1350 /*******************************************************************
1351 * write a structure.
1352 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1353 ********************************************************************/
1355 BOOL
spoolss_io_r_getprinterdata(const char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1360 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1365 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1367 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1370 if (UNMARSHALLING(ps
) && r_u
->size
) {
1371 r_u
->data
= prs_alloc_mem(ps
, r_u
->size
);
1376 if (!prs_uint8s( False
, "data", ps
, depth
, r_u
->data
, r_u
->size
))
1382 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1384 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1390 /*******************************************************************
1392 ********************************************************************/
1394 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1396 if (q_u
== NULL
) return False
;
1398 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1400 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1405 /*******************************************************************
1407 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1408 * called from spoolss_abortprinter (cli_spoolss.c)
1409 ********************************************************************/
1411 BOOL
spoolss_io_q_abortprinter(const char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1413 if (q_u
== NULL
) return False
;
1415 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1421 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1427 /*******************************************************************
1428 * write a structure.
1429 * called from spoolss_r_abortprinter (srv_spoolss.c)
1430 ********************************************************************/
1432 BOOL
spoolss_io_r_abortprinter(const char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1434 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1436 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1442 /*******************************************************************
1444 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1445 * called from spoolss_deleteprinter (cli_spoolss.c)
1446 ********************************************************************/
1448 BOOL
spoolss_io_q_deleteprinter(const char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1450 if (q_u
== NULL
) return False
;
1452 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1458 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1464 /*******************************************************************
1465 * write a structure.
1466 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1467 * called from spoolss_deleteprinter (cli_spoolss.c)
1468 ********************************************************************/
1470 BOOL
spoolss_io_r_deleteprinter(const char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1472 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1478 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1480 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1487 /*******************************************************************
1489 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1490 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1491 ********************************************************************/
1493 BOOL
spoolss_io_q_deleteprinterdriver(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1495 if (q_u
== NULL
) return False
;
1497 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1503 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1505 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1507 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1509 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1517 /*******************************************************************
1518 * write a structure.
1519 ********************************************************************/
1520 BOOL
spoolss_io_r_deleteprinterdriver(const char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1522 if (r_u
== NULL
) return False
;
1524 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1530 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1537 /*******************************************************************
1539 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1540 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1541 ********************************************************************/
1543 BOOL
spoolss_io_q_deleteprinterdriverex(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
1545 if (q_u
== NULL
) return False
;
1547 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriverex");
1553 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1555 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1557 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1559 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1565 if(!prs_uint32("delete_flags ", ps
, depth
, &q_u
->delete_flags
))
1567 if(!prs_uint32("version ", ps
, depth
, &q_u
->version
))
1575 /*******************************************************************
1576 * write a structure.
1577 ********************************************************************/
1578 BOOL
spoolss_io_r_deleteprinterdriverex(const char *desc
, SPOOL_R_DELETEPRINTERDRIVEREX
*r_u
, prs_struct
*ps
, int depth
)
1580 if (r_u
== NULL
) return False
;
1582 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriverex");
1588 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1596 /*******************************************************************
1598 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1599 * called from spoolss_closeprinter (cli_spoolss.c)
1600 ********************************************************************/
1602 BOOL
spoolss_io_q_closeprinter(const char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1604 if (q_u
== NULL
) return False
;
1606 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1612 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1618 /*******************************************************************
1619 * write a structure.
1620 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1621 * called from spoolss_closeprinter (cli_spoolss.c)
1622 ********************************************************************/
1624 BOOL
spoolss_io_r_closeprinter(const char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1626 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1632 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1634 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1640 /*******************************************************************
1642 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1643 ********************************************************************/
1645 BOOL
spoolss_io_q_startdocprinter(const char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1647 if (q_u
== NULL
) return False
;
1649 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1655 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1658 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1664 /*******************************************************************
1665 * write a structure.
1666 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1667 ********************************************************************/
1669 BOOL
spoolss_io_r_startdocprinter(const char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1671 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1673 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1675 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1681 /*******************************************************************
1683 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1684 ********************************************************************/
1686 BOOL
spoolss_io_q_enddocprinter(const char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1688 if (q_u
== NULL
) return False
;
1690 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1696 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1702 /*******************************************************************
1703 * write a structure.
1704 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1705 ********************************************************************/
1707 BOOL
spoolss_io_r_enddocprinter(const char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1709 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1711 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1717 /*******************************************************************
1719 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1720 ********************************************************************/
1722 BOOL
spoolss_io_q_startpageprinter(const char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1724 if (q_u
== NULL
) return False
;
1726 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1732 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1738 /*******************************************************************
1739 * write a structure.
1740 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1741 ********************************************************************/
1743 BOOL
spoolss_io_r_startpageprinter(const char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1745 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1747 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1753 /*******************************************************************
1755 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1756 ********************************************************************/
1758 BOOL
spoolss_io_q_endpageprinter(const char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1760 if (q_u
== NULL
) return False
;
1762 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1768 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1774 /*******************************************************************
1775 * write a structure.
1776 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1777 ********************************************************************/
1779 BOOL
spoolss_io_r_endpageprinter(const char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1781 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1783 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1789 /*******************************************************************
1791 * called from spoolss_q_writeprinter (srv_spoolss.c)
1792 ********************************************************************/
1794 BOOL
spoolss_io_q_writeprinter(const char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1796 if (q_u
== NULL
) return False
;
1798 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1804 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1806 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1809 if (q_u
->buffer_size
!=0)
1811 if (UNMARSHALLING(ps
))
1812 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1813 if(q_u
->buffer
== NULL
)
1815 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1820 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1826 /*******************************************************************
1827 * write a structure.
1828 * called from spoolss_r_writeprinter (srv_spoolss.c)
1829 ********************************************************************/
1831 BOOL
spoolss_io_r_writeprinter(const char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1833 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1835 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1837 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1843 /*******************************************************************
1845 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1846 ********************************************************************/
1848 BOOL
spoolss_io_q_rffpcnex(const char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1850 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1856 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1858 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1860 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1862 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1864 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1870 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1873 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1876 if (q_u
->option_ptr
!=0) {
1878 if (UNMARSHALLING(ps
))
1879 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1882 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1889 /*******************************************************************
1890 * write a structure.
1891 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1892 ********************************************************************/
1894 BOOL
spoolss_io_r_rffpcnex(const char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1896 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1899 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1905 /*******************************************************************
1907 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1908 ********************************************************************/
1910 BOOL
spoolss_io_q_rfnpcnex(const char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1912 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1918 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1921 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1924 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1927 if (q_u
->option_ptr
!=0) {
1929 if (UNMARSHALLING(ps
))
1930 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1933 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1940 /*******************************************************************
1941 * write a structure.
1942 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1943 ********************************************************************/
1945 BOOL
spoolss_io_r_rfnpcnex(const char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1947 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1953 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1956 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1961 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1967 /*******************************************************************
1968 * return the length of a uint16 (obvious, but the code is clean)
1969 ********************************************************************/
1971 static uint32
size_of_uint16(uint16
*value
)
1973 return (sizeof(*value
));
1976 /*******************************************************************
1977 * return the length of a uint32 (obvious, but the code is clean)
1978 ********************************************************************/
1980 static uint32
size_of_uint32(uint32
*value
)
1982 return (sizeof(*value
));
1985 /*******************************************************************
1986 * return the length of a NTTIME (obvious, but the code is clean)
1987 ********************************************************************/
1989 static uint32
size_of_nttime(NTTIME
*value
)
1991 return (sizeof(*value
));
1994 /*******************************************************************
1995 * return the length of a UNICODE string in number of char, includes:
1996 * - the leading zero
1997 * - the relative pointer size
1998 ********************************************************************/
2000 static uint32
size_of_relative_string(UNISTR
*string
)
2004 size
=str_len_uni(string
); /* the string length */
2005 size
=size
+1; /* add the trailing zero */
2006 size
=size
*2; /* convert in char */
2007 size
=size
+4; /* add the size of the ptr */
2011 * Do not include alignment as Win2k does not align relative
2012 * strings within a buffer --jerry
2014 /* Ensure size is 4 byte multiple (prs_align is being called...). */
2015 /* size += ((4 - (size & 3)) & 3); */
2021 /*******************************************************************
2022 * return the length of a uint32 (obvious, but the code is clean)
2023 ********************************************************************/
2025 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
2030 return (4+devmode
->size
+devmode
->driverextra
);
2033 /*******************************************************************
2034 * return the length of a uint32 (obvious, but the code is clean)
2035 ********************************************************************/
2037 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
2042 return (sizeof(SYSTEMTIME
) +4);
2045 /*******************************************************************
2046 * write a UNICODE string and its relative pointer.
2047 * used by all the RPC structs passing a buffer
2049 * As I'm a nice guy, I'm forcing myself to explain this code.
2050 * MS did a good job in the overall spoolss code except in some
2051 * functions where they are passing the API buffer directly in the
2052 * RPC request/reply. That's to maintain compatiility at the API level.
2053 * They could have done it the good way the first time.
2055 * So what happen is: the strings are written at the buffer's end,
2056 * in the reverse order of the original structure. Some pointers to
2057 * the strings are also in the buffer. Those are relative to the
2060 * If you don't understand or want to change that function,
2061 * first get in touch with me: jfm@samba.org
2063 ********************************************************************/
2065 static BOOL
smb_io_relstr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
2067 prs_struct
*ps
=&buffer
->prs
;
2069 if (MARSHALLING(ps
)) {
2070 uint32 struct_offset
= prs_offset(ps
);
2071 uint32 relative_offset
;
2073 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
2074 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2078 * Win2k does not align strings in a buffer
2079 * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry
2084 buffer
->string_at_end
= prs_offset(ps
);
2086 /* write the string */
2087 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2090 if(!prs_set_offset(ps
, struct_offset
))
2093 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2094 /* write its offset */
2095 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2101 /* read the offset */
2102 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
2105 if (buffer
->string_at_end
== 0)
2108 old_offset
= prs_offset(ps
);
2109 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
2112 /* read the string */
2113 if (!smb_io_unistr(desc
, string
, ps
, depth
))
2116 if(!prs_set_offset(ps
, old_offset
))
2122 /*******************************************************************
2123 * write a array of UNICODE strings and its relative pointer.
2124 * used by 2 RPC structs
2125 ********************************************************************/
2127 static BOOL
smb_io_relarraystr(const char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
2131 prs_struct
*ps
=&buffer
->prs
;
2133 if (MARSHALLING(ps
)) {
2134 uint32 struct_offset
= prs_offset(ps
);
2135 uint32 relative_offset
;
2142 /* first write the last 0 */
2143 buffer
->string_at_end
-= 2;
2144 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2147 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
2150 while (p
&& (*p
!=0)) {
2154 /* Yes this should be malloc not talloc. Don't change. */
2156 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
2157 if (chaine
.buffer
== NULL
)
2160 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
2162 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
2164 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
2165 SAFE_FREE(chaine
.buffer
);
2169 /* write the string */
2170 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
2171 SAFE_FREE(chaine
.buffer
);
2177 SAFE_FREE(chaine
.buffer
);
2180 if(!prs_set_offset(ps
, struct_offset
))
2183 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2184 /* write its offset */
2185 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2193 uint16
*chaine2
=NULL
;
2196 size_t realloc_size
= 0;
2200 /* read the offset */
2201 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2204 old_offset
= prs_offset(ps
);
2205 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2209 if (!smb_io_unistr(desc
, &chaine
, ps
, depth
))
2212 l_chaine
=str_len_uni(&chaine
);
2214 /* we're going to add two more bytes here in case this
2215 is the last string in the array and we need to add
2216 an extra NULL for termination */
2221 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
2223 /* Yes this should be realloc - it's freed below. JRA */
2225 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
2230 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
2231 l_chaine2
+=l_chaine
+1;
2234 } while(l_chaine
!=0);
2236 /* the end should be bould NULL terminated so add
2237 the second one here */
2240 chaine2
[l_chaine2
] = '\0';
2241 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
2245 if(!prs_set_offset(ps
, old_offset
))
2251 /*******************************************************************
2252 Parse a DEVMODE structure and its relative pointer.
2253 ********************************************************************/
2255 static BOOL
smb_io_relsecdesc(const char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
2257 prs_struct
*ps
= &buffer
->prs
;
2259 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
2262 if (MARSHALLING(ps
)) {
2263 uint32 struct_offset
= prs_offset(ps
);
2264 uint32 relative_offset
;
2267 relative_offset
= 0;
2268 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2273 if (*secdesc
!= NULL
) {
2274 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
2276 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2278 /* write the secdesc */
2279 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2282 if(!prs_set_offset(ps
, struct_offset
))
2286 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2287 /* write its offset */
2289 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2294 /* read the offset */
2295 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2298 old_offset
= prs_offset(ps
);
2299 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2303 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2306 if(!prs_set_offset(ps
, old_offset
))
2312 /*******************************************************************
2313 Parse a DEVMODE structure and its relative pointer.
2314 ********************************************************************/
2316 static BOOL
smb_io_reldevmode(const char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2318 prs_struct
*ps
=&buffer
->prs
;
2320 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2323 if (MARSHALLING(ps
)) {
2324 uint32 struct_offset
= prs_offset(ps
);
2325 uint32 relative_offset
;
2327 if (*devmode
== NULL
) {
2329 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2331 DEBUG(8, ("boing, the devmode was NULL\n"));
2336 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2338 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2341 /* write the DEVMODE */
2342 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2345 if(!prs_set_offset(ps
, struct_offset
))
2348 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2349 /* write its offset */
2350 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2356 /* read the offset */
2357 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2359 if (buffer
->string_at_end
== 0) {
2364 old_offset
= prs_offset(ps
);
2365 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2368 /* read the string */
2369 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2371 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2374 if(!prs_set_offset(ps
, old_offset
))
2380 /*******************************************************************
2381 Parse a PRINTER_INFO_0 structure.
2382 ********************************************************************/
2384 BOOL
smb_io_printer_info_0(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2386 prs_struct
*ps
=&buffer
->prs
;
2388 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2391 buffer
->struct_start
=prs_offset(ps
);
2393 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2395 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2398 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2400 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2402 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2405 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2407 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2409 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2411 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2413 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2415 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2417 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2419 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2422 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2424 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2427 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2429 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2431 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2433 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2435 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2437 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2439 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2441 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2443 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2445 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2447 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2449 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2451 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2453 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2455 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2457 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2459 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2461 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2463 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2465 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2467 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2469 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2471 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2473 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2475 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2481 /*******************************************************************
2482 Parse a PRINTER_INFO_1 structure.
2483 ********************************************************************/
2485 BOOL
smb_io_printer_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2487 prs_struct
*ps
=&buffer
->prs
;
2489 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2492 buffer
->struct_start
=prs_offset(ps
);
2494 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2496 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2498 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2500 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2506 /*******************************************************************
2507 Parse a PRINTER_INFO_2 structure.
2508 ********************************************************************/
2510 BOOL
smb_io_printer_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2512 prs_struct
*ps
=&buffer
->prs
;
2513 uint32 dm_offset
, sd_offset
, current_offset
;
2514 uint32 dummy_value
= 0, has_secdesc
= 0;
2516 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2519 buffer
->struct_start
=prs_offset(ps
);
2521 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2523 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2525 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2527 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2529 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2531 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2533 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2536 /* save current offset and wind forwared by a uint32 */
2537 dm_offset
= prs_offset(ps
);
2538 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
2541 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2543 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2545 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2547 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2550 /* save current offset for the sec_desc */
2551 sd_offset
= prs_offset(ps
);
2552 if (!prs_uint32("sec_desc", ps
, depth
, &has_secdesc
))
2556 /* save current location so we can pick back up here */
2557 current_offset
= prs_offset(ps
);
2559 /* parse the devmode */
2560 if (!prs_set_offset(ps
, dm_offset
))
2562 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2565 /* parse the sec_desc */
2567 if (!prs_set_offset(ps
, sd_offset
))
2569 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2573 /* pick up where we left off */
2574 if (!prs_set_offset(ps
, current_offset
))
2577 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2579 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2581 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2583 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2585 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2587 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2589 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2591 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2597 /*******************************************************************
2598 Parse a PRINTER_INFO_3 structure.
2599 ********************************************************************/
2601 BOOL
smb_io_printer_info_3(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2603 prs_struct
*ps
=&buffer
->prs
;
2605 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2608 buffer
->struct_start
=prs_offset(ps
);
2610 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2612 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2618 /*******************************************************************
2619 Parse a PRINTER_INFO_4 structure.
2620 ********************************************************************/
2622 BOOL
smb_io_printer_info_4(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2624 prs_struct
*ps
=&buffer
->prs
;
2626 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2629 buffer
->struct_start
=prs_offset(ps
);
2631 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2633 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2635 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2640 /*******************************************************************
2641 Parse a PRINTER_INFO_5 structure.
2642 ********************************************************************/
2644 BOOL
smb_io_printer_info_5(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2646 prs_struct
*ps
=&buffer
->prs
;
2648 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2651 buffer
->struct_start
=prs_offset(ps
);
2653 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2655 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2657 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2659 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2661 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2666 /*******************************************************************
2667 Parse a PRINTER_INFO_7 structure.
2668 ********************************************************************/
2670 BOOL
smb_io_printer_info_7(const char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_7
*info
, int depth
)
2672 prs_struct
*ps
=&buffer
->prs
;
2674 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_7");
2677 buffer
->struct_start
=prs_offset(ps
);
2679 if (!smb_io_relstr("guid", buffer
, depth
, &info
->guid
))
2681 if (!prs_uint32("action", ps
, depth
, &info
->action
))
2686 /*******************************************************************
2687 Parse a PORT_INFO_1 structure.
2688 ********************************************************************/
2690 BOOL
smb_io_port_info_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2692 prs_struct
*ps
=&buffer
->prs
;
2694 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2697 buffer
->struct_start
=prs_offset(ps
);
2699 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2705 /*******************************************************************
2706 Parse a PORT_INFO_2 structure.
2707 ********************************************************************/
2709 BOOL
smb_io_port_info_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2711 prs_struct
*ps
=&buffer
->prs
;
2713 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2716 buffer
->struct_start
=prs_offset(ps
);
2718 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2720 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2722 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2724 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2726 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2732 /*******************************************************************
2733 Parse a DRIVER_INFO_1 structure.
2734 ********************************************************************/
2736 BOOL
smb_io_printer_driver_info_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2738 prs_struct
*ps
=&buffer
->prs
;
2740 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2743 buffer
->struct_start
=prs_offset(ps
);
2745 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2751 /*******************************************************************
2752 Parse a DRIVER_INFO_2 structure.
2753 ********************************************************************/
2755 BOOL
smb_io_printer_driver_info_2(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2757 prs_struct
*ps
=&buffer
->prs
;
2759 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2762 buffer
->struct_start
=prs_offset(ps
);
2764 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2766 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2768 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2770 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2772 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2774 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2780 /*******************************************************************
2781 Parse a DRIVER_INFO_3 structure.
2782 ********************************************************************/
2784 BOOL
smb_io_printer_driver_info_3(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2786 prs_struct
*ps
=&buffer
->prs
;
2788 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2791 buffer
->struct_start
=prs_offset(ps
);
2793 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2795 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2797 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2799 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2801 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2803 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2805 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2808 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2811 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2813 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2819 /*******************************************************************
2820 Parse a DRIVER_INFO_6 structure.
2821 ********************************************************************/
2823 BOOL
smb_io_printer_driver_info_6(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2825 prs_struct
*ps
=&buffer
->prs
;
2827 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2830 buffer
->struct_start
=prs_offset(ps
);
2832 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2834 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2836 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2838 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2840 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2842 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2844 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2847 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2850 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2852 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2855 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2858 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2860 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2863 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2866 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2869 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2872 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2874 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2876 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2878 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2884 /*******************************************************************
2885 Parse a JOB_INFO_1 structure.
2886 ********************************************************************/
2888 BOOL
smb_io_job_info_1(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2890 prs_struct
*ps
=&buffer
->prs
;
2892 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2895 buffer
->struct_start
=prs_offset(ps
);
2897 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2899 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2901 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2903 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2905 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2907 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2909 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2911 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2913 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2915 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2917 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2919 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2921 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2927 /*******************************************************************
2928 Parse a JOB_INFO_2 structure.
2929 ********************************************************************/
2931 BOOL
smb_io_job_info_2(const char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2934 prs_struct
*ps
=&buffer
->prs
;
2936 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2939 buffer
->struct_start
=prs_offset(ps
);
2941 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2943 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2945 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2947 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2949 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2951 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2953 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2956 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2958 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2960 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2962 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2964 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2967 /* SEC_DESC sec_desc;*/
2968 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2971 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2973 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2975 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2977 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2979 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2981 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2983 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2985 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2987 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2989 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2995 /*******************************************************************
2996 ********************************************************************/
2998 BOOL
smb_io_form_1(const char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
3000 prs_struct
*ps
=&buffer
->prs
;
3002 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
3005 buffer
->struct_start
=prs_offset(ps
);
3007 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
3010 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3013 if (!prs_uint32("width", ps
, depth
, &info
->width
))
3015 if (!prs_uint32("length", ps
, depth
, &info
->length
))
3017 if (!prs_uint32("left", ps
, depth
, &info
->left
))
3019 if (!prs_uint32("top", ps
, depth
, &info
->top
))
3021 if (!prs_uint32("right", ps
, depth
, &info
->right
))
3023 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
3029 /*******************************************************************
3030 Read/write a BUFFER struct.
3031 ********************************************************************/
3033 static BOOL
spoolss_io_buffer(const char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
3035 NEW_BUFFER
*buffer
= *pp_buffer
;
3037 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
3040 if (UNMARSHALLING(ps
))
3041 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
3046 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
3050 if (UNMARSHALLING(ps
)) {
3052 buffer
->string_at_end
=0;
3054 if (buffer
->ptr
==0) {
3056 * JRA. I'm not sure if the data in here is in big-endian format if
3057 * the client is big-endian. Leave as default (little endian) for now.
3060 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
3065 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3069 * JRA. I'm not sure if the data in here is in big-endian format if
3070 * the client is big-endian. Leave as default (little endian) for now.
3073 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
3076 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
3079 if (!prs_set_offset(&buffer
->prs
, 0))
3082 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
3085 buffer
->string_at_end
=buffer
->size
;
3093 if (buffer
->ptr
==0) {
3094 /* We have finished with the data in buffer->prs - free it. */
3095 prs_mem_free(&buffer
->prs
);
3099 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
3102 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
3108 /* We have finished with the data in buffer->prs - free it. */
3109 prs_mem_free(&buffer
->prs
);
3115 /*******************************************************************
3116 move a BUFFER from the query to the reply.
3117 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
3118 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
3119 Clears the memory to zero also.
3120 ********************************************************************/
3122 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
3124 prs_switch_type(&src
->prs
, MARSHALL
);
3125 if(!prs_set_offset(&src
->prs
, 0))
3127 prs_force_dynamic(&src
->prs
);
3128 prs_mem_clear(&src
->prs
);
3132 /*******************************************************************
3133 Get the size of a BUFFER struct.
3134 ********************************************************************/
3136 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
3138 return (buffer
->size
);
3141 /*******************************************************************
3142 Parse a DRIVER_DIRECTORY_1 structure.
3143 ********************************************************************/
3145 BOOL
smb_io_driverdir_1(const char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
3147 prs_struct
*ps
=&buffer
->prs
;
3149 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
3152 buffer
->struct_start
=prs_offset(ps
);
3154 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
3160 /*******************************************************************
3161 Parse a PORT_INFO_1 structure.
3162 ********************************************************************/
3164 BOOL
smb_io_port_1(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
3166 prs_struct
*ps
=&buffer
->prs
;
3168 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
3171 buffer
->struct_start
=prs_offset(ps
);
3173 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3179 /*******************************************************************
3180 Parse a PORT_INFO_2 structure.
3181 ********************************************************************/
3183 BOOL
smb_io_port_2(const char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
3185 prs_struct
*ps
=&buffer
->prs
;
3187 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
3190 buffer
->struct_start
=prs_offset(ps
);
3192 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
3194 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
3196 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
3198 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
3200 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
3206 /*******************************************************************
3207 ********************************************************************/
3209 BOOL
smb_io_printprocessor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
3211 prs_struct
*ps
=&buffer
->prs
;
3213 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
3216 buffer
->struct_start
=prs_offset(ps
);
3218 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3224 /*******************************************************************
3225 ********************************************************************/
3227 BOOL
smb_io_printprocdatatype_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
3229 prs_struct
*ps
=&buffer
->prs
;
3231 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
3234 buffer
->struct_start
=prs_offset(ps
);
3236 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
3242 /*******************************************************************
3243 ********************************************************************/
3245 BOOL
smb_io_printmonitor_info_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
3247 prs_struct
*ps
=&buffer
->prs
;
3249 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
3252 buffer
->struct_start
=prs_offset(ps
);
3254 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3260 /*******************************************************************
3261 ********************************************************************/
3263 BOOL
smb_io_printmonitor_info_2(const char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
3265 prs_struct
*ps
=&buffer
->prs
;
3267 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
3270 buffer
->struct_start
=prs_offset(ps
);
3272 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3274 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
3276 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
3282 /*******************************************************************
3283 return the size required by a struct in the stream
3284 ********************************************************************/
3286 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
3290 size
+=size_of_relative_string( &info
->printername
);
3291 size
+=size_of_relative_string( &info
->servername
);
3293 size
+=size_of_uint32( &info
->cjobs
);
3294 size
+=size_of_uint32( &info
->total_jobs
);
3295 size
+=size_of_uint32( &info
->total_bytes
);
3297 size
+=size_of_uint16( &info
->year
);
3298 size
+=size_of_uint16( &info
->month
);
3299 size
+=size_of_uint16( &info
->dayofweek
);
3300 size
+=size_of_uint16( &info
->day
);
3301 size
+=size_of_uint16( &info
->hour
);
3302 size
+=size_of_uint16( &info
->minute
);
3303 size
+=size_of_uint16( &info
->second
);
3304 size
+=size_of_uint16( &info
->milliseconds
);
3306 size
+=size_of_uint32( &info
->global_counter
);
3307 size
+=size_of_uint32( &info
->total_pages
);
3309 size
+=size_of_uint16( &info
->major_version
);
3310 size
+=size_of_uint16( &info
->build_version
);
3312 size
+=size_of_uint32( &info
->unknown7
);
3313 size
+=size_of_uint32( &info
->unknown8
);
3314 size
+=size_of_uint32( &info
->unknown9
);
3315 size
+=size_of_uint32( &info
->session_counter
);
3316 size
+=size_of_uint32( &info
->unknown11
);
3317 size
+=size_of_uint32( &info
->printer_errors
);
3318 size
+=size_of_uint32( &info
->unknown13
);
3319 size
+=size_of_uint32( &info
->unknown14
);
3320 size
+=size_of_uint32( &info
->unknown15
);
3321 size
+=size_of_uint32( &info
->unknown16
);
3322 size
+=size_of_uint32( &info
->change_id
);
3323 size
+=size_of_uint32( &info
->unknown18
);
3324 size
+=size_of_uint32( &info
->status
);
3325 size
+=size_of_uint32( &info
->unknown20
);
3326 size
+=size_of_uint32( &info
->c_setprinter
);
3328 size
+=size_of_uint16( &info
->unknown22
);
3329 size
+=size_of_uint16( &info
->unknown23
);
3330 size
+=size_of_uint16( &info
->unknown24
);
3331 size
+=size_of_uint16( &info
->unknown25
);
3332 size
+=size_of_uint16( &info
->unknown26
);
3333 size
+=size_of_uint16( &info
->unknown27
);
3334 size
+=size_of_uint16( &info
->unknown28
);
3335 size
+=size_of_uint16( &info
->unknown29
);
3340 /*******************************************************************
3341 return the size required by a struct in the stream
3342 ********************************************************************/
3344 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3348 size
+=size_of_uint32( &info
->flags
);
3349 size
+=size_of_relative_string( &info
->description
);
3350 size
+=size_of_relative_string( &info
->name
);
3351 size
+=size_of_relative_string( &info
->comment
);
3356 /*******************************************************************
3357 return the size required by a struct in the stream
3358 ********************************************************************/
3360 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3366 size
+= sec_desc_size( info
->secdesc
);
3368 size
+=size_of_device_mode( info
->devmode
);
3370 size
+=size_of_relative_string( &info
->servername
);
3371 size
+=size_of_relative_string( &info
->printername
);
3372 size
+=size_of_relative_string( &info
->sharename
);
3373 size
+=size_of_relative_string( &info
->portname
);
3374 size
+=size_of_relative_string( &info
->drivername
);
3375 size
+=size_of_relative_string( &info
->comment
);
3376 size
+=size_of_relative_string( &info
->location
);
3378 size
+=size_of_relative_string( &info
->sepfile
);
3379 size
+=size_of_relative_string( &info
->printprocessor
);
3380 size
+=size_of_relative_string( &info
->datatype
);
3381 size
+=size_of_relative_string( &info
->parameters
);
3383 size
+=size_of_uint32( &info
->attributes
);
3384 size
+=size_of_uint32( &info
->priority
);
3385 size
+=size_of_uint32( &info
->defaultpriority
);
3386 size
+=size_of_uint32( &info
->starttime
);
3387 size
+=size_of_uint32( &info
->untiltime
);
3388 size
+=size_of_uint32( &info
->status
);
3389 size
+=size_of_uint32( &info
->cjobs
);
3390 size
+=size_of_uint32( &info
->averageppm
);
3393 * add any adjustments for alignment. This is
3394 * not optimal since we could be calling this
3395 * function from a loop (e.g. enumprinters), but
3396 * it is easier to maintain the calculation here and
3397 * not place the burden on the caller to remember. --jerry
3399 if ((size
% 4) != 0)
3400 size
+= 4 - (size
% 4);
3405 /*******************************************************************
3406 return the size required by a struct in the stream
3407 ********************************************************************/
3409 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3413 size
+=size_of_relative_string( &info
->printername
);
3414 size
+=size_of_relative_string( &info
->servername
);
3416 size
+=size_of_uint32( &info
->attributes
);
3420 /*******************************************************************
3421 return the size required by a struct in the stream
3422 ********************************************************************/
3424 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3428 size
+=size_of_relative_string( &info
->printername
);
3429 size
+=size_of_relative_string( &info
->portname
);
3431 size
+=size_of_uint32( &info
->attributes
);
3432 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3433 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3438 /*******************************************************************
3439 return the size required by a struct in the stream
3440 ********************************************************************/
3442 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3444 /* The 4 is for the self relative pointer.. */
3445 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3446 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3449 /*******************************************************************
3450 return the size required by a struct in the stream
3451 ********************************************************************/
3453 uint32
spoolss_size_printer_info_7(PRINTER_INFO_7
*info
)
3457 size
+=size_of_relative_string( &info
->guid
);
3458 size
+=size_of_uint32( &info
->action
);
3462 /*******************************************************************
3463 return the size required by a struct in the stream
3464 ********************************************************************/
3466 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3469 size
+=size_of_relative_string( &info
->name
);
3474 /*******************************************************************
3475 return the size required by a struct in the stream
3476 ********************************************************************/
3478 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3481 size
+=size_of_uint32( &info
->version
);
3482 size
+=size_of_relative_string( &info
->name
);
3483 size
+=size_of_relative_string( &info
->architecture
);
3484 size
+=size_of_relative_string( &info
->driverpath
);
3485 size
+=size_of_relative_string( &info
->datafile
);
3486 size
+=size_of_relative_string( &info
->configfile
);
3491 /*******************************************************************
3492 return the size required by a string array.
3493 ********************************************************************/
3495 uint32
spoolss_size_string_array(uint16
*string
)
3500 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3502 i
=i
+2; /* to count all chars including the leading zero */
3503 i
=2*i
; /* because we need the value in bytes */
3504 i
=i
+4; /* the offset pointer size */
3509 /*******************************************************************
3510 return the size required by a struct in the stream
3511 ********************************************************************/
3513 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3517 size
+=size_of_uint32( &info
->version
);
3518 size
+=size_of_relative_string( &info
->name
);
3519 size
+=size_of_relative_string( &info
->architecture
);
3520 size
+=size_of_relative_string( &info
->driverpath
);
3521 size
+=size_of_relative_string( &info
->datafile
);
3522 size
+=size_of_relative_string( &info
->configfile
);
3523 size
+=size_of_relative_string( &info
->helpfile
);
3524 size
+=size_of_relative_string( &info
->monitorname
);
3525 size
+=size_of_relative_string( &info
->defaultdatatype
);
3527 size
+=spoolss_size_string_array(info
->dependentfiles
);
3532 /*******************************************************************
3533 return the size required by a struct in the stream
3534 ********************************************************************/
3536 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3540 size
+=size_of_uint32( &info
->version
);
3541 size
+=size_of_relative_string( &info
->name
);
3542 size
+=size_of_relative_string( &info
->architecture
);
3543 size
+=size_of_relative_string( &info
->driverpath
);
3544 size
+=size_of_relative_string( &info
->datafile
);
3545 size
+=size_of_relative_string( &info
->configfile
);
3546 size
+=size_of_relative_string( &info
->helpfile
);
3548 size
+=spoolss_size_string_array(info
->dependentfiles
);
3550 size
+=size_of_relative_string( &info
->monitorname
);
3551 size
+=size_of_relative_string( &info
->defaultdatatype
);
3553 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3555 size
+=size_of_nttime(&info
->driver_date
);
3556 size
+=size_of_uint32( &info
->padding
);
3557 size
+=size_of_uint32( &info
->driver_version_low
);
3558 size
+=size_of_uint32( &info
->driver_version_high
);
3559 size
+=size_of_relative_string( &info
->mfgname
);
3560 size
+=size_of_relative_string( &info
->oem_url
);
3561 size
+=size_of_relative_string( &info
->hardware_id
);
3562 size
+=size_of_relative_string( &info
->provider
);
3567 /*******************************************************************
3568 return the size required by a struct in the stream
3569 ********************************************************************/
3571 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3574 size
+=size_of_uint32( &info
->jobid
);
3575 size
+=size_of_relative_string( &info
->printername
);
3576 size
+=size_of_relative_string( &info
->machinename
);
3577 size
+=size_of_relative_string( &info
->username
);
3578 size
+=size_of_relative_string( &info
->document
);
3579 size
+=size_of_relative_string( &info
->datatype
);
3580 size
+=size_of_relative_string( &info
->text_status
);
3581 size
+=size_of_uint32( &info
->status
);
3582 size
+=size_of_uint32( &info
->priority
);
3583 size
+=size_of_uint32( &info
->position
);
3584 size
+=size_of_uint32( &info
->totalpages
);
3585 size
+=size_of_uint32( &info
->pagesprinted
);
3586 size
+=size_of_systemtime( &info
->submitted
);
3591 /*******************************************************************
3592 return the size required by a struct in the stream
3593 ********************************************************************/
3595 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3599 size
+=4; /* size of sec desc ptr */
3601 size
+=size_of_uint32( &info
->jobid
);
3602 size
+=size_of_relative_string( &info
->printername
);
3603 size
+=size_of_relative_string( &info
->machinename
);
3604 size
+=size_of_relative_string( &info
->username
);
3605 size
+=size_of_relative_string( &info
->document
);
3606 size
+=size_of_relative_string( &info
->notifyname
);
3607 size
+=size_of_relative_string( &info
->datatype
);
3608 size
+=size_of_relative_string( &info
->printprocessor
);
3609 size
+=size_of_relative_string( &info
->parameters
);
3610 size
+=size_of_relative_string( &info
->drivername
);
3611 size
+=size_of_device_mode( info
->devmode
);
3612 size
+=size_of_relative_string( &info
->text_status
);
3613 /* SEC_DESC sec_desc;*/
3614 size
+=size_of_uint32( &info
->status
);
3615 size
+=size_of_uint32( &info
->priority
);
3616 size
+=size_of_uint32( &info
->position
);
3617 size
+=size_of_uint32( &info
->starttime
);
3618 size
+=size_of_uint32( &info
->untiltime
);
3619 size
+=size_of_uint32( &info
->totalpages
);
3620 size
+=size_of_uint32( &info
->size
);
3621 size
+=size_of_systemtime( &info
->submitted
);
3622 size
+=size_of_uint32( &info
->timeelapsed
);
3623 size
+=size_of_uint32( &info
->pagesprinted
);
3628 /*******************************************************************
3629 return the size required by a struct in the stream
3630 ********************************************************************/
3632 uint32
spoolss_size_form_1(FORM_1
*info
)
3636 size
+=size_of_uint32( &info
->flag
);
3637 size
+=size_of_relative_string( &info
->name
);
3638 size
+=size_of_uint32( &info
->width
);
3639 size
+=size_of_uint32( &info
->length
);
3640 size
+=size_of_uint32( &info
->left
);
3641 size
+=size_of_uint32( &info
->top
);
3642 size
+=size_of_uint32( &info
->right
);
3643 size
+=size_of_uint32( &info
->bottom
);
3648 /*******************************************************************
3649 return the size required by a struct in the stream
3650 ********************************************************************/
3652 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3656 size
+=size_of_relative_string( &info
->port_name
);
3661 /*******************************************************************
3662 return the size required by a struct in the stream
3663 ********************************************************************/
3665 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3669 size
=str_len_uni(&info
->name
); /* the string length */
3670 size
=size
+1; /* add the leading zero */
3671 size
=size
*2; /* convert in char */
3676 /*******************************************************************
3677 return the size required by a struct in the stream
3678 ********************************************************************/
3680 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3684 size
=str_len_uni(&info
->name
); /* the string length */
3685 size
=size
+1; /* add the leading zero */
3686 size
=size
*2; /* convert in char */
3691 /*******************************************************************
3692 return the size required by a struct in the stream
3693 ********************************************************************/
3695 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3699 size
+=size_of_relative_string( &info
->port_name
);
3700 size
+=size_of_relative_string( &info
->monitor_name
);
3701 size
+=size_of_relative_string( &info
->description
);
3703 size
+=size_of_uint32( &info
->port_type
);
3704 size
+=size_of_uint32( &info
->reserved
);
3709 /*******************************************************************
3710 return the size required by a struct in the stream
3711 ********************************************************************/
3713 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3716 size
+=size_of_relative_string( &info
->name
);
3721 /*******************************************************************
3722 return the size required by a struct in the stream
3723 ********************************************************************/
3725 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3728 size
+=size_of_relative_string( &info
->name
);
3733 /*******************************************************************
3734 return the size required by a struct in the stream
3735 ********************************************************************/
3736 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3743 /* uint32(offset) + uint32(length) + length) */
3744 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3745 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
+ (p
->data_len
%2) ;
3747 size
+= size_of_uint32(&p
->type
);
3752 /*******************************************************************
3753 return the size required by a struct in the stream
3754 ********************************************************************/
3756 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3759 size
+=size_of_relative_string( &info
->name
);
3764 /*******************************************************************
3765 return the size required by a struct in the stream
3766 ********************************************************************/
3768 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3771 size
+=size_of_relative_string( &info
->name
);
3772 size
+=size_of_relative_string( &info
->environment
);
3773 size
+=size_of_relative_string( &info
->dll_name
);
3778 /*******************************************************************
3780 ********************************************************************/
3782 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3783 const POLICY_HND
*hnd
,
3784 const fstring architecture
,
3785 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3786 NEW_BUFFER
*buffer
, uint32 offered
)
3791 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3793 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3796 q_u
->clientmajorversion
=clientmajor
;
3797 q_u
->clientminorversion
=clientminor
;
3800 q_u
->offered
=offered
;
3805 /*******************************************************************
3807 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3808 ********************************************************************/
3810 BOOL
spoolss_io_q_getprinterdriver2(const char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3812 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3818 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3820 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3822 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3827 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3830 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3836 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3839 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3841 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3847 /*******************************************************************
3849 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3850 ********************************************************************/
3852 BOOL
spoolss_io_r_getprinterdriver2(const char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3854 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3860 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3865 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3867 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3869 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3871 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3877 /*******************************************************************
3879 ********************************************************************/
3881 BOOL
make_spoolss_q_enumprinters(
3882 SPOOL_Q_ENUMPRINTERS
*q_u
,
3892 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3893 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3897 q_u
->offered
=offered
;
3902 /*******************************************************************
3904 ********************************************************************/
3906 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3907 fstring servername
, uint32 level
,
3908 NEW_BUFFER
*buffer
, uint32 offered
)
3910 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3911 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3915 q_u
->offered
=offered
;
3920 /*******************************************************************
3922 * called from spoolss_enumprinters (srv_spoolss.c)
3923 ********************************************************************/
3925 BOOL
spoolss_io_q_enumprinters(const char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3927 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3933 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3935 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3938 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3943 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3946 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3951 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3957 /*******************************************************************
3958 Parse a SPOOL_R_ENUMPRINTERS structure.
3959 ********************************************************************/
3961 BOOL
spoolss_io_r_enumprinters(const char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3963 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3969 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3975 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3978 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3981 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3987 /*******************************************************************
3988 * write a structure.
3989 * called from spoolss_r_enum_printers (srv_spoolss.c)
3991 ********************************************************************/
3993 BOOL
spoolss_io_r_getprinter(const char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3995 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
4001 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4007 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4010 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4016 /*******************************************************************
4018 * called from spoolss_getprinter (srv_spoolss.c)
4019 ********************************************************************/
4021 BOOL
spoolss_io_q_getprinter(const char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4023 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
4029 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4031 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4034 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4039 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4045 /*******************************************************************
4047 ********************************************************************/
4049 BOOL
make_spoolss_q_getprinter(
4050 TALLOC_CTX
*mem_ctx
,
4051 SPOOL_Q_GETPRINTER
*q_u
,
4052 const POLICY_HND
*hnd
,
4062 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4066 q_u
->offered
=offered
;
4071 /*******************************************************************
4073 ********************************************************************/
4074 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
4075 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
4079 DEVICEMODE
*devmode
;
4084 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4087 q_u
->info
.level
= level
;
4088 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
4091 /* There's no such thing as a setprinter level 1 */
4094 secdesc
= info
->printers_2
->secdesc
;
4095 devmode
= info
->printers_2
->devmode
;
4097 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
4098 #if 1 /* JERRY TEST */
4099 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
4100 if (!q_u
->secdesc_ctr
)
4102 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
4103 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4104 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
4105 q_u
->secdesc_ctr
->sec
= secdesc
;
4107 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
4108 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
4109 q_u
->devmode_ctr
.devmode
= devmode
;
4111 q_u
->secdesc_ctr
= NULL
;
4113 q_u
->devmode_ctr
.devmode_ptr
= 0;
4114 q_u
->devmode_ctr
.size
= 0;
4115 q_u
->devmode_ctr
.devmode
= NULL
;
4119 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
4124 q_u
->command
= command
;
4130 /*******************************************************************
4131 ********************************************************************/
4133 BOOL
spoolss_io_r_setprinter(const char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
4135 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
4141 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4147 /*******************************************************************
4148 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
4149 ********************************************************************/
4151 BOOL
spoolss_io_q_setprinter(const char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4153 uint32 ptr_sec_desc
= 0;
4155 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
4161 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
4163 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4166 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4169 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4179 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4184 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4190 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4195 /* Parse a NULL security descriptor. This should really
4196 happen inside the sec_io_desc_buf() function. */
4198 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4199 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4201 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
4205 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4211 /*******************************************************************
4212 ********************************************************************/
4214 BOOL
spoolss_io_r_fcpn(const char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
4216 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
4222 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4228 /*******************************************************************
4229 ********************************************************************/
4231 BOOL
spoolss_io_q_fcpn(const char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
4234 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
4240 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4247 /*******************************************************************
4248 ********************************************************************/
4250 BOOL
spoolss_io_r_addjob(const char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
4252 prs_debug(ps
, depth
, desc
, "");
4258 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4264 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4267 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4273 /*******************************************************************
4274 ********************************************************************/
4276 BOOL
spoolss_io_q_addjob(const char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
4278 prs_debug(ps
, depth
, desc
, "");
4284 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4286 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4289 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4295 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4301 /*******************************************************************
4302 ********************************************************************/
4304 BOOL
spoolss_io_r_enumjobs(const char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
4306 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
4312 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4318 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4321 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4324 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4330 /*******************************************************************
4331 ********************************************************************/
4333 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4344 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4345 q_u
->firstjob
= firstjob
;
4346 q_u
->numofjobs
= numofjobs
;
4348 q_u
->buffer
= buffer
;
4349 q_u
->offered
= offered
;
4353 /*******************************************************************
4354 ********************************************************************/
4356 BOOL
spoolss_io_q_enumjobs(const char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4358 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4364 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4367 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4369 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
4371 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4374 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4380 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4386 /*******************************************************************
4387 ********************************************************************/
4389 BOOL
spoolss_io_r_schedulejob(const char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4391 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4397 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4403 /*******************************************************************
4404 ********************************************************************/
4406 BOOL
spoolss_io_q_schedulejob(const char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4408 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4414 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4416 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4422 /*******************************************************************
4423 ********************************************************************/
4425 BOOL
spoolss_io_r_setjob(const char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4427 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4433 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4439 /*******************************************************************
4440 ********************************************************************/
4442 BOOL
spoolss_io_q_setjob(const char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4444 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4450 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4452 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4455 * level is usually 0. If (level!=0) then I'm in trouble !
4456 * I will try to generate setjob command with level!=0, one day.
4458 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4460 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4466 /*******************************************************************
4467 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4468 ********************************************************************/
4470 BOOL
spoolss_io_r_enumprinterdrivers(const char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4472 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4478 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4484 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4487 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4490 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4496 /*******************************************************************
4498 ********************************************************************/
4500 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4502 const char *environment
,
4504 NEW_BUFFER
*buffer
, uint32 offered
)
4506 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4507 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4511 q_u
->offered
=offered
;
4516 /*******************************************************************
4517 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4518 ********************************************************************/
4520 BOOL
spoolss_io_q_enumprinterdrivers(const char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4523 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4529 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4531 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4536 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4538 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4543 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4546 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4552 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4558 /*******************************************************************
4559 ********************************************************************/
4561 BOOL
spoolss_io_q_enumforms(const char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4564 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4569 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4571 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4574 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4579 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4585 /*******************************************************************
4586 ********************************************************************/
4588 BOOL
spoolss_io_r_enumforms(const char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4590 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4596 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4602 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4605 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4608 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4614 /*******************************************************************
4615 ********************************************************************/
4617 BOOL
spoolss_io_q_getform(const char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4620 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4625 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4627 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4633 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4636 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4641 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4647 /*******************************************************************
4648 ********************************************************************/
4650 BOOL
spoolss_io_r_getform(const char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4652 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4658 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4664 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4667 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4673 /*******************************************************************
4674 Parse a SPOOL_R_ENUMPORTS structure.
4675 ********************************************************************/
4677 BOOL
spoolss_io_r_enumports(const char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4679 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4685 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4691 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4694 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4697 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4703 /*******************************************************************
4704 ********************************************************************/
4706 BOOL
spoolss_io_q_enumports(const char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4708 prs_debug(ps
, depth
, desc
, "");
4714 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4716 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4721 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4724 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4729 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4735 /*******************************************************************
4736 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4737 ********************************************************************/
4739 BOOL
spool_io_printer_info_level_1(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4741 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4747 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4749 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4751 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4753 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4756 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4758 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4760 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4766 /*******************************************************************
4767 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4768 ********************************************************************/
4770 BOOL
spool_io_printer_info_level_3(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4772 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4778 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4784 /*******************************************************************
4785 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4786 ********************************************************************/
4788 BOOL
spool_io_printer_info_level_2(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4790 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4796 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4798 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4800 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4802 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4805 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4807 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4809 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4811 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4813 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4815 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4817 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4819 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4821 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4824 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4826 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4828 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4830 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4832 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4834 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4836 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4838 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4841 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4843 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4845 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4847 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4849 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4851 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4853 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4855 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4857 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4859 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4861 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4867 BOOL
spool_io_printer_info_level_7(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_7
*il
, prs_struct
*ps
, int depth
)
4869 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_7");
4875 if(!prs_uint32("guid_ptr", ps
, depth
, &il
->guid_ptr
))
4877 if(!prs_uint32("action", ps
, depth
, &il
->action
))
4880 if(!smb_io_unistr2("servername", &il
->guid
, il
->guid_ptr
, ps
, depth
))
4885 /*******************************************************************
4886 ********************************************************************/
4888 BOOL
spool_io_printer_info_level(const char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4890 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4895 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4897 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4900 /* if no struct inside just return */
4901 if (il
->info_ptr
==0) {
4902 if (UNMARSHALLING(ps
)) {
4909 switch (il
->level
) {
4911 * level 0 is used by setprinter when managing the queue
4912 * (hold, stop, start a queue)
4916 /* DOCUMENT ME!!! What is level 1 used for? */
4919 if (UNMARSHALLING(ps
)) {
4920 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4923 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4928 * level 2 is used by addprinter
4929 * and by setprinter when updating printer's info
4932 if (UNMARSHALLING(ps
)) {
4933 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4936 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4939 /* DOCUMENT ME!!! What is level 3 used for? */
4942 if (UNMARSHALLING(ps
)) {
4943 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4946 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4951 if (UNMARSHALLING(ps
))
4952 if ((il
->info_7
=(SPOOL_PRINTER_INFO_LEVEL_7
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_7
))) == NULL
)
4954 if (!spool_io_printer_info_level_7("", il
->info_7
, ps
, depth
))
4962 /*******************************************************************
4963 ********************************************************************/
4965 BOOL
spoolss_io_q_addprinterex(const char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4967 uint32 ptr_sec_desc
= 0;
4969 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4974 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4976 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4982 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4985 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4988 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4994 switch (q_u
->level
) {
4996 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4999 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
5003 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
5008 /* Parse a NULL security descriptor. This should really
5009 happen inside the sec_io_desc_buf() function. */
5011 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
5012 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
5014 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
5018 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
5020 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
5026 /*******************************************************************
5027 ********************************************************************/
5029 BOOL
spoolss_io_r_addprinterex(const char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
5030 prs_struct
*ps
, int depth
)
5032 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
5035 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5038 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5044 /*******************************************************************
5045 ********************************************************************/
5047 BOOL
spool_io_printer_driver_info_level_3(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
5048 prs_struct
*ps
, int depth
)
5050 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
5052 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
5056 if (UNMARSHALLING(ps
)) {
5057 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
5069 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
5071 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
5073 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
5075 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
5077 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
5079 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
5081 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
5083 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
5085 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5087 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
5089 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
5095 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5097 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5099 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5101 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5103 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5105 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5107 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5109 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5115 if (il
->dependentfiles_ptr
)
5116 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
5121 /*******************************************************************
5122 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
5123 ********************************************************************/
5125 BOOL
spool_io_printer_driver_info_level_6(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
5126 prs_struct
*ps
, int depth
)
5128 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
5130 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
5134 if (UNMARSHALLING(ps
)) {
5135 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
5148 * I know this seems weird, but I have no other explanation.
5149 * This is observed behavior on both NT4 and 2K servers.
5153 if (!prs_align_uint64(ps
))
5156 /* parse the main elements the packet */
5158 if(!prs_uint32("cversion ", ps
, depth
, &il
->version
))
5160 if(!prs_uint32("name ", ps
, depth
, &il
->name_ptr
))
5162 if(!prs_uint32("environment ", ps
, depth
, &il
->environment_ptr
))
5164 if(!prs_uint32("driverpath ", ps
, depth
, &il
->driverpath_ptr
))
5166 if(!prs_uint32("datafile ", ps
, depth
, &il
->datafile_ptr
))
5168 if(!prs_uint32("configfile ", ps
, depth
, &il
->configfile_ptr
))
5170 if(!prs_uint32("helpfile ", ps
, depth
, &il
->helpfile_ptr
))
5172 if(!prs_uint32("monitorname ", ps
, depth
, &il
->monitorname_ptr
))
5174 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
5176 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_len
))
5178 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_ptr
))
5180 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_len
))
5182 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_ptr
))
5184 if(!smb_io_time("driverdate ", &il
->driverdate
, ps
, depth
))
5186 if(!prs_uint32("dummy4 ", ps
, depth
, &il
->dummy4
))
5188 if(!prs_uint64("driverversion ", ps
, depth
, &il
->driverversion
))
5190 if(!prs_uint32("mfgname ", ps
, depth
, &il
->mfgname_ptr
))
5192 if(!prs_uint32("oemurl ", ps
, depth
, &il
->oemurl_ptr
))
5194 if(!prs_uint32("hardwareid ", ps
, depth
, &il
->hardwareid_ptr
))
5196 if(!prs_uint32("provider ", ps
, depth
, &il
->provider_ptr
))
5199 /* parse the structures in the packet */
5201 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
5206 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
5211 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5216 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5221 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5226 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5231 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5236 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5240 if (il
->dependentfiles_ptr
) {
5241 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
5246 if (il
->previousnames_ptr
) {
5247 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
5252 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
5256 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
5260 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
5264 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
5270 /*******************************************************************
5271 convert a buffer of UNICODE strings null terminated
5272 the buffer is terminated by a NULL
5274 convert to an dos codepage array (null terminated)
5276 dynamically allocate memory
5278 ********************************************************************/
5279 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
5288 src
= (char *)buf5
->buffer
;
5291 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
5292 rpcstr_pull(f
, src
, sizeof(f
)-1, -1, STR_TERMINATE
);
5293 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
5294 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
5299 fstrcpy((*ar
)[n
], f
);
5302 fstrcpy((*ar
)[n
], "");
5310 /*******************************************************************
5311 read a UNICODE array with null terminated strings
5312 and null terminated array
5313 and size of array at beginning
5314 ********************************************************************/
5316 BOOL
smb_io_unibuffer(const char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
5318 if (buffer
==NULL
) return False
;
5321 buffer
->uni_str_len
=buffer
->uni_max_len
;
5323 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
5326 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
5332 /*******************************************************************
5333 ********************************************************************/
5335 BOOL
spool_io_printer_driver_info_level(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
5337 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
5342 if(!prs_uint32("level", ps
, depth
, &il
->level
))
5344 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
5350 switch (il
->level
) {
5352 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
5356 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5366 /*******************************************************************
5367 init a SPOOL_Q_ADDPRINTERDRIVER struct
5368 ******************************************************************/
5370 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5371 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5372 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5374 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5376 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
5377 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
5381 q_u
->info
.level
= level
;
5382 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
5385 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5387 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5391 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5398 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5399 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5400 DRIVER_INFO_3
*info3
)
5403 uint16
*ptr
= info3
->dependentfiles
;
5405 BOOL null_char
= False
;
5406 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5408 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
5411 inf
->cversion
= info3
->version
;
5412 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5413 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5414 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5415 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5416 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5417 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5418 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5419 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5421 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5422 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5423 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5424 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5425 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5426 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5427 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5428 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5435 /* the null_char BOOL is used to help locate
5436 two '\0's back to back */
5451 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5452 inf
->dependentfilessize
= len
;
5453 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5459 *spool_drv_info
= inf
;
5464 /*******************************************************************
5465 make a BUFFER5 struct from a uint16*
5466 ******************************************************************/
5467 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5470 buf5
->buf_len
= len
;
5471 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5473 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5480 /*******************************************************************
5481 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5482 ********************************************************************/
5484 BOOL
spoolss_io_q_addprinterdriver(const char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5486 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5492 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5494 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5499 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5502 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5508 /*******************************************************************
5509 ********************************************************************/
5511 BOOL
spoolss_io_r_addprinterdriver(const char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5513 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5516 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5522 /*******************************************************************
5523 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5524 ********************************************************************/
5526 BOOL
spoolss_io_q_addprinterdriverex(const char *desc
, SPOOL_Q_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5528 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriverex");
5534 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5536 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5541 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5544 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5549 if(!prs_uint32("copy flags", ps
, depth
, &q_u
->copy_flags
))
5555 /*******************************************************************
5556 ********************************************************************/
5558 BOOL
spoolss_io_r_addprinterdriverex(const char *desc
, SPOOL_R_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5560 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriverex");
5563 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5569 /*******************************************************************
5570 ********************************************************************/
5572 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5573 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5575 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5577 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5581 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5589 d
->cversion
=uni
->cversion
;
5591 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5592 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5593 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5594 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5595 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5596 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5597 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5598 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5600 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5601 DEBUGADD(8,( "name: %s\n", d
->name
));
5602 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5603 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5604 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5605 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5606 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5607 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5608 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5610 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5617 /*******************************************************************
5618 ********************************************************************/
5619 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5620 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5622 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5624 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5628 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5636 d
->version
=uni
->version
;
5638 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5639 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5640 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5641 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5642 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5643 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5644 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5645 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5647 DEBUGADD(8,( "version: %d\n", d
->version
));
5648 DEBUGADD(8,( "name: %s\n", d
->name
));
5649 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5650 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5651 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5652 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5653 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5654 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5655 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5657 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5659 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5669 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5670 NT_PRINTER_INFO_LEVEL_2
**asc
)
5672 NT_PRINTER_INFO_LEVEL_2
*d
;
5675 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5676 time_unix
=time(NULL
);
5679 DEBUGADD(8,("allocating memory\n"));
5681 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5686 /* we allocate memory iff called from
5687 * addprinter(ex) so we can do one time stuff here.
5689 (*asc
)->setuptime
=time_unix
;
5692 DEBUGADD(8,("start converting\n"));
5696 d
->attributes
=uni
->attributes
;
5697 d
->priority
=uni
->priority
;
5698 d
->default_priority
=uni
->default_priority
;
5699 d
->starttime
=uni
->starttime
;
5700 d
->untiltime
=uni
->untiltime
;
5701 d
->status
=uni
->status
;
5702 d
->cjobs
=uni
->cjobs
;
5704 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5705 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5706 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5707 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5708 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5709 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5710 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5711 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5712 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5713 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5714 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5719 /*******************************************************************
5721 ********************************************************************/
5723 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5724 fstring servername
, fstring env_name
, uint32 level
,
5725 NEW_BUFFER
*buffer
, uint32 offered
)
5727 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5728 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5732 q_u
->offered
=offered
;
5737 /*******************************************************************
5738 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5739 ********************************************************************/
5741 BOOL
spoolss_io_q_getprinterdriverdir(const char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5743 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5748 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5750 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5756 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5758 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5764 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5767 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5773 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5779 /*******************************************************************
5780 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5781 ********************************************************************/
5783 BOOL
spoolss_io_r_getprinterdriverdir(const char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5785 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5791 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5797 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5800 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5806 /*******************************************************************
5807 ********************************************************************/
5809 BOOL
spoolss_io_r_enumprintprocessors(const char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5811 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5817 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5823 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5826 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5829 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5835 /*******************************************************************
5836 ********************************************************************/
5838 BOOL
spoolss_io_q_enumprintprocessors(const char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5840 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5846 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5848 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5854 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5856 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5862 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5865 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5871 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5877 /*******************************************************************
5878 ********************************************************************/
5880 BOOL
spoolss_io_q_addprintprocessor(const char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5882 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5888 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5890 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5895 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5900 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5905 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5911 /*******************************************************************
5912 ********************************************************************/
5914 BOOL
spoolss_io_r_addprintprocessor(const char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5916 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5922 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5928 /*******************************************************************
5929 ********************************************************************/
5931 BOOL
spoolss_io_r_enumprintprocdatatypes(const char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5933 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5939 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5945 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5948 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5951 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5957 /*******************************************************************
5958 ********************************************************************/
5960 BOOL
spoolss_io_q_enumprintprocdatatypes(const char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5962 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5968 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5970 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5976 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5978 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5984 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5987 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5993 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5999 /*******************************************************************
6000 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
6001 ********************************************************************/
6003 BOOL
spoolss_io_q_enumprintmonitors(const char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
6005 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
6011 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
6013 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6019 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
6022 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6028 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6034 /*******************************************************************
6035 ********************************************************************/
6037 BOOL
spoolss_io_r_enumprintmonitors(const char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
6039 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
6045 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6051 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6054 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6057 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6063 /*******************************************************************
6064 ********************************************************************/
6066 BOOL
spoolss_io_r_enumprinterdata(const char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6068 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
6073 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
6076 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
6077 r_u
->value
= (uint16
*)prs_alloc_mem(ps
, r_u
->valuesize
* 2);
6079 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
6084 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
6090 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
6093 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
6096 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
6099 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
6100 r_u
->data
= (uint8
*)prs_alloc_mem(ps
, r_u
->datasize
);
6102 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
6107 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
6112 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
6114 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6120 /*******************************************************************
6121 ********************************************************************/
6123 BOOL
spoolss_io_q_enumprinterdata(const char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6125 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
6130 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6132 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
6134 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
6136 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
6142 /*******************************************************************
6143 ********************************************************************/
6145 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
6146 const POLICY_HND
*hnd
,
6147 uint32 idx
, uint32 valuelen
, uint32 datalen
)
6149 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6151 q_u
->valuesize
=valuelen
;
6152 q_u
->datasize
=datalen
;
6157 /*******************************************************************
6158 ********************************************************************/
6160 BOOL
make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX
*q_u
,
6161 const POLICY_HND
*hnd
, const char *key
,
6164 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6165 init_unistr2(&q_u
->key
, key
, strlen(key
)+1);
6171 /*******************************************************************
6172 ********************************************************************/
6173 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, const POLICY_HND
*hnd
,
6174 char* value
, uint32 data_type
, char* data
, uint32 data_size
)
6176 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6177 q_u
->type
= data_type
;
6178 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
6180 q_u
->max_len
= q_u
->real_len
= data_size
;
6186 /*******************************************************************
6187 ********************************************************************/
6188 BOOL
make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX
*q_u
, const POLICY_HND
*hnd
,
6189 char *key
, char* value
, uint32 data_type
, char* data
,
6192 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6193 q_u
->type
= data_type
;
6194 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
6195 init_unistr2(&q_u
->key
, key
, strlen(key
)+1);
6197 q_u
->max_len
= q_u
->real_len
= data_size
;
6203 /*******************************************************************
6204 ********************************************************************/
6206 BOOL
spoolss_io_q_setprinterdata(const char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
6208 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
6213 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6215 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6221 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6224 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6234 if (UNMARSHALLING(ps
))
6235 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6236 if(q_u
->data
== NULL
)
6238 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6246 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6252 /*******************************************************************
6253 ********************************************************************/
6255 BOOL
spoolss_io_r_setprinterdata(const char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6257 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
6262 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6268 /*******************************************************************
6269 ********************************************************************/
6270 BOOL
spoolss_io_q_resetprinter(const char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6272 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
6277 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6280 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
6283 if (q_u
->datatype_ptr
) {
6284 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
6288 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
6295 /*******************************************************************
6296 ********************************************************************/
6297 BOOL
spoolss_io_r_resetprinter(const char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6299 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
6304 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6310 /*******************************************************************
6311 ********************************************************************/
6313 static BOOL
spoolss_io_addform(const char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
6315 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
6322 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
6324 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
6326 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
6328 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
6330 if(!prs_uint32("left", ps
, depth
, &f
->left
))
6332 if(!prs_uint32("top", ps
, depth
, &f
->top
))
6334 if(!prs_uint32("right", ps
, depth
, &f
->right
))
6336 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
6339 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
6346 /*******************************************************************
6347 ********************************************************************/
6349 BOOL
spoolss_io_q_deleteform(const char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
6351 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
6356 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6358 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
6364 /*******************************************************************
6365 ********************************************************************/
6367 BOOL
spoolss_io_r_deleteform(const char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
6369 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
6374 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6380 /*******************************************************************
6381 ********************************************************************/
6383 BOOL
spoolss_io_q_addform(const char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
6385 uint32 useless_ptr
=1;
6386 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
6391 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6393 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6395 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6400 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6402 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6409 /*******************************************************************
6410 ********************************************************************/
6412 BOOL
spoolss_io_r_addform(const char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6414 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6419 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6425 /*******************************************************************
6426 ********************************************************************/
6428 BOOL
spoolss_io_q_setform(const char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6430 uint32 useless_ptr
=1;
6431 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6436 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6438 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6444 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6446 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6451 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6453 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6460 /*******************************************************************
6461 ********************************************************************/
6463 BOOL
spoolss_io_r_setform(const char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6465 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6470 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6476 /*******************************************************************
6477 Parse a SPOOL_R_GETJOB structure.
6478 ********************************************************************/
6480 BOOL
spoolss_io_r_getjob(const char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6482 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6488 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6494 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6497 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6503 /*******************************************************************
6504 Parse a SPOOL_Q_GETJOB structure.
6505 ********************************************************************/
6507 BOOL
spoolss_io_q_getjob(const char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6509 prs_debug(ps
, depth
, desc
, "");
6515 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6517 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6519 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6522 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6528 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6534 void free_devmode(DEVICEMODE
*devmode
)
6536 if (devmode
!=NULL
) {
6537 SAFE_FREE(devmode
->private);
6542 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6547 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6549 if (printer
!=NULL
) {
6550 free_devmode(printer
->devmode
);
6551 printer
->devmode
= NULL
;
6556 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6561 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6566 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6571 void free_printer_info_7(PRINTER_INFO_7
*printer
)
6576 void free_job_info_2(JOB_INFO_2
*job
)
6579 free_devmode(job
->devmode
);
6582 /*******************************************************************
6584 ********************************************************************/
6586 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6587 const fstring string
, uint32 printer
, uint32 type
)
6592 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
6594 q_u
->printer
=printer
;
6603 /*******************************************************************
6604 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6605 ********************************************************************/
6607 BOOL
spoolss_io_q_replyopenprinter(const char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6609 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6615 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6621 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6623 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6626 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6628 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6634 /*******************************************************************
6635 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6636 ********************************************************************/
6638 BOOL
spoolss_io_r_replyopenprinter(const char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6640 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6646 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6649 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6655 /*******************************************************************
6657 ********************************************************************/
6658 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6659 uint32 condition
, uint32 change_id
)
6662 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6664 q_u
->condition
= condition
;
6665 q_u
->change_id
= change_id
;
6668 q_u
->unknown1
= 0x1;
6669 memset(q_u
->unknown2
, 0x0, 5);
6670 q_u
->unknown2
[0] = 0x1;
6675 /*******************************************************************
6676 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6677 ********************************************************************/
6678 BOOL
spoolss_io_q_routerreplyprinter (const char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6681 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6687 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6690 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6693 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6696 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6699 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6705 /*******************************************************************
6706 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6707 ********************************************************************/
6708 BOOL
spoolss_io_r_routerreplyprinter (const char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6710 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6716 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6722 /*******************************************************************
6724 ********************************************************************/
6726 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6731 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6736 /*******************************************************************
6737 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6738 ********************************************************************/
6740 BOOL
spoolss_io_q_replycloseprinter(const char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6742 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6748 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6754 /*******************************************************************
6755 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6756 ********************************************************************/
6758 BOOL
spoolss_io_r_replycloseprinter(const char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6760 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6766 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6769 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6775 #if 0 /* JERRY - not currently used but could be :-) */
6777 /*******************************************************************
6778 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6779 ******************************************************************/
6780 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6781 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6785 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6787 for (i
=0; i
<n
; i
++) {
6791 if (src
->size
!= POINTER
)
6793 len
= src
->notify_data
.data
.length
;
6794 s
= malloc(sizeof(uint16
)*len
);
6796 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6800 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6801 dst
->notify_data
.data
.string
= s
;
6807 /*******************************************************************
6808 Deep copy a SPOOL_NOTIFY_INFO structure
6809 ******************************************************************/
6810 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6813 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6817 dst
->version
= src
->version
;
6818 dst
->flags
= src
->flags
;
6819 dst
->count
= src
->count
;
6823 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6825 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6828 if (dst
->data
== NULL
) {
6829 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6834 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6841 /*******************************************************************
6843 ********************************************************************/
6845 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6846 uint32 change_low
, uint32 change_high
,
6847 SPOOL_NOTIFY_INFO
*info
)
6852 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6854 q_u
->change_low
=change_low
;
6855 q_u
->change_high
=change_high
;
6860 q_u
->info_ptr
=0x0FF0ADDE;
6862 q_u
->info
.version
=2;
6865 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6867 q_u
->info
.version
= info
->version
;
6868 q_u
->info
.flags
= info
->flags
;
6869 q_u
->info
.count
= info
->count
;
6870 /* pointer field - be careful! */
6871 q_u
->info
.data
= info
->data
;
6874 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6881 /*******************************************************************
6882 Parse a SPOOL_Q_REPLY_RRPCN structure.
6883 ********************************************************************/
6885 BOOL
spoolss_io_q_reply_rrpcn(const char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6887 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6893 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6896 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6899 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6902 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6905 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6908 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6911 if(q_u
->info_ptr
!=0)
6912 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6918 /*******************************************************************
6919 Parse a SPOOL_R_REPLY_RRPCN structure.
6920 ********************************************************************/
6922 BOOL
spoolss_io_r_reply_rrpcn(const char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6924 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6930 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6933 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6939 /*******************************************************************
6941 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6942 ********************************************************************/
6944 BOOL
spoolss_io_q_getprinterdataex(const char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6949 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6954 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6958 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6962 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6966 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6972 /*******************************************************************
6973 * write a structure.
6974 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6975 ********************************************************************/
6977 BOOL
spoolss_io_r_getprinterdataex(const char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6982 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6987 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6989 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6992 if (UNMARSHALLING(ps
) && r_u
->size
) {
6993 r_u
->data
= prs_alloc_mem(ps
, r_u
->size
);
6998 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
7004 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7006 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
7012 /*******************************************************************
7014 ********************************************************************/
7016 BOOL
spoolss_io_q_setprinterdataex(const char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7018 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
7023 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7025 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7031 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
7037 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
7040 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
7050 if (UNMARSHALLING(ps
))
7051 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
7052 if(q_u
->data
== NULL
)
7054 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
7062 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
7068 /*******************************************************************
7069 * write a structure.
7070 ********************************************************************/
7072 BOOL
spoolss_io_r_setprinterdataex(const char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7074 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
7079 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7085 /*******************************************************************
7087 ********************************************************************/
7088 BOOL
make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY
*q_u
,
7089 POLICY_HND
*hnd
, const char *key
,
7092 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
7094 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7095 init_unistr2(&q_u
->key
, key
, strlen(key
)+1);
7101 /*******************************************************************
7103 ********************************************************************/
7105 BOOL
spoolss_io_q_enumprinterkey(const char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7107 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
7112 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7115 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7121 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7127 /*******************************************************************
7128 * write a structure.
7129 ********************************************************************/
7131 BOOL
spoolss_io_r_enumprinterkey(const char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7133 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
7139 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
7145 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7148 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7154 /*******************************************************************
7156 ********************************************************************/
7158 BOOL
make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY
*q_u
,
7159 POLICY_HND
*hnd
, char *keyname
)
7161 DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
7163 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
7164 init_unistr2(&q_u
->keyname
, keyname
, strlen(keyname
)+1);
7169 /*******************************************************************
7171 ********************************************************************/
7173 BOOL
spoolss_io_q_deleteprinterkey(const char *desc
, SPOOL_Q_DELETEPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
7175 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterkey");
7180 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7183 if(!smb_io_unistr2("", &q_u
->keyname
, True
, ps
, depth
))
7189 /*******************************************************************
7190 * write a structure.
7191 ********************************************************************/
7193 BOOL
spoolss_io_r_deleteprinterkey(const char *desc
, SPOOL_R_DELETEPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
7195 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterkey");
7201 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7208 /*******************************************************************
7210 ********************************************************************/
7212 BOOL
spoolss_io_q_enumprinterdataex(const char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
7214 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
7219 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7222 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7228 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7234 /*******************************************************************
7235 ********************************************************************/
7237 static BOOL
spoolss_io_printer_enum_values_ctr(const char *desc
, prs_struct
*ps
,
7238 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
7241 uint32 valuename_offset
,
7244 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
7246 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
7250 * offset data begins at 20 bytes per structure * size_of_array.
7251 * Don't forget the uint32 at the beginning
7254 current_offset
= basic_unit
* ctr
->size_of_array
;
7256 /* first loop to write basic enum_value information */
7258 if (UNMARSHALLING(ps
)) {
7259 ctr
->values
= (PRINTER_ENUM_VALUES
*)prs_alloc_mem(
7260 ps
, ctr
->size_of_array
* sizeof(PRINTER_ENUM_VALUES
));
7265 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7266 valuename_offset
= current_offset
;
7267 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
7270 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
7273 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
7276 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
7278 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
7281 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
7284 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
7285 /* account for 2 byte alignment */
7286 current_offset
+= (current_offset
% 2);
7290 * loop #2 for writing the dynamically size objects; pay
7291 * attention to 2-byte alignment here....
7294 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7296 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
7299 if (UNMARSHALLING(ps
)) {
7300 ctr
->values
[i
].data
= (uint8
*)prs_alloc_mem(
7301 ps
, ctr
->values
[i
].data_len
);
7302 if (!ctr
->values
[i
].data
)
7306 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
7309 if ( !prs_align_uint16(ps
) )
7316 /*******************************************************************
7317 * write a structure.
7318 ********************************************************************/
7320 BOOL
spoolss_io_r_enumprinterdataex(const char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7322 uint32 data_offset
, end_offset
;
7323 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
7329 if (!prs_uint32("size", ps
, depth
, &r_u
->ctr
.size
))
7332 data_offset
= prs_offset(ps
);
7334 if (!prs_set_offset(ps
, data_offset
+ r_u
->ctr
.size
))
7340 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7343 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
7346 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7349 r_u
->ctr
.size_of_array
= r_u
->returned
;
7351 end_offset
= prs_offset(ps
);
7353 if (!prs_set_offset(ps
, data_offset
))
7357 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
7360 if (!prs_set_offset(ps
, end_offset
))
7365 /*******************************************************************
7366 * write a structure.
7367 ********************************************************************/
7370 uint32 GetPrintProcessorDirectory(
7372 [in] unistr2 *environment,
7374 [in,out] NEW_BUFFER buffer,
7375 [in] uint32 offered,
7376 [out] uint32 needed,
7377 [out] uint32 returned
7382 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, NEW_BUFFER
*buffer
, uint32 offered
)
7384 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
7386 init_unistr2(&q_u
->name
, name
, strlen(name
)+1);
7387 init_unistr2(&q_u
->environment
, environment
, strlen(environment
)+1);
7391 q_u
->buffer
= buffer
;
7392 q_u
->offered
= offered
;
7397 BOOL
spoolss_io_q_getprintprocessordirectory(const char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
7401 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
7407 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7411 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
7418 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7422 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
7430 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7433 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
7439 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
7445 /*******************************************************************
7446 * write a structure.
7447 ********************************************************************/
7449 BOOL
spoolss_io_r_getprintprocessordirectory(const char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
7451 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
7457 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
7463 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7466 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7472 BOOL
smb_io_printprocessordirectory_1(const char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
7474 prs_struct
*ps
=&buffer
->prs
;
7476 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
7479 buffer
->struct_start
=prs_offset(ps
);
7481 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
7487 /*******************************************************************
7489 ********************************************************************/
7491 BOOL
make_spoolss_q_addform(SPOOL_Q_ADDFORM
*q_u
, POLICY_HND
*handle
,
7492 int level
, FORM
*form
)
7494 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7496 q_u
->level2
= level
;
7497 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7502 /*******************************************************************
7504 ********************************************************************/
7506 BOOL
make_spoolss_q_setform(SPOOL_Q_SETFORM
*q_u
, POLICY_HND
*handle
,
7507 int level
, const char *form_name
, FORM
*form
)
7509 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7511 q_u
->level2
= level
;
7512 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7513 init_unistr2(&q_u
->name
, form_name
, strlen(form_name
) + 1);
7518 /*******************************************************************
7520 ********************************************************************/
7522 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
,
7525 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7526 init_unistr2(&q_u
->name
, form
, strlen(form
) + 1);
7530 /*******************************************************************
7532 ********************************************************************/
7534 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7535 const char *formname
, uint32 level
,
7536 NEW_BUFFER
*buffer
, uint32 offered
)
7538 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7540 init_unistr2(&q_u
->formname
, formname
, strlen(formname
) + 1);
7542 q_u
->offered
=offered
;
7547 /*******************************************************************
7549 ********************************************************************/
7551 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7552 uint32 level
, NEW_BUFFER
*buffer
,
7555 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7558 q_u
->offered
=offered
;
7563 /*******************************************************************
7565 ********************************************************************/
7567 BOOL
make_spoolss_q_setjob(SPOOL_Q_SETJOB
*q_u
, POLICY_HND
*handle
,
7568 uint32 jobid
, uint32 level
, uint32 command
)
7570 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7574 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7575 the server side code has it marked as unused. */
7577 q_u
->command
= command
;
7582 /*******************************************************************
7584 ********************************************************************/
7586 BOOL
make_spoolss_q_getjob(SPOOL_Q_GETJOB
*q_u
, POLICY_HND
*handle
,
7587 uint32 jobid
, uint32 level
, NEW_BUFFER
*buffer
,
7590 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7593 q_u
->buffer
= buffer
;
7594 q_u
->offered
= offered
;
7599 /*******************************************************************
7601 ********************************************************************/
7603 BOOL
make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER
*q_u
,
7606 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7611 /*******************************************************************
7613 ********************************************************************/
7615 BOOL
make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER
*q_u
,
7618 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7623 /*******************************************************************
7625 ********************************************************************/
7627 BOOL
make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER
*q_u
,
7628 POLICY_HND
*handle
, uint32 level
,
7629 char *docname
, char *outputfile
,
7632 DOC_INFO_CONTAINER
*ctr
= &q_u
->doc_info_container
;
7634 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7640 ctr
->docinfo
.switch_value
= level
;
7642 ctr
->docinfo
.doc_info_1
.p_docname
= docname
? 1 : 0;
7643 ctr
->docinfo
.doc_info_1
.p_outputfile
= outputfile
? 1 : 0;
7644 ctr
->docinfo
.doc_info_1
.p_datatype
= datatype
? 1 : 0;
7647 init_unistr2(&ctr
->docinfo
.doc_info_1
.docname
, docname
,
7648 strlen(docname
) + 1);
7651 init_unistr2(&ctr
->docinfo
.doc_info_1
.outputfile
, outputfile
,
7652 strlen(outputfile
) + 1);
7655 init_unistr2(&ctr
->docinfo
.doc_info_1
.datatype
, datatype
,
7656 strlen(datatype
) + 1);
7660 /* DOC_INFO_2 is only used by Windows 9x and since it
7661 doesn't do printing over RPC we don't have to worry
7664 DEBUG(3, ("unsupported info level %d\n", level
));
7671 /*******************************************************************
7673 ********************************************************************/
7675 BOOL
make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER
*q_u
,
7678 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7683 /*******************************************************************
7685 ********************************************************************/
7687 BOOL
make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER
*q_u
,
7688 POLICY_HND
*handle
, uint32 data_size
,
7691 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7692 q_u
->buffer_size
= q_u
->buffer_size2
= data_size
;
7697 /*******************************************************************
7699 ********************************************************************/
7701 BOOL
make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA
*q_u
,
7702 POLICY_HND
*handle
, char *valuename
)
7704 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7705 init_unistr2(&q_u
->valuename
, valuename
, strlen(valuename
) + 1);
7710 /*******************************************************************
7712 ********************************************************************/
7714 BOOL
make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX
*q_u
,
7715 POLICY_HND
*handle
, char *key
,
7718 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7719 init_unistr2(&q_u
->valuename
, value
, strlen(value
) + 1);
7720 init_unistr2(&q_u
->keyname
, key
, strlen(key
) + 1);
7725 /*******************************************************************
7727 ********************************************************************/
7729 BOOL
make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX
*q_u
, POLICY_HND
*handle
,
7730 uint32 flags
, uint32 options
, const char *localmachine
,
7731 uint32 printerlocal
, SPOOL_NOTIFY_OPTION
*option
)
7733 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7736 q_u
->options
= options
;
7738 q_u
->localmachine_ptr
= 1;
7740 init_unistr2(&q_u
->localmachine
, localmachine
,
7741 strlen(localmachine
) + 1);
7743 q_u
->printerlocal
= printerlocal
;
7746 q_u
->option_ptr
= 1;
7748 q_u
->option
= option
;