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
31 /*******************************************************************
32 This should be moved in a more generic lib.
33 ********************************************************************/
35 BOOL
spoolss_io_system_time(const char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
37 if(!prs_uint16("year", ps
, depth
, &systime
->year
))
39 if(!prs_uint16("month", ps
, depth
, &systime
->month
))
41 if(!prs_uint16("dayofweek", ps
, depth
, &systime
->dayofweek
))
43 if(!prs_uint16("day", ps
, depth
, &systime
->day
))
45 if(!prs_uint16("hour", ps
, depth
, &systime
->hour
))
47 if(!prs_uint16("minute", ps
, depth
, &systime
->minute
))
49 if(!prs_uint16("second", ps
, depth
, &systime
->second
))
51 if(!prs_uint16("milliseconds", ps
, depth
, &systime
->milliseconds
))
57 /*******************************************************************
58 ********************************************************************/
60 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
62 systime
->year
=unixtime
->tm_year
+1900;
63 systime
->month
=unixtime
->tm_mon
+1;
64 systime
->dayofweek
=unixtime
->tm_wday
;
65 systime
->day
=unixtime
->tm_mday
;
66 systime
->hour
=unixtime
->tm_hour
;
67 systime
->minute
=unixtime
->tm_min
;
68 systime
->second
=unixtime
->tm_sec
;
69 systime
->milliseconds
=0;
74 /*******************************************************************
75 reads or writes an DOC_INFO structure.
76 ********************************************************************/
78 static BOOL
smb_io_doc_info_1(const char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
80 if (info_1
== NULL
) return False
;
82 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
88 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
90 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
92 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
95 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
97 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
99 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
105 /*******************************************************************
106 reads or writes an DOC_INFO structure.
107 ********************************************************************/
109 static BOOL
smb_io_doc_info(const char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
111 uint32 useless_ptr
=0;
113 if (info
== NULL
) return False
;
115 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
121 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
124 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
127 switch (info
->switch_value
)
130 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
135 this is just a placeholder
137 MSDN July 1998 says doc_info_2 is only on
138 Windows 95, and as Win95 doesn't do RPC to print
139 this case is nearly impossible
141 Maybe one day with Windows for dishwasher 2037 ...
144 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
147 DEBUG(0,("Something is obviously wrong somewhere !\n"));
154 /*******************************************************************
155 reads or writes an DOC_INFO_CONTAINER structure.
156 ********************************************************************/
158 static BOOL
smb_io_doc_info_container(const char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
160 if (cont
== NULL
) return False
;
162 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
168 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
171 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
177 /*******************************************************************
178 reads or writes an NOTIFY OPTION TYPE structure.
179 ********************************************************************/
181 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
182 structure. The _TYPE structure is really the deferred referrants (i.e
183 the notify fields array) of the _TYPE structure. -tpot */
185 static BOOL
smb_io_notify_option_type(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
187 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
193 if(!prs_uint16("type", ps
, depth
, &type
->type
))
195 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
197 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
199 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
201 if(!prs_uint32("count", ps
, depth
, &type
->count
))
203 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
209 /*******************************************************************
210 reads or writes an NOTIFY OPTION TYPE DATA.
211 ********************************************************************/
213 static BOOL
smb_io_notify_option_type_data(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
217 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
220 /* if there are no fields just return */
221 if (type
->fields_ptr
==0)
227 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
230 if (type
->count2
!= type
->count
)
231 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
233 if (type
->count2
> MAX_NOTIFY_TYPE_FOR_NOW
) {
237 /* parse the option type data */
238 for(i
=0;i
<type
->count2
;i
++)
239 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
244 /*******************************************************************
245 reads or writes an NOTIFY OPTION structure.
246 ********************************************************************/
248 static BOOL
smb_io_notify_option_type_ctr(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
252 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
255 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
259 if (UNMARSHALLING(ps
) && ctr
->count
)
260 if((ctr
->type
=PRS_ALLOC_MEM(ps
,SPOOL_NOTIFY_OPTION_TYPE
,ctr
->count
)) == NULL
)
263 /* the option type struct */
264 for(i
=0;i
<ctr
->count
;i
++)
265 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
268 /* the type associated with the option type struct */
269 for(i
=0;i
<ctr
->count
;i
++)
270 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
276 /*******************************************************************
277 reads or writes an NOTIFY OPTION structure.
278 ********************************************************************/
280 static BOOL
smb_io_notify_option(const char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
282 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
285 if(!prs_uint32("version", ps
, depth
, &option
->version
))
287 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
289 if(!prs_uint32("count", ps
, depth
, &option
->count
))
291 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
294 /* marshalling or unmarshalling, that would work */
295 if (option
->option_type_ptr
!=0) {
296 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
300 option
->ctr
.type
=NULL
;
307 /*******************************************************************
308 reads or writes an NOTIFY INFO DATA structure.
309 ********************************************************************/
311 static BOOL
smb_io_notify_info_data(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
313 uint32 useless_ptr
=0x0FF0ADDE;
315 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
320 if(!prs_uint16("type", ps
, depth
, &data
->type
))
322 if(!prs_uint16("field", ps
, depth
, &data
->field
))
325 if(!prs_uint32("how many words", ps
, depth
, &data
->size
))
327 if(!prs_uint32("id", ps
, depth
, &data
->id
))
329 if(!prs_uint32("how many words", ps
, depth
, &data
->size
))
332 switch (data
->enc_type
) {
334 /* One and two value data has two uint32 values */
336 case NOTIFY_ONE_VALUE
:
337 case NOTIFY_TWO_VALUE
:
339 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
341 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
345 /* Pointers and strings have a string length and a
346 pointer. For a string the length is expressed as
347 the number of uint16 characters plus a trailing
352 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
354 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
361 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
364 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
370 if( !prs_uint32( "sd size", ps
, depth
, &data
->notify_data
.sd
.size
) )
372 if( !prs_uint32( "pointer", ps
, depth
, &useless_ptr
) )
378 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data\n",
386 /*******************************************************************
387 reads or writes an NOTIFY INFO DATA structure.
388 ********************************************************************/
390 BOOL
smb_io_notify_info_data_strings(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
391 prs_struct
*ps
, int depth
)
393 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
399 switch(data
->enc_type
) {
401 /* No data for values */
403 case NOTIFY_ONE_VALUE
:
404 case NOTIFY_TWO_VALUE
:
408 /* Strings start with a length in uint16s */
413 data
->notify_data
.data
.length
/= 2;
415 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
418 if (UNMARSHALLING(ps
) && data
->notify_data
.data
.length
) {
419 data
->notify_data
.data
.string
= PRS_ALLOC_MEM(ps
, uint16
,
420 data
->notify_data
.data
.length
);
422 if (!data
->notify_data
.data
.string
)
426 if (!prs_uint16uni(True
, "string", ps
, depth
, data
->notify_data
.data
.string
,
427 data
->notify_data
.data
.length
))
431 data
->notify_data
.data
.length
*= 2;
437 if (UNMARSHALLING(ps
) && data
->notify_data
.data
.length
) {
438 data
->notify_data
.data
.string
= PRS_ALLOC_MEM(ps
, uint16
,
439 data
->notify_data
.data
.length
);
441 if (!data
->notify_data
.data
.string
)
445 if(!prs_uint8s(True
,"buffer",ps
,depth
,(uint8
*)data
->notify_data
.data
.string
,data
->notify_data
.data
.length
))
451 if( !prs_uint32("secdesc size ", ps
, depth
, &data
->notify_data
.sd
.size
) )
453 if ( !sec_io_desc( "sec_desc", &data
->notify_data
.sd
.desc
, ps
, depth
) )
458 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data_strings\n",
464 if (isvalue
==False
) {
466 /* length of string in unicode include \0 */
467 x
=data
->notify_data
.data
.length
+1;
469 if (data
->field
!= 16)
470 if(!prs_uint32("string length", ps
, depth
, &x
))
473 if (MARSHALLING(ps
)) {
474 /* These are already in little endian format. Don't byte swap. */
477 /* No memory allocated for this string
478 therefore following the data.string
479 pointer is a bad idea. Use a pointer to
480 the uint32 length union member to
481 provide a source for a unicode NULL */
483 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
487 if (data
->field
== 16)
490 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
495 /* Tallocate memory for string */
498 data
->notify_data
.data
.string
= PRS_ALLOC_MEM(ps
, uint16
, x
* 2);
499 if (!data
->notify_data
.data
.string
)
502 data
->notify_data
.data
.string
= NULL
;
505 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
513 /* Win2k does not seem to put this parse align here */
521 /*******************************************************************
522 reads or writes an NOTIFY INFO structure.
523 ********************************************************************/
525 static BOOL
smb_io_notify_info(const char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
529 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
535 if(!prs_uint32("count", ps
, depth
, &info
->count
))
537 if(!prs_uint32("version", ps
, depth
, &info
->version
))
539 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
541 if(!prs_uint32("count", ps
, depth
, &info
->count
))
544 for (i
=0;i
<info
->count
;i
++) {
545 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
549 /* now do the strings at the end of the stream */
550 for (i
=0;i
<info
->count
;i
++) {
551 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
558 /*******************************************************************
559 ********************************************************************/
561 BOOL
spool_io_user_level_1( const char *desc
, prs_struct
*ps
, int depth
, SPOOL_USER_1
*q_u
)
563 prs_debug(ps
, depth
, desc
, "");
569 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
572 if (!prs_io_unistr2_p("", ps
, depth
, &q_u
->client_name
))
574 if (!prs_io_unistr2_p("", ps
, depth
, &q_u
->user_name
))
577 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
579 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
581 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
583 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
586 if (!prs_io_unistr2("", ps
, depth
, q_u
->client_name
))
591 if (!prs_io_unistr2("", ps
, depth
, q_u
->user_name
))
597 /*******************************************************************
598 ********************************************************************/
600 static BOOL
spool_io_user_level(const char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
605 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
611 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
614 switch ( q_u
->level
)
617 if ( !prs_pointer( "" , ps
, depth
, (void*)&q_u
->user
.user1
,
618 sizeof(SPOOL_USER_1
), (PRS_POINTER_CAST
)spool_io_user_level_1
))
630 /*******************************************************************
631 * read or write a DEVICEMODE struct.
632 * on reading allocate memory for the private member
633 ********************************************************************/
635 #define DM_NUM_OPTIONAL_FIELDS 8
637 BOOL
spoolss_io_devmode(const char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
639 int available_space
; /* size of the device mode left to parse */
640 /* only important on unmarshalling */
642 uint16
*unistr_buffer
;
645 struct optional_fields
{
648 } opt_fields
[DM_NUM_OPTIONAL_FIELDS
] = {
649 { "icmmethod", NULL
},
650 { "icmintent", NULL
},
651 { "mediatype", NULL
},
652 { "dithertype", NULL
},
653 { "reserved1", NULL
},
654 { "reserved2", NULL
},
655 { "panningwidth", NULL
},
656 { "panningheight", NULL
}
659 /* assign at run time to keep non-gcc compilers happy */
661 opt_fields
[0].field
= &devmode
->icmmethod
;
662 opt_fields
[1].field
= &devmode
->icmintent
;
663 opt_fields
[2].field
= &devmode
->mediatype
;
664 opt_fields
[3].field
= &devmode
->dithertype
;
665 opt_fields
[4].field
= &devmode
->reserved1
;
666 opt_fields
[5].field
= &devmode
->reserved2
;
667 opt_fields
[6].field
= &devmode
->panningwidth
;
668 opt_fields
[7].field
= &devmode
->panningheight
;
671 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
674 if (UNMARSHALLING(ps
)) {
675 devmode
->devicename
.buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
676 if (devmode
->devicename
.buffer
== NULL
)
678 unistr_buffer
= devmode
->devicename
.buffer
;
681 /* devicename is a static sized string but the buffer we set is not */
682 unistr_buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
683 memset( unistr_buffer
, 0x0, MAXDEVICENAME
);
684 for ( j
=0; devmode
->devicename
.buffer
[j
]; j
++ )
685 unistr_buffer
[j
] = devmode
->devicename
.buffer
[j
];
688 if (!prs_uint16uni(True
,"devicename", ps
, depth
, unistr_buffer
, MAXDEVICENAME
))
691 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
694 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
696 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
698 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
700 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
702 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
704 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
706 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
708 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
710 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
712 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
714 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
716 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
718 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
720 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
722 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
724 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
726 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
729 if (UNMARSHALLING(ps
)) {
730 devmode
->formname
.buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
731 if (devmode
->formname
.buffer
== NULL
)
733 unistr_buffer
= devmode
->formname
.buffer
;
736 /* devicename is a static sized string but the buffer we set is not */
737 unistr_buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
738 memset( unistr_buffer
, 0x0, MAXDEVICENAME
);
739 for ( j
=0; devmode
->formname
.buffer
[j
]; j
++ )
740 unistr_buffer
[j
] = devmode
->formname
.buffer
[j
];
743 if (!prs_uint16uni(True
, "formname", ps
, depth
, unistr_buffer
, MAXDEVICENAME
))
745 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
747 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
749 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
751 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
753 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
755 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
758 * every device mode I've ever seen on the wire at least has up
759 * to the displayfrequency field. --jerry (05-09-2002)
762 /* add uint32's + uint16's + two UNICODE strings */
764 available_space
= devmode
->size
- (sizeof(uint32
)*6 + sizeof(uint16
)*18 + sizeof(uint16
)*64);
766 /* Sanity check - we only have uint32's left tp parse */
768 if ( available_space
&& ((available_space
% sizeof(uint32
)) != 0) ) {
769 DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n",
770 available_space
, devmode
->size
));
771 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
776 * Conditional parsing. Assume that the DeviceMode has been
777 * zero'd by the caller.
780 while ((available_space
> 0) && (i
< DM_NUM_OPTIONAL_FIELDS
))
782 DEBUG(11, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space
));
783 if (!prs_uint32(opt_fields
[i
].name
, ps
, depth
, opt_fields
[i
].field
))
785 available_space
-= sizeof(uint32
);
789 /* Sanity Check - we should no available space at this point unless
790 MS changes the device mode structure */
792 if (available_space
) {
793 DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n"));
794 DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n",
795 available_space
, devmode
->size
));
796 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
801 if (devmode
->driverextra
!=0) {
802 if (UNMARSHALLING(ps
)) {
803 devmode
->dev_private
=PRS_ALLOC_MEM(ps
, uint8
, devmode
->driverextra
);
804 if(devmode
->dev_private
== NULL
)
806 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for dev_private\n",devmode
->driverextra
));
809 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of dev_private\n",devmode
->driverextra
));
810 if (!prs_uint8s(False
, "dev_private", ps
, depth
,
811 devmode
->dev_private
, devmode
->driverextra
))
818 /*******************************************************************
819 Read or write a DEVICEMODE container
820 ********************************************************************/
822 static BOOL
spoolss_io_devmode_cont(const char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
827 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
833 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
836 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
839 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
840 if (UNMARSHALLING(ps
))
841 /* if while reading there is no DEVMODE ... */
846 /* so we have a DEVICEMODE to follow */
847 if (UNMARSHALLING(ps
)) {
848 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
849 dm_c
->devmode
=PRS_ALLOC_MEM(ps
,DEVICEMODE
,1);
850 if(dm_c
->devmode
== NULL
)
854 /* this is bad code, shouldn't be there */
855 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
858 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
864 /*******************************************************************
865 ********************************************************************/
867 static BOOL
spoolss_io_printer_default(const char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
872 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
875 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
878 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
884 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
890 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
896 /*******************************************************************
898 ********************************************************************/
900 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
901 const fstring printername
,
902 const fstring datatype
,
903 uint32 access_required
,
904 const fstring clientname
,
905 const fstring user_name
)
907 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
909 q_u
->printername
= TALLOC_P( get_talloc_ctx(), UNISTR2
);
910 if (!q_u
->printername
) {
913 init_unistr2(q_u
->printername
, printername
, UNI_STR_TERMINATE
);
915 q_u
->printer_default
.datatype_ptr
= 0;
917 q_u
->printer_default
.devmode_cont
.size
=0;
918 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
919 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
920 q_u
->printer_default
.access_required
=access_required
;
922 q_u
->user_switch
= 1;
924 q_u
->user_ctr
.level
= 1;
925 q_u
->user_ctr
.user
.user1
= TALLOC_P( get_talloc_ctx(), SPOOL_USER_1
);
926 if (!q_u
->user_ctr
.user
.user1
) {
929 q_u
->user_ctr
.user
.user1
->size
= strlen(clientname
) + strlen(user_name
) + 10;
930 q_u
->user_ctr
.user
.user1
->build
= 1381;
931 q_u
->user_ctr
.user
.user1
->major
= 2;
932 q_u
->user_ctr
.user
.user1
->minor
= 0;
933 q_u
->user_ctr
.user
.user1
->processor
= 0;
935 q_u
->user_ctr
.user
.user1
->client_name
= TALLOC_P( get_talloc_ctx(), UNISTR2
);
936 if (!q_u
->user_ctr
.user
.user1
->client_name
) {
939 q_u
->user_ctr
.user
.user1
->user_name
= TALLOC_P( get_talloc_ctx(), UNISTR2
);
940 if (!q_u
->user_ctr
.user
.user1
->user_name
) {
944 init_unistr2(q_u
->user_ctr
.user
.user1
->client_name
, clientname
, UNI_STR_TERMINATE
);
945 init_unistr2(q_u
->user_ctr
.user
.user1
->user_name
, user_name
, UNI_STR_TERMINATE
);
950 /*******************************************************************
952 ********************************************************************/
954 BOOL
make_spoolss_q_addprinterex( TALLOC_CTX
*mem_ctx
, SPOOL_Q_ADDPRINTEREX
*q_u
,
955 const char *srv_name
, const char* clientname
, const char* user_name
,
956 uint32 level
, PRINTER_INFO_CTR
*ctr
)
958 DEBUG(5,("make_spoolss_q_addprinterex\n"));
960 if (!ctr
|| !ctr
->printers_2
)
965 q_u
->server_name
= TALLOC_P( mem_ctx
, UNISTR2
);
966 if (!q_u
->server_name
) {
969 init_unistr2(q_u
->server_name
, srv_name
, UNI_FLAGS_NONE
);
973 q_u
->info
.level
= level
;
974 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
977 /* init q_u->info.info2 from *info */
978 if (!make_spoolss_printer_info_2(mem_ctx
, &q_u
->info
.info_2
, ctr
->printers_2
)) {
979 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
989 q_u
->user_ctr
.level
= 1;
990 q_u
->user_ctr
.user
.user1
= TALLOC_P( get_talloc_ctx(), SPOOL_USER_1
);
991 if (!q_u
->user_ctr
.user
.user1
) {
994 q_u
->user_ctr
.user
.user1
->build
= 1381;
995 q_u
->user_ctr
.user
.user1
->major
= 2;
996 q_u
->user_ctr
.user
.user1
->minor
= 0;
997 q_u
->user_ctr
.user
.user1
->processor
= 0;
999 q_u
->user_ctr
.user
.user1
->client_name
= TALLOC_P( mem_ctx
, UNISTR2
);
1000 if (!q_u
->user_ctr
.user
.user1
->client_name
) {
1003 q_u
->user_ctr
.user
.user1
->user_name
= TALLOC_P( mem_ctx
, UNISTR2
);
1004 if (!q_u
->user_ctr
.user
.user1
->user_name
) {
1007 init_unistr2(q_u
->user_ctr
.user
.user1
->client_name
, clientname
, UNI_STR_TERMINATE
);
1008 init_unistr2(q_u
->user_ctr
.user
.user1
->user_name
, user_name
, UNI_STR_TERMINATE
);
1010 q_u
->user_ctr
.user
.user1
->size
= q_u
->user_ctr
.user
.user1
->user_name
->uni_str_len
+
1011 q_u
->user_ctr
.user
.user1
->client_name
->uni_str_len
+ 2;
1016 /*******************************************************************
1017 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
1018 *******************************************************************/
1020 BOOL
make_spoolss_printer_info_2(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
1021 PRINTER_INFO_2
*info
)
1024 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
1026 /* allocate the necessary memory */
1027 if (!(inf
=TALLOC_P(mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_2
))) {
1028 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
1032 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
1033 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
1034 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
1035 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
1036 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
1037 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
1038 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
1039 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
1040 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
1041 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
1042 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
1043 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
1044 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
1045 inf
->attributes
= info
->attributes
;
1046 inf
->priority
= info
->priority
;
1047 inf
->default_priority
= info
->defaultpriority
;
1048 inf
->starttime
= info
->starttime
;
1049 inf
->untiltime
= info
->untiltime
;
1050 inf
->cjobs
= info
->cjobs
;
1051 inf
->averageppm
= info
->averageppm
;
1052 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
1053 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
1054 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
1055 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
1056 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
1057 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
1058 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
1059 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
1060 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
1061 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
1062 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
1063 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
1070 /*******************************************************************
1071 create a SPOOL_PRINTER_INFO_3 struct from a PRINTER_INFO_3 struct
1072 *******************************************************************/
1074 BOOL
make_spoolss_printer_info_3(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_3
**spool_info3
,
1075 PRINTER_INFO_3
*info
)
1078 SPOOL_PRINTER_INFO_LEVEL_3
*inf
;
1080 /* allocate the necessary memory */
1081 if (!(inf
=TALLOC_P(mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_3
))) {
1082 DEBUG(0,("make_spoolss_printer_info_3: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_3 sruct!\n"));
1086 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
1093 /*******************************************************************
1094 create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
1095 *******************************************************************/
1097 BOOL
make_spoolss_printer_info_7(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_7
**spool_info7
,
1098 PRINTER_INFO_7
*info
)
1101 SPOOL_PRINTER_INFO_LEVEL_7
*inf
;
1103 /* allocate the necessary memory */
1104 if (!(inf
=TALLOC_P(mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_7
))) {
1105 DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
1109 inf
->guid_ptr
= (info
->guid
.buffer
!=NULL
)?1:0;
1110 inf
->action
= info
->action
;
1111 init_unistr2_from_unistr(&inf
->guid
, &info
->guid
);
1119 /*******************************************************************
1121 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1122 ********************************************************************/
1124 BOOL
spoolss_io_q_open_printer(const char *desc
, SPOOL_Q_OPEN_PRINTER
*q_u
, prs_struct
*ps
, int depth
)
1129 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer");
1135 if (!prs_io_unistr2_p("ptr", ps
, depth
, &q_u
->printername
))
1137 if (!prs_io_unistr2("printername", ps
, depth
, q_u
->printername
))
1143 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1149 /*******************************************************************
1150 * write a structure.
1151 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1152 * called from spoolss_open_printer_ex (cli_spoolss.c)
1153 ********************************************************************/
1155 BOOL
spoolss_io_r_open_printer(const char *desc
, SPOOL_R_OPEN_PRINTER
*r_u
, prs_struct
*ps
, int depth
)
1157 if (r_u
== NULL
) return False
;
1159 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer");
1165 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1168 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1175 /*******************************************************************
1177 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
1178 ********************************************************************/
1180 BOOL
spoolss_io_q_open_printer_ex(const char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
1185 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
1191 if (!prs_io_unistr2_p("ptr", ps
, depth
, &q_u
->printername
))
1193 if (!prs_io_unistr2("printername", ps
, depth
, q_u
->printername
))
1199 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
1202 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
1204 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
1210 /*******************************************************************
1211 * write a structure.
1212 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
1213 * called from spoolss_open_printer_ex (cli_spoolss.c)
1214 ********************************************************************/
1216 BOOL
spoolss_io_r_open_printer_ex(const char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
1218 if (r_u
== NULL
) return False
;
1220 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
1226 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1229 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1235 /*******************************************************************
1237 ********************************************************************/
1238 BOOL
make_spoolss_q_deleteprinterdriverex( TALLOC_CTX
*mem_ctx
,
1239 SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
,
1245 DEBUG(5,("make_spoolss_q_deleteprinterdriverex\n"));
1247 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1248 q_u
->delete_flags
= DPD_DELETE_UNUSED_FILES
;
1250 /* these must be NULL terminated or else NT4 will
1251 complain about invalid parameters --jerry */
1252 init_unistr2(&q_u
->server
, server
, UNI_STR_TERMINATE
);
1253 init_unistr2(&q_u
->arch
, arch
, UNI_STR_TERMINATE
);
1254 init_unistr2(&q_u
->driver
, driver
, UNI_STR_TERMINATE
);
1257 q_u
->delete_flags
|= DPD_DELETE_SPECIFIC_VERSION
;
1258 q_u
->version
= version
;
1265 /*******************************************************************
1267 ********************************************************************/
1268 BOOL
make_spoolss_q_deleteprinterdriver(
1269 TALLOC_CTX
*mem_ctx
,
1270 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
1276 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1278 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1280 /* these must be NULL terminated or else NT4 will
1281 complain about invalid parameters --jerry */
1282 init_unistr2(&q_u
->server
, server
, UNI_STR_TERMINATE
);
1283 init_unistr2(&q_u
->arch
, arch
, UNI_STR_TERMINATE
);
1284 init_unistr2(&q_u
->driver
, driver
, UNI_STR_TERMINATE
);
1289 /*******************************************************************
1291 ********************************************************************/
1293 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
1294 const POLICY_HND
*handle
,
1295 const char *valuename
, uint32 size
)
1297 if (q_u
== NULL
) return False
;
1299 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1301 q_u
->handle
= *handle
;
1302 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
1308 /*******************************************************************
1310 ********************************************************************/
1312 BOOL
make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX
*q_u
,
1313 const POLICY_HND
*handle
,
1314 const char *keyname
,
1315 const char *valuename
, uint32 size
)
1317 if (q_u
== NULL
) return False
;
1319 DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
1321 q_u
->handle
= *handle
;
1322 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
1323 init_unistr2(&q_u
->keyname
, keyname
, UNI_STR_TERMINATE
);
1329 /*******************************************************************
1331 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1332 ********************************************************************/
1334 BOOL
spoolss_io_q_getprinterdata(const char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1339 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1344 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1348 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1352 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1358 /*******************************************************************
1360 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1361 ********************************************************************/
1363 BOOL
spoolss_io_q_deleteprinterdata(const char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1368 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1373 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1377 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1383 /*******************************************************************
1384 * write a structure.
1385 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1386 ********************************************************************/
1388 BOOL
spoolss_io_r_deleteprinterdata(const char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1390 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1392 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1398 /*******************************************************************
1400 * called from spoolss_q_deleteprinterdataex (srv_spoolss.c)
1401 ********************************************************************/
1403 BOOL
spoolss_io_q_deleteprinterdataex(const char *desc
, SPOOL_Q_DELETEPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
1408 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdataex");
1413 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1416 if (!smb_io_unistr2("keyname ", &q_u
->keyname
, True
, ps
, depth
))
1418 if (!smb_io_unistr2("valuename", &q_u
->valuename
, True
, ps
, depth
))
1424 /*******************************************************************
1425 * write a structure.
1426 * called from spoolss_r_deleteprinterdataex (srv_spoolss.c)
1427 ********************************************************************/
1429 BOOL
spoolss_io_r_deleteprinterdataex(const char *desc
, SPOOL_R_DELETEPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
1431 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdataex");
1434 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1440 /*******************************************************************
1441 * write a structure.
1442 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1443 ********************************************************************/
1445 BOOL
spoolss_io_r_getprinterdata(const char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1450 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1455 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1457 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1460 if (UNMARSHALLING(ps
) && r_u
->size
) {
1461 r_u
->data
= PRS_ALLOC_MEM(ps
, unsigned char, r_u
->size
);
1466 if (!prs_uint8s( False
, "data", ps
, depth
, r_u
->data
, r_u
->size
))
1472 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1474 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1480 /*******************************************************************
1482 ********************************************************************/
1484 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1486 if (q_u
== NULL
) return False
;
1488 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1490 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1495 /*******************************************************************
1497 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1498 * called from spoolss_abortprinter (cli_spoolss.c)
1499 ********************************************************************/
1501 BOOL
spoolss_io_q_abortprinter(const char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1503 if (q_u
== NULL
) return False
;
1505 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1511 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1517 /*******************************************************************
1518 * write a structure.
1519 * called from spoolss_r_abortprinter (srv_spoolss.c)
1520 ********************************************************************/
1522 BOOL
spoolss_io_r_abortprinter(const char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1524 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1526 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1532 /*******************************************************************
1534 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1535 * called from spoolss_deleteprinter (cli_spoolss.c)
1536 ********************************************************************/
1538 BOOL
spoolss_io_q_deleteprinter(const char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1540 if (q_u
== NULL
) return False
;
1542 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1548 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1554 /*******************************************************************
1555 * write a structure.
1556 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1557 * called from spoolss_deleteprinter (cli_spoolss.c)
1558 ********************************************************************/
1560 BOOL
spoolss_io_r_deleteprinter(const char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1562 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1568 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1570 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1577 /*******************************************************************
1579 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1580 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1581 ********************************************************************/
1583 BOOL
spoolss_io_q_deleteprinterdriver(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1585 if (q_u
== NULL
) return False
;
1587 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1593 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1595 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1597 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1599 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1607 /*******************************************************************
1608 * write a structure.
1609 ********************************************************************/
1610 BOOL
spoolss_io_r_deleteprinterdriver(const char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1612 if (r_u
== NULL
) return False
;
1614 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1620 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1627 /*******************************************************************
1629 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1630 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1631 ********************************************************************/
1633 BOOL
spoolss_io_q_deleteprinterdriverex(const char *desc
, SPOOL_Q_DELETEPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
1635 if (q_u
== NULL
) return False
;
1637 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriverex");
1643 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1645 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1647 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1649 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1655 if(!prs_uint32("delete_flags ", ps
, depth
, &q_u
->delete_flags
))
1657 if(!prs_uint32("version ", ps
, depth
, &q_u
->version
))
1665 /*******************************************************************
1666 * write a structure.
1667 ********************************************************************/
1668 BOOL
spoolss_io_r_deleteprinterdriverex(const char *desc
, SPOOL_R_DELETEPRINTERDRIVEREX
*r_u
, prs_struct
*ps
, int depth
)
1670 if (r_u
== NULL
) return False
;
1672 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriverex");
1678 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1686 /*******************************************************************
1688 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1689 * called from spoolss_closeprinter (cli_spoolss.c)
1690 ********************************************************************/
1692 BOOL
spoolss_io_q_closeprinter(const char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1694 if (q_u
== NULL
) return False
;
1696 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1702 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1708 /*******************************************************************
1709 * write a structure.
1710 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1711 * called from spoolss_closeprinter (cli_spoolss.c)
1712 ********************************************************************/
1714 BOOL
spoolss_io_r_closeprinter(const char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1716 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1722 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1724 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1730 /*******************************************************************
1732 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1733 ********************************************************************/
1735 BOOL
spoolss_io_q_startdocprinter(const char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1737 if (q_u
== NULL
) return False
;
1739 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1745 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1748 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1754 /*******************************************************************
1755 * write a structure.
1756 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1757 ********************************************************************/
1759 BOOL
spoolss_io_r_startdocprinter(const char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1761 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1763 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1765 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1771 /*******************************************************************
1773 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1774 ********************************************************************/
1776 BOOL
spoolss_io_q_enddocprinter(const char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1778 if (q_u
== NULL
) return False
;
1780 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1786 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1792 /*******************************************************************
1793 * write a structure.
1794 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1795 ********************************************************************/
1797 BOOL
spoolss_io_r_enddocprinter(const char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1799 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1801 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1807 /*******************************************************************
1809 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1810 ********************************************************************/
1812 BOOL
spoolss_io_q_startpageprinter(const char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1814 if (q_u
== NULL
) return False
;
1816 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1822 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1828 /*******************************************************************
1829 * write a structure.
1830 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1831 ********************************************************************/
1833 BOOL
spoolss_io_r_startpageprinter(const char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1835 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1837 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1843 /*******************************************************************
1845 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1846 ********************************************************************/
1848 BOOL
spoolss_io_q_endpageprinter(const char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1850 if (q_u
== NULL
) return False
;
1852 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1858 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1864 /*******************************************************************
1865 * write a structure.
1866 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1867 ********************************************************************/
1869 BOOL
spoolss_io_r_endpageprinter(const char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1871 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1873 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1879 /*******************************************************************
1881 * called from spoolss_q_writeprinter (srv_spoolss.c)
1882 ********************************************************************/
1884 BOOL
spoolss_io_q_writeprinter(const char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1886 if (q_u
== NULL
) return False
;
1888 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1894 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1896 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1899 if (q_u
->buffer_size
!=0)
1901 if (UNMARSHALLING(ps
))
1902 q_u
->buffer
=PRS_ALLOC_MEM(ps
, uint8
, q_u
->buffer_size
);
1903 if(q_u
->buffer
== NULL
)
1905 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1910 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1916 /*******************************************************************
1917 * write a structure.
1918 * called from spoolss_r_writeprinter (srv_spoolss.c)
1919 ********************************************************************/
1921 BOOL
spoolss_io_r_writeprinter(const char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1923 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1925 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1927 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1933 /*******************************************************************
1935 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1936 ********************************************************************/
1938 BOOL
spoolss_io_q_rffpcnex(const char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1940 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1946 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1948 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1950 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1952 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1954 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1960 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1963 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1966 if (q_u
->option_ptr
!=0) {
1968 if (UNMARSHALLING(ps
))
1969 if((q_u
->option
=PRS_ALLOC_MEM(ps
,SPOOL_NOTIFY_OPTION
,1)) == NULL
)
1972 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1979 /*******************************************************************
1980 * write a structure.
1981 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1982 ********************************************************************/
1984 BOOL
spoolss_io_r_rffpcnex(const char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1986 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1989 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1995 /*******************************************************************
1997 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1998 ********************************************************************/
2000 BOOL
spoolss_io_q_rfnpcnex(const char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
2002 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
2008 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
2011 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
2014 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
2017 if (q_u
->option_ptr
!=0) {
2019 if (UNMARSHALLING(ps
))
2020 if((q_u
->option
=PRS_ALLOC_MEM(ps
,SPOOL_NOTIFY_OPTION
,1)) == NULL
)
2023 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
2030 /*******************************************************************
2031 * write a structure.
2032 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
2033 ********************************************************************/
2035 BOOL
spoolss_io_r_rfnpcnex(const char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
2037 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
2043 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
2046 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
2051 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
2057 /*******************************************************************
2058 * return the length of a uint16 (obvious, but the code is clean)
2059 ********************************************************************/
2061 static uint32
size_of_uint16(uint16
*value
)
2063 return (sizeof(*value
));
2066 /*******************************************************************
2067 * return the length of a uint32 (obvious, but the code is clean)
2068 ********************************************************************/
2070 static uint32
size_of_uint32(uint32
*value
)
2072 return (sizeof(*value
));
2075 /*******************************************************************
2076 * return the length of a NTTIME (obvious, but the code is clean)
2077 ********************************************************************/
2079 static uint32
size_of_nttime(NTTIME
*value
)
2081 return (sizeof(*value
));
2084 /*******************************************************************
2085 * return the length of a uint32 (obvious, but the code is clean)
2086 ********************************************************************/
2088 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
2093 return (4+devmode
->size
+devmode
->driverextra
);
2096 /*******************************************************************
2097 * return the length of a uint32 (obvious, but the code is clean)
2098 ********************************************************************/
2100 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
2105 return (sizeof(SYSTEMTIME
) +4);
2108 /*******************************************************************
2109 Parse a DEVMODE structure and its relative pointer.
2110 ********************************************************************/
2112 static BOOL
smb_io_reldevmode(const char *desc
, RPC_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2114 prs_struct
*ps
=&buffer
->prs
;
2116 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2119 if (MARSHALLING(ps
)) {
2120 uint32 struct_offset
= prs_offset(ps
);
2121 uint32 relative_offset
;
2123 if (*devmode
== NULL
) {
2125 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2127 DEBUG(8, ("boing, the devmode was NULL\n"));
2132 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2134 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2137 /* write the DEVMODE */
2138 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2141 if(!prs_set_offset(ps
, struct_offset
))
2144 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2145 /* write its offset */
2146 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2152 /* read the offset */
2153 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2155 if (buffer
->string_at_end
== 0) {
2160 old_offset
= prs_offset(ps
);
2161 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2164 /* read the string */
2165 if((*devmode
=PRS_ALLOC_MEM(ps
,DEVICEMODE
,1)) == NULL
)
2167 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2170 if(!prs_set_offset(ps
, old_offset
))
2176 /*******************************************************************
2177 Parse a PRINTER_INFO_0 structure.
2178 ********************************************************************/
2180 BOOL
smb_io_printer_info_0(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2182 prs_struct
*ps
=&buffer
->prs
;
2184 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2187 buffer
->struct_start
=prs_offset(ps
);
2189 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2191 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2194 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2196 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2198 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2201 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2203 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2205 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2207 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2209 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2211 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2213 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2215 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2218 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2220 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2223 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2225 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2227 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2229 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2231 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2233 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2235 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2237 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2239 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2241 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2243 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2245 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2247 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2249 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2251 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2253 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2255 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2257 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2259 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2261 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2263 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2265 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2267 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2269 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2271 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2277 /*******************************************************************
2278 Parse a PRINTER_INFO_1 structure.
2279 ********************************************************************/
2281 BOOL
smb_io_printer_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2283 prs_struct
*ps
=&buffer
->prs
;
2285 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2288 buffer
->struct_start
=prs_offset(ps
);
2290 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2292 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2294 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2296 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2302 /*******************************************************************
2303 Parse a PRINTER_INFO_2 structure.
2304 ********************************************************************/
2306 BOOL
smb_io_printer_info_2(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2308 prs_struct
*ps
=&buffer
->prs
;
2309 uint32 dm_offset
, sd_offset
, current_offset
;
2310 uint32 dummy_value
= 0, has_secdesc
= 0;
2312 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2315 buffer
->struct_start
=prs_offset(ps
);
2317 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2319 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2321 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2323 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2325 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2327 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2329 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2332 /* save current offset and wind forwared by a uint32 */
2333 dm_offset
= prs_offset(ps
);
2334 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
2337 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2339 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2341 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2343 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2346 /* save current offset for the sec_desc */
2347 sd_offset
= prs_offset(ps
);
2348 if (!prs_uint32("sec_desc", ps
, depth
, &has_secdesc
))
2352 /* save current location so we can pick back up here */
2353 current_offset
= prs_offset(ps
);
2355 /* parse the devmode */
2356 if (!prs_set_offset(ps
, dm_offset
))
2358 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2361 /* parse the sec_desc */
2362 if (info
->secdesc
) {
2363 if (!prs_set_offset(ps
, sd_offset
))
2365 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2369 /* pick up where we left off */
2370 if (!prs_set_offset(ps
, current_offset
))
2373 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2375 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2377 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2379 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2381 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2383 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2385 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2387 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2393 /*******************************************************************
2394 Parse a PRINTER_INFO_3 structure.
2395 ********************************************************************/
2397 BOOL
smb_io_printer_info_3(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2400 prs_struct
*ps
=&buffer
->prs
;
2402 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2405 buffer
->struct_start
=prs_offset(ps
);
2407 if (MARSHALLING(ps
)) {
2408 /* Ensure the SD is 8 byte aligned in the buffer. */
2409 uint start
= prs_offset(ps
); /* Remember the start position. */
2412 /* Write a dummy value. */
2413 if (!prs_uint32("offset", ps
, depth
, &off_val
))
2417 if (!prs_align_uint64(ps
))
2420 /* Remember where we must seek back to write the SD. */
2421 offset
= prs_offset(ps
);
2423 /* Calculate the real offset for the SD. */
2425 off_val
= offset
- start
;
2427 /* Seek back to where we store the SD offset & store. */
2428 prs_set_offset(ps
, start
);
2429 if (!prs_uint32("offset", ps
, depth
, &off_val
))
2432 /* Return to after the 8 byte align. */
2433 prs_set_offset(ps
, offset
);
2436 if (!prs_uint32("offset", ps
, depth
, &offset
))
2438 /* Seek within the buffer. */
2439 if (!prs_set_offset(ps
, offset
))
2442 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2448 /*******************************************************************
2449 Parse a PRINTER_INFO_4 structure.
2450 ********************************************************************/
2452 BOOL
smb_io_printer_info_4(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2454 prs_struct
*ps
=&buffer
->prs
;
2456 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2459 buffer
->struct_start
=prs_offset(ps
);
2461 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2463 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2465 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2470 /*******************************************************************
2471 Parse a PRINTER_INFO_5 structure.
2472 ********************************************************************/
2474 BOOL
smb_io_printer_info_5(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2476 prs_struct
*ps
=&buffer
->prs
;
2478 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2481 buffer
->struct_start
=prs_offset(ps
);
2483 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2485 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2487 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2489 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2491 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2496 /*******************************************************************
2497 Parse a PRINTER_INFO_6 structure.
2498 ********************************************************************/
2500 BOOL
smb_io_printer_info_6(const char *desc
, RPC_BUFFER
*buffer
,
2501 PRINTER_INFO_6
*info
, int depth
)
2503 prs_struct
*ps
=&buffer
->prs
;
2505 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_6");
2508 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2514 /*******************************************************************
2515 Parse a PRINTER_INFO_7 structure.
2516 ********************************************************************/
2518 BOOL
smb_io_printer_info_7(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_7
*info
, int depth
)
2520 prs_struct
*ps
=&buffer
->prs
;
2522 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_7");
2525 buffer
->struct_start
=prs_offset(ps
);
2527 if (!smb_io_relstr("guid", buffer
, depth
, &info
->guid
))
2529 if (!prs_uint32("action", ps
, depth
, &info
->action
))
2534 /*******************************************************************
2535 Parse a PORT_INFO_1 structure.
2536 ********************************************************************/
2538 BOOL
smb_io_port_info_1(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2540 prs_struct
*ps
=&buffer
->prs
;
2542 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2545 buffer
->struct_start
=prs_offset(ps
);
2547 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2553 /*******************************************************************
2554 Parse a PORT_INFO_2 structure.
2555 ********************************************************************/
2557 BOOL
smb_io_port_info_2(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2559 prs_struct
*ps
=&buffer
->prs
;
2561 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2564 buffer
->struct_start
=prs_offset(ps
);
2566 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2568 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2570 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2572 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2574 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2580 /*******************************************************************
2581 Parse a DRIVER_INFO_1 structure.
2582 ********************************************************************/
2584 BOOL
smb_io_printer_driver_info_1(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2586 prs_struct
*ps
=&buffer
->prs
;
2588 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2591 buffer
->struct_start
=prs_offset(ps
);
2593 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2599 /*******************************************************************
2600 Parse a DRIVER_INFO_2 structure.
2601 ********************************************************************/
2603 BOOL
smb_io_printer_driver_info_2(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2605 prs_struct
*ps
=&buffer
->prs
;
2607 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2610 buffer
->struct_start
=prs_offset(ps
);
2612 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2614 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2616 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2618 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2620 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2622 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2628 /*******************************************************************
2629 Parse a DRIVER_INFO_3 structure.
2630 ********************************************************************/
2632 BOOL
smb_io_printer_driver_info_3(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2634 prs_struct
*ps
=&buffer
->prs
;
2636 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2639 buffer
->struct_start
=prs_offset(ps
);
2641 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2643 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2645 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2647 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2649 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2651 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2653 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2656 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2659 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2661 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2667 /*******************************************************************
2668 Parse a DRIVER_INFO_6 structure.
2669 ********************************************************************/
2671 BOOL
smb_io_printer_driver_info_6(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2673 prs_struct
*ps
=&buffer
->prs
;
2675 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2678 buffer
->struct_start
=prs_offset(ps
);
2680 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2682 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2684 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2686 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2688 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2690 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2692 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2695 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2698 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2700 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2703 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2706 if (!prs_uint64("date", ps
, depth
, &info
->driver_date
))
2709 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2712 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2715 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2718 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2720 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2722 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2724 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2730 /*******************************************************************
2731 Parse a JOB_INFO_1 structure.
2732 ********************************************************************/
2734 BOOL
smb_io_job_info_1(const char *desc
, RPC_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2736 prs_struct
*ps
=&buffer
->prs
;
2738 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2741 buffer
->struct_start
=prs_offset(ps
);
2743 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2745 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2747 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2749 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2751 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2753 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2755 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2757 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2759 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2761 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2763 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2765 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2767 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2773 /*******************************************************************
2774 Parse a JOB_INFO_2 structure.
2775 ********************************************************************/
2777 BOOL
smb_io_job_info_2(const char *desc
, RPC_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2780 prs_struct
*ps
=&buffer
->prs
;
2782 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2785 buffer
->struct_start
=prs_offset(ps
);
2787 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2789 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2791 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2793 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2795 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2797 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2799 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2802 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2804 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2806 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2808 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2810 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2813 /* SEC_DESC sec_desc;*/
2814 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2817 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2819 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2821 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2823 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2825 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2827 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2829 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2831 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2833 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2835 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2841 /*******************************************************************
2842 ********************************************************************/
2844 BOOL
smb_io_form_1(const char *desc
, RPC_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2846 prs_struct
*ps
=&buffer
->prs
;
2848 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
2851 buffer
->struct_start
=prs_offset(ps
);
2853 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2856 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2859 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2861 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2863 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2865 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2867 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2869 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2877 /*******************************************************************
2878 Parse a DRIVER_DIRECTORY_1 structure.
2879 ********************************************************************/
2881 BOOL
smb_io_driverdir_1(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2883 prs_struct
*ps
=&buffer
->prs
;
2885 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
2888 buffer
->struct_start
=prs_offset(ps
);
2890 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2896 /*******************************************************************
2897 Parse a PORT_INFO_1 structure.
2898 ********************************************************************/
2900 BOOL
smb_io_port_1(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2902 prs_struct
*ps
=&buffer
->prs
;
2904 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
2907 buffer
->struct_start
=prs_offset(ps
);
2909 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2915 /*******************************************************************
2916 Parse a PORT_INFO_2 structure.
2917 ********************************************************************/
2919 BOOL
smb_io_port_2(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2921 prs_struct
*ps
=&buffer
->prs
;
2923 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
2926 buffer
->struct_start
=prs_offset(ps
);
2928 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2930 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2932 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2934 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2936 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2942 /*******************************************************************
2943 ********************************************************************/
2945 BOOL
smb_io_printprocessor_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2947 prs_struct
*ps
=&buffer
->prs
;
2949 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2952 buffer
->struct_start
=prs_offset(ps
);
2954 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2960 /*******************************************************************
2961 ********************************************************************/
2963 BOOL
smb_io_printprocdatatype_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2965 prs_struct
*ps
=&buffer
->prs
;
2967 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2970 buffer
->struct_start
=prs_offset(ps
);
2972 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2978 /*******************************************************************
2979 ********************************************************************/
2981 BOOL
smb_io_printmonitor_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2983 prs_struct
*ps
=&buffer
->prs
;
2985 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2988 buffer
->struct_start
=prs_offset(ps
);
2990 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2996 /*******************************************************************
2997 ********************************************************************/
2999 BOOL
smb_io_printmonitor_info_2(const char *desc
, RPC_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
3001 prs_struct
*ps
=&buffer
->prs
;
3003 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
3006 buffer
->struct_start
=prs_offset(ps
);
3008 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
3010 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
3012 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
3018 /*******************************************************************
3019 return the size required by a struct in the stream
3020 ********************************************************************/
3022 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
3026 size
+=size_of_relative_string( &info
->printername
);
3027 size
+=size_of_relative_string( &info
->servername
);
3029 size
+=size_of_uint32( &info
->cjobs
);
3030 size
+=size_of_uint32( &info
->total_jobs
);
3031 size
+=size_of_uint32( &info
->total_bytes
);
3033 size
+=size_of_uint16( &info
->year
);
3034 size
+=size_of_uint16( &info
->month
);
3035 size
+=size_of_uint16( &info
->dayofweek
);
3036 size
+=size_of_uint16( &info
->day
);
3037 size
+=size_of_uint16( &info
->hour
);
3038 size
+=size_of_uint16( &info
->minute
);
3039 size
+=size_of_uint16( &info
->second
);
3040 size
+=size_of_uint16( &info
->milliseconds
);
3042 size
+=size_of_uint32( &info
->global_counter
);
3043 size
+=size_of_uint32( &info
->total_pages
);
3045 size
+=size_of_uint16( &info
->major_version
);
3046 size
+=size_of_uint16( &info
->build_version
);
3048 size
+=size_of_uint32( &info
->unknown7
);
3049 size
+=size_of_uint32( &info
->unknown8
);
3050 size
+=size_of_uint32( &info
->unknown9
);
3051 size
+=size_of_uint32( &info
->session_counter
);
3052 size
+=size_of_uint32( &info
->unknown11
);
3053 size
+=size_of_uint32( &info
->printer_errors
);
3054 size
+=size_of_uint32( &info
->unknown13
);
3055 size
+=size_of_uint32( &info
->unknown14
);
3056 size
+=size_of_uint32( &info
->unknown15
);
3057 size
+=size_of_uint32( &info
->unknown16
);
3058 size
+=size_of_uint32( &info
->change_id
);
3059 size
+=size_of_uint32( &info
->unknown18
);
3060 size
+=size_of_uint32( &info
->status
);
3061 size
+=size_of_uint32( &info
->unknown20
);
3062 size
+=size_of_uint32( &info
->c_setprinter
);
3064 size
+=size_of_uint16( &info
->unknown22
);
3065 size
+=size_of_uint16( &info
->unknown23
);
3066 size
+=size_of_uint16( &info
->unknown24
);
3067 size
+=size_of_uint16( &info
->unknown25
);
3068 size
+=size_of_uint16( &info
->unknown26
);
3069 size
+=size_of_uint16( &info
->unknown27
);
3070 size
+=size_of_uint16( &info
->unknown28
);
3071 size
+=size_of_uint16( &info
->unknown29
);
3076 /*******************************************************************
3077 return the size required by a struct in the stream
3078 ********************************************************************/
3080 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3084 size
+=size_of_uint32( &info
->flags
);
3085 size
+=size_of_relative_string( &info
->description
);
3086 size
+=size_of_relative_string( &info
->name
);
3087 size
+=size_of_relative_string( &info
->comment
);
3092 /*******************************************************************
3093 return the size required by a struct in the stream
3094 ********************************************************************/
3096 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3102 size
+= sec_desc_size( info
->secdesc
);
3104 size
+=size_of_device_mode( info
->devmode
);
3106 size
+=size_of_relative_string( &info
->servername
);
3107 size
+=size_of_relative_string( &info
->printername
);
3108 size
+=size_of_relative_string( &info
->sharename
);
3109 size
+=size_of_relative_string( &info
->portname
);
3110 size
+=size_of_relative_string( &info
->drivername
);
3111 size
+=size_of_relative_string( &info
->comment
);
3112 size
+=size_of_relative_string( &info
->location
);
3114 size
+=size_of_relative_string( &info
->sepfile
);
3115 size
+=size_of_relative_string( &info
->printprocessor
);
3116 size
+=size_of_relative_string( &info
->datatype
);
3117 size
+=size_of_relative_string( &info
->parameters
);
3119 size
+=size_of_uint32( &info
->attributes
);
3120 size
+=size_of_uint32( &info
->priority
);
3121 size
+=size_of_uint32( &info
->defaultpriority
);
3122 size
+=size_of_uint32( &info
->starttime
);
3123 size
+=size_of_uint32( &info
->untiltime
);
3124 size
+=size_of_uint32( &info
->status
);
3125 size
+=size_of_uint32( &info
->cjobs
);
3126 size
+=size_of_uint32( &info
->averageppm
);
3129 * add any adjustments for alignment. This is
3130 * not optimal since we could be calling this
3131 * function from a loop (e.g. enumprinters), but
3132 * it is easier to maintain the calculation here and
3133 * not place the burden on the caller to remember. --jerry
3135 if ((size
% 4) != 0)
3136 size
+= 4 - (size
% 4);
3141 /*******************************************************************
3142 return the size required by a struct in the stream
3143 ********************************************************************/
3145 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3149 size
+=size_of_relative_string( &info
->printername
);
3150 size
+=size_of_relative_string( &info
->servername
);
3152 size
+=size_of_uint32( &info
->attributes
);
3156 /*******************************************************************
3157 return the size required by a struct in the stream
3158 ********************************************************************/
3160 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3164 size
+=size_of_relative_string( &info
->printername
);
3165 size
+=size_of_relative_string( &info
->portname
);
3167 size
+=size_of_uint32( &info
->attributes
);
3168 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3169 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3173 /*******************************************************************
3174 return the size required by a struct in the stream
3175 ********************************************************************/
3177 uint32
spoolss_size_printer_info_6(PRINTER_INFO_6
*info
)
3179 return sizeof(uint32
);
3182 /*******************************************************************
3183 return the size required by a struct in the stream
3184 ********************************************************************/
3186 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3188 /* The 8 is for the self relative pointer - 8 byte aligned.. */
3189 return 8 + (uint32
)sec_desc_size( info
->secdesc
);
3192 /*******************************************************************
3193 return the size required by a struct in the stream
3194 ********************************************************************/
3196 uint32
spoolss_size_printer_info_7(PRINTER_INFO_7
*info
)
3200 size
+=size_of_relative_string( &info
->guid
);
3201 size
+=size_of_uint32( &info
->action
);
3205 /*******************************************************************
3206 return the size required by a struct in the stream
3207 ********************************************************************/
3209 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3212 size
+=size_of_relative_string( &info
->name
);
3217 /*******************************************************************
3218 return the size required by a struct in the stream
3219 ********************************************************************/
3221 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3224 size
+=size_of_uint32( &info
->version
);
3225 size
+=size_of_relative_string( &info
->name
);
3226 size
+=size_of_relative_string( &info
->architecture
);
3227 size
+=size_of_relative_string( &info
->driverpath
);
3228 size
+=size_of_relative_string( &info
->datafile
);
3229 size
+=size_of_relative_string( &info
->configfile
);
3234 /*******************************************************************
3235 return the size required by a string array.
3236 ********************************************************************/
3238 uint32
spoolss_size_string_array(uint16
*string
)
3243 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3245 i
=i
+2; /* to count all chars including the leading zero */
3246 i
=2*i
; /* because we need the value in bytes */
3247 i
=i
+4; /* the offset pointer size */
3252 /*******************************************************************
3253 return the size required by a struct in the stream
3254 ********************************************************************/
3256 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3260 size
+=size_of_uint32( &info
->version
);
3261 size
+=size_of_relative_string( &info
->name
);
3262 size
+=size_of_relative_string( &info
->architecture
);
3263 size
+=size_of_relative_string( &info
->driverpath
);
3264 size
+=size_of_relative_string( &info
->datafile
);
3265 size
+=size_of_relative_string( &info
->configfile
);
3266 size
+=size_of_relative_string( &info
->helpfile
);
3267 size
+=size_of_relative_string( &info
->monitorname
);
3268 size
+=size_of_relative_string( &info
->defaultdatatype
);
3270 size
+=spoolss_size_string_array(info
->dependentfiles
);
3275 /*******************************************************************
3276 return the size required by a struct in the stream
3277 ********************************************************************/
3279 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3283 size
+=size_of_uint32( &info
->version
);
3284 size
+=size_of_relative_string( &info
->name
);
3285 size
+=size_of_relative_string( &info
->architecture
);
3286 size
+=size_of_relative_string( &info
->driverpath
);
3287 size
+=size_of_relative_string( &info
->datafile
);
3288 size
+=size_of_relative_string( &info
->configfile
);
3289 size
+=size_of_relative_string( &info
->helpfile
);
3291 size
+=spoolss_size_string_array(info
->dependentfiles
);
3293 size
+=size_of_relative_string( &info
->monitorname
);
3294 size
+=size_of_relative_string( &info
->defaultdatatype
);
3296 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3298 size
+=size_of_nttime(&info
->driver_date
);
3299 size
+=size_of_uint32( &info
->padding
);
3300 size
+=size_of_uint32( &info
->driver_version_low
);
3301 size
+=size_of_uint32( &info
->driver_version_high
);
3302 size
+=size_of_relative_string( &info
->mfgname
);
3303 size
+=size_of_relative_string( &info
->oem_url
);
3304 size
+=size_of_relative_string( &info
->hardware_id
);
3305 size
+=size_of_relative_string( &info
->provider
);
3310 /*******************************************************************
3311 return the size required by a struct in the stream
3312 ********************************************************************/
3314 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3317 size
+=size_of_uint32( &info
->jobid
);
3318 size
+=size_of_relative_string( &info
->printername
);
3319 size
+=size_of_relative_string( &info
->machinename
);
3320 size
+=size_of_relative_string( &info
->username
);
3321 size
+=size_of_relative_string( &info
->document
);
3322 size
+=size_of_relative_string( &info
->datatype
);
3323 size
+=size_of_relative_string( &info
->text_status
);
3324 size
+=size_of_uint32( &info
->status
);
3325 size
+=size_of_uint32( &info
->priority
);
3326 size
+=size_of_uint32( &info
->position
);
3327 size
+=size_of_uint32( &info
->totalpages
);
3328 size
+=size_of_uint32( &info
->pagesprinted
);
3329 size
+=size_of_systemtime( &info
->submitted
);
3334 /*******************************************************************
3335 return the size required by a struct in the stream
3336 ********************************************************************/
3338 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3342 size
+=4; /* size of sec desc ptr */
3344 size
+=size_of_uint32( &info
->jobid
);
3345 size
+=size_of_relative_string( &info
->printername
);
3346 size
+=size_of_relative_string( &info
->machinename
);
3347 size
+=size_of_relative_string( &info
->username
);
3348 size
+=size_of_relative_string( &info
->document
);
3349 size
+=size_of_relative_string( &info
->notifyname
);
3350 size
+=size_of_relative_string( &info
->datatype
);
3351 size
+=size_of_relative_string( &info
->printprocessor
);
3352 size
+=size_of_relative_string( &info
->parameters
);
3353 size
+=size_of_relative_string( &info
->drivername
);
3354 size
+=size_of_device_mode( info
->devmode
);
3355 size
+=size_of_relative_string( &info
->text_status
);
3356 /* SEC_DESC sec_desc;*/
3357 size
+=size_of_uint32( &info
->status
);
3358 size
+=size_of_uint32( &info
->priority
);
3359 size
+=size_of_uint32( &info
->position
);
3360 size
+=size_of_uint32( &info
->starttime
);
3361 size
+=size_of_uint32( &info
->untiltime
);
3362 size
+=size_of_uint32( &info
->totalpages
);
3363 size
+=size_of_uint32( &info
->size
);
3364 size
+=size_of_systemtime( &info
->submitted
);
3365 size
+=size_of_uint32( &info
->timeelapsed
);
3366 size
+=size_of_uint32( &info
->pagesprinted
);
3371 /*******************************************************************
3372 return the size required by a struct in the stream
3373 ********************************************************************/
3375 uint32
spoolss_size_form_1(FORM_1
*info
)
3379 size
+=size_of_uint32( &info
->flag
);
3380 size
+=size_of_relative_string( &info
->name
);
3381 size
+=size_of_uint32( &info
->width
);
3382 size
+=size_of_uint32( &info
->length
);
3383 size
+=size_of_uint32( &info
->left
);
3384 size
+=size_of_uint32( &info
->top
);
3385 size
+=size_of_uint32( &info
->right
);
3386 size
+=size_of_uint32( &info
->bottom
);
3391 /*******************************************************************
3392 return the size required by a struct in the stream
3393 ********************************************************************/
3395 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3399 size
+=size_of_relative_string( &info
->port_name
);
3404 /*******************************************************************
3405 return the size required by a struct in the stream
3406 ********************************************************************/
3408 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3412 size
=str_len_uni(&info
->name
); /* the string length */
3413 size
=size
+1; /* add the leading zero */
3414 size
=size
*2; /* convert in char */
3419 /*******************************************************************
3420 return the size required by a struct in the stream
3421 ********************************************************************/
3423 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3427 size
=str_len_uni(&info
->name
); /* the string length */
3428 size
=size
+1; /* add the leading zero */
3429 size
=size
*2; /* convert in char */
3434 /*******************************************************************
3435 return the size required by a struct in the stream
3436 ********************************************************************/
3438 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3442 size
+=size_of_relative_string( &info
->port_name
);
3443 size
+=size_of_relative_string( &info
->monitor_name
);
3444 size
+=size_of_relative_string( &info
->description
);
3446 size
+=size_of_uint32( &info
->port_type
);
3447 size
+=size_of_uint32( &info
->reserved
);
3452 /*******************************************************************
3453 return the size required by a struct in the stream
3454 ********************************************************************/
3456 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3459 size
+=size_of_relative_string( &info
->name
);
3464 /*******************************************************************
3465 return the size required by a struct in the stream
3466 ********************************************************************/
3468 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3471 size
+=size_of_relative_string( &info
->name
);
3476 /*******************************************************************
3477 return the size required by a struct in the stream
3478 ********************************************************************/
3479 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3486 /* uint32(offset) + uint32(length) + length) */
3487 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3488 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
+ (p
->data_len
%2) ;
3490 size
+= size_of_uint32(&p
->type
);
3495 /*******************************************************************
3496 return the size required by a struct in the stream
3497 ********************************************************************/
3499 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3502 size
+=size_of_relative_string( &info
->name
);
3507 /*******************************************************************
3508 return the size required by a struct in the stream
3509 ********************************************************************/
3511 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3514 size
+=size_of_relative_string( &info
->name
);
3515 size
+=size_of_relative_string( &info
->environment
);
3516 size
+=size_of_relative_string( &info
->dll_name
);
3521 /*******************************************************************
3523 ********************************************************************/
3525 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3526 const POLICY_HND
*hnd
,
3527 const fstring architecture
,
3528 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3529 RPC_BUFFER
*buffer
, uint32 offered
)
3534 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3536 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3539 q_u
->clientmajorversion
=clientmajor
;
3540 q_u
->clientminorversion
=clientminor
;
3543 q_u
->offered
=offered
;
3548 /*******************************************************************
3550 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3551 ********************************************************************/
3553 BOOL
spoolss_io_q_getprinterdriver2(const char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3555 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3561 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3563 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3565 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3570 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3573 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
3579 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3582 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3584 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3590 /*******************************************************************
3592 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3593 ********************************************************************/
3595 BOOL
spoolss_io_r_getprinterdriver2(const char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3597 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3603 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
3608 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3610 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3612 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3614 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3620 /*******************************************************************
3622 ********************************************************************/
3624 BOOL
make_spoolss_q_enumprinters(
3625 SPOOL_Q_ENUMPRINTERS
*q_u
,
3635 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3636 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3640 q_u
->offered
=offered
;
3645 /*******************************************************************
3647 ********************************************************************/
3649 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3650 fstring servername
, uint32 level
,
3651 RPC_BUFFER
*buffer
, uint32 offered
)
3653 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3654 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3658 q_u
->offered
=offered
;
3663 /*******************************************************************
3665 * called from spoolss_enumprinters (srv_spoolss.c)
3666 ********************************************************************/
3668 BOOL
spoolss_io_q_enumprinters(const char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3670 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3676 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3678 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3681 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3686 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3689 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
3694 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3700 /*******************************************************************
3701 Parse a SPOOL_R_ENUMPRINTERS structure.
3702 ********************************************************************/
3704 BOOL
spoolss_io_r_enumprinters(const char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3706 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3712 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
3718 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3721 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3724 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3730 /*******************************************************************
3731 * write a structure.
3732 * called from spoolss_r_enum_printers (srv_spoolss.c)
3734 ********************************************************************/
3736 BOOL
spoolss_io_r_getprinter(const char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3738 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3744 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
3750 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3753 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3759 /*******************************************************************
3761 * called from spoolss_getprinter (srv_spoolss.c)
3762 ********************************************************************/
3764 BOOL
spoolss_io_q_getprinter(const char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3766 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3772 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3774 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3777 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
3782 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3788 /*******************************************************************
3790 ********************************************************************/
3792 BOOL
make_spoolss_q_getprinter(
3793 TALLOC_CTX
*mem_ctx
,
3794 SPOOL_Q_GETPRINTER
*q_u
,
3795 const POLICY_HND
*hnd
,
3805 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3809 q_u
->offered
=offered
;
3814 /*******************************************************************
3816 ********************************************************************/
3817 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
3818 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
3822 DEVICEMODE
*devmode
;
3827 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3830 q_u
->info
.level
= level
;
3831 q_u
->info
.info_ptr
= 1; /* Info is != NULL, see above */
3834 /* There's no such thing as a setprinter level 1 */
3837 secdesc
= info
->printers_2
->secdesc
;
3838 devmode
= info
->printers_2
->devmode
;
3840 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
3841 #if 1 /* JERRY TEST */
3842 q_u
->secdesc_ctr
= SMB_MALLOC_P(SEC_DESC_BUF
);
3843 if (!q_u
->secdesc_ctr
)
3845 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
3846 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3847 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3848 q_u
->secdesc_ctr
->sec
= secdesc
;
3850 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
3851 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
3852 q_u
->devmode_ctr
.devmode
= devmode
;
3854 q_u
->secdesc_ctr
= NULL
;
3856 q_u
->devmode_ctr
.devmode_ptr
= 0;
3857 q_u
->devmode_ctr
.size
= 0;
3858 q_u
->devmode_ctr
.devmode
= NULL
;
3862 secdesc
= info
->printers_3
->secdesc
;
3864 make_spoolss_printer_info_3 (mem_ctx
, &q_u
->info
.info_3
, info
->printers_3
);
3866 q_u
->secdesc_ctr
= SMB_MALLOC_P(SEC_DESC_BUF
);
3867 if (!q_u
->secdesc_ctr
)
3869 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
3870 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3871 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3872 q_u
->secdesc_ctr
->sec
= secdesc
;
3876 make_spoolss_printer_info_7 (mem_ctx
, &q_u
->info
.info_7
, info
->printers_7
);
3880 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
3885 q_u
->command
= command
;
3891 /*******************************************************************
3892 ********************************************************************/
3894 BOOL
spoolss_io_r_setprinter(const char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3896 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3902 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3908 /*******************************************************************
3909 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3910 ********************************************************************/
3912 BOOL
spoolss_io_q_setprinter(const char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3914 uint32 ptr_sec_desc
= 0;
3916 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3922 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3924 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3927 /* check for supported levels and structures we know about */
3929 switch ( q_u
->level
) {
3934 /* supported levels */
3937 DEBUG(0,("spoolss_io_q_setprinter: unsupported printer info level [%d]\n",
3943 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3946 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3956 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3961 /* FIXME ! Our parsing here is wrong I think,
3962 * but for a level3 it makes no sense for
3963 * ptr_sec_desc to be NULL. JRA. Based on
3964 * a Vista sniff from Martin Zielinski <mz@seh.de>.
3966 if (UNMARSHALLING(ps
)) {
3969 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3976 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3981 /* Parse a NULL security descriptor. This should really
3982 happen inside the sec_io_desc_buf() function. */
3984 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3985 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
3987 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
3991 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3997 /*******************************************************************
3998 ********************************************************************/
4000 BOOL
spoolss_io_r_fcpn(const char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
4002 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
4008 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4014 /*******************************************************************
4015 ********************************************************************/
4017 BOOL
spoolss_io_q_fcpn(const char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
4020 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
4026 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4033 /*******************************************************************
4034 ********************************************************************/
4036 BOOL
spoolss_io_r_addjob(const char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
4038 prs_debug(ps
, depth
, desc
, "");
4044 if(!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4050 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4053 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4059 /*******************************************************************
4060 ********************************************************************/
4062 BOOL
spoolss_io_q_addjob(const char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
4064 prs_debug(ps
, depth
, desc
, "");
4070 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4072 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4075 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4081 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4087 /*******************************************************************
4088 ********************************************************************/
4090 BOOL
spoolss_io_r_enumjobs(const char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
4092 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
4098 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4104 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4107 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4110 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4116 /*******************************************************************
4117 ********************************************************************/
4119 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4130 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4131 q_u
->firstjob
= firstjob
;
4132 q_u
->numofjobs
= numofjobs
;
4134 q_u
->buffer
= buffer
;
4135 q_u
->offered
= offered
;
4139 /*******************************************************************
4140 ********************************************************************/
4142 BOOL
spoolss_io_q_enumjobs(const char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4144 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4150 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4153 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4155 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
4157 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4160 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4166 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4172 /*******************************************************************
4173 ********************************************************************/
4175 BOOL
spoolss_io_r_schedulejob(const char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4177 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4183 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4189 /*******************************************************************
4190 ********************************************************************/
4192 BOOL
spoolss_io_q_schedulejob(const char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4194 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4200 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4202 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4208 /*******************************************************************
4209 ********************************************************************/
4211 BOOL
spoolss_io_r_setjob(const char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4213 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4219 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4225 /*******************************************************************
4226 ********************************************************************/
4228 BOOL
spoolss_io_q_setjob(const char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4230 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4236 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4238 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4241 * level is usually 0. If (level!=0) then I'm in trouble !
4242 * I will try to generate setjob command with level!=0, one day.
4244 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4246 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4252 /*******************************************************************
4253 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4254 ********************************************************************/
4256 BOOL
spoolss_io_r_enumprinterdrivers(const char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4258 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4264 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4270 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4273 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4276 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4282 /*******************************************************************
4284 ********************************************************************/
4286 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4288 const char *environment
,
4290 RPC_BUFFER
*buffer
, uint32 offered
)
4292 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4293 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4297 q_u
->offered
=offered
;
4302 /*******************************************************************
4303 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4304 ********************************************************************/
4306 BOOL
spoolss_io_q_enumprinterdrivers(const char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4309 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4315 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4317 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4322 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4324 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4329 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4332 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4338 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4344 /*******************************************************************
4345 ********************************************************************/
4347 BOOL
spoolss_io_q_enumforms(const char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4350 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4355 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4357 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4360 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4365 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4371 /*******************************************************************
4372 ********************************************************************/
4374 BOOL
spoolss_io_r_enumforms(const char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4376 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4382 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4388 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4391 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4394 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4400 /*******************************************************************
4401 ********************************************************************/
4403 BOOL
spoolss_io_q_getform(const char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4406 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4411 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4413 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4419 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4422 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4427 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4433 /*******************************************************************
4434 ********************************************************************/
4436 BOOL
spoolss_io_r_getform(const char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4438 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4444 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4450 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4453 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4459 /*******************************************************************
4460 Parse a SPOOL_R_ENUMPORTS structure.
4461 ********************************************************************/
4463 BOOL
spoolss_io_r_enumports(const char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4465 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4471 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4477 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4480 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4483 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4489 /*******************************************************************
4490 ********************************************************************/
4492 BOOL
spoolss_io_q_enumports(const char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4494 prs_debug(ps
, depth
, desc
, "");
4500 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4502 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4507 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4510 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4515 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4521 /*******************************************************************
4522 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4523 ********************************************************************/
4525 BOOL
spool_io_printer_info_level_1(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4527 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4533 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4535 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4537 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4539 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4542 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4544 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4546 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4552 /*******************************************************************
4553 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4554 ********************************************************************/
4556 BOOL
spool_io_printer_info_level_3(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4558 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4564 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4570 /*******************************************************************
4571 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4572 ********************************************************************/
4574 BOOL
spool_io_printer_info_level_2(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4576 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4582 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4584 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4586 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4588 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4591 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4593 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4595 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4597 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4599 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4601 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4603 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4605 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4607 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4610 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4612 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4614 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4616 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4618 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4620 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4622 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4624 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4627 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4629 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4631 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4633 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4635 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4637 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4639 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4641 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4643 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4645 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4647 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4653 BOOL
spool_io_printer_info_level_7(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_7
*il
, prs_struct
*ps
, int depth
)
4655 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_7");
4661 if(!prs_uint32("guid_ptr", ps
, depth
, &il
->guid_ptr
))
4663 if(!prs_uint32("action", ps
, depth
, &il
->action
))
4666 if(!smb_io_unistr2("servername", &il
->guid
, il
->guid_ptr
, ps
, depth
))
4671 /*******************************************************************
4672 ********************************************************************/
4674 BOOL
spool_io_printer_info_level(const char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4676 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4681 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4683 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4686 /* if no struct inside just return */
4687 if (il
->info_ptr
==0) {
4688 if (UNMARSHALLING(ps
)) {
4695 switch (il
->level
) {
4697 * level 0 is used by setprinter when managing the queue
4698 * (hold, stop, start a queue)
4702 /* DOCUMENT ME!!! What is level 1 used for? */
4705 if (UNMARSHALLING(ps
)) {
4706 if ((il
->info_1
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_1
,1)) == NULL
)
4709 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4714 * level 2 is used by addprinter
4715 * and by setprinter when updating printer's info
4718 if (UNMARSHALLING(ps
)) {
4719 if ((il
->info_2
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_2
,1)) == NULL
)
4722 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4725 /* DOCUMENT ME!!! What is level 3 used for? */
4728 if (UNMARSHALLING(ps
)) {
4729 if ((il
->info_3
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_3
,1)) == NULL
)
4732 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4737 if (UNMARSHALLING(ps
))
4738 if ((il
->info_7
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_7
,1)) == NULL
)
4740 if (!spool_io_printer_info_level_7("", il
->info_7
, ps
, depth
))
4748 /*******************************************************************
4749 ********************************************************************/
4751 BOOL
spoolss_io_q_addprinterex(const char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4753 uint32 ptr_sec_desc
= 0;
4755 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4761 if (!prs_io_unistr2_p("ptr", ps
, depth
, &q_u
->server_name
))
4763 if (!prs_io_unistr2("servername", ps
, depth
, q_u
->server_name
))
4769 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4772 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4775 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4781 switch (q_u
->level
) {
4783 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4786 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4790 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4795 /* Parse a NULL security descriptor. This should really
4796 happen inside the sec_io_desc_buf() function. */
4798 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4799 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4801 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
4805 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4807 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4813 /*******************************************************************
4814 ********************************************************************/
4816 BOOL
spoolss_io_r_addprinterex(const char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4817 prs_struct
*ps
, int depth
)
4819 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4822 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4825 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4831 /*******************************************************************
4832 ********************************************************************/
4834 BOOL
spool_io_printer_driver_info_level_3(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4835 prs_struct
*ps
, int depth
)
4837 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4839 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4843 if (UNMARSHALLING(ps
)) {
4844 il
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
,1);
4856 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4858 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4860 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4862 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4864 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4866 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4868 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4870 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4872 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4874 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4876 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4882 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4884 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4886 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4888 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4890 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4892 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4894 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4896 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4902 if (il
->dependentfiles_ptr
)
4903 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
4908 /*******************************************************************
4909 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4910 ********************************************************************/
4912 BOOL
spool_io_printer_driver_info_level_6(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4913 prs_struct
*ps
, int depth
)
4915 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4917 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4921 if (UNMARSHALLING(ps
)) {
4922 il
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
,1);
4935 * I know this seems weird, but I have no other explanation.
4936 * This is observed behavior on both NT4 and 2K servers.
4940 if (!prs_align_uint64(ps
))
4943 /* parse the main elements the packet */
4945 if(!prs_uint32("cversion ", ps
, depth
, &il
->version
))
4947 if(!prs_uint32("name ", ps
, depth
, &il
->name_ptr
))
4949 if(!prs_uint32("environment ", ps
, depth
, &il
->environment_ptr
))
4951 if(!prs_uint32("driverpath ", ps
, depth
, &il
->driverpath_ptr
))
4953 if(!prs_uint32("datafile ", ps
, depth
, &il
->datafile_ptr
))
4955 if(!prs_uint32("configfile ", ps
, depth
, &il
->configfile_ptr
))
4957 if(!prs_uint32("helpfile ", ps
, depth
, &il
->helpfile_ptr
))
4959 if(!prs_uint32("monitorname ", ps
, depth
, &il
->monitorname_ptr
))
4961 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4963 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_len
))
4965 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_ptr
))
4967 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_len
))
4969 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_ptr
))
4971 if(!smb_io_time("driverdate ", &il
->driverdate
, ps
, depth
))
4973 if(!prs_uint32("dummy4 ", ps
, depth
, &il
->dummy4
))
4975 if(!prs_uint64("driverversion ", ps
, depth
, &il
->driverversion
))
4977 if(!prs_uint32("mfgname ", ps
, depth
, &il
->mfgname_ptr
))
4979 if(!prs_uint32("oemurl ", ps
, depth
, &il
->oemurl_ptr
))
4981 if(!prs_uint32("hardwareid ", ps
, depth
, &il
->hardwareid_ptr
))
4983 if(!prs_uint32("provider ", ps
, depth
, &il
->provider_ptr
))
4986 /* parse the structures in the packet */
4988 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4993 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4998 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
5003 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
5008 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
5013 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
5018 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
5023 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
5027 if (il
->dependentfiles_ptr
) {
5028 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
5033 if (il
->previousnames_ptr
) {
5034 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
5039 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
5043 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
5047 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
5051 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
5057 /*******************************************************************
5058 convert a buffer of UNICODE strings null terminated
5059 the buffer is terminated by a NULL
5061 convert to an dos codepage array (null terminated)
5063 dynamically allocate memory
5065 ********************************************************************/
5067 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
5076 src
= (char *)buf5
->buffer
;
5077 *ar
= SMB_MALLOC_ARRAY(fstring
, 1);
5082 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
5083 rpcstr_pull(f
, src
, sizeof(f
)-1, -1, STR_TERMINATE
);
5084 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
5085 *ar
= SMB_REALLOC_ARRAY(*ar
, fstring
, n
+2);
5089 fstrcpy((*ar
)[n
], f
);
5093 fstrcpy((*ar
)[n
], "");
5098 /*******************************************************************
5099 read a UNICODE array with null terminated strings
5100 and null terminated array
5101 and size of array at beginning
5102 ********************************************************************/
5104 BOOL
smb_io_unibuffer(const char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
5106 if (buffer
==NULL
) return False
;
5109 buffer
->uni_str_len
=buffer
->uni_max_len
;
5111 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
5114 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
5120 /*******************************************************************
5121 ********************************************************************/
5123 BOOL
spool_io_printer_driver_info_level(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
5125 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
5130 if(!prs_uint32("level", ps
, depth
, &il
->level
))
5132 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
5138 switch (il
->level
) {
5140 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
5144 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5154 /*******************************************************************
5155 init a SPOOL_Q_ADDPRINTERDRIVER struct
5156 ******************************************************************/
5158 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5159 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5160 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5162 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5164 if (!srv_name
|| !info
) {
5168 q_u
->server_name_ptr
= 1; /* srv_name is != NULL, see above */
5169 init_unistr2(&q_u
->server_name
, srv_name
, UNI_STR_TERMINATE
);
5173 q_u
->info
.level
= level
;
5174 q_u
->info
.ptr
= 1; /* Info is != NULL, see above */
5177 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5179 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5183 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5190 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5191 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5192 DRIVER_INFO_3
*info3
)
5195 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5197 if (!(inf
=TALLOC_ZERO_P(mem_ctx
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
)))
5200 inf
->cversion
= info3
->version
;
5201 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5202 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5203 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5204 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5205 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5206 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5207 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5208 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5210 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5211 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5212 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5213 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5214 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5215 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5216 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5217 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5219 if (info3
->dependentfiles
) {
5221 BOOL null_char
= False
;
5222 uint16
*ptr
= info3
->dependentfiles
;
5227 /* the null_char BOOL is used to help locate
5228 two '\0's back to back */
5245 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5246 inf
->dependentfilessize
= (info3
->dependentfiles
!= NULL
) ? len
: 0;
5247 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
)) {
5252 *spool_drv_info
= inf
;
5257 /*******************************************************************
5258 make a BUFFER5 struct from a uint16*
5259 ******************************************************************/
5261 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5264 buf5
->buf_len
= len
;
5267 if((buf5
->buffer
=(uint16
*)TALLOC_MEMDUP(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
) {
5268 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5272 buf5
->buffer
= NULL
;
5281 /*******************************************************************
5282 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5283 ********************************************************************/
5285 BOOL
spoolss_io_q_addprinterdriver(const char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5287 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5293 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5295 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5300 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5303 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5309 /*******************************************************************
5310 ********************************************************************/
5312 BOOL
spoolss_io_r_addprinterdriver(const char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5314 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5317 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5323 /*******************************************************************
5324 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5325 ********************************************************************/
5327 BOOL
spoolss_io_q_addprinterdriverex(const char *desc
, SPOOL_Q_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5329 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriverex");
5335 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5337 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5342 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5345 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5350 if(!prs_uint32("copy flags", ps
, depth
, &q_u
->copy_flags
))
5356 /*******************************************************************
5357 ********************************************************************/
5359 BOOL
spoolss_io_r_addprinterdriverex(const char *desc
, SPOOL_R_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
5361 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriverex");
5364 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5370 /*******************************************************************
5371 ********************************************************************/
5373 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5374 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5376 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5378 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5382 *asc
=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_3
);
5390 d
->cversion
=uni
->cversion
;
5392 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5393 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5394 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5395 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5396 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5397 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5398 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5399 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5401 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5402 DEBUGADD(8,( "name: %s\n", d
->name
));
5403 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5404 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5405 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5406 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5407 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5408 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5409 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5411 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5418 /*******************************************************************
5419 ********************************************************************/
5420 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5421 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5423 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5425 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5429 *asc
=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_6
);
5437 d
->version
=uni
->version
;
5439 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5440 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5441 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5442 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5443 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5444 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5445 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5446 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5448 DEBUGADD(8,( "version: %d\n", d
->version
));
5449 DEBUGADD(8,( "name: %s\n", d
->name
));
5450 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5451 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5452 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5453 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5454 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5455 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5456 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5458 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5460 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5470 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5471 NT_PRINTER_INFO_LEVEL_2
*d
)
5473 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5475 d
->attributes
=uni
->attributes
;
5476 d
->priority
=uni
->priority
;
5477 d
->default_priority
=uni
->default_priority
;
5478 d
->starttime
=uni
->starttime
;
5479 d
->untiltime
=uni
->untiltime
;
5480 d
->status
=uni
->status
;
5481 d
->cjobs
=uni
->cjobs
;
5483 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5484 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5485 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5486 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5487 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5488 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5489 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5490 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5491 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5492 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5493 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5498 /*******************************************************************
5500 ********************************************************************/
5502 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5503 fstring servername
, fstring env_name
, uint32 level
,
5504 RPC_BUFFER
*buffer
, uint32 offered
)
5506 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5507 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5511 q_u
->offered
=offered
;
5516 /*******************************************************************
5517 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5518 ********************************************************************/
5520 BOOL
spoolss_io_q_getprinterdriverdir(const char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5522 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5527 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5529 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5535 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5537 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5543 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5546 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
5552 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5558 /*******************************************************************
5559 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5560 ********************************************************************/
5562 BOOL
spoolss_io_r_getprinterdriverdir(const char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5564 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5570 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
5576 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5579 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5585 /*******************************************************************
5586 ********************************************************************/
5588 BOOL
spoolss_io_r_enumprintprocessors(const char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5590 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5596 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
5602 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5605 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5608 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5614 /*******************************************************************
5615 ********************************************************************/
5617 BOOL
spoolss_io_q_enumprintprocessors(const char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5619 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5625 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5627 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5633 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5635 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5641 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5644 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
5650 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5656 /*******************************************************************
5657 ********************************************************************/
5659 BOOL
spoolss_io_q_addprintprocessor(const char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5661 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5667 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5669 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5674 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5679 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5684 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5690 /*******************************************************************
5691 ********************************************************************/
5693 BOOL
spoolss_io_r_addprintprocessor(const char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5695 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5701 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5707 /*******************************************************************
5708 ********************************************************************/
5710 BOOL
spoolss_io_r_enumprintprocdatatypes(const char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5712 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5718 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
5724 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5727 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5730 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5736 /*******************************************************************
5737 ********************************************************************/
5739 BOOL
spoolss_io_q_enumprintprocdatatypes(const char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5741 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5747 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5749 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5755 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5757 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5763 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5766 if(!prs_rpcbuffer_p("buffer", ps
, depth
, &q_u
->buffer
))
5772 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5778 /*******************************************************************
5779 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5780 ********************************************************************/
5782 BOOL
spoolss_io_q_enumprintmonitors(const char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5784 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5790 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5792 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5798 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5801 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
5807 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5813 /*******************************************************************
5814 ********************************************************************/
5816 BOOL
spoolss_io_r_enumprintmonitors(const char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5818 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5824 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
5830 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5833 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5836 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5842 /*******************************************************************
5843 ********************************************************************/
5845 BOOL
spoolss_io_r_enumprinterdata(const char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5847 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5852 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5855 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
5856 r_u
->value
= PRS_ALLOC_MEM(ps
, uint16
, r_u
->valuesize
);
5858 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
5863 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5869 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5872 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5875 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5878 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
5879 r_u
->data
= PRS_ALLOC_MEM(ps
, uint8
, r_u
->datasize
);
5881 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
5886 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
5891 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
5893 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5899 /*******************************************************************
5900 ********************************************************************/
5902 BOOL
spoolss_io_q_enumprinterdata(const char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5904 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
5909 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5911 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
5913 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
5915 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
5921 /*******************************************************************
5922 ********************************************************************/
5924 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
5925 const POLICY_HND
*hnd
,
5926 uint32 idx
, uint32 valuelen
, uint32 datalen
)
5928 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5930 q_u
->valuesize
=valuelen
;
5931 q_u
->datasize
=datalen
;
5936 /*******************************************************************
5937 ********************************************************************/
5939 BOOL
make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX
*q_u
,
5940 const POLICY_HND
*hnd
, const char *key
,
5943 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5944 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
5950 /*******************************************************************
5951 ********************************************************************/
5952 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, const POLICY_HND
*hnd
,
5953 char* value
, uint32 data_type
, char* data
, uint32 data_size
)
5955 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5956 q_u
->type
= data_type
;
5957 init_unistr2(&q_u
->value
, value
, UNI_STR_TERMINATE
);
5959 q_u
->max_len
= q_u
->real_len
= data_size
;
5960 q_u
->data
= (unsigned char *)data
;
5965 /*******************************************************************
5966 ********************************************************************/
5967 BOOL
make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX
*q_u
, const POLICY_HND
*hnd
,
5968 char *key
, char* value
, uint32 data_type
, char* data
,
5971 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5972 q_u
->type
= data_type
;
5973 init_unistr2(&q_u
->value
, value
, UNI_STR_TERMINATE
);
5974 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
5976 q_u
->max_len
= q_u
->real_len
= data_size
;
5977 q_u
->data
= (unsigned char *)data
;
5982 /*******************************************************************
5983 ********************************************************************/
5985 BOOL
spoolss_io_q_setprinterdata(const char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5987 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
5992 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5994 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6000 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6003 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6013 if (UNMARSHALLING(ps
))
6014 q_u
->data
=PRS_ALLOC_MEM(ps
, uint8
, q_u
->max_len
);
6015 if(q_u
->data
== NULL
)
6017 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6025 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6031 /*******************************************************************
6032 ********************************************************************/
6034 BOOL
spoolss_io_r_setprinterdata(const char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
6036 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
6041 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6047 /*******************************************************************
6048 ********************************************************************/
6049 BOOL
spoolss_io_q_resetprinter(const char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6051 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
6056 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6059 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
6062 if (q_u
->datatype_ptr
) {
6063 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
6067 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
6074 /*******************************************************************
6075 ********************************************************************/
6076 BOOL
spoolss_io_r_resetprinter(const char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6078 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
6083 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6089 /*******************************************************************
6090 ********************************************************************/
6092 static BOOL
spoolss_io_addform(const char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
6094 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
6101 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
6103 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
6105 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
6107 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
6109 if(!prs_uint32("left", ps
, depth
, &f
->left
))
6111 if(!prs_uint32("top", ps
, depth
, &f
->top
))
6113 if(!prs_uint32("right", ps
, depth
, &f
->right
))
6115 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
6118 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
6125 /*******************************************************************
6126 ********************************************************************/
6128 BOOL
spoolss_io_q_deleteform(const char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
6130 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
6135 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6137 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
6143 /*******************************************************************
6144 ********************************************************************/
6146 BOOL
spoolss_io_r_deleteform(const char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
6148 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
6153 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6159 /*******************************************************************
6160 ********************************************************************/
6162 BOOL
spoolss_io_q_addform(const char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
6164 uint32 useless_ptr
=1;
6165 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
6170 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6172 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6174 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6179 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6181 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6188 /*******************************************************************
6189 ********************************************************************/
6191 BOOL
spoolss_io_r_addform(const char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6193 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6198 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6204 /*******************************************************************
6205 ********************************************************************/
6207 BOOL
spoolss_io_q_setform(const char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6209 uint32 useless_ptr
=1;
6210 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6215 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6217 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6223 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6225 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6230 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6232 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6239 /*******************************************************************
6240 ********************************************************************/
6242 BOOL
spoolss_io_r_setform(const char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6244 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6249 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6255 /*******************************************************************
6256 Parse a SPOOL_R_GETJOB structure.
6257 ********************************************************************/
6259 BOOL
spoolss_io_r_getjob(const char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6261 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6267 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
6273 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6276 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6282 /*******************************************************************
6283 Parse a SPOOL_Q_GETJOB structure.
6284 ********************************************************************/
6286 BOOL
spoolss_io_q_getjob(const char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6288 prs_debug(ps
, depth
, desc
, "");
6294 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6296 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6298 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6301 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
6307 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6313 void free_devmode(DEVICEMODE
*devmode
)
6315 if (devmode
!=NULL
) {
6316 SAFE_FREE(devmode
->dev_private
);
6321 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6326 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6328 if (printer
!=NULL
) {
6329 free_devmode(printer
->devmode
);
6330 printer
->devmode
= NULL
;
6335 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6340 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6345 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6350 void free_printer_info_6(PRINTER_INFO_6
*printer
)
6355 void free_printer_info_7(PRINTER_INFO_7
*printer
)
6360 void free_job_info_2(JOB_INFO_2
*job
)
6363 free_devmode(job
->devmode
);
6366 /*******************************************************************
6368 ********************************************************************/
6370 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6371 const fstring string
, uint32 printer
, uint32 type
)
6376 init_unistr2(&q_u
->string
, string
, UNI_STR_TERMINATE
);
6378 q_u
->printer
=printer
;
6387 /*******************************************************************
6388 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6389 ********************************************************************/
6391 BOOL
spoolss_io_q_replyopenprinter(const char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6393 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6399 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6405 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6407 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6410 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6412 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6418 /*******************************************************************
6419 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6420 ********************************************************************/
6422 BOOL
spoolss_io_r_replyopenprinter(const char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6424 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6430 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6433 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6439 /*******************************************************************
6441 ********************************************************************/
6442 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6443 uint32 condition
, uint32 change_id
)
6446 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6448 q_u
->condition
= condition
;
6449 q_u
->change_id
= change_id
;
6452 q_u
->unknown1
= 0x1;
6453 memset(q_u
->unknown2
, 0x0, 5);
6454 q_u
->unknown2
[0] = 0x1;
6459 /*******************************************************************
6460 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6461 ********************************************************************/
6462 BOOL
spoolss_io_q_routerreplyprinter (const char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6465 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6471 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6474 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6477 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6480 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6483 if (!prs_uint8s(False
, "dev_private", ps
, depth
, q_u
->unknown2
, 5))
6489 /*******************************************************************
6490 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6491 ********************************************************************/
6492 BOOL
spoolss_io_r_routerreplyprinter (const char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6494 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6500 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6506 /*******************************************************************
6508 ********************************************************************/
6510 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6515 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6520 /*******************************************************************
6521 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6522 ********************************************************************/
6524 BOOL
spoolss_io_q_replycloseprinter(const char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6526 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6532 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6538 /*******************************************************************
6539 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6540 ********************************************************************/
6542 BOOL
spoolss_io_r_replycloseprinter(const char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6544 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6550 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6553 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6559 #if 0 /* JERRY - not currently used but could be :-) */
6561 /*******************************************************************
6562 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6563 ******************************************************************/
6564 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6565 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6569 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6571 for (i
=0; i
<n
; i
++) {
6575 if (src
->size
!= POINTER
)
6577 len
= src
->notify_data
.data
.length
;
6578 s
= SMB_MALLOC_ARRAY(uint16
, len
);
6580 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6584 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6585 dst
->notify_data
.data
.string
= s
;
6591 /*******************************************************************
6592 Deep copy a SPOOL_NOTIFY_INFO structure
6593 ******************************************************************/
6594 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6597 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6601 dst
->version
= src
->version
;
6602 dst
->flags
= src
->flags
;
6603 dst
->count
= src
->count
;
6607 dst
->data
= SMB_MALLOC_ARRAY(SPOOL_NOTIFY_INFO_DATA
, dst
->count
);
6609 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6612 if (dst
->data
== NULL
) {
6613 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6618 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6625 /*******************************************************************
6627 ********************************************************************/
6629 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6630 uint32 change_low
, uint32 change_high
,
6631 SPOOL_NOTIFY_INFO
*info
)
6636 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6638 q_u
->change_low
=change_low
;
6639 q_u
->change_high
=change_high
;
6644 q_u
->info_ptr
=0x0FF0ADDE;
6646 q_u
->info
.version
=2;
6649 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6651 q_u
->info
.version
= info
->version
;
6652 q_u
->info
.flags
= info
->flags
;
6653 q_u
->info
.count
= info
->count
;
6654 /* pointer field - be careful! */
6655 q_u
->info
.data
= info
->data
;
6658 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6665 /*******************************************************************
6666 Parse a SPOOL_Q_REPLY_RRPCN structure.
6667 ********************************************************************/
6669 BOOL
spoolss_io_q_reply_rrpcn(const char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6671 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6677 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6680 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6683 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6686 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6689 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6692 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6695 if(q_u
->info_ptr
!=0)
6696 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6702 /*******************************************************************
6703 Parse a SPOOL_R_REPLY_RRPCN structure.
6704 ********************************************************************/
6706 BOOL
spoolss_io_r_reply_rrpcn(const char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6708 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6714 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6717 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6723 /*******************************************************************
6725 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6726 ********************************************************************/
6728 BOOL
spoolss_io_q_getprinterdataex(const char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6733 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6738 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6742 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6746 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6750 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6756 /*******************************************************************
6757 * write a structure.
6758 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6759 ********************************************************************/
6761 BOOL
spoolss_io_r_getprinterdataex(const char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6766 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6771 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6773 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6776 if (UNMARSHALLING(ps
) && r_u
->size
) {
6777 r_u
->data
= PRS_ALLOC_MEM(ps
, unsigned char, r_u
->size
);
6782 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
6788 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6790 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6796 /*******************************************************************
6798 ********************************************************************/
6800 BOOL
spoolss_io_q_setprinterdataex(const char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6802 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
6807 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6809 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6815 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6821 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6824 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6834 if (UNMARSHALLING(ps
))
6835 q_u
->data
=PRS_ALLOC_MEM(ps
, uint8
, q_u
->max_len
);
6836 if(q_u
->data
== NULL
)
6838 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6846 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6852 /*******************************************************************
6853 * write a structure.
6854 ********************************************************************/
6856 BOOL
spoolss_io_r_setprinterdataex(const char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6858 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
6863 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6869 /*******************************************************************
6871 ********************************************************************/
6872 BOOL
make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY
*q_u
,
6873 POLICY_HND
*hnd
, const char *key
,
6876 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
6878 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6879 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
6885 /*******************************************************************
6887 ********************************************************************/
6889 BOOL
spoolss_io_q_enumprinterkey(const char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
6891 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
6896 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6899 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6905 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6911 /*******************************************************************
6912 * write a structure.
6913 ********************************************************************/
6915 BOOL
spoolss_io_r_enumprinterkey(const char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
6917 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
6923 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
6929 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6932 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6938 /*******************************************************************
6940 ********************************************************************/
6942 BOOL
make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY
*q_u
,
6943 POLICY_HND
*hnd
, char *keyname
)
6945 DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
6947 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6948 init_unistr2(&q_u
->keyname
, keyname
, UNI_STR_TERMINATE
);
6953 /*******************************************************************
6955 ********************************************************************/
6957 BOOL
spoolss_io_q_deleteprinterkey(const char *desc
, SPOOL_Q_DELETEPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
6959 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterkey");
6964 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6967 if(!smb_io_unistr2("", &q_u
->keyname
, True
, ps
, depth
))
6973 /*******************************************************************
6974 * write a structure.
6975 ********************************************************************/
6977 BOOL
spoolss_io_r_deleteprinterkey(const char *desc
, SPOOL_R_DELETEPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
6979 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterkey");
6985 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6992 /*******************************************************************
6994 ********************************************************************/
6996 BOOL
spoolss_io_q_enumprinterdataex(const char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6998 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
7003 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7006 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
7012 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
7018 /*******************************************************************
7019 ********************************************************************/
7021 static BOOL
spoolss_io_printer_enum_values_ctr(const char *desc
, prs_struct
*ps
,
7022 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
7025 uint32 valuename_offset
,
7028 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
7030 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
7034 * offset data begins at 20 bytes per structure * size_of_array.
7035 * Don't forget the uint32 at the beginning
7038 current_offset
= basic_unit
* ctr
->size_of_array
;
7040 /* first loop to write basic enum_value information */
7042 if (UNMARSHALLING(ps
) && ctr
->size_of_array
) {
7043 ctr
->values
= PRS_ALLOC_MEM(ps
, PRINTER_ENUM_VALUES
, ctr
->size_of_array
);
7048 for (i
=0; i
<ctr
->size_of_array
; i
++) {
7049 uint32 base_offset
, return_offset
;
7051 base_offset
= prs_offset(ps
);
7053 valuename_offset
= current_offset
;
7054 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
7057 /* Read or write the value. */
7059 return_offset
= prs_offset(ps
);
7061 if (!prs_set_offset(ps
, base_offset
+ valuename_offset
)) {
7065 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
7069 if (!prs_set_offset(ps
, return_offset
))
7072 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
7075 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
7078 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
7080 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
7083 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
7086 /* Read or write the data. */
7088 return_offset
= prs_offset(ps
);
7090 if (!prs_set_offset(ps
, base_offset
+ data_offset
)) {
7094 if ( ctr
->values
[i
].data_len
) {
7095 if ( UNMARSHALLING(ps
) ) {
7096 ctr
->values
[i
].data
= PRS_ALLOC_MEM(ps
, uint8
, ctr
->values
[i
].data_len
);
7097 if (!ctr
->values
[i
].data
)
7100 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
7104 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
7105 /* account for 2 byte alignment */
7106 current_offset
+= (current_offset
% 2);
7108 /* Remember how far we got. */
7109 data_offset
= prs_offset(ps
);
7112 if (!prs_set_offset(ps
, return_offset
))
7117 /* Go to the last data offset we got to. */
7119 if (!prs_set_offset(ps
, data_offset
))
7122 /* And ensure we're 2 byte aligned. */
7124 if ( !prs_align_uint16(ps
) )
7130 /*******************************************************************
7131 * write a structure.
7132 ********************************************************************/
7134 BOOL
spoolss_io_r_enumprinterdataex(const char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
7136 uint32 data_offset
, end_offset
;
7137 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
7143 if (!prs_uint32("size", ps
, depth
, &r_u
->ctr
.size
))
7146 data_offset
= prs_offset(ps
);
7148 if (!prs_set_offset(ps
, data_offset
+ r_u
->ctr
.size
))
7154 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7157 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
7160 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7163 r_u
->ctr
.size_of_array
= r_u
->returned
;
7165 end_offset
= prs_offset(ps
);
7167 if (!prs_set_offset(ps
, data_offset
))
7171 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
7174 if (!prs_set_offset(ps
, end_offset
))
7179 /*******************************************************************
7180 * write a structure.
7181 ********************************************************************/
7184 uint32 GetPrintProcessorDirectory(
7186 [in] unistr2 *environment,
7188 [in,out] RPC_BUFFER buffer,
7189 [in] uint32 offered,
7190 [out] uint32 needed,
7191 [out] uint32 returned
7196 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, RPC_BUFFER
*buffer
, uint32 offered
)
7198 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
7200 init_unistr2(&q_u
->name
, name
, UNI_STR_TERMINATE
);
7201 init_unistr2(&q_u
->environment
, environment
, UNI_STR_TERMINATE
);
7205 q_u
->buffer
= buffer
;
7206 q_u
->offered
= offered
;
7211 BOOL
spoolss_io_q_getprintprocessordirectory(const char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
7215 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
7221 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7225 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
7232 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
7236 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
7244 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
7247 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
7253 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
7259 /*******************************************************************
7260 * write a structure.
7261 ********************************************************************/
7263 BOOL
spoolss_io_r_getprintprocessordirectory(const char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
7265 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
7271 if(!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
7277 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7280 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7286 BOOL
smb_io_printprocessordirectory_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
7288 prs_struct
*ps
=&buffer
->prs
;
7290 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
7293 buffer
->struct_start
=prs_offset(ps
);
7295 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
7301 /*******************************************************************
7303 ********************************************************************/
7305 BOOL
make_spoolss_q_addform(SPOOL_Q_ADDFORM
*q_u
, POLICY_HND
*handle
,
7306 int level
, FORM
*form
)
7308 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7310 q_u
->level2
= level
;
7311 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7316 /*******************************************************************
7318 ********************************************************************/
7320 BOOL
make_spoolss_q_setform(SPOOL_Q_SETFORM
*q_u
, POLICY_HND
*handle
,
7321 int level
, const char *form_name
, FORM
*form
)
7323 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7325 q_u
->level2
= level
;
7326 memcpy(&q_u
->form
, form
, sizeof(FORM
));
7327 init_unistr2(&q_u
->name
, form_name
, UNI_STR_TERMINATE
);
7332 /*******************************************************************
7334 ********************************************************************/
7336 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
,
7339 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7340 init_unistr2(&q_u
->name
, form
, UNI_STR_TERMINATE
);
7344 /*******************************************************************
7346 ********************************************************************/
7348 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7349 const char *formname
, uint32 level
,
7350 RPC_BUFFER
*buffer
, uint32 offered
)
7352 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7354 init_unistr2(&q_u
->formname
, formname
, UNI_STR_TERMINATE
);
7356 q_u
->offered
=offered
;
7361 /*******************************************************************
7363 ********************************************************************/
7365 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7366 uint32 level
, RPC_BUFFER
*buffer
,
7369 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7372 q_u
->offered
=offered
;
7377 /*******************************************************************
7379 ********************************************************************/
7381 BOOL
make_spoolss_q_setjob(SPOOL_Q_SETJOB
*q_u
, POLICY_HND
*handle
,
7382 uint32 jobid
, uint32 level
, uint32 command
)
7384 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7388 /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but
7389 the server side code has it marked as unused. */
7391 q_u
->command
= command
;
7396 /*******************************************************************
7398 ********************************************************************/
7400 BOOL
make_spoolss_q_getjob(SPOOL_Q_GETJOB
*q_u
, POLICY_HND
*handle
,
7401 uint32 jobid
, uint32 level
, RPC_BUFFER
*buffer
,
7404 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7407 q_u
->buffer
= buffer
;
7408 q_u
->offered
= offered
;
7413 /*******************************************************************
7415 ********************************************************************/
7417 BOOL
make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER
*q_u
,
7420 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7425 /*******************************************************************
7427 ********************************************************************/
7429 BOOL
make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER
*q_u
,
7432 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7437 /*******************************************************************
7439 ********************************************************************/
7441 BOOL
make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER
*q_u
,
7442 POLICY_HND
*handle
, uint32 level
,
7443 char *docname
, char *outputfile
,
7446 DOC_INFO_CONTAINER
*ctr
= &q_u
->doc_info_container
;
7448 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7454 ctr
->docinfo
.switch_value
= level
;
7456 ctr
->docinfo
.doc_info_1
.p_docname
= docname
? 1 : 0;
7457 ctr
->docinfo
.doc_info_1
.p_outputfile
= outputfile
? 1 : 0;
7458 ctr
->docinfo
.doc_info_1
.p_datatype
= datatype
? 1 : 0;
7460 init_unistr2(&ctr
->docinfo
.doc_info_1
.docname
, docname
, UNI_STR_TERMINATE
);
7461 init_unistr2(&ctr
->docinfo
.doc_info_1
.outputfile
, outputfile
, UNI_STR_TERMINATE
);
7462 init_unistr2(&ctr
->docinfo
.doc_info_1
.datatype
, datatype
, UNI_STR_TERMINATE
);
7466 /* DOC_INFO_2 is only used by Windows 9x and since it
7467 doesn't do printing over RPC we don't have to worry
7470 DEBUG(3, ("unsupported info level %d\n", level
));
7477 /*******************************************************************
7479 ********************************************************************/
7481 BOOL
make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER
*q_u
,
7484 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7489 /*******************************************************************
7491 ********************************************************************/
7493 BOOL
make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER
*q_u
,
7494 POLICY_HND
*handle
, uint32 data_size
,
7497 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7498 q_u
->buffer_size
= q_u
->buffer_size2
= data_size
;
7499 q_u
->buffer
= (unsigned char *)data
;
7503 /*******************************************************************
7505 ********************************************************************/
7507 BOOL
make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA
*q_u
,
7508 POLICY_HND
*handle
, char *valuename
)
7510 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7511 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
7516 /*******************************************************************
7518 ********************************************************************/
7520 BOOL
make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX
*q_u
,
7521 POLICY_HND
*handle
, char *key
,
7524 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7525 init_unistr2(&q_u
->valuename
, value
, UNI_STR_TERMINATE
);
7526 init_unistr2(&q_u
->keyname
, key
, UNI_STR_TERMINATE
);
7531 /*******************************************************************
7533 ********************************************************************/
7535 BOOL
make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX
*q_u
, POLICY_HND
*handle
,
7536 uint32 flags
, uint32 options
, const char *localmachine
,
7537 uint32 printerlocal
, SPOOL_NOTIFY_OPTION
*option
)
7539 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7542 q_u
->options
= options
;
7544 q_u
->localmachine_ptr
= 1;
7546 init_unistr2(&q_u
->localmachine
, localmachine
, UNI_STR_TERMINATE
);
7548 q_u
->printerlocal
= printerlocal
;
7551 q_u
->option_ptr
= 1;
7553 q_u
->option
= option
;
7559 /*******************************************************************
7560 ********************************************************************/
7562 BOOL
spoolss_io_q_xcvdataport(const char *desc
, SPOOL_Q_XCVDATAPORT
*q_u
, prs_struct
*ps
, int depth
)
7564 prs_debug(ps
, depth
, desc
, "spoolss_io_q_xcvdataport");
7570 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
7573 if(!smb_io_unistr2("", &q_u
->dataname
, True
, ps
, depth
))
7579 if(!prs_rpcbuffer("", ps
, depth
, &q_u
->indata
))
7585 if (!prs_uint32("indata_len", ps
, depth
, &q_u
->indata_len
))
7587 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
7589 if (!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
7595 /*******************************************************************
7596 ********************************************************************/
7598 BOOL
spoolss_io_r_xcvdataport(const char *desc
, SPOOL_R_XCVDATAPORT
*r_u
, prs_struct
*ps
, int depth
)
7600 prs_debug(ps
, depth
, desc
, "spoolss_io_r_xcvdataport");
7605 if(!prs_rpcbuffer("", ps
, depth
, &r_u
->outdata
))
7611 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
7613 if (!prs_uint32("unknown", ps
, depth
, &r_u
->unknown
))
7616 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
7622 /*******************************************************************
7623 ********************************************************************/
7625 BOOL
make_monitorui_buf( RPC_BUFFER
*buf
, const char *dllname
)
7632 init_unistr( &string
, dllname
);
7634 if ( !prs_unistr( "ui_dll", &buf
->prs
, 0, &string
) )
7640 /*******************************************************************
7641 ********************************************************************/
7643 #define PORT_DATA_1_PAD 540
7645 static BOOL
smb_io_port_data_1( const char *desc
, RPC_BUFFER
*buf
, int depth
, SPOOL_PORT_DATA_1
*p1
)
7647 prs_struct
*ps
= &buf
->prs
;
7648 uint8 padding
[PORT_DATA_1_PAD
];
7650 prs_debug(ps
, depth
, desc
, "smb_io_port_data_1");
7656 if( !prs_uint16s(True
, "portname", ps
, depth
, p1
->portname
, MAX_PORTNAME
))
7659 if (!prs_uint32("version", ps
, depth
, &p1
->version
))
7661 if (!prs_uint32("protocol", ps
, depth
, &p1
->protocol
))
7663 if (!prs_uint32("size", ps
, depth
, &p1
->size
))
7665 if (!prs_uint32("reserved", ps
, depth
, &p1
->reserved
))
7668 if( !prs_uint16s(True
, "hostaddress", ps
, depth
, p1
->hostaddress
, MAX_NETWORK_NAME
))
7670 if( !prs_uint16s(True
, "snmpcommunity", ps
, depth
, p1
->snmpcommunity
, MAX_SNMP_COMM_NAME
))
7673 if (!prs_uint32("dblspool", ps
, depth
, &p1
->dblspool
))
7676 if( !prs_uint16s(True
, "queue", ps
, depth
, p1
->queue
, MAX_QUEUE_NAME
))
7678 if( !prs_uint16s(True
, "ipaddress", ps
, depth
, p1
->ipaddress
, MAX_IPADDR_STRING
))
7681 if( !prs_uint8s(False
, "", ps
, depth
, padding
, PORT_DATA_1_PAD
))
7684 if (!prs_uint32("port", ps
, depth
, &p1
->port
))
7686 if (!prs_uint32("snmpenabled", ps
, depth
, &p1
->snmpenabled
))
7688 if (!prs_uint32("snmpdevindex", ps
, depth
, &p1
->snmpdevindex
))
7694 /*******************************************************************
7695 ********************************************************************/
7697 BOOL
convert_port_data_1( NT_PORT_DATA_1
*port1
, RPC_BUFFER
*buf
)
7699 SPOOL_PORT_DATA_1 spdata_1
;
7701 ZERO_STRUCT( spdata_1
);
7703 if ( !smb_io_port_data_1( "port_data_1", buf
, 0, &spdata_1
) )
7706 rpcstr_pull(port1
->name
, spdata_1
.portname
, sizeof(port1
->name
), -1, 0);
7707 rpcstr_pull(port1
->queue
, spdata_1
.queue
, sizeof(port1
->queue
), -1, 0);
7708 rpcstr_pull(port1
->hostaddr
, spdata_1
.hostaddress
, sizeof(port1
->hostaddr
), -1, 0);
7710 port1
->port
= spdata_1
.port
;
7712 switch ( spdata_1
.protocol
) {
7714 port1
->protocol
= PORT_PROTOCOL_DIRECT
;
7717 port1
->protocol
= PORT_PROTOCOL_LPR
;
7720 DEBUG(3,("convert_port_data_1: unknown protocol [%d]!\n",
7721 spdata_1
.protocol
));