2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Jean François Micouleau 1998-2000,
8 * Copyright (C) Gerald Carter 2000-2002
9 * Copyright (C) Tim Potter 2001.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 /*******************************************************************
29 return the length of a UNISTR string.
30 ********************************************************************/
32 static uint32
str_len_uni(UNISTR
*source
)
39 while (source
->buffer
[i
])
45 /*******************************************************************
46 This should be moved in a more generic lib.
47 ********************************************************************/
49 static BOOL
spoolss_io_system_time(char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
51 if(!prs_uint16("year", ps
, depth
, &systime
->year
))
53 if(!prs_uint16("month", ps
, depth
, &systime
->month
))
55 if(!prs_uint16("dayofweek", ps
, depth
, &systime
->dayofweek
))
57 if(!prs_uint16("day", ps
, depth
, &systime
->day
))
59 if(!prs_uint16("hour", ps
, depth
, &systime
->hour
))
61 if(!prs_uint16("minute", ps
, depth
, &systime
->minute
))
63 if(!prs_uint16("second", ps
, depth
, &systime
->second
))
65 if(!prs_uint16("milliseconds", ps
, depth
, &systime
->milliseconds
))
71 /*******************************************************************
72 ********************************************************************/
74 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
76 systime
->year
=unixtime
->tm_year
+1900;
77 systime
->month
=unixtime
->tm_mon
+1;
78 systime
->dayofweek
=unixtime
->tm_wday
;
79 systime
->day
=unixtime
->tm_mday
;
80 systime
->hour
=unixtime
->tm_hour
;
81 systime
->minute
=unixtime
->tm_min
;
82 systime
->second
=unixtime
->tm_sec
;
83 systime
->milliseconds
=0;
88 /*******************************************************************
89 reads or writes an DOC_INFO structure.
90 ********************************************************************/
92 static BOOL
smb_io_doc_info_1(char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
94 if (info_1
== NULL
) return False
;
96 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
102 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
104 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
106 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
109 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
111 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
113 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
119 /*******************************************************************
120 reads or writes an DOC_INFO structure.
121 ********************************************************************/
123 static BOOL
smb_io_doc_info(char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
125 uint32 useless_ptr
=0;
127 if (info
== NULL
) return False
;
129 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
135 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
138 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
141 switch (info
->switch_value
)
144 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
149 this is just a placeholder
151 MSDN July 1998 says doc_info_2 is only on
152 Windows 95, and as Win95 doesn't do RPC to print
153 this case is nearly impossible
155 Maybe one day with Windows for dishwasher 2037 ...
158 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
161 DEBUG(0,("Something is obviously wrong somewhere !\n"));
168 /*******************************************************************
169 reads or writes an DOC_INFO_CONTAINER structure.
170 ********************************************************************/
172 static BOOL
smb_io_doc_info_container(char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
174 if (cont
== NULL
) return False
;
176 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
182 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
185 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
191 /*******************************************************************
192 reads or writes an NOTIFY OPTION TYPE structure.
193 ********************************************************************/
195 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
196 structure. The _TYPE structure is really the deferred referrants (i.e
197 the notify fields array) of the _TYPE structure. -tpot */
199 static BOOL
smb_io_notify_option_type(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
201 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
207 if(!prs_uint16("type", ps
, depth
, &type
->type
))
209 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
211 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
213 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
215 if(!prs_uint32("count", ps
, depth
, &type
->count
))
217 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
223 /*******************************************************************
224 reads or writes an NOTIFY OPTION TYPE DATA.
225 ********************************************************************/
227 static BOOL
smb_io_notify_option_type_data(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
231 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
234 /* if there are no fields just return */
235 if (type
->fields_ptr
==0)
241 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
244 if (type
->count2
!= type
->count
)
245 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
247 /* parse the option type data */
248 for(i
=0;i
<type
->count2
;i
++)
249 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
254 /*******************************************************************
255 reads or writes an NOTIFY OPTION structure.
256 ********************************************************************/
258 static BOOL
smb_io_notify_option_type_ctr(char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
262 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
265 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
269 if (UNMARSHALLING(ps
))
270 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)prs_alloc_mem(ps
,ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
273 /* the option type struct */
274 for(i
=0;i
<ctr
->count
;i
++)
275 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
278 /* the type associated with the option type struct */
279 for(i
=0;i
<ctr
->count
;i
++)
280 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
286 /*******************************************************************
287 reads or writes an NOTIFY OPTION structure.
288 ********************************************************************/
290 static BOOL
smb_io_notify_option(char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
292 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
295 if(!prs_uint32("version", ps
, depth
, &option
->version
))
297 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
299 if(!prs_uint32("count", ps
, depth
, &option
->count
))
301 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
304 /* marshalling or unmarshalling, that would work */
305 if (option
->option_type_ptr
!=0) {
306 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
310 option
->ctr
.type
=NULL
;
317 /*******************************************************************
318 reads or writes an NOTIFY INFO DATA structure.
319 ********************************************************************/
321 static BOOL
smb_io_notify_info_data(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
323 uint32 useless_ptr
=0xADDE0FF0;
325 uint32 how_many_words
;
329 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
332 how_many_words
=data
->size
;
333 if (how_many_words
==POINTER
) {
334 how_many_words
=TWO_VALUE
;
337 isvalue
=data
->enc_type
;
341 if(!prs_uint16("type", ps
, depth
, &data
->type
))
343 if(!prs_uint16("field", ps
, depth
, &data
->field
))
347 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
349 if(!prs_uint32("id", ps
, depth
, &data
->id
))
351 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
358 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
360 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
365 /* length in ascii including \0 */
366 x
=2*(data
->notify_data
.data
.length
+1);
367 if(!prs_uint32("string length", ps
, depth
, &x
))
369 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
377 /*******************************************************************
378 reads or writes an NOTIFY INFO DATA structure.
379 ********************************************************************/
381 BOOL
smb_io_notify_info_data_strings(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
382 prs_struct
*ps
, int depth
)
387 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
393 isvalue
=data
->enc_type
;
395 if (isvalue
==False
) {
396 /* length of string in unicode include \0 */
397 x
=data
->notify_data
.data
.length
+1;
398 if(!prs_uint32("string length", ps
, depth
, &x
))
400 if (MARSHALLING(ps
)) {
401 /* These are already in little endian format. Don't byte swap. */
404 /* No memory allocated for this string
405 therefore following the data.string
406 pointer is a bad idea. Use a pointer to
407 the uint32 length union member to
408 provide a source for a unicode NULL */
410 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
413 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
418 /* Tallocate memory for string */
420 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
421 if (!data
->notify_data
.data
.string
)
424 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
430 /* Win2k does not seem to put this parse align here */
439 /*******************************************************************
440 reads or writes an NOTIFY INFO structure.
441 ********************************************************************/
443 static BOOL
smb_io_notify_info(char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
447 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
453 if(!prs_uint32("count", ps
, depth
, &info
->count
))
455 if(!prs_uint32("version", ps
, depth
, &info
->version
))
457 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
459 if(!prs_uint32("count", ps
, depth
, &info
->count
))
462 for (i
=0;i
<info
->count
;i
++) {
463 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
467 /* now do the strings at the end of the stream */
468 for (i
=0;i
<info
->count
;i
++) {
469 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
476 /*******************************************************************
477 ********************************************************************/
479 static BOOL
spool_io_user_level_1(char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
481 prs_debug(ps
, depth
, desc
, "");
485 if (UNMARSHALLING(ps
))
490 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
492 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
494 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
496 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
498 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
500 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
502 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
505 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
509 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
515 /*******************************************************************
516 ********************************************************************/
518 static BOOL
spool_io_user_level(char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
523 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
528 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
530 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
533 switch (q_u
->level
) {
535 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
545 /*******************************************************************
546 * read or write a DEVICEMODE struct.
547 * on reading allocate memory for the private member
548 ********************************************************************/
550 BOOL
spoolss_io_devmode(char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
552 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
555 if (UNMARSHALLING(ps
)) {
556 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
557 if (devmode
->devicename
.buffer
== NULL
)
561 if (!prs_uint16uni(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, 32))
563 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
565 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
567 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
569 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
571 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
573 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
575 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
577 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
579 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
581 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
583 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
585 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
587 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
589 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
591 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
593 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
595 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
597 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
600 if (UNMARSHALLING(ps
)) {
601 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
602 if (devmode
->formname
.buffer
== NULL
)
606 if (!prs_uint16uni(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
608 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
610 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
612 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
614 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
616 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
618 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
622 * Conditional parsing. Assume that the DeviceMode has been
623 * zero'd by the caller.
625 switch(devmode
->specversion
) {
627 /* Used by spooler when issuing OpenPrinter() calls. NT 3.5x? */
631 /* See the comments on the DEVMODE in the msdn GDI documentation */
634 if (!prs_uint32("icmmethod", ps
, depth
, &devmode
->icmmethod
))
636 if (!prs_uint32("icmintent", ps
, depth
, &devmode
->icmintent
))
638 if (!prs_uint32("mediatype", ps
, depth
, &devmode
->mediatype
))
640 if (!prs_uint32("dithertype", ps
, depth
, &devmode
->dithertype
))
642 if (!prs_uint32("reserved1", ps
, depth
, &devmode
->reserved1
))
644 if (!prs_uint32("reserved2", ps
, depth
, &devmode
->reserved2
))
646 if (!prs_uint32("panningwidth", ps
, depth
, &devmode
->panningwidth
))
648 if (!prs_uint32("panningheight", ps
, depth
, &devmode
->panningheight
))
652 /* log an error if we see something else */
654 DEBUG(0,("spoolss_io_devmode: Unknown specversion [0x%x]!\n", devmode
->specversion
));
655 DEBUG(0,("spoolss_io_devmode: Please report to samba-technical@samba.org\n"));
659 if (devmode
->driverextra
!=0) {
660 if (UNMARSHALLING(ps
)) {
661 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
662 if(devmode
->private == NULL
)
664 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
667 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
668 if (!prs_uint8s(False
, "private", ps
, depth
,
669 devmode
->private, devmode
->driverextra
))
676 /*******************************************************************
677 Read or write a DEVICEMODE container
678 ********************************************************************/
680 static BOOL
spoolss_io_devmode_cont(char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
685 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
691 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
694 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
697 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
698 if (UNMARSHALLING(ps
))
699 /* if while reading there is no DEVMODE ... */
704 /* so we have a DEVICEMODE to follow */
705 if (UNMARSHALLING(ps
)) {
706 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
707 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
708 if(dm_c
->devmode
== NULL
)
712 /* this is bad code, shouldn't be there */
713 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
716 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
722 /*******************************************************************
723 ********************************************************************/
725 static BOOL
spoolss_io_printer_default(char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
730 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
733 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
736 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
742 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
748 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
754 /*******************************************************************
756 ********************************************************************/
758 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
759 const fstring printername
,
760 const fstring datatype
,
761 uint32 access_required
,
762 const fstring clientname
,
763 const fstring user_name
)
765 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
766 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
767 init_unistr2(&q_u
->printername
, printername
, strlen(printername
)+1);
769 q_u
->printer_default
.datatype_ptr
= 0;
771 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
772 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
774 q_u
->printer_default
.devmode_cont
.size
=0;
775 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
776 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
777 q_u
->printer_default
.access_required
=access_required
;
779 q_u
->user_ctr
.level
=1;
781 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
782 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
783 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
784 q_u
->user_ctr
.user1
.build
=1381;
785 q_u
->user_ctr
.user1
.major
=2;
786 q_u
->user_ctr
.user1
.minor
=0;
787 q_u
->user_ctr
.user1
.processor
=0;
788 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
789 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
794 /*******************************************************************
796 ********************************************************************/
798 BOOL
make_spoolss_q_addprinterex(
800 SPOOL_Q_ADDPRINTEREX
*q_u
,
801 const char *srv_name
,
802 const char* clientname
,
803 const char* user_name
,
805 PRINTER_INFO_CTR
*ctr
)
807 DEBUG(5,("make_spoolss_q_addprinterex\n"));
809 if (!ctr
) return False
;
813 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
814 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
));
818 q_u
->info
.level
= level
;
819 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
822 /* init q_u->info.info2 from *info */
823 if (!make_spoolss_printer_info_2(mem_ctx
, &q_u
->info
.info_2
, ctr
->printers_2
)) {
824 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
834 q_u
->user_ctr
.level
=1;
836 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
837 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
838 q_u
->user_ctr
.user1
.build
=1381;
839 q_u
->user_ctr
.user1
.major
=2;
840 q_u
->user_ctr
.user1
.minor
=0;
841 q_u
->user_ctr
.user1
.processor
=0;
842 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
843 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
844 q_u
->user_ctr
.user1
.size
=q_u
->user_ctr
.user1
.user_name
.uni_str_len
+
845 q_u
->user_ctr
.user1
.client_name
.uni_str_len
+ 2;
850 /*******************************************************************
851 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
852 *******************************************************************/
854 BOOL
make_spoolss_printer_info_2(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
855 PRINTER_INFO_2
*info
)
858 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
860 /* allocate the necessary memory */
861 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_2
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_2
)))) {
862 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
866 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
867 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
868 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
869 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
870 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
871 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
872 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
873 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
874 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
875 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
876 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
877 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
878 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
879 inf
->attributes
= info
->attributes
;
880 inf
->priority
= info
->priority
;
881 inf
->default_priority
= info
->defaultpriority
;
882 inf
->starttime
= info
->starttime
;
883 inf
->untiltime
= info
->untiltime
;
884 inf
->cjobs
= info
->cjobs
;
885 inf
->averageppm
= info
->averageppm
;
886 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
887 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
888 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
889 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
890 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
891 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
892 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
893 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
894 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
895 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
896 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
897 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
905 /*******************************************************************
907 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
908 ********************************************************************/
910 BOOL
spoolss_io_q_open_printer(char *desc
, SPOOL_Q_OPEN_PRINTER
*q_u
, prs_struct
*ps
, int depth
)
915 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer");
921 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
923 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
929 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
935 /*******************************************************************
937 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
938 * called from spoolss_open_printer_ex (cli_spoolss.c)
939 ********************************************************************/
941 BOOL
spoolss_io_r_open_printer(char *desc
, SPOOL_R_OPEN_PRINTER
*r_u
, prs_struct
*ps
, int depth
)
943 if (r_u
== NULL
) return False
;
945 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer");
951 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
954 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
961 /*******************************************************************
963 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
964 ********************************************************************/
966 BOOL
spoolss_io_q_open_printer_ex(char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
971 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
977 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
979 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
985 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
988 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
990 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
996 /*******************************************************************
998 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
999 * called from spoolss_open_printer_ex (cli_spoolss.c)
1000 ********************************************************************/
1002 BOOL
spoolss_io_r_open_printer_ex(char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
1004 if (r_u
== NULL
) return False
;
1006 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
1012 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
1015 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
1021 /*******************************************************************
1023 ********************************************************************/
1024 BOOL
make_spoolss_q_deleteprinterdriver(
1025 TALLOC_CTX
*mem_ctx
,
1026 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
1032 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
1034 q_u
->server_ptr
= (server
!=NULL
)?1:0;
1036 /* these must be NULL terminated or else NT4 will
1037 complain about invalid parameters --jerry */
1038 init_unistr2(&q_u
->server
, server
, strlen(server
)+1);
1039 init_unistr2(&q_u
->arch
, arch
, strlen(arch
)+1);
1040 init_unistr2(&q_u
->driver
, driver
, strlen(driver
)+1);
1047 /*******************************************************************
1049 ********************************************************************/
1051 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
1052 const POLICY_HND
*handle
,
1053 UNISTR2
*valuename
, uint32 size
)
1055 if (q_u
== NULL
) return False
;
1057 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
1059 q_u
->handle
= *handle
;
1060 copy_unistr2(&q_u
->valuename
, valuename
);
1066 /*******************************************************************
1068 * called from spoolss_q_getprinterdata (srv_spoolss.c)
1069 ********************************************************************/
1071 BOOL
spoolss_io_q_getprinterdata(char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1076 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
1081 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1085 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1089 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1095 /*******************************************************************
1097 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1098 ********************************************************************/
1100 BOOL
spoolss_io_q_deleteprinterdata(char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1105 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1110 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1114 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1120 /*******************************************************************
1121 * write a structure.
1122 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1123 ********************************************************************/
1125 BOOL
spoolss_io_r_deleteprinterdata(char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1127 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1129 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1135 /*******************************************************************
1136 * write a structure.
1137 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1138 ********************************************************************/
1140 BOOL
spoolss_io_r_getprinterdata(char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1145 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1150 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1152 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1155 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
1161 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1163 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1169 /*******************************************************************
1171 ********************************************************************/
1173 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1175 if (q_u
== NULL
) return False
;
1177 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1179 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1184 /*******************************************************************
1186 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1187 * called from spoolss_abortprinter (cli_spoolss.c)
1188 ********************************************************************/
1190 BOOL
spoolss_io_q_abortprinter(char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1192 if (q_u
== NULL
) return False
;
1194 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1200 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1206 /*******************************************************************
1207 * write a structure.
1208 * called from spoolss_r_abortprinter (srv_spoolss.c)
1209 ********************************************************************/
1211 BOOL
spoolss_io_r_abortprinter(char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1213 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1215 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1221 /*******************************************************************
1223 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1224 * called from spoolss_deleteprinter (cli_spoolss.c)
1225 ********************************************************************/
1227 BOOL
spoolss_io_q_deleteprinter(char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1229 if (q_u
== NULL
) return False
;
1231 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1237 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1243 /*******************************************************************
1244 * write a structure.
1245 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1246 * called from spoolss_deleteprinter (cli_spoolss.c)
1247 ********************************************************************/
1249 BOOL
spoolss_io_r_deleteprinter(char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1251 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1257 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1259 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1266 /*******************************************************************
1268 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1269 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1270 ********************************************************************/
1272 BOOL
spoolss_io_q_deleteprinterdriver(char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1274 if (q_u
== NULL
) return False
;
1276 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1282 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1284 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1286 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1288 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1296 /*******************************************************************
1297 * write a structure.
1298 ********************************************************************/
1299 BOOL
spoolss_io_r_deleteprinterdriver(char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1301 if (r_u
== NULL
) return False
;
1303 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1309 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1317 /*******************************************************************
1319 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1320 * called from spoolss_closeprinter (cli_spoolss.c)
1321 ********************************************************************/
1323 BOOL
spoolss_io_q_closeprinter(char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1325 if (q_u
== NULL
) return False
;
1327 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1333 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1339 /*******************************************************************
1340 * write a structure.
1341 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1342 * called from spoolss_closeprinter (cli_spoolss.c)
1343 ********************************************************************/
1345 BOOL
spoolss_io_r_closeprinter(char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1347 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1353 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1355 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1361 /*******************************************************************
1363 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1364 ********************************************************************/
1366 BOOL
spoolss_io_q_startdocprinter(char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1368 if (q_u
== NULL
) return False
;
1370 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1376 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1379 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1385 /*******************************************************************
1386 * write a structure.
1387 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1388 ********************************************************************/
1390 BOOL
spoolss_io_r_startdocprinter(char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1392 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1394 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1396 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1402 /*******************************************************************
1404 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1405 ********************************************************************/
1407 BOOL
spoolss_io_q_enddocprinter(char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1409 if (q_u
== NULL
) return False
;
1411 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1417 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1423 /*******************************************************************
1424 * write a structure.
1425 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1426 ********************************************************************/
1428 BOOL
spoolss_io_r_enddocprinter(char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1430 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1432 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1438 /*******************************************************************
1440 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1441 ********************************************************************/
1443 BOOL
spoolss_io_q_startpageprinter(char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1445 if (q_u
== NULL
) return False
;
1447 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1453 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1459 /*******************************************************************
1460 * write a structure.
1461 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1462 ********************************************************************/
1464 BOOL
spoolss_io_r_startpageprinter(char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1466 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1468 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1474 /*******************************************************************
1476 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1477 ********************************************************************/
1479 BOOL
spoolss_io_q_endpageprinter(char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1481 if (q_u
== NULL
) return False
;
1483 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1489 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1495 /*******************************************************************
1496 * write a structure.
1497 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1498 ********************************************************************/
1500 BOOL
spoolss_io_r_endpageprinter(char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1502 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1504 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1510 /*******************************************************************
1512 * called from spoolss_q_writeprinter (srv_spoolss.c)
1513 ********************************************************************/
1515 BOOL
spoolss_io_q_writeprinter(char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1517 if (q_u
== NULL
) return False
;
1519 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1525 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1527 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1530 if (q_u
->buffer_size
!=0)
1532 if (UNMARSHALLING(ps
))
1533 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1534 if(q_u
->buffer
== NULL
)
1536 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1541 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1547 /*******************************************************************
1548 * write a structure.
1549 * called from spoolss_r_writeprinter (srv_spoolss.c)
1550 ********************************************************************/
1552 BOOL
spoolss_io_r_writeprinter(char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1554 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1556 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1558 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1564 /*******************************************************************
1566 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1567 ********************************************************************/
1569 BOOL
spoolss_io_q_rffpcnex(char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1571 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1577 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1579 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1581 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1583 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1585 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1591 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1594 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1597 if (q_u
->option_ptr
!=0) {
1599 if (UNMARSHALLING(ps
))
1600 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1603 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1610 /*******************************************************************
1611 * write a structure.
1612 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1613 ********************************************************************/
1615 BOOL
spoolss_io_r_rffpcnex(char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1617 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1620 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1626 /*******************************************************************
1628 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1629 ********************************************************************/
1631 BOOL
spoolss_io_q_rfnpcnex(char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1633 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1639 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1642 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1645 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1648 if (q_u
->option_ptr
!=0) {
1650 if (UNMARSHALLING(ps
))
1651 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1654 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1661 /*******************************************************************
1662 * write a structure.
1663 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1664 ********************************************************************/
1666 BOOL
spoolss_io_r_rfnpcnex(char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1668 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1674 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1677 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1682 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1688 /*******************************************************************
1689 * return the length of a uint16 (obvious, but the code is clean)
1690 ********************************************************************/
1692 static uint32
size_of_uint16(uint16
*value
)
1694 return (sizeof(*value
));
1697 /*******************************************************************
1698 * return the length of a uint32 (obvious, but the code is clean)
1699 ********************************************************************/
1701 static uint32
size_of_uint32(uint32
*value
)
1703 return (sizeof(*value
));
1706 /*******************************************************************
1707 * return the length of a NTTIME (obvious, but the code is clean)
1708 ********************************************************************/
1710 static uint32
size_of_nttime(NTTIME
*value
)
1712 return (sizeof(*value
));
1715 /*******************************************************************
1716 * return the length of a UNICODE string in number of char, includes:
1717 * - the leading zero
1718 * - the relative pointer size
1719 ********************************************************************/
1721 static uint32
size_of_relative_string(UNISTR
*string
)
1725 size
=str_len_uni(string
); /* the string length */
1726 size
=size
+1; /* add the leading zero */
1727 size
=size
*2; /* convert in char */
1728 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1729 size
+= ((4 - (size
& 3)) & 3);
1730 size
=size
+4; /* add the size of the ptr */
1735 /*******************************************************************
1736 * return the length of a uint32 (obvious, but the code is clean)
1737 ********************************************************************/
1739 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1744 return (4+devmode
->size
+devmode
->driverextra
);
1747 /*******************************************************************
1748 * return the length of a uint32 (obvious, but the code is clean)
1749 ********************************************************************/
1751 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1756 return (sizeof(SYSTEMTIME
) +4);
1759 /*******************************************************************
1760 * write a UNICODE string.
1761 * used by all the RPC structs passing a buffer
1762 ********************************************************************/
1764 static BOOL
spoolss_smb_io_unistr(char *desc
, UNISTR
*uni
, prs_struct
*ps
, int depth
)
1769 prs_debug(ps
, depth
, desc
, "spoolss_smb_io_unistr");
1772 /* there should be no align here as it can mess up
1773 parsing a NEW_BUFFER->prs */
1779 if (!prs_unistr("unistr", ps
, depth
, uni
))
1785 /*******************************************************************
1786 * write a UNICODE string and its relative pointer.
1787 * used by all the RPC structs passing a buffer
1789 * As I'm a nice guy, I'm forcing myself to explain this code.
1790 * MS did a good job in the overall spoolss code except in some
1791 * functions where they are passing the API buffer directly in the
1792 * RPC request/reply. That's to maintain compatiility at the API level.
1793 * They could have done it the good way the first time.
1795 * So what happen is: the strings are written at the buffer's end,
1796 * in the reverse order of the original structure. Some pointers to
1797 * the strings are also in the buffer. Those are relative to the
1800 * If you don't understand or want to change that function,
1801 * first get in touch with me: jfm@samba.org
1803 ********************************************************************/
1805 static BOOL
smb_io_relstr(char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
1807 prs_struct
*ps
=&buffer
->prs
;
1809 if (MARSHALLING(ps
)) {
1810 uint32 struct_offset
= prs_offset(ps
);
1811 uint32 relative_offset
;
1813 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
1814 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1818 buffer
->string_at_end
= prs_offset(ps
);
1820 /* write the string */
1821 if (!smb_io_unistr(desc
, string
, ps
, depth
))
1824 if(!prs_set_offset(ps
, struct_offset
))
1827 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1828 /* write its offset */
1829 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1835 /* read the offset */
1836 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
1839 old_offset
= prs_offset(ps
);
1840 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
1843 /* read the string */
1844 if (!spoolss_smb_io_unistr(desc
, string
, ps
, depth
))
1847 if(!prs_set_offset(ps
, old_offset
))
1853 /*******************************************************************
1854 * write a array of UNICODE strings and its relative pointer.
1855 * used by 2 RPC structs
1856 ********************************************************************/
1858 static BOOL
smb_io_relarraystr(char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
1862 prs_struct
*ps
=&buffer
->prs
;
1864 if (MARSHALLING(ps
)) {
1865 uint32 struct_offset
= prs_offset(ps
);
1866 uint32 relative_offset
;
1873 /* first write the last 0 */
1874 buffer
->string_at_end
-= 2;
1875 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1878 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
1881 while (p
&& (*p
!=0)) {
1885 /* Yes this should be malloc not talloc. Don't change. */
1887 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
1888 if (chaine
.buffer
== NULL
)
1891 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
1893 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
1895 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
1896 SAFE_FREE(chaine
.buffer
);
1900 /* write the string */
1901 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
1902 SAFE_FREE(chaine
.buffer
);
1908 SAFE_FREE(chaine
.buffer
);
1911 if(!prs_set_offset(ps
, struct_offset
))
1914 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1915 /* write its offset */
1916 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1924 uint16
*chaine2
=NULL
;
1927 size_t realloc_size
= 0;
1931 /* read the offset */
1932 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1935 old_offset
= prs_offset(ps
);
1936 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1940 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
))
1943 l_chaine
=str_len_uni(&chaine
);
1945 /* we're going to add two more bytes here in case this
1946 is the last string in the array and we need to add
1947 an extra NULL for termination */
1952 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
1954 /* Yes this should be realloc - it's freed below. JRA */
1956 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
1961 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
1962 l_chaine2
+=l_chaine
+1;
1965 } while(l_chaine
!=0);
1967 /* the end should be bould NULL terminated so add
1968 the second one here */
1971 chaine2
[l_chaine2
] = '\0';
1972 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
1976 if(!prs_set_offset(ps
, old_offset
))
1982 /*******************************************************************
1983 Parse a DEVMODE structure and its relative pointer.
1984 ********************************************************************/
1986 static BOOL
smb_io_relsecdesc(char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
1988 prs_struct
*ps
= &buffer
->prs
;
1990 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
1993 if (MARSHALLING(ps
)) {
1994 uint32 struct_offset
= prs_offset(ps
);
1995 uint32 relative_offset
;
1998 relative_offset
= 0;
1999 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2004 if (*secdesc
!= NULL
) {
2005 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
2007 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2009 /* write the secdesc */
2010 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2013 if(!prs_set_offset(ps
, struct_offset
))
2017 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2018 /* write its offset */
2020 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2025 /* read the offset */
2026 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2029 old_offset
= prs_offset(ps
);
2030 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2034 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
2037 if(!prs_set_offset(ps
, old_offset
))
2043 /*******************************************************************
2044 Parse a DEVMODE structure and its relative pointer.
2045 ********************************************************************/
2047 static BOOL
smb_io_reldevmode(char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
2049 prs_struct
*ps
=&buffer
->prs
;
2051 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
2054 if (MARSHALLING(ps
)) {
2055 uint32 struct_offset
= prs_offset(ps
);
2056 uint32 relative_offset
;
2058 if (*devmode
== NULL
) {
2060 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2062 DEBUG(8, ("boing, the devmode was NULL\n"));
2067 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
2069 if(!prs_set_offset(ps
, buffer
->string_at_end
))
2072 /* write the DEVMODE */
2073 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2076 if(!prs_set_offset(ps
, struct_offset
))
2079 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
2080 /* write its offset */
2081 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2087 /* read the offset */
2088 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2091 old_offset
= prs_offset(ps
);
2092 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2095 /* read the string */
2096 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2098 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2101 if(!prs_set_offset(ps
, old_offset
))
2107 /*******************************************************************
2108 Parse a PRINTER_INFO_0 structure.
2109 ********************************************************************/
2111 BOOL
smb_io_printer_info_0(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2113 prs_struct
*ps
=&buffer
->prs
;
2115 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2118 buffer
->struct_start
=prs_offset(ps
);
2120 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2122 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2125 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2127 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2129 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2132 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2134 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2136 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2138 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2140 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2142 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2144 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2146 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2149 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2151 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2154 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2156 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2158 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2160 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2162 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2164 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2166 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2168 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2170 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2172 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2174 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2176 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2178 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2180 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2182 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2184 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2186 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2188 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2190 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2192 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2194 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2196 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2198 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2200 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2202 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2208 /*******************************************************************
2209 Parse a PRINTER_INFO_1 structure.
2210 ********************************************************************/
2212 BOOL
smb_io_printer_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2214 prs_struct
*ps
=&buffer
->prs
;
2216 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2219 buffer
->struct_start
=prs_offset(ps
);
2221 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2223 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2225 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2227 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2233 /*******************************************************************
2234 Parse a PRINTER_INFO_2 structure.
2235 ********************************************************************/
2237 BOOL
smb_io_printer_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2239 prs_struct
*ps
=&buffer
->prs
;
2241 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2244 buffer
->struct_start
=prs_offset(ps
);
2246 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2248 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2250 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2252 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2254 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2256 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2258 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2261 /* NT parses the DEVMODE at the end of the struct */
2262 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2265 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2267 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2269 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2271 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2274 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2277 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2279 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2281 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2283 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2285 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2287 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2289 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2291 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2295 if (!prs_uint32_post("secdesc_ptr", ps
, depth
, NULL
, sec_offset
, info
->secdesc
? prs_offset(ps
)-buffer
->struct_start
: 0 ))
2298 if (!sec_io_desc("secdesc", &info
->secdesc
, ps
, depth
))
2304 /*******************************************************************
2305 Parse a PRINTER_INFO_3 structure.
2306 ********************************************************************/
2308 BOOL
smb_io_printer_info_3(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2310 prs_struct
*ps
=&buffer
->prs
;
2312 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2315 buffer
->struct_start
=prs_offset(ps
);
2317 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2319 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2325 /*******************************************************************
2326 Parse a PRINTER_INFO_4 structure.
2327 ********************************************************************/
2329 BOOL
smb_io_printer_info_4(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2331 prs_struct
*ps
=&buffer
->prs
;
2333 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2336 buffer
->struct_start
=prs_offset(ps
);
2338 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2340 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2342 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2347 /*******************************************************************
2348 Parse a PRINTER_INFO_5 structure.
2349 ********************************************************************/
2351 BOOL
smb_io_printer_info_5(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2353 prs_struct
*ps
=&buffer
->prs
;
2355 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2358 buffer
->struct_start
=prs_offset(ps
);
2360 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2362 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2364 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2366 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2368 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2373 /*******************************************************************
2374 Parse a PORT_INFO_1 structure.
2375 ********************************************************************/
2377 BOOL
smb_io_port_info_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2379 prs_struct
*ps
=&buffer
->prs
;
2381 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2384 buffer
->struct_start
=prs_offset(ps
);
2386 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2392 /*******************************************************************
2393 Parse a PORT_INFO_2 structure.
2394 ********************************************************************/
2396 BOOL
smb_io_port_info_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2398 prs_struct
*ps
=&buffer
->prs
;
2400 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2403 buffer
->struct_start
=prs_offset(ps
);
2405 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2407 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2409 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2411 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2413 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2419 /*******************************************************************
2420 Parse a DRIVER_INFO_1 structure.
2421 ********************************************************************/
2423 BOOL
smb_io_printer_driver_info_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2425 prs_struct
*ps
=&buffer
->prs
;
2427 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2430 buffer
->struct_start
=prs_offset(ps
);
2432 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2438 /*******************************************************************
2439 Parse a DRIVER_INFO_2 structure.
2440 ********************************************************************/
2442 BOOL
smb_io_printer_driver_info_2(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2444 prs_struct
*ps
=&buffer
->prs
;
2446 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2449 buffer
->struct_start
=prs_offset(ps
);
2451 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2453 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2455 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2457 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2459 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2461 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2467 /*******************************************************************
2468 Parse a DRIVER_INFO_3 structure.
2469 ********************************************************************/
2471 BOOL
smb_io_printer_driver_info_3(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2473 prs_struct
*ps
=&buffer
->prs
;
2475 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2478 buffer
->struct_start
=prs_offset(ps
);
2480 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2482 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2484 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2486 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2488 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2490 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2492 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2495 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2498 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2500 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2506 /*******************************************************************
2507 Parse a DRIVER_INFO_6 structure.
2508 ********************************************************************/
2510 BOOL
smb_io_printer_driver_info_6(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2512 prs_struct
*ps
=&buffer
->prs
;
2514 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2517 buffer
->struct_start
=prs_offset(ps
);
2519 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2521 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2523 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2525 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2527 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2529 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2531 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2534 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2537 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2539 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2542 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2545 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2547 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2550 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2553 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2556 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2559 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2561 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2563 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2565 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2571 /*******************************************************************
2572 Parse a JOB_INFO_1 structure.
2573 ********************************************************************/
2575 BOOL
smb_io_job_info_1(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2577 prs_struct
*ps
=&buffer
->prs
;
2579 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2582 buffer
->struct_start
=prs_offset(ps
);
2584 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2586 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2588 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2590 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2592 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2594 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2596 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2598 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2600 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2602 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2604 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2606 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2608 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2614 /*******************************************************************
2615 Parse a JOB_INFO_2 structure.
2616 ********************************************************************/
2618 BOOL
smb_io_job_info_2(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2621 prs_struct
*ps
=&buffer
->prs
;
2623 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2626 buffer
->struct_start
=prs_offset(ps
);
2628 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2630 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2632 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2634 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2636 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2638 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2640 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2643 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2645 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2647 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2649 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2651 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2654 /* SEC_DESC sec_desc;*/
2655 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2658 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2660 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2662 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2664 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2666 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2668 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2670 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2672 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2674 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2676 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2682 /*******************************************************************
2683 ********************************************************************/
2685 BOOL
smb_io_form_1(char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2687 prs_struct
*ps
=&buffer
->prs
;
2689 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
2692 buffer
->struct_start
=prs_offset(ps
);
2694 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2697 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2700 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2702 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2704 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2706 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2708 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2710 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2716 /*******************************************************************
2717 Read/write a BUFFER struct.
2718 ********************************************************************/
2720 static BOOL
spoolss_io_buffer(char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
2722 NEW_BUFFER
*buffer
= *pp_buffer
;
2724 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
2727 if (UNMARSHALLING(ps
))
2728 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
2733 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2737 if (UNMARSHALLING(ps
)) {
2739 buffer
->string_at_end
=0;
2741 if (buffer
->ptr
==0) {
2743 * JRA. I'm not sure if the data in here is in big-endian format if
2744 * the client is big-endian. Leave as default (little endian) for now.
2747 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
2752 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2756 * JRA. I'm not sure if the data in here is in big-endian format if
2757 * the client is big-endian. Leave as default (little endian) for now.
2760 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
2763 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
2766 if (!prs_set_offset(&buffer
->prs
, 0))
2769 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
2772 buffer
->string_at_end
=buffer
->size
;
2780 if (buffer
->ptr
==0) {
2781 /* We have finished with the data in buffer->prs - free it. */
2782 prs_mem_free(&buffer
->prs
);
2786 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2789 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
2795 /* We have finished with the data in buffer->prs - free it. */
2796 prs_mem_free(&buffer
->prs
);
2802 /*******************************************************************
2803 move a BUFFER from the query to the reply.
2804 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2805 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2806 Clears the memory to zero also.
2807 ********************************************************************/
2809 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
2811 prs_switch_type(&src
->prs
, MARSHALL
);
2812 if(!prs_set_offset(&src
->prs
, 0))
2814 prs_force_dynamic(&src
->prs
);
2815 prs_mem_clear(&src
->prs
);
2819 /*******************************************************************
2820 Get the size of a BUFFER struct.
2821 ********************************************************************/
2823 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
2825 return (buffer
->size
);
2828 /*******************************************************************
2829 Parse a DRIVER_DIRECTORY_1 structure.
2830 ********************************************************************/
2832 BOOL
smb_io_driverdir_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2834 prs_struct
*ps
=&buffer
->prs
;
2836 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
2839 buffer
->struct_start
=prs_offset(ps
);
2841 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2847 /*******************************************************************
2848 Parse a PORT_INFO_1 structure.
2849 ********************************************************************/
2851 BOOL
smb_io_port_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2853 prs_struct
*ps
=&buffer
->prs
;
2855 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
2858 buffer
->struct_start
=prs_offset(ps
);
2860 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2866 /*******************************************************************
2867 Parse a PORT_INFO_2 structure.
2868 ********************************************************************/
2870 BOOL
smb_io_port_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2872 prs_struct
*ps
=&buffer
->prs
;
2874 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
2877 buffer
->struct_start
=prs_offset(ps
);
2879 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2881 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2883 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2885 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2887 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2893 /*******************************************************************
2894 ********************************************************************/
2896 BOOL
smb_io_printprocessor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2898 prs_struct
*ps
=&buffer
->prs
;
2900 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2903 buffer
->struct_start
=prs_offset(ps
);
2905 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2911 /*******************************************************************
2912 ********************************************************************/
2914 BOOL
smb_io_printprocdatatype_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2916 prs_struct
*ps
=&buffer
->prs
;
2918 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2921 buffer
->struct_start
=prs_offset(ps
);
2923 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2929 /*******************************************************************
2930 ********************************************************************/
2932 BOOL
smb_io_printmonitor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2934 prs_struct
*ps
=&buffer
->prs
;
2936 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2939 buffer
->struct_start
=prs_offset(ps
);
2941 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2947 /*******************************************************************
2948 ********************************************************************/
2950 BOOL
smb_io_printmonitor_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
2952 prs_struct
*ps
=&buffer
->prs
;
2954 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
2957 buffer
->struct_start
=prs_offset(ps
);
2959 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2961 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
2963 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
2969 /*******************************************************************
2970 return the size required by a struct in the stream
2971 ********************************************************************/
2973 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
2977 size
+=size_of_relative_string( &info
->printername
);
2978 size
+=size_of_relative_string( &info
->servername
);
2980 size
+=size_of_uint32( &info
->cjobs
);
2981 size
+=size_of_uint32( &info
->total_jobs
);
2982 size
+=size_of_uint32( &info
->total_bytes
);
2984 size
+=size_of_uint16( &info
->year
);
2985 size
+=size_of_uint16( &info
->month
);
2986 size
+=size_of_uint16( &info
->dayofweek
);
2987 size
+=size_of_uint16( &info
->day
);
2988 size
+=size_of_uint16( &info
->hour
);
2989 size
+=size_of_uint16( &info
->minute
);
2990 size
+=size_of_uint16( &info
->second
);
2991 size
+=size_of_uint16( &info
->milliseconds
);
2993 size
+=size_of_uint32( &info
->global_counter
);
2994 size
+=size_of_uint32( &info
->total_pages
);
2996 size
+=size_of_uint16( &info
->major_version
);
2997 size
+=size_of_uint16( &info
->build_version
);
2999 size
+=size_of_uint32( &info
->unknown7
);
3000 size
+=size_of_uint32( &info
->unknown8
);
3001 size
+=size_of_uint32( &info
->unknown9
);
3002 size
+=size_of_uint32( &info
->session_counter
);
3003 size
+=size_of_uint32( &info
->unknown11
);
3004 size
+=size_of_uint32( &info
->printer_errors
);
3005 size
+=size_of_uint32( &info
->unknown13
);
3006 size
+=size_of_uint32( &info
->unknown14
);
3007 size
+=size_of_uint32( &info
->unknown15
);
3008 size
+=size_of_uint32( &info
->unknown16
);
3009 size
+=size_of_uint32( &info
->change_id
);
3010 size
+=size_of_uint32( &info
->unknown18
);
3011 size
+=size_of_uint32( &info
->status
);
3012 size
+=size_of_uint32( &info
->unknown20
);
3013 size
+=size_of_uint32( &info
->c_setprinter
);
3015 size
+=size_of_uint16( &info
->unknown22
);
3016 size
+=size_of_uint16( &info
->unknown23
);
3017 size
+=size_of_uint16( &info
->unknown24
);
3018 size
+=size_of_uint16( &info
->unknown25
);
3019 size
+=size_of_uint16( &info
->unknown26
);
3020 size
+=size_of_uint16( &info
->unknown27
);
3021 size
+=size_of_uint16( &info
->unknown28
);
3022 size
+=size_of_uint16( &info
->unknown29
);
3027 /*******************************************************************
3028 return the size required by a struct in the stream
3029 ********************************************************************/
3031 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
3035 size
+=size_of_uint32( &info
->flags
);
3036 size
+=size_of_relative_string( &info
->description
);
3037 size
+=size_of_relative_string( &info
->name
);
3038 size
+=size_of_relative_string( &info
->comment
);
3043 /*******************************************************************
3044 return the size required by a struct in the stream
3045 ********************************************************************/
3047 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
3052 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3053 size
+= sec_desc_size( info
->secdesc
);
3055 size
+=size_of_device_mode( info
->devmode
);
3057 size
+=size_of_relative_string( &info
->servername
);
3058 size
+=size_of_relative_string( &info
->printername
);
3059 size
+=size_of_relative_string( &info
->sharename
);
3060 size
+=size_of_relative_string( &info
->portname
);
3061 size
+=size_of_relative_string( &info
->drivername
);
3062 size
+=size_of_relative_string( &info
->comment
);
3063 size
+=size_of_relative_string( &info
->location
);
3065 size
+=size_of_relative_string( &info
->sepfile
);
3066 size
+=size_of_relative_string( &info
->printprocessor
);
3067 size
+=size_of_relative_string( &info
->datatype
);
3068 size
+=size_of_relative_string( &info
->parameters
);
3070 size
+=size_of_uint32( &info
->attributes
);
3071 size
+=size_of_uint32( &info
->priority
);
3072 size
+=size_of_uint32( &info
->defaultpriority
);
3073 size
+=size_of_uint32( &info
->starttime
);
3074 size
+=size_of_uint32( &info
->untiltime
);
3075 size
+=size_of_uint32( &info
->status
);
3076 size
+=size_of_uint32( &info
->cjobs
);
3077 size
+=size_of_uint32( &info
->averageppm
);
3081 /*******************************************************************
3082 return the size required by a struct in the stream
3083 ********************************************************************/
3085 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3089 size
+=size_of_relative_string( &info
->printername
);
3090 size
+=size_of_relative_string( &info
->servername
);
3092 size
+=size_of_uint32( &info
->attributes
);
3096 /*******************************************************************
3097 return the size required by a struct in the stream
3098 ********************************************************************/
3100 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3104 size
+=size_of_relative_string( &info
->printername
);
3105 size
+=size_of_relative_string( &info
->portname
);
3107 size
+=size_of_uint32( &info
->attributes
);
3108 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3109 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3114 /*******************************************************************
3115 return the size required by a struct in the stream
3116 ********************************************************************/
3118 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3120 /* The 4 is for the self relative pointer.. */
3121 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3122 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3125 /*******************************************************************
3126 return the size required by a struct in the stream
3127 ********************************************************************/
3129 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3132 size
+=size_of_relative_string( &info
->name
);
3137 /*******************************************************************
3138 return the size required by a struct in the stream
3139 ********************************************************************/
3141 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3144 size
+=size_of_uint32( &info
->version
);
3145 size
+=size_of_relative_string( &info
->name
);
3146 size
+=size_of_relative_string( &info
->architecture
);
3147 size
+=size_of_relative_string( &info
->driverpath
);
3148 size
+=size_of_relative_string( &info
->datafile
);
3149 size
+=size_of_relative_string( &info
->configfile
);
3154 /*******************************************************************
3155 return the size required by a string array.
3156 ********************************************************************/
3158 uint32
spoolss_size_string_array(uint16
*string
)
3163 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3165 i
=i
+2; /* to count all chars including the leading zero */
3166 i
=2*i
; /* because we need the value in bytes */
3167 i
=i
+4; /* the offset pointer size */
3172 /*******************************************************************
3173 return the size required by a struct in the stream
3174 ********************************************************************/
3176 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3180 size
+=size_of_uint32( &info
->version
);
3181 size
+=size_of_relative_string( &info
->name
);
3182 size
+=size_of_relative_string( &info
->architecture
);
3183 size
+=size_of_relative_string( &info
->driverpath
);
3184 size
+=size_of_relative_string( &info
->datafile
);
3185 size
+=size_of_relative_string( &info
->configfile
);
3186 size
+=size_of_relative_string( &info
->helpfile
);
3187 size
+=size_of_relative_string( &info
->monitorname
);
3188 size
+=size_of_relative_string( &info
->defaultdatatype
);
3190 size
+=spoolss_size_string_array(info
->dependentfiles
);
3195 /*******************************************************************
3196 return the size required by a struct in the stream
3197 ********************************************************************/
3199 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3203 size
+=size_of_uint32( &info
->version
);
3204 size
+=size_of_relative_string( &info
->name
);
3205 size
+=size_of_relative_string( &info
->architecture
);
3206 size
+=size_of_relative_string( &info
->driverpath
);
3207 size
+=size_of_relative_string( &info
->datafile
);
3208 size
+=size_of_relative_string( &info
->configfile
);
3209 size
+=size_of_relative_string( &info
->helpfile
);
3211 size
+=spoolss_size_string_array(info
->dependentfiles
);
3213 size
+=size_of_relative_string( &info
->monitorname
);
3214 size
+=size_of_relative_string( &info
->defaultdatatype
);
3216 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3218 size
+=size_of_nttime(&info
->driver_date
);
3219 size
+=size_of_uint32( &info
->padding
);
3220 size
+=size_of_uint32( &info
->driver_version_low
);
3221 size
+=size_of_uint32( &info
->driver_version_high
);
3222 size
+=size_of_relative_string( &info
->mfgname
);
3223 size
+=size_of_relative_string( &info
->oem_url
);
3224 size
+=size_of_relative_string( &info
->hardware_id
);
3225 size
+=size_of_relative_string( &info
->provider
);
3230 /*******************************************************************
3231 return the size required by a struct in the stream
3232 ********************************************************************/
3234 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3237 size
+=size_of_uint32( &info
->jobid
);
3238 size
+=size_of_relative_string( &info
->printername
);
3239 size
+=size_of_relative_string( &info
->machinename
);
3240 size
+=size_of_relative_string( &info
->username
);
3241 size
+=size_of_relative_string( &info
->document
);
3242 size
+=size_of_relative_string( &info
->datatype
);
3243 size
+=size_of_relative_string( &info
->text_status
);
3244 size
+=size_of_uint32( &info
->status
);
3245 size
+=size_of_uint32( &info
->priority
);
3246 size
+=size_of_uint32( &info
->position
);
3247 size
+=size_of_uint32( &info
->totalpages
);
3248 size
+=size_of_uint32( &info
->pagesprinted
);
3249 size
+=size_of_systemtime( &info
->submitted
);
3254 /*******************************************************************
3255 return the size required by a struct in the stream
3256 ********************************************************************/
3258 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3262 size
+=4; /* size of sec desc ptr */
3264 size
+=size_of_uint32( &info
->jobid
);
3265 size
+=size_of_relative_string( &info
->printername
);
3266 size
+=size_of_relative_string( &info
->machinename
);
3267 size
+=size_of_relative_string( &info
->username
);
3268 size
+=size_of_relative_string( &info
->document
);
3269 size
+=size_of_relative_string( &info
->notifyname
);
3270 size
+=size_of_relative_string( &info
->datatype
);
3271 size
+=size_of_relative_string( &info
->printprocessor
);
3272 size
+=size_of_relative_string( &info
->parameters
);
3273 size
+=size_of_relative_string( &info
->drivername
);
3274 size
+=size_of_device_mode( info
->devmode
);
3275 size
+=size_of_relative_string( &info
->text_status
);
3276 /* SEC_DESC sec_desc;*/
3277 size
+=size_of_uint32( &info
->status
);
3278 size
+=size_of_uint32( &info
->priority
);
3279 size
+=size_of_uint32( &info
->position
);
3280 size
+=size_of_uint32( &info
->starttime
);
3281 size
+=size_of_uint32( &info
->untiltime
);
3282 size
+=size_of_uint32( &info
->totalpages
);
3283 size
+=size_of_uint32( &info
->size
);
3284 size
+=size_of_systemtime( &info
->submitted
);
3285 size
+=size_of_uint32( &info
->timeelapsed
);
3286 size
+=size_of_uint32( &info
->pagesprinted
);
3291 /*******************************************************************
3292 return the size required by a struct in the stream
3293 ********************************************************************/
3295 uint32
spoolss_size_form_1(FORM_1
*info
)
3299 size
+=size_of_uint32( &info
->flag
);
3300 size
+=size_of_relative_string( &info
->name
);
3301 size
+=size_of_uint32( &info
->width
);
3302 size
+=size_of_uint32( &info
->length
);
3303 size
+=size_of_uint32( &info
->left
);
3304 size
+=size_of_uint32( &info
->top
);
3305 size
+=size_of_uint32( &info
->right
);
3306 size
+=size_of_uint32( &info
->bottom
);
3311 /*******************************************************************
3312 return the size required by a struct in the stream
3313 ********************************************************************/
3315 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3319 size
+=size_of_relative_string( &info
->port_name
);
3324 /*******************************************************************
3325 return the size required by a struct in the stream
3326 ********************************************************************/
3328 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3332 size
=str_len_uni(&info
->name
); /* the string length */
3333 size
=size
+1; /* add the leading zero */
3334 size
=size
*2; /* convert in char */
3339 /*******************************************************************
3340 return the size required by a struct in the stream
3341 ********************************************************************/
3343 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3347 size
=str_len_uni(&info
->name
); /* the string length */
3348 size
=size
+1; /* add the leading zero */
3349 size
=size
*2; /* convert in char */
3354 /*******************************************************************
3355 return the size required by a struct in the stream
3356 ********************************************************************/
3358 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3362 size
+=size_of_relative_string( &info
->port_name
);
3363 size
+=size_of_relative_string( &info
->monitor_name
);
3364 size
+=size_of_relative_string( &info
->description
);
3366 size
+=size_of_uint32( &info
->port_type
);
3367 size
+=size_of_uint32( &info
->reserved
);
3372 /*******************************************************************
3373 return the size required by a struct in the stream
3374 ********************************************************************/
3376 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3379 size
+=size_of_relative_string( &info
->name
);
3384 /*******************************************************************
3385 return the size required by a struct in the stream
3386 ********************************************************************/
3388 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3391 size
+=size_of_relative_string( &info
->name
);
3396 /*******************************************************************
3397 return the size required by a struct in the stream
3398 ********************************************************************/
3399 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3406 /* uint32(offset) + uint32(length) + length) */
3407 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3408 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
;
3410 size
+= size_of_uint32(&p
->type
);
3415 /*******************************************************************
3416 return the size required by a struct in the stream
3417 ********************************************************************/
3419 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3422 size
+=size_of_relative_string( &info
->name
);
3427 /*******************************************************************
3428 return the size required by a struct in the stream
3429 ********************************************************************/
3431 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3434 size
+=size_of_relative_string( &info
->name
);
3435 size
+=size_of_relative_string( &info
->environment
);
3436 size
+=size_of_relative_string( &info
->dll_name
);
3441 /*******************************************************************
3443 ********************************************************************/
3445 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3446 const POLICY_HND
*hnd
,
3447 const fstring architecture
,
3448 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3449 NEW_BUFFER
*buffer
, uint32 offered
)
3454 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3456 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3459 q_u
->clientmajorversion
=clientmajor
;
3460 q_u
->clientminorversion
=clientminor
;
3463 q_u
->offered
=offered
;
3468 /*******************************************************************
3470 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3471 ********************************************************************/
3473 BOOL
spoolss_io_q_getprinterdriver2(char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3475 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3481 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3483 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3485 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3490 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3493 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3499 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3502 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3504 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3510 /*******************************************************************
3512 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3513 ********************************************************************/
3515 BOOL
spoolss_io_r_getprinterdriver2(char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3517 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3523 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3528 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3530 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3532 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3534 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3540 /*******************************************************************
3542 ********************************************************************/
3544 BOOL
make_spoolss_q_enumprinters(
3545 SPOOL_Q_ENUMPRINTERS
*q_u
,
3555 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3556 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3560 q_u
->offered
=offered
;
3565 /*******************************************************************
3567 ********************************************************************/
3569 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3570 fstring servername
, uint32 level
,
3571 NEW_BUFFER
*buffer
, uint32 offered
)
3573 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3574 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3578 q_u
->offered
=offered
;
3583 /*******************************************************************
3585 * called from spoolss_enumprinters (srv_spoolss.c)
3586 ********************************************************************/
3588 BOOL
spoolss_io_q_enumprinters(char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3590 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3596 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3598 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3601 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3606 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3609 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3614 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3620 /*******************************************************************
3621 Parse a SPOOL_R_ENUMPRINTERS structure.
3622 ********************************************************************/
3624 BOOL
spoolss_io_r_enumprinters(char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3626 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3632 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3638 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3641 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3644 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3650 /*******************************************************************
3651 * write a structure.
3652 * called from spoolss_r_enum_printers (srv_spoolss.c)
3654 ********************************************************************/
3656 BOOL
spoolss_io_r_getprinter(char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3658 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3664 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3670 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3673 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3679 /*******************************************************************
3681 * called from spoolss_getprinter (srv_spoolss.c)
3682 ********************************************************************/
3684 BOOL
spoolss_io_q_getprinter(char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3686 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3692 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3694 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3697 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3702 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3708 /*******************************************************************
3710 ********************************************************************/
3712 BOOL
make_spoolss_q_getprinter(
3713 TALLOC_CTX
*mem_ctx
,
3714 SPOOL_Q_GETPRINTER
*q_u
,
3715 const POLICY_HND
*hnd
,
3725 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3729 q_u
->offered
=offered
;
3734 /*******************************************************************
3736 ********************************************************************/
3737 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
3738 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
3742 DEVICEMODE
*devmode
;
3747 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3750 q_u
->info
.level
= level
;
3751 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
3754 /* There's no such thing as a setprinter level 1 */
3757 secdesc
= info
->printers_2
->secdesc
;
3758 devmode
= info
->printers_2
->devmode
;
3760 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
3761 #if 1 /* JERRY TEST */
3762 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
3763 if (!q_u
->secdesc_ctr
)
3765 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
3766 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3767 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3768 q_u
->secdesc_ctr
->sec
= secdesc
;
3770 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
3771 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
3772 q_u
->devmode_ctr
.devmode
= devmode
;
3774 q_u
->secdesc_ctr
= NULL
;
3776 q_u
->devmode_ctr
.devmode_ptr
= 0;
3777 q_u
->devmode_ctr
.size
= 0;
3778 q_u
->devmode_ctr
.devmode
= NULL
;
3782 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
3787 q_u
->command
= command
;
3793 /*******************************************************************
3794 ********************************************************************/
3796 BOOL
spoolss_io_r_setprinter(char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3798 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3804 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3810 /*******************************************************************
3811 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3812 ********************************************************************/
3814 BOOL
spoolss_io_q_setprinter(char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3816 uint32 ptr_sec_desc
= 0;
3818 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3824 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3826 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3829 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3832 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3842 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3847 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3853 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3858 /* Parse a NULL security descriptor. This should really
3859 happen inside the sec_io_desc_buf() function. */
3861 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3862 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
3864 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
3868 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3874 /*******************************************************************
3875 ********************************************************************/
3877 BOOL
spoolss_io_r_fcpn(char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
3879 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
3885 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3891 /*******************************************************************
3892 ********************************************************************/
3894 BOOL
spoolss_io_q_fcpn(char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
3897 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
3903 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3910 /*******************************************************************
3911 ********************************************************************/
3913 BOOL
spoolss_io_r_addjob(char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
3915 prs_debug(ps
, depth
, desc
, "");
3921 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3927 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3930 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3936 /*******************************************************************
3937 ********************************************************************/
3939 BOOL
spoolss_io_q_addjob(char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
3941 prs_debug(ps
, depth
, desc
, "");
3947 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3949 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3952 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3958 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3964 /*******************************************************************
3965 ********************************************************************/
3967 BOOL
spoolss_io_r_enumjobs(char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
3969 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
3975 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3981 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3984 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3987 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3993 /*******************************************************************
3994 ********************************************************************/
3996 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
4007 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4008 q_u
->firstjob
= firstjob
;
4009 q_u
->numofjobs
= numofjobs
;
4011 q_u
->buffer
= buffer
;
4012 q_u
->offered
= offered
;
4016 /*******************************************************************
4017 ********************************************************************/
4019 BOOL
spoolss_io_q_enumjobs(char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
4021 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
4027 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
4030 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
4032 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
4034 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4037 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4043 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4049 /*******************************************************************
4050 ********************************************************************/
4052 BOOL
spoolss_io_r_schedulejob(char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
4054 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
4060 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4066 /*******************************************************************
4067 ********************************************************************/
4069 BOOL
spoolss_io_q_schedulejob(char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
4071 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
4077 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4079 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4085 /*******************************************************************
4086 ********************************************************************/
4088 BOOL
spoolss_io_r_setjob(char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
4090 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4096 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4102 /*******************************************************************
4103 ********************************************************************/
4105 BOOL
spoolss_io_q_setjob(char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4107 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4113 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4115 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4118 * level is usually 0. If (level!=0) then I'm in trouble !
4119 * I will try to generate setjob command with level!=0, one day.
4121 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4123 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4129 /*******************************************************************
4130 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4131 ********************************************************************/
4133 BOOL
spoolss_io_r_enumprinterdrivers(char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4135 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4141 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4147 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4150 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4153 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4159 /*******************************************************************
4161 ********************************************************************/
4163 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4165 const char *environment
,
4167 NEW_BUFFER
*buffer
, uint32 offered
)
4169 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4170 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4174 q_u
->offered
=offered
;
4179 /*******************************************************************
4180 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4181 ********************************************************************/
4183 BOOL
spoolss_io_q_enumprinterdrivers(char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4186 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4192 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4194 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4199 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4201 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4206 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4209 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4215 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4221 /*******************************************************************
4222 ********************************************************************/
4224 BOOL
spoolss_io_q_enumforms(char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4227 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4232 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4234 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4237 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4242 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4248 /*******************************************************************
4249 ********************************************************************/
4251 BOOL
spoolss_io_r_enumforms(char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4253 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4259 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4265 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4268 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4271 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4277 /*******************************************************************
4278 ********************************************************************/
4280 BOOL
spoolss_io_q_getform(char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4283 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4288 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4290 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4296 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4299 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4304 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4310 /*******************************************************************
4311 ********************************************************************/
4313 BOOL
spoolss_io_r_getform(char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4315 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4321 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4327 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4330 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4336 /*******************************************************************
4337 Parse a SPOOL_R_ENUMPORTS structure.
4338 ********************************************************************/
4340 BOOL
spoolss_io_r_enumports(char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4342 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4348 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4354 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4357 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4360 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4366 /*******************************************************************
4367 ********************************************************************/
4369 BOOL
spoolss_io_q_enumports(char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4371 prs_debug(ps
, depth
, desc
, "");
4377 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4379 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4384 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4387 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4392 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4398 /*******************************************************************
4399 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4400 ********************************************************************/
4402 BOOL
spool_io_printer_info_level_1(char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4404 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4410 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4412 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4414 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4416 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4419 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4421 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4423 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4429 /*******************************************************************
4430 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4431 ********************************************************************/
4433 BOOL
spool_io_printer_info_level_3(char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4435 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4441 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4447 /*******************************************************************
4448 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4449 ********************************************************************/
4451 BOOL
spool_io_printer_info_level_2(char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4453 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4459 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4461 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4463 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4465 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4468 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4470 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4472 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4474 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4476 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4478 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4480 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4482 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4484 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4487 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4489 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4491 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4493 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4495 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4497 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4499 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4501 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4504 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4506 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4508 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4510 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4512 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4514 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4516 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4518 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4520 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4522 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4524 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4530 /*******************************************************************
4531 ********************************************************************/
4533 BOOL
spool_io_printer_info_level(char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4535 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4540 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4542 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4545 /* if no struct inside just return */
4546 if (il
->info_ptr
==0) {
4547 if (UNMARSHALLING(ps
)) {
4554 switch (il
->level
) {
4556 * level 0 is used by setprinter when managing the queue
4557 * (hold, stop, start a queue)
4561 /* DOCUMENT ME!!! What is level 1 used for? */
4564 if (UNMARSHALLING(ps
)) {
4565 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4568 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4573 * level 2 is used by addprinter
4574 * and by setprinter when updating printer's info
4577 if (UNMARSHALLING(ps
)) {
4578 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4581 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4584 /* DOCUMENT ME!!! What is level 3 used for? */
4587 if (UNMARSHALLING(ps
)) {
4588 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4591 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4600 /*******************************************************************
4601 ********************************************************************/
4603 BOOL
spoolss_io_q_addprinterex(char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4605 uint32 ptr_sec_desc
= 0;
4607 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4612 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4614 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4620 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4623 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4626 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4632 switch (q_u
->level
) {
4634 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4637 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4641 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4646 /* Parse a NULL security descriptor. This should really
4647 happen inside the sec_io_desc_buf() function. */
4649 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4650 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4652 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
4656 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4658 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4664 /*******************************************************************
4665 ********************************************************************/
4667 BOOL
spoolss_io_r_addprinterex(char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4668 prs_struct
*ps
, int depth
)
4670 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4673 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4676 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4682 /*******************************************************************
4683 ********************************************************************/
4685 BOOL
spool_io_printer_driver_info_level_3(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4686 prs_struct
*ps
, int depth
)
4688 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4690 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4694 if (UNMARSHALLING(ps
)) {
4695 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4707 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4709 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4711 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4713 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4715 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4717 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4719 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4721 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4723 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4725 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4727 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4733 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4735 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4737 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4739 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4741 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4743 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4745 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4747 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4753 if (il
->dependentfiles_ptr
)
4754 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
4759 /*******************************************************************
4760 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4761 ********************************************************************/
4763 BOOL
spool_io_printer_driver_info_level_6(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4764 prs_struct
*ps
, int depth
)
4766 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4768 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4772 if (UNMARSHALLING(ps
)) {
4773 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
4786 /* parse the main elements the packet */
4788 if(!prs_uint32("version", ps
, depth
, &il
->version
))
4791 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4794 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4795 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4796 * from W2K CDROM (which uses unidriver). JohnR 010205
4798 if (!il
->name_ptr
) {
4799 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4800 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4804 if(!prs_uint32("environment_ptr", ps
, depth
, &il
->environment_ptr
))
4806 if(!prs_uint32("driverpath_ptr", ps
, depth
, &il
->driverpath_ptr
))
4808 if(!prs_uint32("datafile_ptr", ps
, depth
, &il
->datafile_ptr
))
4810 if(!prs_uint32("configfile_ptr", ps
, depth
, &il
->configfile_ptr
))
4812 if(!prs_uint32("helpfile_ptr", ps
, depth
, &il
->helpfile_ptr
))
4814 if(!prs_uint32("monitorname_ptr", ps
, depth
, &il
->monitorname_ptr
))
4816 if(!prs_uint32("defaultdatatype_ptr", ps
, depth
, &il
->defaultdatatype_ptr
))
4818 if(!prs_uint32("dependentfiles_len", ps
, depth
, &il
->dependentfiles_len
))
4820 if(!prs_uint32("dependentfiles_ptr", ps
, depth
, &il
->dependentfiles_ptr
))
4822 if(!prs_uint32("previousnames_len", ps
, depth
, &il
->previousnames_len
))
4824 if(!prs_uint32("previousnames_ptr", ps
, depth
, &il
->previousnames_ptr
))
4826 if(!smb_io_time("driverdate", &il
->driverdate
, ps
, depth
))
4828 if(!prs_uint32("dummy4", ps
, depth
, &il
->dummy4
))
4830 if(!prs_uint64("driverversion", ps
, depth
, &il
->driverversion
))
4832 if(!prs_uint32("mfgname_ptr", ps
, depth
, &il
->mfgname_ptr
))
4834 if(!prs_uint32("oemurl_ptr", ps
, depth
, &il
->oemurl_ptr
))
4836 if(!prs_uint32("hardwareid_ptr", ps
, depth
, &il
->hardwareid_ptr
))
4838 if(!prs_uint32("provider_ptr", ps
, depth
, &il
->provider_ptr
))
4841 /* parse the structures in the packet */
4843 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4848 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4853 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4858 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4863 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4868 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4873 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4878 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4882 if (il
->dependentfiles_ptr
) {
4883 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
4888 if (il
->previousnames_ptr
) {
4889 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
4894 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
4898 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
4902 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
4906 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
4912 /*******************************************************************
4913 convert a buffer of UNICODE strings null terminated
4914 the buffer is terminated by a NULL
4916 convert to an dos codepage array (null terminated)
4918 dynamically allocate memory
4920 ********************************************************************/
4921 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
4930 src
= (char *)buf5
->buffer
;
4933 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
4934 unistr_to_dos(f
, src
, sizeof(f
)-1);
4935 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
4936 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
4941 fstrcpy((*ar
)[n
], f
);
4944 fstrcpy((*ar
)[n
], "");
4952 /*******************************************************************
4953 read a UNICODE array with null terminated strings
4954 and null terminated array
4955 and size of array at beginning
4956 ********************************************************************/
4958 BOOL
smb_io_unibuffer(char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
4960 if (buffer
==NULL
) return False
;
4963 buffer
->uni_str_len
=buffer
->uni_max_len
;
4965 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
4968 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
4974 /*******************************************************************
4975 ********************************************************************/
4977 BOOL
spool_io_printer_driver_info_level(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4979 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
4984 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4986 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
4992 switch (il
->level
) {
4994 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
4998 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
5008 /*******************************************************************
5009 init a SPOOL_Q_ADDPRINTERDRIVER struct
5010 ******************************************************************/
5012 BOOL
make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
5013 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
5014 uint32 level
, PRINTER_DRIVER_CTR
*info
)
5016 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
5018 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
5019 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
5023 q_u
->info
.level
= level
;
5024 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
5027 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
5029 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
5032 /* info level 6 is supported by WinME and Win2k */
5034 /* WRITEME!! will add later --jerry */
5038 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
5045 BOOL
make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
5046 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
5047 DRIVER_INFO_3
*info3
)
5050 uint16
*ptr
= info3
->dependentfiles
;
5052 BOOL null_char
= False
;
5053 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
5055 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
5058 inf
->cversion
= info3
->version
;
5059 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
5060 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
5061 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
5062 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
5063 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
5064 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
5065 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
5066 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
5068 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
5069 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
5070 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
5071 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
5072 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
5073 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
5074 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
5075 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
5082 /* the null_char BOOL is used to help locate
5083 two '\0's back to back */
5098 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5099 inf
->dependentfilessize
= len
;
5100 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5106 *spool_drv_info
= inf
;
5111 /*******************************************************************
5112 make a BUFFER5 struct from a uint16*
5113 ******************************************************************/
5114 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5117 buf5
->buf_len
= len
;
5118 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5120 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5127 /*******************************************************************
5128 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5129 ********************************************************************/
5131 BOOL
spoolss_io_q_addprinterdriver(char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5133 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5139 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5141 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5146 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5149 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5155 /*******************************************************************
5156 ********************************************************************/
5158 BOOL
spoolss_io_r_addprinterdriver(char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5160 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5163 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5169 /*******************************************************************
5170 ********************************************************************/
5172 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5173 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5175 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5177 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5181 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5189 d
->cversion
=uni
->cversion
;
5191 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5192 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5193 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5194 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5195 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5196 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5197 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5198 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5200 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5201 DEBUGADD(8,( "name: %s\n", d
->name
));
5202 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5203 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5204 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5205 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5206 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5207 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5208 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5210 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5217 /*******************************************************************
5218 ********************************************************************/
5219 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5220 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5222 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5224 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5228 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5236 d
->version
=uni
->version
;
5238 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5239 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5240 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5241 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5242 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5243 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5244 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5245 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5247 DEBUGADD(8,( "version: %d\n", d
->version
));
5248 DEBUGADD(8,( "name: %s\n", d
->name
));
5249 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5250 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5251 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5252 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5253 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5254 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5255 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5257 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5259 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5269 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5270 NT_PRINTER_INFO_LEVEL_2
**asc
)
5272 NT_PRINTER_INFO_LEVEL_2
*d
;
5275 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5276 time_unix
=time(NULL
);
5279 DEBUGADD(8,("allocating memory\n"));
5281 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5286 /* we allocate memory iff called from
5287 * addprinter(ex) so we can do one time stuff here.
5289 (*asc
)->setuptime
=time_unix
;
5291 DEBUGADD(8,("start converting\n"));
5295 d
->attributes
=uni
->attributes
;
5296 d
->priority
=uni
->priority
;
5297 d
->default_priority
=uni
->default_priority
;
5298 d
->starttime
=uni
->starttime
;
5299 d
->untiltime
=uni
->untiltime
;
5300 d
->status
=uni
->status
;
5301 d
->cjobs
=uni
->cjobs
;
5303 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5304 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5305 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5306 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5307 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5308 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5309 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5310 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5311 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5312 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5313 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5318 /*******************************************************************
5320 ********************************************************************/
5322 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5323 fstring servername
, fstring env_name
, uint32 level
,
5324 NEW_BUFFER
*buffer
, uint32 offered
)
5326 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5327 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5331 q_u
->offered
=offered
;
5336 /*******************************************************************
5337 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5338 ********************************************************************/
5340 BOOL
spoolss_io_q_getprinterdriverdir(char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5342 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5347 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5349 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5355 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5357 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5363 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5366 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5372 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5378 /*******************************************************************
5379 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5380 ********************************************************************/
5382 BOOL
spoolss_io_r_getprinterdriverdir(char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5384 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5390 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5396 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5399 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5405 /*******************************************************************
5406 ********************************************************************/
5408 BOOL
spoolss_io_r_enumprintprocessors(char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5410 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5416 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5422 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5425 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5428 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5434 /*******************************************************************
5435 ********************************************************************/
5437 BOOL
spoolss_io_q_enumprintprocessors(char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5439 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5445 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5447 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5453 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5455 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5461 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5464 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5470 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5476 /*******************************************************************
5477 ********************************************************************/
5479 BOOL
spoolss_io_q_addprintprocessor(char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5481 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5487 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5489 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5494 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5499 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5504 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5510 /*******************************************************************
5511 ********************************************************************/
5513 BOOL
spoolss_io_r_addprintprocessor(char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5515 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5521 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5527 /*******************************************************************
5528 ********************************************************************/
5530 BOOL
spoolss_io_r_enumprintprocdatatypes(char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5532 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5538 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5544 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5547 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5550 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5556 /*******************************************************************
5557 ********************************************************************/
5559 BOOL
spoolss_io_q_enumprintprocdatatypes(char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5561 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5567 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5569 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5575 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5577 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5583 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5586 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5592 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5598 /*******************************************************************
5599 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5600 ********************************************************************/
5602 BOOL
spoolss_io_q_enumprintmonitors(char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5604 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5610 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5612 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5618 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5621 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5627 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5633 /*******************************************************************
5634 ********************************************************************/
5636 BOOL
spoolss_io_r_enumprintmonitors(char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5638 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5644 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5650 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5653 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5656 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5662 /*******************************************************************
5663 ********************************************************************/
5665 BOOL
spoolss_io_r_enumprinterdata(char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5667 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5672 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5675 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5681 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5684 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5687 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5689 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
5694 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
5696 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5702 /*******************************************************************
5703 ********************************************************************/
5705 BOOL
spoolss_io_q_enumprinterdata(char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5707 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
5712 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5714 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
5716 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
5718 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
5724 /*******************************************************************
5725 ********************************************************************/
5727 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
5728 const POLICY_HND
*hnd
,
5729 uint32 idx
, uint32 valuelen
, uint32 datalen
)
5731 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5733 q_u
->valuesize
=valuelen
;
5734 q_u
->datasize
=datalen
;
5739 /*******************************************************************
5740 ********************************************************************/
5741 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, TALLOC_CTX
*ctx
, const POLICY_HND
*hnd
,
5742 char* value
, char* data
)
5746 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5748 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
5750 init_unistr2(&tmp
, data
, strlen(data
)+1);
5751 q_u
->max_len
= q_u
->real_len
= tmp
.uni_max_len
*2;
5752 q_u
->data
= talloc(ctx
, q_u
->real_len
);
5753 memcpy(q_u
->data
, tmp
.buffer
, q_u
->real_len
);
5757 /*******************************************************************
5758 ********************************************************************/
5760 BOOL
spoolss_io_q_setprinterdata(char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5762 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
5767 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5769 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
5775 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5778 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
5788 if (UNMARSHALLING(ps
))
5789 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
5790 if(q_u
->data
== NULL
)
5792 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
5800 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
5806 /*******************************************************************
5807 ********************************************************************/
5809 BOOL
spoolss_io_r_setprinterdata(char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5811 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
5816 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5822 /*******************************************************************
5823 ********************************************************************/
5824 BOOL
spoolss_io_q_resetprinter(char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5826 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
5831 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5834 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
5837 if (q_u
->datatype_ptr
) {
5838 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
5842 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
5849 /*******************************************************************
5850 ********************************************************************/
5851 BOOL
spoolss_io_r_resetprinter(char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5853 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
5858 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5864 /*******************************************************************
5865 ********************************************************************/
5866 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
5867 uint32 type
, const uint8
*data
, uint32 len
)
5869 DEBUG(5,("converting a specific param struct\n"));
5873 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
5876 memset((char *)*param
, '\0', sizeof(NT_PRINTER_PARAM
));
5877 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5879 unistr2_to_ascii((*param
)->value
, value
, sizeof((*param
)->value
)-1);
5880 (*param
)->type
= type
;
5882 /* le champ data n'est pas NULL termine */
5883 /* on stocke donc la longueur */
5885 (*param
)->data_len
=len
;
5888 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
5889 if((*param
)->data
== NULL
)
5891 memcpy((*param
)->data
, data
, len
);
5894 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
5895 dump_data(10, (char *)(*param
)->data
, (*param
)->data_len
);
5900 /*******************************************************************
5901 ********************************************************************/
5903 static BOOL
spoolss_io_addform(char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
5905 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
5912 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
5914 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
5916 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
5918 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
5920 if(!prs_uint32("left", ps
, depth
, &f
->left
))
5922 if(!prs_uint32("top", ps
, depth
, &f
->top
))
5924 if(!prs_uint32("right", ps
, depth
, &f
->right
))
5926 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
5929 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
5936 /*******************************************************************
5937 ********************************************************************/
5939 BOOL
spoolss_io_q_deleteform(char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
5941 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
5946 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5948 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
5954 /*******************************************************************
5955 ********************************************************************/
5957 BOOL
spoolss_io_r_deleteform(char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
5959 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
5964 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5970 /*******************************************************************
5971 ********************************************************************/
5973 BOOL
spoolss_io_q_addform(char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
5975 uint32 useless_ptr
=1;
5976 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
5981 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5983 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5985 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5990 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5992 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5999 /*******************************************************************
6000 ********************************************************************/
6002 BOOL
spoolss_io_r_addform(char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
6004 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
6009 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6015 /*******************************************************************
6016 ********************************************************************/
6018 BOOL
spoolss_io_q_setform(char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
6020 uint32 useless_ptr
=1;
6021 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
6026 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6028 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
6034 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6036 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
6041 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
6043 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
6050 /*******************************************************************
6051 ********************************************************************/
6053 BOOL
spoolss_io_r_setform(char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
6055 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
6060 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6066 /*******************************************************************
6067 Parse a SPOOL_R_GETJOB structure.
6068 ********************************************************************/
6070 BOOL
spoolss_io_r_getjob(char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
6072 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
6078 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6084 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6087 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6093 /*******************************************************************
6094 Parse a SPOOL_Q_GETJOB structure.
6095 ********************************************************************/
6097 BOOL
spoolss_io_q_getjob(char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6099 prs_debug(ps
, depth
, desc
, "");
6105 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6107 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6109 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6112 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6118 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6124 void free_devmode(DEVICEMODE
*devmode
)
6126 if (devmode
!=NULL
) {
6127 SAFE_FREE(devmode
->private);
6132 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6137 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6139 if (printer
!=NULL
) {
6140 free_devmode(printer
->devmode
);
6141 printer
->devmode
= NULL
;
6146 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6151 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6156 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6161 void free_job_info_2(JOB_INFO_2
*job
)
6164 free_devmode(job
->devmode
);
6167 /*******************************************************************
6169 ********************************************************************/
6171 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6172 const fstring string
, uint32 printer
, uint32 type
)
6177 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
6179 q_u
->printer
=printer
;
6188 /*******************************************************************
6189 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6190 ********************************************************************/
6192 BOOL
spoolss_io_q_replyopenprinter(char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6194 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6200 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6206 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6208 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6211 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6213 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6219 /*******************************************************************
6220 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6221 ********************************************************************/
6223 BOOL
spoolss_io_r_replyopenprinter(char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6225 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6231 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6234 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6240 /*******************************************************************
6242 ********************************************************************/
6243 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6244 uint32 condition
, uint32 change_id
)
6247 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6249 q_u
->condition
= condition
;
6250 q_u
->change_id
= change_id
;
6253 q_u
->unknown1
= 0x1;
6254 memset(q_u
->unknown2
, 0x0, 5);
6255 q_u
->unknown2
[0] = 0x1;
6260 /*******************************************************************
6261 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6262 ********************************************************************/
6263 BOOL
spoolss_io_q_routerreplyprinter (char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6266 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6272 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6275 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6278 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6281 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6284 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6290 /*******************************************************************
6291 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6292 ********************************************************************/
6293 BOOL
spoolss_io_r_routerreplyprinter (char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6295 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6301 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6307 /*******************************************************************
6309 ********************************************************************/
6311 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6316 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6321 /*******************************************************************
6322 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6323 ********************************************************************/
6325 BOOL
spoolss_io_q_replycloseprinter(char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6327 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6333 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6339 /*******************************************************************
6340 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6341 ********************************************************************/
6343 BOOL
spoolss_io_r_replycloseprinter(char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6345 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6351 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6354 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6360 #if 0 /* JERRY - not currently used but could be :-) */
6362 /*******************************************************************
6363 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6364 ******************************************************************/
6365 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6366 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6370 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6372 for (i
=0; i
<n
; i
++) {
6376 if (src
->size
!= POINTER
)
6378 len
= src
->notify_data
.data
.length
;
6379 s
= malloc(sizeof(uint16
)*len
);
6381 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6385 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6386 dst
->notify_data
.data
.string
= s
;
6392 /*******************************************************************
6393 Deep copy a SPOOL_NOTIFY_INFO structure
6394 ******************************************************************/
6395 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6398 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6402 dst
->version
= src
->version
;
6403 dst
->flags
= src
->flags
;
6404 dst
->count
= src
->count
;
6408 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6410 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6413 if (dst
->data
== NULL
) {
6414 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6419 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6426 /*******************************************************************
6428 ********************************************************************/
6430 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6431 uint32 change_low
, uint32 change_high
,
6432 SPOOL_NOTIFY_INFO
*info
)
6437 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6439 q_u
->change_low
=change_low
;
6440 q_u
->change_high
=change_high
;
6445 q_u
->info_ptr
=0xaddee11e;
6447 q_u
->info
.version
=2;
6450 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6452 q_u
->info
.version
= info
->version
;
6453 q_u
->info
.flags
= info
->flags
;
6454 q_u
->info
.count
= info
->count
;
6455 /* pointer field - be careful! */
6456 q_u
->info
.data
= info
->data
;
6459 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6466 /*******************************************************************
6467 Parse a SPOOL_Q_REPLY_RRPCN structure.
6468 ********************************************************************/
6470 BOOL
spoolss_io_q_reply_rrpcn(char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6472 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6478 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6481 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6484 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6487 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6490 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6493 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6496 if(q_u
->info_ptr
!=0)
6497 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6503 /*******************************************************************
6504 Parse a SPOOL_R_REPLY_RRPCN structure.
6505 ********************************************************************/
6507 BOOL
spoolss_io_r_reply_rrpcn(char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6509 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6515 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6518 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6524 /*******************************************************************
6526 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6527 ********************************************************************/
6529 BOOL
spoolss_io_q_getprinterdataex(char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6534 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6539 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6543 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6547 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6551 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6557 /*******************************************************************
6558 * write a structure.
6559 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6560 ********************************************************************/
6562 BOOL
spoolss_io_r_getprinterdataex(char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6567 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6572 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6574 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6577 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
6583 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6585 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6591 /*******************************************************************
6593 ********************************************************************/
6595 BOOL
spoolss_io_q_setprinterdataex(char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6597 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
6602 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6604 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6610 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6616 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6619 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6629 if (UNMARSHALLING(ps
))
6630 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6631 if(q_u
->data
== NULL
)
6633 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6641 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6647 /*******************************************************************
6648 * write a structure.
6649 ********************************************************************/
6651 BOOL
spoolss_io_r_setprinterdataex(char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6653 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
6658 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6665 /*******************************************************************
6667 ********************************************************************/
6669 BOOL
spoolss_io_q_enumprinterkey(char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
6671 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
6676 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6679 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6685 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6691 /*******************************************************************
6692 * write a structure.
6693 ********************************************************************/
6695 BOOL
spoolss_io_r_enumprinterkey(char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
6697 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
6703 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
6709 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6712 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6719 /*******************************************************************
6721 ********************************************************************/
6723 BOOL
spoolss_io_q_enumprinterdataex(char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6725 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
6730 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6733 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6739 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6745 /*******************************************************************
6746 ********************************************************************/
6747 static BOOL
spoolss_io_printer_enum_values_ctr(char *desc
, prs_struct
*ps
,
6748 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
6751 uint32 valuename_offset
,
6754 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
6756 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
6759 if (!prs_uint32("size", ps
, depth
, &ctr
->size
))
6762 /* offset data begins at 20 bytes per structure * size_of_array.
6763 Don't forget the uint32 at the beginning */
6765 current_offset
= basic_unit
* ctr
->size_of_array
;
6767 /* first loop to write basic enum_value information */
6769 for (i
=0; i
<ctr
->size_of_array
; i
++)
6771 valuename_offset
= current_offset
;
6772 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
6775 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
6778 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
6781 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
6782 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
6785 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
6788 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
6791 /* loop #2 for writing the dynamically size objects
6792 while viewing conversations between Win2k -> Win2k,
6793 4-byte alignment does not seem to matter here --jerry */
6795 for (i
=0; i
<ctr
->size_of_array
; i
++)
6798 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
6801 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
6811 /*******************************************************************
6812 * write a structure.
6813 ********************************************************************/
6815 BOOL
spoolss_io_r_enumprinterdataex(char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6817 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
6823 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
6829 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6832 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6835 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6842 /*******************************************************************
6843 * write a structure.
6844 ********************************************************************/
6847 uint32 GetPrintProcessorDirectory(
6849 [in] unistr2 *environment,
6851 [in,out] NEW_BUFFER buffer,
6852 [in] uint32 offered,
6853 [out] uint32 needed,
6854 [out] uint32 returned
6859 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, NEW_BUFFER
*buffer
, uint32 offered
)
6861 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
6863 init_unistr2(&q_u
->name
, name
, strlen(name
)+1);
6864 init_unistr2(&q_u
->environment
, environment
, strlen(environment
)+1);
6868 q_u
->buffer
= buffer
;
6869 q_u
->offered
= offered
;
6874 BOOL
spoolss_io_q_getprintprocessordirectory(char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
6878 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
6884 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
6888 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6895 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
6899 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
6907 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6910 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6916 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6922 /*******************************************************************
6923 * write a structure.
6924 ********************************************************************/
6926 BOOL
spoolss_io_r_getprintprocessordirectory(char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
6928 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
6934 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6940 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6943 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6949 BOOL
smb_io_printprocessordirectory_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
6951 prs_struct
*ps
=&buffer
->prs
;
6953 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
6956 buffer
->struct_start
=prs_offset(ps
);
6958 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
6964 /*******************************************************************
6966 ********************************************************************/
6968 BOOL
make_spoolss_q_addform(SPOOL_Q_ADDFORM
*q_u
, POLICY_HND
*handle
,
6969 int level
, FORM
*form
)
6971 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
6973 q_u
->level2
= level
;
6974 memcpy(&q_u
->form
, form
, sizeof(FORM
));
6979 /*******************************************************************
6981 ********************************************************************/
6983 BOOL
make_spoolss_q_setform(SPOOL_Q_SETFORM
*q_u
, POLICY_HND
*handle
,
6984 int level
, char *form_name
, FORM
*form
)
6986 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
6988 q_u
->level2
= level
;
6989 memcpy(&q_u
->form
, form
, sizeof(FORM
));
6990 init_unistr2(&q_u
->name
, form_name
, strlen(form_name
) + 1);
6995 /*******************************************************************
6997 ********************************************************************/
6999 BOOL
make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM
*q_u
, POLICY_HND
*handle
, char *form
)
7001 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7002 init_unistr2(&q_u
->name
, form
, strlen(form
) + 1);
7006 /*******************************************************************
7008 ********************************************************************/
7010 BOOL
make_spoolss_q_getform(SPOOL_Q_GETFORM
*q_u
, POLICY_HND
*handle
,
7011 char *formname
, uint32 level
, NEW_BUFFER
*buffer
,
7014 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7016 init_unistr2(&q_u
->formname
, formname
, strlen(formname
) + 1);
7018 q_u
->offered
=offered
;
7023 /*******************************************************************
7025 ********************************************************************/
7027 BOOL
make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
7028 uint32 level
, NEW_BUFFER
*buffer
,
7031 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
7034 q_u
->offered
=offered
;