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
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 extern int DEBUGLEVEL
;
29 /*******************************************************************
30 return the length of a UNISTR string.
31 ********************************************************************/
33 static uint32
str_len_uni(UNISTR
*source
)
40 while (source
->buffer
[i
])
46 /*******************************************************************
47 This should be moved in a more generic lib.
48 ********************************************************************/
50 static BOOL
spoolss_io_system_time(char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
52 if(!prs_uint16("year", ps
, depth
, &(systime
->year
)))
54 if(!prs_uint16("month", ps
, depth
, &(systime
->month
)))
56 if(!prs_uint16("dayofweek", ps
, depth
, &(systime
->dayofweek
)))
58 if(!prs_uint16("day", ps
, depth
, &(systime
->day
)))
60 if(!prs_uint16("hour", ps
, depth
, &(systime
->hour
)))
62 if(!prs_uint16("minute", ps
, depth
, &(systime
->minute
)))
64 if(!prs_uint16("second", ps
, depth
, &(systime
->second
)))
66 if(!prs_uint16("milliseconds", ps
, depth
, &(systime
->milliseconds
)))
72 /*******************************************************************
73 ********************************************************************/
75 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
77 systime
->year
=unixtime
->tm_year
+1900;
78 systime
->month
=unixtime
->tm_mon
+1;
79 systime
->dayofweek
=unixtime
->tm_wday
;
80 systime
->day
=unixtime
->tm_mday
;
81 systime
->hour
=unixtime
->tm_hour
;
82 systime
->minute
=unixtime
->tm_min
;
83 systime
->second
=unixtime
->tm_sec
;
84 systime
->milliseconds
=0;
89 /*******************************************************************
90 reads or writes an DOC_INFO structure.
91 ********************************************************************/
93 static BOOL
smb_io_doc_info_1(char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
95 if (info_1
== NULL
) return False
;
97 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
103 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
105 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
107 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
110 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
112 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
114 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
120 /*******************************************************************
121 reads or writes an DOC_INFO structure.
122 ********************************************************************/
124 static BOOL
smb_io_doc_info(char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
126 uint32 useless_ptr
=0;
128 if (info
== NULL
) return False
;
130 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
136 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
139 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
142 switch (info
->switch_value
)
145 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
150 this is just a placeholder
152 MSDN July 1998 says doc_info_2 is only on
153 Windows 95, and as Win95 doesn't do RPC to print
154 this case is nearly impossible
156 Maybe one day with Windows for dishwasher 2037 ...
159 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
162 DEBUG(0,("Something is obviously wrong somewhere !\n"));
169 /*******************************************************************
170 reads or writes an DOC_INFO_CONTAINER structure.
171 ********************************************************************/
173 static BOOL
smb_io_doc_info_container(char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
175 if (cont
== NULL
) return False
;
177 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
183 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
186 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
192 /*******************************************************************
193 reads or writes an NOTIFY OPTION TYPE structure.
194 ********************************************************************/
196 static BOOL
smb_io_notify_option_type(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
198 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
204 if(!prs_uint16("type", ps
, depth
, &type
->type
))
206 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
208 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
210 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
212 if(!prs_uint32("count", ps
, depth
, &type
->count
))
214 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
220 /*******************************************************************
221 reads or writes an NOTIFY OPTION TYPE DATA.
222 ********************************************************************/
224 static BOOL
smb_io_notify_option_type_data(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
228 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
231 /* if there are no fields just return */
232 if (type
->fields_ptr
==0)
238 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
241 if (type
->count2
!= type
->count
)
242 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
244 /* parse the option type data */
245 for(i
=0;i
<type
->count2
;i
++)
246 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
251 /*******************************************************************
252 reads or writes an NOTIFY OPTION structure.
253 ********************************************************************/
255 static BOOL
smb_io_notify_option_type_ctr(char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
259 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
262 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
266 if (UNMARSHALLING(ps
))
267 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)prs_alloc_mem(ps
,ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
270 /* the option type struct */
271 for(i
=0;i
<ctr
->count
;i
++)
272 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
275 /* the type associated with the option type struct */
276 for(i
=0;i
<ctr
->count
;i
++)
277 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
283 /*******************************************************************
284 reads or writes an NOTIFY OPTION structure.
285 ********************************************************************/
287 static BOOL
smb_io_notify_option(char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
289 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
292 if(!prs_uint32("version", ps
, depth
, &option
->version
))
294 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
296 if(!prs_uint32("count", ps
, depth
, &option
->count
))
298 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
301 /* marshalling or unmarshalling, that would work */
302 if (option
->option_type_ptr
!=0) {
303 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
307 option
->ctr
.type
=NULL
;
314 /*******************************************************************
315 reads or writes an NOTIFY INFO DATA structure.
316 ********************************************************************/
318 static BOOL
smb_io_notify_info_data(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
320 uint32 useless_ptr
=0xADDE0FF0;
322 uint32 how_many_words
;
326 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
329 how_many_words
=data
->size
;
330 if (how_many_words
==POINTER
) {
331 how_many_words
=TWO_VALUE
;
334 isvalue
=data
->enc_type
;
338 if(!prs_uint16("type", ps
, depth
, &data
->type
))
340 if(!prs_uint16("field", ps
, depth
, &data
->field
))
344 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
346 if(!prs_uint32("id", ps
, depth
, &data
->id
))
348 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
355 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
357 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
362 /* length in ascii including \0 */
363 x
=2*(data
->notify_data
.data
.length
+1);
364 if(!prs_uint32("string length", ps
, depth
, &x
))
366 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
374 /*******************************************************************
375 reads or writes an NOTIFY INFO DATA structure.
376 ********************************************************************/
378 BOOL
smb_io_notify_info_data_strings(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
379 prs_struct
*ps
, int depth
)
384 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
390 isvalue
=data
->enc_type
;
392 if (isvalue
==False
) {
393 /* length of string in unicode include \0 */
394 x
=data
->notify_data
.data
.length
+1;
395 if(!prs_uint32("string length", ps
, depth
, &x
))
397 if (MARSHALLING(ps
)) {
398 /* These are already in little endian format. Don't byte swap. */
401 /* No memory allocated for this string
402 therefore following the data.string
403 pointer is a bad idea. Use a pointer to
404 the uint32 length union member to
405 provide a source for a unicode NULL */
407 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
410 if(!prs_uint8s(True
,"string",ps
,depth
,(uint8
*)data
->notify_data
.data
.string
,x
*2))
415 /* Tallocate memory for string */
417 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
418 if (!data
->notify_data
.data
.string
)
421 if(!prs_uint16s(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
431 /*******************************************************************
432 reads or writes an NOTIFY INFO structure.
433 ********************************************************************/
435 static BOOL
smb_io_notify_info(char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
439 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
445 if(!prs_uint32("count", ps
, depth
, &info
->count
))
447 if(!prs_uint32("version", ps
, depth
, &info
->version
))
449 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
451 if(!prs_uint32("count", ps
, depth
, &info
->count
))
454 for (i
=0;i
<info
->count
;i
++) {
455 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
459 /* now do the strings at the end of the stream */
460 for (i
=0;i
<info
->count
;i
++) {
461 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
468 /*******************************************************************
469 ********************************************************************/
471 static BOOL
spool_io_user_level_1(char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
473 prs_debug(ps
, depth
, desc
, "");
477 if (UNMARSHALLING(ps
))
482 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
484 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
486 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
488 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
490 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
492 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
494 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
497 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
501 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
507 /*******************************************************************
508 ********************************************************************/
510 static BOOL
spool_io_user_level(char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
515 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
520 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
522 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
525 switch (q_u
->level
) {
527 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
537 /*******************************************************************
538 * read or write a DEVICEMODE struct.
539 * on reading allocate memory for the private member
540 ********************************************************************/
542 static BOOL
spoolss_io_devmode(char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
544 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
547 if (UNMARSHALLING(ps
)) {
548 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
549 if (devmode
->devicename
.buffer
== NULL
)
553 if (!prs_uint16s(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, 32))
555 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
557 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
559 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
561 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
563 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
565 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
567 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
569 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
571 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
573 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
575 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
577 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
579 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
581 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
583 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
585 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
587 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
589 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
592 if (UNMARSHALLING(ps
)) {
593 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
594 if (devmode
->formname
.buffer
== NULL
)
598 if (!prs_uint16s(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
600 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
602 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
604 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
606 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
608 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
610 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
612 if (!prs_uint32("icmmethod", ps
, depth
, &devmode
->icmmethod
))
614 if (!prs_uint32("icmintent", ps
, depth
, &devmode
->icmintent
))
616 if (!prs_uint32("mediatype", ps
, depth
, &devmode
->mediatype
))
618 if (!prs_uint32("dithertype", ps
, depth
, &devmode
->dithertype
))
620 if (!prs_uint32("reserved1", ps
, depth
, &devmode
->reserved1
))
622 if (!prs_uint32("reserved2", ps
, depth
, &devmode
->reserved2
))
624 if (!prs_uint32("panningwidth", ps
, depth
, &devmode
->panningwidth
))
626 if (!prs_uint32("panningheight", ps
, depth
, &devmode
->panningheight
))
629 if (devmode
->driverextra
!=0) {
630 if (UNMARSHALLING(ps
)) {
631 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
632 if(devmode
->private == NULL
)
634 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
637 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
638 if (!prs_uint8s(True
, "private", ps
, depth
, devmode
->private, devmode
->driverextra
))
645 /*******************************************************************
646 Read or write a DEVICEMODE container
647 ********************************************************************/
649 static BOOL
spoolss_io_devmode_cont(char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
654 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
660 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
663 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
666 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
667 if (UNMARSHALLING(ps
))
668 /* if while reading there is no DEVMODE ... */
673 /* so we have a DEVICEMODE to follow */
674 if (UNMARSHALLING(ps
)) {
675 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
676 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
677 if(dm_c
->devmode
== NULL
)
681 /* this is bad code, shouldn't be there */
682 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
685 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
691 /*******************************************************************
692 ********************************************************************/
694 static BOOL
spoolss_io_printer_default(char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
699 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
702 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
705 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
711 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
714 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
720 /*******************************************************************
722 ********************************************************************/
724 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
725 const fstring printername
,
726 const fstring datatype
,
727 uint32 access_required
,
728 const fstring clientname
,
729 const fstring user_name
)
731 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
732 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
733 init_unistr2(&q_u
->printername
, printername
, strlen(printername
)+1);
735 q_u
->printer_default
.datatype_ptr
= 0;
737 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
738 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
740 q_u
->printer_default
.devmode_cont
.size
=0;
741 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
742 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
743 q_u
->printer_default
.access_required
=access_required
;
745 q_u
->user_ctr
.level
=1;
747 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
748 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
749 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
750 q_u
->user_ctr
.user1
.build
=1381;
751 q_u
->user_ctr
.user1
.major
=2;
752 q_u
->user_ctr
.user1
.minor
=0;
753 q_u
->user_ctr
.user1
.processor
=0;
754 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
755 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
760 /*******************************************************************
762 ********************************************************************/
763 BOOL
make_spoolss_q_addprinterex(
764 SPOOL_Q_ADDPRINTEREX
*q_u
,
765 const char *srv_name
,
766 const char* clientname
,
767 const char* user_name
,
769 PRINTER_INFO_CTR
*ctr
)
771 DEBUG(5,("make_spoolss_q_addprinterex\n"));
773 if (!ctr
) return False
;
775 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
776 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
));
780 q_u
->info
.level
= level
;
781 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
785 /* init q_u->info.info2 from *info */
786 if (!make_spool_printer_info_2(&q_u
->info
.info_2
, ctr
->printers_2
))
788 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
796 q_u
->unk0
= q_u
->unk1
= q_u
->unk2
= q_u
->unk3
= 0;
800 q_u
->user_ctr
.level
=1;
802 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
803 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
804 q_u
->user_ctr
.user1
.build
=1381;
805 q_u
->user_ctr
.user1
.major
=2;
806 q_u
->user_ctr
.user1
.minor
=0;
807 q_u
->user_ctr
.user1
.processor
=0;
808 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
809 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
810 q_u
->user_ctr
.user1
.size
=q_u
->user_ctr
.user1
.user_name
.uni_str_len
+
811 q_u
->user_ctr
.user1
.client_name
.uni_str_len
+ 2;
816 /*******************************************************************
817 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
818 *******************************************************************/
820 BOOL
make_spool_printer_info_2(
821 SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
826 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
828 /* allocate the necessary memory */
829 inf
= (SPOOL_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_2
));
830 if (spool_info2
== NULL
)
832 DEBUG(0,("make_spool_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
836 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
837 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
838 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
839 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
840 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
841 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
842 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
843 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
844 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
845 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
846 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
847 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
848 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
849 inf
->attributes
= info
->attributes
;
850 inf
->priority
= info
->priority
;
851 inf
->default_priority
= info
->defaultpriority
;
852 inf
->starttime
= info
->starttime
;
853 inf
->untiltime
= info
->untiltime
;
854 inf
->cjobs
= info
->cjobs
;
855 inf
->averageppm
= info
->averageppm
;
856 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
857 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
858 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
859 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
860 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
861 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
862 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
863 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
864 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
865 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
866 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
867 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
875 /*******************************************************************
877 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
878 ********************************************************************/
880 BOOL
spoolss_io_q_open_printer_ex(char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
885 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
891 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
893 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
899 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
902 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
904 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
910 /*******************************************************************
912 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
913 * called from spoolss_open_printer_ex (cli_spoolss.c)
914 ********************************************************************/
916 BOOL
spoolss_io_r_open_printer_ex(char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
918 if (r_u
== NULL
) return False
;
920 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
926 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
929 if (!prs_uint32("status code", ps
, depth
, &(r_u
->status
)))
935 /*******************************************************************
937 ********************************************************************/
939 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
940 const POLICY_HND
*handle
,
941 UNISTR2
*valuename
, uint32 size
)
943 if (q_u
== NULL
) return False
;
945 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
947 q_u
->handle
= *handle
;
948 copy_unistr2(&q_u
->valuename
, valuename
);
954 /*******************************************************************
956 * called from spoolss_q_getprinterdata (srv_spoolss.c)
957 ********************************************************************/
959 BOOL
spoolss_io_q_getprinterdata(char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
964 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
969 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
973 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
977 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
983 /*******************************************************************
985 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
986 ********************************************************************/
988 BOOL
spoolss_io_q_deleteprinterdata(char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
993 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
998 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1002 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1008 /*******************************************************************
1009 * write a structure.
1010 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1011 ********************************************************************/
1013 BOOL
spoolss_io_r_deleteprinterdata(char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1015 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1017 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1023 /*******************************************************************
1024 * write a structure.
1025 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1026 ********************************************************************/
1028 BOOL
spoolss_io_r_getprinterdata(char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1033 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1038 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1040 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1043 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
1049 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1051 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1057 /*******************************************************************
1059 ********************************************************************/
1061 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1063 if (q_u
== NULL
) return False
;
1065 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1067 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1072 /*******************************************************************
1074 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1075 * called from spoolss_abortprinter (cli_spoolss.c)
1076 ********************************************************************/
1078 BOOL
spoolss_io_q_abortprinter(char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1080 if (q_u
== NULL
) return False
;
1082 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1088 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1094 /*******************************************************************
1095 * write a structure.
1096 * called from spoolss_r_abortprinter (srv_spoolss.c)
1097 ********************************************************************/
1099 BOOL
spoolss_io_r_abortprinter(char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1101 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1103 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1109 /*******************************************************************
1111 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1112 * called from spoolss_deleteprinter (cli_spoolss.c)
1113 ********************************************************************/
1115 BOOL
spoolss_io_q_deleteprinter(char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1117 if (q_u
== NULL
) return False
;
1119 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1125 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1131 /*******************************************************************
1132 * write a structure.
1133 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1134 * called from spoolss_deleteprinter (cli_spoolss.c)
1135 ********************************************************************/
1137 BOOL
spoolss_io_r_deleteprinter(char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1139 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1145 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1147 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1153 /*******************************************************************
1155 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1156 * called from spoolss_closeprinter (cli_spoolss.c)
1157 ********************************************************************/
1159 BOOL
spoolss_io_q_closeprinter(char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1161 if (q_u
== NULL
) return False
;
1163 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1169 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1175 /*******************************************************************
1176 * write a structure.
1177 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1178 * called from spoolss_closeprinter (cli_spoolss.c)
1179 ********************************************************************/
1181 BOOL
spoolss_io_r_closeprinter(char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1183 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1189 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1191 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1197 /*******************************************************************
1199 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1200 ********************************************************************/
1202 BOOL
spoolss_io_q_startdocprinter(char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1204 if (q_u
== NULL
) return False
;
1206 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1212 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1215 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1221 /*******************************************************************
1222 * write a structure.
1223 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1224 ********************************************************************/
1226 BOOL
spoolss_io_r_startdocprinter(char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1228 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1230 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1232 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1238 /*******************************************************************
1240 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1241 ********************************************************************/
1243 BOOL
spoolss_io_q_enddocprinter(char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1245 if (q_u
== NULL
) return False
;
1247 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1253 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1259 /*******************************************************************
1260 * write a structure.
1261 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1262 ********************************************************************/
1264 BOOL
spoolss_io_r_enddocprinter(char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1266 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1268 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1274 /*******************************************************************
1276 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1277 ********************************************************************/
1279 BOOL
spoolss_io_q_startpageprinter(char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1281 if (q_u
== NULL
) return False
;
1283 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1289 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1295 /*******************************************************************
1296 * write a structure.
1297 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1298 ********************************************************************/
1300 BOOL
spoolss_io_r_startpageprinter(char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1302 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1304 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1310 /*******************************************************************
1312 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1313 ********************************************************************/
1315 BOOL
spoolss_io_q_endpageprinter(char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1317 if (q_u
== NULL
) return False
;
1319 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1325 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1331 /*******************************************************************
1332 * write a structure.
1333 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1334 ********************************************************************/
1336 BOOL
spoolss_io_r_endpageprinter(char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1338 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1340 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1346 /*******************************************************************
1348 * called from spoolss_q_writeprinter (srv_spoolss.c)
1349 ********************************************************************/
1351 BOOL
spoolss_io_q_writeprinter(char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1353 if (q_u
== NULL
) return False
;
1355 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1361 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1363 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1366 if (q_u
->buffer_size
!=0)
1368 if (UNMARSHALLING(ps
))
1369 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1370 if(q_u
->buffer
== NULL
)
1372 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1377 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1383 /*******************************************************************
1384 * write a structure.
1385 * called from spoolss_r_writeprinter (srv_spoolss.c)
1386 ********************************************************************/
1388 BOOL
spoolss_io_r_writeprinter(char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1390 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1392 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1394 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1400 /*******************************************************************
1402 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1403 ********************************************************************/
1405 BOOL
spoolss_io_q_rffpcnex(char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1407 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1413 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1415 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1417 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1419 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1421 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1427 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1430 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1433 if (q_u
->option_ptr
!=0) {
1435 if (UNMARSHALLING(ps
))
1436 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1439 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1446 /*******************************************************************
1447 * write a structure.
1448 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1449 ********************************************************************/
1451 BOOL
spoolss_io_r_rffpcnex(char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1453 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1456 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1462 /*******************************************************************
1464 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1465 ********************************************************************/
1467 BOOL
spoolss_io_q_rfnpcnex(char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1469 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1475 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1478 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1481 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1484 if (q_u
->option_ptr
!=0) {
1486 if (UNMARSHALLING(ps
))
1487 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1490 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1497 /*******************************************************************
1498 * write a structure.
1499 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1500 ********************************************************************/
1502 BOOL
spoolss_io_r_rfnpcnex(char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1504 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1510 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1513 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1518 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1524 /*******************************************************************
1525 * return the length of a uint16 (obvious, but the code is clean)
1526 ********************************************************************/
1528 static uint32
size_of_uint16(uint16
*value
)
1530 return (sizeof(*value
));
1533 /*******************************************************************
1534 * return the length of a uint32 (obvious, but the code is clean)
1535 ********************************************************************/
1537 static uint32
size_of_uint32(uint32
*value
)
1539 return (sizeof(*value
));
1542 /*******************************************************************
1543 * return the length of a NTTIME (obvious, but the code is clean)
1544 ********************************************************************/
1546 static uint32
size_of_nttime(NTTIME
*value
)
1548 return (sizeof(*value
));
1551 /*******************************************************************
1552 * return the length of a UNICODE string in number of char, includes:
1553 * - the leading zero
1554 * - the relative pointer size
1555 ********************************************************************/
1557 static uint32
size_of_relative_string(UNISTR
*string
)
1561 size
=str_len_uni(string
); /* the string length */
1562 size
=size
+1; /* add the leading zero */
1563 size
=size
*2; /* convert in char */
1564 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1565 size
+= ((4 - (size
& 3)) & 3);
1566 size
=size
+4; /* add the size of the ptr */
1571 /*******************************************************************
1572 * return the length of a uint32 (obvious, but the code is clean)
1573 ********************************************************************/
1575 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1580 return (4+devmode
->size
+devmode
->driverextra
);
1583 /*******************************************************************
1584 * return the length of a uint32 (obvious, but the code is clean)
1585 ********************************************************************/
1587 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1592 return (sizeof(SYSTEMTIME
) +4);
1595 /*******************************************************************
1596 * write a UNICODE string.
1597 * used by all the RPC structs passing a buffer
1598 ********************************************************************/
1600 static BOOL
spoolss_smb_io_unistr(char *desc
, UNISTR
*uni
, prs_struct
*ps
, int depth
)
1605 prs_debug(ps
, depth
, desc
, "spoolss_smb_io_unistr");
1608 /* there should be no align here as it can mess up
1609 parsing a NEW_BUFFER->prs */
1615 if (!prs_unistr("unistr", ps
, depth
, uni
))
1621 /*******************************************************************
1622 * write a UNICODE string and its relative pointer.
1623 * used by all the RPC structs passing a buffer
1625 * As I'm a nice guy, I'm forcing myself to explain this code.
1626 * MS did a good job in the overall spoolss code except in some
1627 * functions where they are passing the API buffer directly in the
1628 * RPC request/reply. That's to maintain compatiility at the API level.
1629 * They could have done it the good way the first time.
1631 * So what happen is: the strings are written at the buffer's end,
1632 * in the reverse order of the original structure. Some pointers to
1633 * the strings are also in the buffer. Those are relative to the
1636 * If you don't understand or want to change that function,
1637 * first get in touch with me: jfm@samba.org
1639 ********************************************************************/
1641 static BOOL
new_smb_io_relstr(char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
1643 prs_struct
*ps
=&buffer
->prs
;
1645 if (MARSHALLING(ps
)) {
1646 uint32 struct_offset
= prs_offset(ps
);
1647 uint32 relative_offset
;
1649 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
1650 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1654 buffer
->string_at_end
= prs_offset(ps
);
1656 /* write the string */
1657 if (!smb_io_unistr(desc
, string
, ps
, depth
))
1660 if(!prs_set_offset(ps
, struct_offset
))
1663 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1664 /* write its offset */
1665 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1671 /* read the offset */
1672 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
1675 old_offset
= prs_offset(ps
);
1676 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
1679 /* read the string */
1680 if (!spoolss_smb_io_unistr(desc
, string
, ps
, depth
))
1683 if(!prs_set_offset(ps
, old_offset
))
1689 /*******************************************************************
1690 * write a array of UNICODE strings and its relative pointer.
1691 * used by 2 RPC structs
1692 ********************************************************************/
1694 static BOOL
new_smb_io_relarraystr(char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
1698 prs_struct
*ps
=&buffer
->prs
;
1700 if (MARSHALLING(ps
)) {
1701 uint32 struct_offset
= prs_offset(ps
);
1702 uint32 relative_offset
;
1709 /* first write the last 0 */
1710 buffer
->string_at_end
-= 2;
1711 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1714 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
1717 while (p
&& (*p
!=0)) {
1721 /* Yes this should be malloc not talloc. Don't change. */
1723 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
1724 if (chaine
.buffer
== NULL
)
1727 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
1729 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
1731 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
1732 free(chaine
.buffer
);
1736 /* write the string */
1737 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
1738 free(chaine
.buffer
);
1744 free(chaine
.buffer
);
1747 if(!prs_set_offset(ps
, struct_offset
))
1750 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1751 /* write its offset */
1752 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1760 uint16
*chaine2
=NULL
;
1763 size_t realloc_size
= 0;
1767 /* read the offset */
1768 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1771 old_offset
= prs_offset(ps
);
1772 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1776 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
))
1779 l_chaine
=str_len_uni(&chaine
);
1781 /* we're going to add two more bytes here in case this
1782 is the last string in the array and we need to add
1783 an extra NULL for termination */
1786 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
1788 /* Yes this should be realloc - it's freed below. JRA */
1790 if((chaine2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
)
1792 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
1793 l_chaine2
+=l_chaine
+1;
1796 } while(l_chaine
!=0);
1798 /* the end should be bould NULL terminated so add
1799 the second one here */
1802 chaine2
[l_chaine2
] = '\0';
1803 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
1807 if(!prs_set_offset(ps
, old_offset
))
1813 /*******************************************************************
1814 Parse a DEVMODE structure and its relative pointer.
1815 ********************************************************************/
1817 static BOOL
new_smb_io_relsecdesc(char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
1819 prs_struct
*ps
= &buffer
->prs
;
1821 prs_debug(ps
, depth
, desc
, "new_smb_io_relsecdesc");
1824 if (MARSHALLING(ps
)) {
1825 uint32 struct_offset
= prs_offset(ps
);
1826 uint32 relative_offset
;
1829 relative_offset
= 0;
1830 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1835 if (*secdesc
!= NULL
) {
1836 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
1838 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1840 /* write the secdesc */
1841 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1844 if(!prs_set_offset(ps
, struct_offset
))
1848 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1849 /* write its offset */
1851 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1856 /* read the offset */
1857 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1860 old_offset
= prs_offset(ps
);
1861 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1865 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1868 if(!prs_set_offset(ps
, old_offset
))
1874 /*******************************************************************
1875 Parse a DEVMODE structure and its relative pointer.
1876 ********************************************************************/
1878 static BOOL
new_smb_io_reldevmode(char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
1880 prs_struct
*ps
=&buffer
->prs
;
1882 prs_debug(ps
, depth
, desc
, "new_smb_io_reldevmode");
1885 if (MARSHALLING(ps
)) {
1886 uint32 struct_offset
= prs_offset(ps
);
1887 uint32 relative_offset
;
1889 if (*devmode
== NULL
) {
1891 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1893 DEBUG(8, ("boing, the devmode was NULL\n"));
1898 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
1900 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1903 /* write the DEVMODE */
1904 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1907 if(!prs_set_offset(ps
, struct_offset
))
1910 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1911 /* write its offset */
1912 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1918 /* read the offset */
1919 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1922 old_offset
= prs_offset(ps
);
1923 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1926 /* read the string */
1927 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
1929 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1932 if(!prs_set_offset(ps
, old_offset
))
1938 /*******************************************************************
1939 Parse a PRINTER_INFO_0 structure.
1940 ********************************************************************/
1942 BOOL
new_smb_io_printer_info_0(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
1944 prs_struct
*ps
=&buffer
->prs
;
1946 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
1949 buffer
->struct_start
=prs_offset(ps
);
1951 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1953 if (!new_smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
1956 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
1958 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
1960 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
1963 if(!prs_uint16("year", ps
, depth
, &info
->year
))
1965 if(!prs_uint16("month", ps
, depth
, &info
->month
))
1967 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
1969 if(!prs_uint16("day", ps
, depth
, &info
->day
))
1971 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
1973 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
1975 if(!prs_uint16("second", ps
, depth
, &info
->second
))
1977 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
1980 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
1982 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
1985 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
1987 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
1989 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
1991 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
1993 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
1995 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
1997 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
1999 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2001 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2003 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2005 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2007 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2009 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2011 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2013 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2015 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2017 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2019 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2021 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2023 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2025 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2027 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2029 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2031 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2033 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2039 /*******************************************************************
2040 Parse a PRINTER_INFO_1 structure.
2041 ********************************************************************/
2043 BOOL
new_smb_io_printer_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2045 prs_struct
*ps
=&buffer
->prs
;
2047 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_info_1");
2050 buffer
->struct_start
=prs_offset(ps
);
2052 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2054 if (!new_smb_io_relstr("description", buffer
, depth
, &info
->description
))
2056 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2058 if (!new_smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2064 /*******************************************************************
2065 Parse a PRINTER_INFO_2 structure.
2066 ********************************************************************/
2068 BOOL
new_smb_io_printer_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2070 prs_struct
*ps
=&buffer
->prs
;
2072 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_info_2");
2075 buffer
->struct_start
=prs_offset(ps
);
2077 if (!new_smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2079 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2081 if (!new_smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2083 if (!new_smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2085 if (!new_smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2087 if (!new_smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2089 if (!new_smb_io_relstr("location", buffer
, depth
, &info
->location
))
2092 /* NT parses the DEVMODE at the end of the struct */
2093 if (!new_smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2096 if (!new_smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2098 if (!new_smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2100 if (!new_smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2102 if (!new_smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2105 if (!new_smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2108 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2110 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2112 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2114 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2116 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2118 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2120 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2122 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2126 if (!prs_uint32_post("secdesc_ptr", ps
, depth
, NULL
, sec_offset
, info
->secdesc
? prs_offset(ps
)-buffer
->struct_start
: 0 ))
2129 if (!sec_io_desc("secdesc", &info
->secdesc
, ps
, depth
))
2135 /*******************************************************************
2136 Parse a PRINTER_INFO_3 structure.
2137 ********************************************************************/
2139 BOOL
new_smb_io_printer_info_3(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2141 prs_struct
*ps
=&buffer
->prs
;
2143 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_info_3");
2146 buffer
->struct_start
=prs_offset(ps
);
2148 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2150 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2156 /*******************************************************************
2157 Parse a PORT_INFO_1 structure.
2158 ********************************************************************/
2160 BOOL
new_smb_io_port_info_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2162 prs_struct
*ps
=&buffer
->prs
;
2164 prs_debug(ps
, depth
, desc
, "new_smb_io_port_info_1");
2167 buffer
->struct_start
=prs_offset(ps
);
2169 if (!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2175 /*******************************************************************
2176 Parse a PORT_INFO_2 structure.
2177 ********************************************************************/
2179 BOOL
new_smb_io_port_info_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2181 prs_struct
*ps
=&buffer
->prs
;
2183 prs_debug(ps
, depth
, desc
, "new_smb_io_port_info_2");
2186 buffer
->struct_start
=prs_offset(ps
);
2188 if (!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2190 if (!new_smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2192 if (!new_smb_io_relstr("description", buffer
, depth
, &info
->description
))
2194 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2196 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2202 /*******************************************************************
2203 Parse a DRIVER_INFO_1 structure.
2204 ********************************************************************/
2206 BOOL
new_smb_io_printer_driver_info_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2208 prs_struct
*ps
=&buffer
->prs
;
2210 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_driver_info_1");
2213 buffer
->struct_start
=prs_offset(ps
);
2215 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2221 /*******************************************************************
2222 Parse a DRIVER_INFO_2 structure.
2223 ********************************************************************/
2225 BOOL
new_smb_io_printer_driver_info_2(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2227 prs_struct
*ps
=&buffer
->prs
;
2229 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_driver_info_2");
2232 buffer
->struct_start
=prs_offset(ps
);
2234 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2236 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2238 if (!new_smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2240 if (!new_smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2242 if (!new_smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2244 if (!new_smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2250 /*******************************************************************
2251 Parse a DRIVER_INFO_3 structure.
2252 ********************************************************************/
2254 BOOL
new_smb_io_printer_driver_info_3(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2256 prs_struct
*ps
=&buffer
->prs
;
2258 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_driver_info_3");
2261 buffer
->struct_start
=prs_offset(ps
);
2263 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2265 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2267 if (!new_smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2269 if (!new_smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2271 if (!new_smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2273 if (!new_smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2275 if (!new_smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2278 if (!new_smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2281 if (!new_smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2283 if (!new_smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2289 /*******************************************************************
2290 Parse a DRIVER_INFO_6 structure.
2291 ********************************************************************/
2293 BOOL
new_smb_io_printer_driver_info_6(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2295 prs_struct
*ps
=&buffer
->prs
;
2297 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_driver_info_6");
2300 buffer
->struct_start
=prs_offset(ps
);
2302 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2304 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2306 if (!new_smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2308 if (!new_smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2310 if (!new_smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2312 if (!new_smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2314 if (!new_smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2317 if (!new_smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2320 if (!new_smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2322 if (!new_smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2325 if (!new_smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2328 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2330 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2333 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2336 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2339 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2342 if (!new_smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2344 if (!new_smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2346 if (!new_smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2348 if (!new_smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2354 /*******************************************************************
2355 Parse a JOB_INFO_1 structure.
2356 ********************************************************************/
2358 BOOL
new_smb_io_job_info_1(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2360 prs_struct
*ps
=&buffer
->prs
;
2362 prs_debug(ps
, depth
, desc
, "new_smb_io_job_info_1");
2365 buffer
->struct_start
=prs_offset(ps
);
2367 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2369 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2371 if (!new_smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2373 if (!new_smb_io_relstr("username", buffer
, depth
, &info
->username
))
2375 if (!new_smb_io_relstr("document", buffer
, depth
, &info
->document
))
2377 if (!new_smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2379 if (!new_smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2381 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2383 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2385 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2387 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2389 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2391 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2397 /*******************************************************************
2398 Parse a JOB_INFO_2 structure.
2399 ********************************************************************/
2401 BOOL
new_smb_io_job_info_2(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2404 prs_struct
*ps
=&buffer
->prs
;
2406 prs_debug(ps
, depth
, desc
, "new_smb_io_job_info_2");
2409 buffer
->struct_start
=prs_offset(ps
);
2411 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2413 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2415 if (!new_smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2417 if (!new_smb_io_relstr("username", buffer
, depth
, &info
->username
))
2419 if (!new_smb_io_relstr("document", buffer
, depth
, &info
->document
))
2421 if (!new_smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2423 if (!new_smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2426 if (!new_smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2428 if (!new_smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2430 if (!new_smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2432 if (!new_smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2434 if (!new_smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2437 /* SEC_DESC sec_desc;*/
2438 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2441 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2443 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2445 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2447 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2449 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2451 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2453 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2455 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2457 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2459 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2465 /*******************************************************************
2466 ********************************************************************/
2468 BOOL
new_smb_io_form_1(char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2470 prs_struct
*ps
=&buffer
->prs
;
2472 prs_debug(ps
, depth
, desc
, "new_smb_io_form_1");
2475 buffer
->struct_start
=prs_offset(ps
);
2477 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2480 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2483 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2485 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2487 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2489 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2491 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2493 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2499 /*******************************************************************
2500 Read/write a BUFFER struct.
2501 ********************************************************************/
2503 static BOOL
new_spoolss_io_buffer(char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
2505 NEW_BUFFER
*buffer
= *pp_buffer
;
2507 prs_debug(ps
, depth
, desc
, "new_spoolss_io_buffer");
2510 if (UNMARSHALLING(ps
))
2511 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
2516 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2520 if (UNMARSHALLING(ps
)) {
2522 buffer
->string_at_end
=0;
2524 if (buffer
->ptr
==0) {
2526 * JRA. I'm not sure if the data in here is in big-endian format if
2527 * the client is big-endian. Leave as default (little endian) for now.
2530 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
2535 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2539 * JRA. I'm not sure if the data in here is in big-endian format if
2540 * the client is big-endian. Leave as default (little endian) for now.
2543 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
2546 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
2549 if (!prs_set_offset(&buffer
->prs
, 0))
2552 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
2555 buffer
->string_at_end
=buffer
->size
;
2563 if (buffer
->ptr
==0) {
2564 /* We have finished with the data in buffer->prs - free it. */
2565 prs_mem_free(&buffer
->prs
);
2569 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2572 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
2578 /* We have finished with the data in buffer->prs - free it. */
2579 prs_mem_free(&buffer
->prs
);
2585 /*******************************************************************
2586 move a BUFFER from the query to the reply.
2587 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2588 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2589 ********************************************************************/
2591 void new_spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
2593 prs_switch_type(&src
->prs
, MARSHALL
);
2594 if(!prs_set_offset(&src
->prs
, 0))
2596 prs_force_dynamic(&(src
->prs
));
2601 /*******************************************************************
2602 Get the size of a BUFFER struct.
2603 ********************************************************************/
2605 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
2607 return (buffer
->size
);
2610 /*******************************************************************
2611 Parse a DRIVER_DIRECTORY_1 structure.
2612 ********************************************************************/
2614 BOOL
new_smb_io_driverdir_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2616 prs_struct
*ps
=&buffer
->prs
;
2618 prs_debug(ps
, depth
, desc
, "new_smb_io_driverdir_1");
2621 buffer
->struct_start
=prs_offset(ps
);
2623 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2629 /*******************************************************************
2630 Parse a PORT_INFO_1 structure.
2631 ********************************************************************/
2633 BOOL
new_smb_io_port_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2635 prs_struct
*ps
=&buffer
->prs
;
2637 prs_debug(ps
, depth
, desc
, "new_smb_io_port_1");
2640 buffer
->struct_start
=prs_offset(ps
);
2642 if(!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2648 /*******************************************************************
2649 Parse a PORT_INFO_2 structure.
2650 ********************************************************************/
2652 BOOL
new_smb_io_port_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2654 prs_struct
*ps
=&buffer
->prs
;
2656 prs_debug(ps
, depth
, desc
, "new_smb_io_port_2");
2659 buffer
->struct_start
=prs_offset(ps
);
2661 if(!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2663 if(!new_smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2665 if(!new_smb_io_relstr("description", buffer
, depth
, &info
->description
))
2667 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2669 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2675 /*******************************************************************
2676 ********************************************************************/
2678 BOOL
smb_io_printprocessor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2680 prs_struct
*ps
=&buffer
->prs
;
2682 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2685 buffer
->struct_start
=prs_offset(ps
);
2687 if (new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2693 /*******************************************************************
2694 ********************************************************************/
2696 BOOL
smb_io_printprocdatatype_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2698 prs_struct
*ps
=&buffer
->prs
;
2700 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2703 buffer
->struct_start
=prs_offset(ps
);
2705 if (new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2711 /*******************************************************************
2712 ********************************************************************/
2714 BOOL
smb_io_printmonitor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2716 prs_struct
*ps
=&buffer
->prs
;
2718 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2721 buffer
->struct_start
=prs_offset(ps
);
2723 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2729 /*******************************************************************
2730 ********************************************************************/
2732 BOOL
smb_io_printmonitor_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
2734 prs_struct
*ps
=&buffer
->prs
;
2736 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
2739 buffer
->struct_start
=prs_offset(ps
);
2741 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2743 if (!new_smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
2745 if (!new_smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
2751 /*******************************************************************
2752 return the size required by a struct in the stream
2753 ********************************************************************/
2755 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
2759 size
+=size_of_relative_string( &info
->printername
);
2760 size
+=size_of_relative_string( &info
->servername
);
2762 size
+=size_of_uint32( &info
->cjobs
);
2763 size
+=size_of_uint32( &info
->total_jobs
);
2764 size
+=size_of_uint32( &info
->total_bytes
);
2766 size
+=size_of_uint16( &info
->year
);
2767 size
+=size_of_uint16( &info
->month
);
2768 size
+=size_of_uint16( &info
->dayofweek
);
2769 size
+=size_of_uint16( &info
->day
);
2770 size
+=size_of_uint16( &info
->hour
);
2771 size
+=size_of_uint16( &info
->minute
);
2772 size
+=size_of_uint16( &info
->second
);
2773 size
+=size_of_uint16( &info
->milliseconds
);
2775 size
+=size_of_uint32( &info
->global_counter
);
2776 size
+=size_of_uint32( &info
->total_pages
);
2778 size
+=size_of_uint16( &info
->major_version
);
2779 size
+=size_of_uint16( &info
->build_version
);
2781 size
+=size_of_uint32( &info
->unknown7
);
2782 size
+=size_of_uint32( &info
->unknown8
);
2783 size
+=size_of_uint32( &info
->unknown9
);
2784 size
+=size_of_uint32( &info
->session_counter
);
2785 size
+=size_of_uint32( &info
->unknown11
);
2786 size
+=size_of_uint32( &info
->printer_errors
);
2787 size
+=size_of_uint32( &info
->unknown13
);
2788 size
+=size_of_uint32( &info
->unknown14
);
2789 size
+=size_of_uint32( &info
->unknown15
);
2790 size
+=size_of_uint32( &info
->unknown16
);
2791 size
+=size_of_uint32( &info
->change_id
);
2792 size
+=size_of_uint32( &info
->unknown18
);
2793 size
+=size_of_uint32( &info
->status
);
2794 size
+=size_of_uint32( &info
->unknown20
);
2795 size
+=size_of_uint32( &info
->c_setprinter
);
2797 size
+=size_of_uint16( &info
->unknown22
);
2798 size
+=size_of_uint16( &info
->unknown23
);
2799 size
+=size_of_uint16( &info
->unknown24
);
2800 size
+=size_of_uint16( &info
->unknown25
);
2801 size
+=size_of_uint16( &info
->unknown26
);
2802 size
+=size_of_uint16( &info
->unknown27
);
2803 size
+=size_of_uint16( &info
->unknown28
);
2804 size
+=size_of_uint16( &info
->unknown29
);
2809 /*******************************************************************
2810 return the size required by a struct in the stream
2811 ********************************************************************/
2813 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
2817 size
+=size_of_uint32( &info
->flags
);
2818 size
+=size_of_relative_string( &info
->description
);
2819 size
+=size_of_relative_string( &info
->name
);
2820 size
+=size_of_relative_string( &info
->comment
);
2825 /*******************************************************************
2826 return the size required by a struct in the stream
2827 ********************************************************************/
2829 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
2834 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2835 size
+= sec_desc_size( info
->secdesc
);
2837 size
+=size_of_device_mode( info
->devmode
);
2839 size
+=size_of_relative_string( &info
->servername
);
2840 size
+=size_of_relative_string( &info
->printername
);
2841 size
+=size_of_relative_string( &info
->sharename
);
2842 size
+=size_of_relative_string( &info
->portname
);
2843 size
+=size_of_relative_string( &info
->drivername
);
2844 size
+=size_of_relative_string( &info
->comment
);
2845 size
+=size_of_relative_string( &info
->location
);
2847 size
+=size_of_relative_string( &info
->sepfile
);
2848 size
+=size_of_relative_string( &info
->printprocessor
);
2849 size
+=size_of_relative_string( &info
->datatype
);
2850 size
+=size_of_relative_string( &info
->parameters
);
2852 size
+=size_of_uint32( &info
->attributes
);
2853 size
+=size_of_uint32( &info
->priority
);
2854 size
+=size_of_uint32( &info
->defaultpriority
);
2855 size
+=size_of_uint32( &info
->starttime
);
2856 size
+=size_of_uint32( &info
->untiltime
);
2857 size
+=size_of_uint32( &info
->status
);
2858 size
+=size_of_uint32( &info
->cjobs
);
2859 size
+=size_of_uint32( &info
->averageppm
);
2863 /*******************************************************************
2864 return the size required by a struct in the stream
2865 ********************************************************************/
2867 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
2869 /* The 4 is for the self relative pointer.. */
2870 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2871 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
2874 /*******************************************************************
2875 return the size required by a struct in the stream
2876 ********************************************************************/
2878 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
2881 size
+=size_of_relative_string( &info
->name
);
2886 /*******************************************************************
2887 return the size required by a struct in the stream
2888 ********************************************************************/
2890 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
2893 size
+=size_of_uint32( &info
->version
);
2894 size
+=size_of_relative_string( &info
->name
);
2895 size
+=size_of_relative_string( &info
->architecture
);
2896 size
+=size_of_relative_string( &info
->driverpath
);
2897 size
+=size_of_relative_string( &info
->datafile
);
2898 size
+=size_of_relative_string( &info
->configfile
);
2903 /*******************************************************************
2904 return the size required by a string array.
2905 ********************************************************************/
2907 uint32
spoolss_size_string_array(uint16
*string
)
2912 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
2914 i
=i
+2; /* to count all chars including the leading zero */
2915 i
=2*i
; /* because we need the value in bytes */
2916 i
=i
+4; /* the offset pointer size */
2921 /*******************************************************************
2922 return the size required by a struct in the stream
2923 ********************************************************************/
2925 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
2929 size
+=size_of_uint32( &info
->version
);
2930 size
+=size_of_relative_string( &info
->name
);
2931 size
+=size_of_relative_string( &info
->architecture
);
2932 size
+=size_of_relative_string( &info
->driverpath
);
2933 size
+=size_of_relative_string( &info
->datafile
);
2934 size
+=size_of_relative_string( &info
->configfile
);
2935 size
+=size_of_relative_string( &info
->helpfile
);
2936 size
+=size_of_relative_string( &info
->monitorname
);
2937 size
+=size_of_relative_string( &info
->defaultdatatype
);
2939 size
+=spoolss_size_string_array(info
->dependentfiles
);
2944 /*******************************************************************
2945 return the size required by a struct in the stream
2946 ********************************************************************/
2948 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
2952 size
+=size_of_uint32( &info
->version
);
2953 size
+=size_of_relative_string( &info
->name
);
2954 size
+=size_of_relative_string( &info
->architecture
);
2955 size
+=size_of_relative_string( &info
->driverpath
);
2956 size
+=size_of_relative_string( &info
->datafile
);
2957 size
+=size_of_relative_string( &info
->configfile
);
2958 size
+=size_of_relative_string( &info
->helpfile
);
2960 size
+=spoolss_size_string_array(info
->dependentfiles
);
2962 size
+=size_of_relative_string( &info
->monitorname
);
2963 size
+=size_of_relative_string( &info
->defaultdatatype
);
2965 size
+=spoolss_size_string_array(info
->previousdrivernames
);
2967 size
+=size_of_nttime(&info
->driver_date
);
2968 size
+=size_of_uint32( &info
->padding
);
2969 size
+=size_of_uint32( &info
->driver_version_low
);
2970 size
+=size_of_uint32( &info
->driver_version_high
);
2971 size
+=size_of_relative_string( &info
->mfgname
);
2972 size
+=size_of_relative_string( &info
->oem_url
);
2973 size
+=size_of_relative_string( &info
->hardware_id
);
2974 size
+=size_of_relative_string( &info
->provider
);
2979 /*******************************************************************
2980 return the size required by a struct in the stream
2981 ********************************************************************/
2983 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
2986 size
+=size_of_uint32( &info
->jobid
);
2987 size
+=size_of_relative_string( &info
->printername
);
2988 size
+=size_of_relative_string( &info
->machinename
);
2989 size
+=size_of_relative_string( &info
->username
);
2990 size
+=size_of_relative_string( &info
->document
);
2991 size
+=size_of_relative_string( &info
->datatype
);
2992 size
+=size_of_relative_string( &info
->text_status
);
2993 size
+=size_of_uint32( &info
->status
);
2994 size
+=size_of_uint32( &info
->priority
);
2995 size
+=size_of_uint32( &info
->position
);
2996 size
+=size_of_uint32( &info
->totalpages
);
2997 size
+=size_of_uint32( &info
->pagesprinted
);
2998 size
+=size_of_systemtime( &info
->submitted
);
3003 /*******************************************************************
3004 return the size required by a struct in the stream
3005 ********************************************************************/
3007 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3011 size
+=4; /* size of sec desc ptr */
3013 size
+=size_of_uint32( &info
->jobid
);
3014 size
+=size_of_relative_string( &info
->printername
);
3015 size
+=size_of_relative_string( &info
->machinename
);
3016 size
+=size_of_relative_string( &info
->username
);
3017 size
+=size_of_relative_string( &info
->document
);
3018 size
+=size_of_relative_string( &info
->notifyname
);
3019 size
+=size_of_relative_string( &info
->datatype
);
3020 size
+=size_of_relative_string( &info
->printprocessor
);
3021 size
+=size_of_relative_string( &info
->parameters
);
3022 size
+=size_of_relative_string( &info
->drivername
);
3023 size
+=size_of_device_mode( info
->devmode
);
3024 size
+=size_of_relative_string( &info
->text_status
);
3025 /* SEC_DESC sec_desc;*/
3026 size
+=size_of_uint32( &info
->status
);
3027 size
+=size_of_uint32( &info
->priority
);
3028 size
+=size_of_uint32( &info
->position
);
3029 size
+=size_of_uint32( &info
->starttime
);
3030 size
+=size_of_uint32( &info
->untiltime
);
3031 size
+=size_of_uint32( &info
->totalpages
);
3032 size
+=size_of_uint32( &info
->size
);
3033 size
+=size_of_systemtime( &info
->submitted
);
3034 size
+=size_of_uint32( &info
->timeelapsed
);
3035 size
+=size_of_uint32( &info
->pagesprinted
);
3040 /*******************************************************************
3041 return the size required by a struct in the stream
3042 ********************************************************************/
3044 uint32
spoolss_size_form_1(FORM_1
*info
)
3048 size
+=size_of_uint32( &info
->flag
);
3049 size
+=size_of_relative_string( &info
->name
);
3050 size
+=size_of_uint32( &info
->width
);
3051 size
+=size_of_uint32( &info
->length
);
3052 size
+=size_of_uint32( &info
->left
);
3053 size
+=size_of_uint32( &info
->top
);
3054 size
+=size_of_uint32( &info
->right
);
3055 size
+=size_of_uint32( &info
->bottom
);
3060 /*******************************************************************
3061 return the size required by a struct in the stream
3062 ********************************************************************/
3064 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3068 size
+=size_of_relative_string( &info
->port_name
);
3073 /*******************************************************************
3074 return the size required by a struct in the stream
3075 ********************************************************************/
3077 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3081 size
=str_len_uni(&info
->name
); /* the string length */
3082 size
=size
+1; /* add the leading zero */
3083 size
=size
*2; /* convert in char */
3088 /*******************************************************************
3089 return the size required by a struct in the stream
3090 ********************************************************************/
3092 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3096 size
+=size_of_relative_string( &info
->port_name
);
3097 size
+=size_of_relative_string( &info
->monitor_name
);
3098 size
+=size_of_relative_string( &info
->description
);
3100 size
+=size_of_uint32( &info
->port_type
);
3101 size
+=size_of_uint32( &info
->reserved
);
3106 /*******************************************************************
3107 return the size required by a struct in the stream
3108 ********************************************************************/
3110 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3113 size
+=size_of_relative_string( &info
->name
);
3118 /*******************************************************************
3119 return the size required by a struct in the stream
3120 ********************************************************************/
3122 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3125 size
+=size_of_relative_string( &info
->name
);
3130 /*******************************************************************
3131 return the size required by a struct in the stream
3132 ********************************************************************/
3134 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3137 size
+=size_of_relative_string( &info
->name
);
3142 /*******************************************************************
3143 return the size required by a struct in the stream
3144 ********************************************************************/
3146 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3149 size
+=size_of_relative_string( &info
->name
);
3150 size
+=size_of_relative_string( &info
->environment
);
3151 size
+=size_of_relative_string( &info
->dll_name
);
3156 /*******************************************************************
3158 ********************************************************************/
3160 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3161 const POLICY_HND
*hnd
,
3162 const fstring architecture
,
3163 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3164 NEW_BUFFER
*buffer
, uint32 offered
)
3169 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3171 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3174 q_u
->clientmajorversion
=clientmajor
;
3175 q_u
->clientminorversion
=clientminor
;
3178 q_u
->offered
=offered
;
3183 /*******************************************************************
3185 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3186 ********************************************************************/
3188 BOOL
spoolss_io_q_getprinterdriver2(char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3190 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3196 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3198 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3200 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3205 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3208 if(!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3214 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3217 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3219 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3225 /*******************************************************************
3227 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3228 ********************************************************************/
3230 BOOL
spoolss_io_r_getprinterdriver2(char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3232 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3238 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3243 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3245 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3247 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3249 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3255 /*******************************************************************
3257 ********************************************************************/
3259 BOOL
make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS
*q_u
, uint32 flags
,
3260 fstring servername
, uint32 level
,
3261 NEW_BUFFER
*buffer
, uint32 offered
)
3265 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3266 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3270 q_u
->offered
=offered
;
3275 /*******************************************************************
3277 ********************************************************************/
3279 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3280 fstring servername
, uint32 level
,
3281 NEW_BUFFER
*buffer
, uint32 offered
)
3283 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3284 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3288 q_u
->offered
=offered
;
3293 /*******************************************************************
3295 * called from spoolss_enumprinters (srv_spoolss.c)
3296 ********************************************************************/
3298 BOOL
spoolss_io_q_enumprinters(char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3300 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3306 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3308 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3311 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3316 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3319 if (!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3324 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3330 /*******************************************************************
3331 Parse a SPOOL_R_ENUMPRINTERS structure.
3332 ********************************************************************/
3334 BOOL
new_spoolss_io_r_enumprinters(char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3336 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_enumprinters");
3342 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3348 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3351 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3354 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3360 /*******************************************************************
3361 * write a structure.
3362 * called from spoolss_r_enum_printers (srv_spoolss.c)
3364 ********************************************************************/
3366 BOOL
spoolss_io_r_getprinter(char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3368 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3374 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3380 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3383 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3389 /*******************************************************************
3391 * called from spoolss_getprinter (srv_spoolss.c)
3392 ********************************************************************/
3394 BOOL
spoolss_io_q_getprinter(char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3396 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3402 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3404 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3407 if (!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3412 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3418 /*******************************************************************
3420 ********************************************************************/
3422 BOOL
make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER
*q_u
, const POLICY_HND
*hnd
, uint32 level
,
3423 NEW_BUFFER
*buffer
, uint32 offered
)
3429 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3433 q_u
->offered
=offered
;
3438 /*******************************************************************
3439 ********************************************************************/
3441 BOOL
spoolss_io_r_setprinter(char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3443 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3449 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3455 /*******************************************************************
3456 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3457 ********************************************************************/
3459 BOOL
spoolss_io_q_setprinter(char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3461 uint32 ptr_sec_desc
= 0;
3463 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3469 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3471 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3474 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3477 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3484 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3489 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3495 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3500 /* Parse a NULL security descriptor. This should really
3501 happen inside the sec_io_desc_buf() function. */
3503 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3504 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
)) return False
;
3505 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
3509 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3515 /*******************************************************************
3516 ********************************************************************/
3518 BOOL
spoolss_io_r_fcpn(char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
3520 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
3526 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3532 /*******************************************************************
3533 ********************************************************************/
3535 BOOL
spoolss_io_q_fcpn(char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
3538 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
3544 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3551 /*******************************************************************
3552 ********************************************************************/
3554 BOOL
spoolss_io_r_addjob(char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
3556 prs_debug(ps
, depth
, desc
, "");
3562 if(!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3568 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3571 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3577 /*******************************************************************
3578 ********************************************************************/
3580 BOOL
spoolss_io_q_addjob(char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
3582 prs_debug(ps
, depth
, desc
, "");
3588 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3590 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3593 if(!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3599 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3605 /*******************************************************************
3606 ********************************************************************/
3608 BOOL
spoolss_io_r_enumjobs(char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
3610 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
3616 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3622 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3625 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3628 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3634 /*******************************************************************
3635 ********************************************************************/
3637 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
3648 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3649 q_u
->firstjob
= firstjob
;
3650 q_u
->numofjobs
= numofjobs
;
3652 q_u
->buffer
= buffer
;
3653 q_u
->offered
= offered
;
3657 /*******************************************************************
3658 ********************************************************************/
3660 BOOL
spoolss_io_q_enumjobs(char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
3662 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
3668 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
3671 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
3673 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
3675 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3678 if (!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3681 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3687 /*******************************************************************
3688 ********************************************************************/
3690 BOOL
spoolss_io_r_schedulejob(char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
3692 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
3698 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3704 /*******************************************************************
3705 ********************************************************************/
3707 BOOL
spoolss_io_q_schedulejob(char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
3709 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
3715 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3717 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3723 /*******************************************************************
3724 ********************************************************************/
3726 BOOL
spoolss_io_r_setjob(char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
3728 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
3734 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3740 /*******************************************************************
3741 ********************************************************************/
3743 BOOL
spoolss_io_q_setjob(char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
3745 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
3751 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3753 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3756 * level is usually 0. If (level!=0) then I'm in trouble !
3757 * I will try to generate setjob command with level!=0, one day.
3759 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3761 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3767 /*******************************************************************
3768 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
3769 ********************************************************************/
3771 BOOL
new_spoolss_io_r_enumprinterdrivers(char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
3773 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
3779 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3785 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3788 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3791 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3797 /*******************************************************************
3799 ********************************************************************/
3801 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
3803 const char *environment
,
3805 NEW_BUFFER
*buffer
, uint32 offered
)
3807 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
3808 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
3812 q_u
->offered
=offered
;
3817 /*******************************************************************
3818 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
3819 ********************************************************************/
3821 BOOL
spoolss_io_q_enumprinterdrivers(char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
3824 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
3830 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
3832 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
3837 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
3839 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
3844 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3847 if (!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3853 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3859 /*******************************************************************
3860 ********************************************************************/
3862 BOOL
spoolss_io_q_enumforms(char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
3865 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
3870 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3872 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3875 if (!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3880 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3886 /*******************************************************************
3887 ********************************************************************/
3889 BOOL
new_spoolss_io_r_enumforms(char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
3891 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_enumforms");
3897 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3903 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
3906 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
3909 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3915 /*******************************************************************
3916 ********************************************************************/
3918 BOOL
spoolss_io_q_getform(char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
3921 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
3926 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3928 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
3934 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3937 if (!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3942 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3948 /*******************************************************************
3949 ********************************************************************/
3951 BOOL
new_spoolss_io_r_getform(char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
3953 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_getform");
3959 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3965 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
3968 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3974 /*******************************************************************
3975 Parse a SPOOL_R_ENUMPORTS structure.
3976 ********************************************************************/
3978 BOOL
new_spoolss_io_r_enumports(char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
3980 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_enumports");
3986 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3992 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3995 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3998 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
4004 /*******************************************************************
4005 ********************************************************************/
4007 BOOL
spoolss_io_q_enumports(char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4009 prs_debug(ps
, depth
, desc
, "");
4015 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4017 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4022 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4025 if (!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4030 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4036 /*******************************************************************
4037 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4038 ********************************************************************/
4040 BOOL
spool_io_printer_info_level_1(char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4042 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4048 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4050 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4052 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4054 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4057 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4059 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4061 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4067 /*******************************************************************
4068 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4069 ********************************************************************/
4071 BOOL
spool_io_printer_info_level_3(char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4073 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4079 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4085 /*******************************************************************
4086 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4087 ********************************************************************/
4089 BOOL
spool_io_printer_info_level_2(char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4091 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4097 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4099 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4101 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4103 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4106 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4108 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4110 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4112 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4114 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4116 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4118 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4120 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4122 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4125 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4127 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4129 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4131 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4133 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4135 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4137 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4139 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4142 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4144 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4146 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4148 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4150 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4152 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4154 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4156 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4158 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4160 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4162 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4168 /*******************************************************************
4169 ********************************************************************/
4171 BOOL
spool_io_printer_info_level(char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4173 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4178 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4180 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4183 /* if no struct inside just return */
4184 if (il
->info_ptr
==0) {
4185 if (UNMARSHALLING(ps
)) {
4192 switch (il
->level
) {
4194 * level 0 is used by setprinter when managing the queue
4195 * (hold, stop, start a queue)
4199 /* DOCUMENT ME!!! What is level 1 used for? */
4202 if (UNMARSHALLING(ps
)) {
4203 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4206 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4211 * level 2 is used by addprinter
4212 * and by setprinter when updating printer's info
4215 if (UNMARSHALLING(ps
)) {
4216 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4219 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4222 /* DOCUMENT ME!!! What is level 3 used for? */
4225 if (UNMARSHALLING(ps
)) {
4226 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4229 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4238 /*******************************************************************
4239 ********************************************************************/
4241 BOOL
spoolss_io_q_addprinterex(char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4243 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4248 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4250 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4256 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4259 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4262 /* the 4 unknown are all 0 */
4265 * en fait ils sont pas inconnu
4266 * par recoupement avec rpcSetPrinter
4267 * c'est le devicemode
4268 * et le security descriptor.
4273 if(!prs_uint32("unk0", ps
, depth
, &q_u
->unk0
))
4275 if(!prs_uint32("unk1", ps
, depth
, &q_u
->unk1
))
4277 if(!prs_uint32("unk2", ps
, depth
, &q_u
->unk2
))
4279 if(!prs_uint32("unk3", ps
, depth
, &q_u
->unk3
))
4282 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4284 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4290 /*******************************************************************
4291 ********************************************************************/
4293 BOOL
spoolss_io_r_addprinterex(char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4294 prs_struct
*ps
, int depth
)
4296 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4299 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4302 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
4308 /*******************************************************************
4309 ********************************************************************/
4311 BOOL
spool_io_printer_driver_info_level_3(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4312 prs_struct
*ps
, int depth
)
4314 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4316 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4320 if (UNMARSHALLING(ps
)) {
4321 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4333 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4335 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4337 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4339 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4341 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4343 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4345 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4347 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4349 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4351 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4353 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4359 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4361 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4363 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4365 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4367 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4369 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4371 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4373 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4379 if (il
->dependentfiles_ptr
)
4380 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
4385 /*******************************************************************
4386 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4387 ********************************************************************/
4389 BOOL
spool_io_printer_driver_info_level_6(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4390 prs_struct
*ps
, int depth
)
4392 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4394 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4398 if (UNMARSHALLING(ps
)) {
4399 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
4412 /* parse the main elements the packet */
4414 if(!prs_uint32("version", ps
, depth
, &il
->version
))
4417 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4420 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4421 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4422 * from W2K CDROM (which uses unidriver). JohnR 010205
4424 if (!il
->name_ptr
) {
4425 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4426 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4430 if(!prs_uint32("environment_ptr", ps
, depth
, &il
->environment_ptr
))
4432 if(!prs_uint32("driverpath_ptr", ps
, depth
, &il
->driverpath_ptr
))
4434 if(!prs_uint32("datafile_ptr", ps
, depth
, &il
->datafile_ptr
))
4436 if(!prs_uint32("configfile_ptr", ps
, depth
, &il
->configfile_ptr
))
4438 if(!prs_uint32("helpfile_ptr", ps
, depth
, &il
->helpfile_ptr
))
4440 if(!prs_uint32("monitorname_ptr", ps
, depth
, &il
->monitorname_ptr
))
4442 if(!prs_uint32("defaultdatatype_ptr", ps
, depth
, &il
->defaultdatatype_ptr
))
4444 if(!prs_uint32("dependentfiles_len", ps
, depth
, &il
->dependentfiles_len
))
4446 if(!prs_uint32("dependentfiles_ptr", ps
, depth
, &il
->dependentfiles_ptr
))
4448 if(!prs_uint32("previousnames_len", ps
, depth
, &il
->previousnames_len
))
4450 if(!prs_uint32("previousnames_ptr", ps
, depth
, &il
->previousnames_ptr
))
4452 if(!smb_io_time("driverdate", &il
->driverdate
, ps
, depth
))
4454 if(!prs_uint32("dummy4", ps
, depth
, &il
->dummy4
))
4456 if(!prs_uint64("driverversion", ps
, depth
, &il
->driverversion
))
4458 if(!prs_uint32("mfgname_ptr", ps
, depth
, &il
->mfgname_ptr
))
4460 if(!prs_uint32("oemurl_ptr", ps
, depth
, &il
->oemurl_ptr
))
4462 if(!prs_uint32("hardwareid_ptr", ps
, depth
, &il
->hardwareid_ptr
))
4464 if(!prs_uint32("provider_ptr", ps
, depth
, &il
->provider_ptr
))
4467 /* parse the structures in the packet */
4469 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4474 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4479 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4484 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4489 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4494 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4499 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4504 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4508 if (il
->dependentfiles_ptr
) {
4509 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
4514 if (il
->previousnames_ptr
) {
4515 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
4520 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
4524 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
4528 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
4532 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
4538 /*******************************************************************
4539 convert a buffer of UNICODE strings null terminated
4540 the buffer is terminated by a NULL
4542 convert to an dos codepage array (null terminated)
4544 dynamically allocate memory
4546 ********************************************************************/
4547 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
4553 if (buf5
==NULL
) return False
;
4555 src
= (char *)buf5
->buffer
;
4558 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
4559 unistr_to_dos(f
, src
, sizeof(f
)-1);
4560 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
4561 *ar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
4562 fstrcpy((*ar
)[n
], f
);
4565 fstrcpy((*ar
)[n
], "");
4570 /*******************************************************************
4571 read a UNICODE array with null terminated strings
4572 and null terminated array
4573 and size of array at beginning
4574 ********************************************************************/
4576 BOOL
smb_io_unibuffer(char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
4578 if (buffer
==NULL
) return False
;
4581 buffer
->uni_str_len
=buffer
->uni_max_len
;
4583 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
4586 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
4592 /*******************************************************************
4593 ********************************************************************/
4595 BOOL
spool_io_printer_driver_info_level(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4597 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
4602 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4604 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
4610 switch (il
->level
) {
4612 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
4616 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
4626 /*******************************************************************
4627 init a SPOOL_Q_ADDPRINTERDRIVER struct
4628 ******************************************************************/
4630 BOOL
make_spoolss_q_addprinterdriver(
4631 SPOOL_Q_ADDPRINTERDRIVER
*q_u
,
4632 const char* srv_name
,
4634 PRINTER_DRIVER_CTR
*info
)
4636 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
4638 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
4639 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
4643 q_u
->info
.level
= level
;
4644 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
4647 /* info level 3 is supported by Windows 95/98,
4650 q_u
->info
.info_3
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)
4651 malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4652 memset (q_u
->info
.info_3
, 0x0, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4653 make_spool_driver_info_3(q_u
->info
.info_3
, info
->info3
);
4656 /* info level 6 is supported by WinME and Win2k */
4658 /* WRITEME!! will add later --jerry */
4661 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown \
4662 info level [%d]\n", level
));
4670 BOOL
make_spool_driver_info_3(
4671 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*spool_drv_info
,
4672 DRIVER_INFO_3
*info3
4676 uint16
*ptr
= info3
->dependentfiles
;
4678 BOOL null_char
= False
;
4680 spool_drv_info
->cversion
= info3
->version
;
4681 spool_drv_info
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
4682 spool_drv_info
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
4683 spool_drv_info
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
4684 spool_drv_info
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
4685 spool_drv_info
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
4686 spool_drv_info
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
4687 spool_drv_info
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
4688 spool_drv_info
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
4690 init_unistr2_from_unistr(&spool_drv_info
->name
, &info3
->name
);
4691 init_unistr2_from_unistr(&spool_drv_info
->environment
, &info3
->architecture
);
4692 init_unistr2_from_unistr(&spool_drv_info
->driverpath
, &info3
->driverpath
);
4693 init_unistr2_from_unistr(&spool_drv_info
->datafile
, &info3
->datafile
);
4694 init_unistr2_from_unistr(&spool_drv_info
->configfile
, &info3
->configfile
);
4695 init_unistr2_from_unistr(&spool_drv_info
->helpfile
, &info3
->helpfile
);
4696 init_unistr2_from_unistr(&spool_drv_info
->monitorname
, &info3
->monitorname
);
4697 init_unistr2_from_unistr(&spool_drv_info
->defaultdatatype
, &info3
->defaultdatatype
);
4704 /* the null_char BOOL is used to help locate
4705 two '\0's back to back */
4720 spool_drv_info
->dependentfiles_ptr
= (info3
->dependentfiles
!=NULL
)?1:0;
4721 spool_drv_info
->dependentfilessize
= len
;
4722 if(!make_spool_buffer5(&spool_drv_info
->dependentfiles
, len
, info3
->dependentfiles
))
4728 /*******************************************************************
4729 make a BUFFER5 struct from a uint16*
4730 ******************************************************************/
4732 BOOL
make_spool_buffer5(BUFFER5
*buf5
, uint32 len
, uint16
*src
)
4735 buf5
->buf_len
= len
;
4736 if((buf5
->buffer
=(uint16
*)malloc(sizeof(uint16
)*len
)) == NULL
)
4738 DEBUG(0,("make_spool_buffer5: Unable to talloc memory for buffer!\n"));
4742 memcpy(buf5
->buffer
, src
, sizeof(uint16
)*len
);
4747 /*******************************************************************
4748 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
4749 ********************************************************************/
4751 BOOL
spoolss_io_q_addprinterdriver(char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4753 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
4759 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
4761 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4766 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4769 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
4775 /*******************************************************************
4776 ********************************************************************/
4778 BOOL
spoolss_io_r_addprinterdriver(char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4780 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
4783 if(!prs_uint32("status", ps
, depth
, &q_u
->status
))
4789 /*******************************************************************
4790 ********************************************************************/
4792 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
4793 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
4795 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
4797 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
4801 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
4809 d
->cversion
=uni
->cversion
;
4811 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
4812 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
4813 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
4814 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
4815 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
4816 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
4817 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
4818 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
4820 DEBUGADD(8,( "version: %d\n", d
->cversion
));
4821 DEBUGADD(8,( "name: %s\n", d
->name
));
4822 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4823 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4824 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4825 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4826 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4827 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4828 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4830 uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
);
4835 /*******************************************************************
4836 ********************************************************************/
4837 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
4838 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
4840 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
4842 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
4846 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
4854 d
->version
=uni
->version
;
4856 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
4857 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
4858 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
4859 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
4860 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
4861 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
4862 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
4863 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
4865 DEBUGADD(8,( "version: %d\n", d
->version
));
4866 DEBUGADD(8,( "name: %s\n", d
->name
));
4867 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4868 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4869 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4870 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4871 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4872 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4873 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4875 uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
);
4876 uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
);
4881 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
4882 NT_PRINTER_INFO_LEVEL_2
**asc
)
4884 NT_PRINTER_INFO_LEVEL_2
*d
;
4887 DEBUG(7,("Converting from UNICODE to ASCII\n"));
4888 time_unix
=time(NULL
);
4891 DEBUGADD(8,("allocating memory\n"));
4893 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
4898 /* we allocate memory iff called from
4899 * addprinter(ex) so we can do one time stuff here.
4901 (*asc
)->setuptime
=time_unix
;
4904 DEBUGADD(8,("start converting\n"));
4908 d
->attributes
=uni
->attributes
;
4909 d
->priority
=uni
->priority
;
4910 d
->default_priority
=uni
->default_priority
;
4911 d
->starttime
=uni
->starttime
;
4912 d
->untiltime
=uni
->untiltime
;
4913 d
->status
=uni
->status
;
4914 d
->cjobs
=uni
->cjobs
;
4916 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
4917 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
4918 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
4919 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
4920 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
4921 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
4922 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
4923 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
4924 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
4925 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
4926 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
4931 /*******************************************************************
4933 ********************************************************************/
4935 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
4936 fstring servername
, fstring env_name
, uint32 level
,
4937 NEW_BUFFER
*buffer
, uint32 offered
)
4939 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
4940 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
4944 q_u
->offered
=offered
;
4949 /*******************************************************************
4950 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
4951 ********************************************************************/
4953 BOOL
spoolss_io_q_getprinterdriverdir(char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
4955 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
4960 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4962 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
4968 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
4970 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4976 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4979 if(!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4985 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4991 /*******************************************************************
4992 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
4993 ********************************************************************/
4995 BOOL
spoolss_io_r_getprinterdriverdir(char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
4997 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5003 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5009 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5012 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5018 /*******************************************************************
5019 ********************************************************************/
5021 BOOL
spoolss_io_r_enumprintprocessors(char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5023 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5029 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5035 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5038 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5041 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5047 /*******************************************************************
5048 ********************************************************************/
5050 BOOL
spoolss_io_q_enumprintprocessors(char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5052 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5058 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5060 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5066 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5068 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5074 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5077 if(!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5083 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5089 /*******************************************************************
5090 ********************************************************************/
5092 BOOL
spoolss_io_r_enumprintprocdatatypes(char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5094 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5100 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5106 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5109 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5112 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5118 /*******************************************************************
5119 ********************************************************************/
5121 BOOL
spoolss_io_q_enumprintprocdatatypes(char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5123 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5129 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5131 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5137 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5139 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5145 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5148 if(!new_spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5154 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5160 /*******************************************************************
5161 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5162 ********************************************************************/
5164 BOOL
spoolss_io_q_enumprintmonitors(char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5166 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5172 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5174 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5180 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5183 if(!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5189 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5195 /*******************************************************************
5196 ********************************************************************/
5198 BOOL
spoolss_io_r_enumprintmonitors(char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5200 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5206 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5212 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5215 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5218 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5224 /*******************************************************************
5225 ********************************************************************/
5227 BOOL
spoolss_io_r_enumprinterdata(char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5229 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5234 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5237 if (MARSHALLING(ps
)) {
5238 /* "Value is actually a UNICODE string. It's already little-endian so don't reverse. */
5239 if(!prs_uint8s(False
, "value", ps
, depth
, (uint8
*)r_u
->value
, r_u
->valuesize
* 2))
5242 if(!prs_uint16s(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5249 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5252 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5255 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5257 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
5262 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
5264 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5270 /*******************************************************************
5271 ********************************************************************/
5273 BOOL
spoolss_io_q_enumprinterdata(char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5275 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
5280 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5282 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
5284 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
5286 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
5292 /*******************************************************************
5293 ********************************************************************/
5295 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
5296 const POLICY_HND
*hnd
,
5297 uint32 idx
, uint32 valuelen
, uint32 datalen
)
5299 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5301 q_u
->valuesize
=valuelen
;
5302 q_u
->datasize
=datalen
;
5307 /*******************************************************************
5308 ********************************************************************/
5310 BOOL
spoolss_io_q_setprinterdata(char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5312 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
5317 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5319 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
5325 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5328 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
5337 if (UNMARSHALLING(ps
))
5338 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
5339 if(q_u
->data
== NULL
)
5341 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
5348 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
5354 /*******************************************************************
5355 ********************************************************************/
5357 BOOL
spoolss_io_r_setprinterdata(char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5359 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
5364 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5370 /*******************************************************************
5371 ********************************************************************/
5373 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
5374 uint32 type
, const uint8
*data
, uint32 len
)
5376 DEBUG(5,("converting a specific param struct\n"));
5380 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
5383 memset((char *)*param
, '\0', sizeof(NT_PRINTER_PARAM
));
5384 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5386 unistr2_to_ascii((*param
)->value
, value
, sizeof((*param
)->value
)-1);
5387 (*param
)->type
= type
;
5389 /* le champ data n'est pas NULL termine */
5390 /* on stocke donc la longueur */
5392 (*param
)->data_len
=len
;
5395 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
5396 if((*param
)->data
== NULL
)
5398 memcpy((*param
)->data
, data
, len
);
5401 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
5402 dump_data(10, (char *)(*param
)->data
, (*param
)->data_len
);
5407 /*******************************************************************
5408 ********************************************************************/
5410 static BOOL
spoolss_io_addform(char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
5412 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
5419 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
5421 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
5423 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
5425 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
5427 if(!prs_uint32("left", ps
, depth
, &f
->left
))
5429 if(!prs_uint32("top", ps
, depth
, &f
->top
))
5431 if(!prs_uint32("right", ps
, depth
, &f
->right
))
5433 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
5436 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
5443 /*******************************************************************
5444 ********************************************************************/
5446 BOOL
spoolss_io_q_deleteform(char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
5448 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
5453 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5455 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
5461 /*******************************************************************
5462 ********************************************************************/
5464 BOOL
spoolss_io_r_deleteform(char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
5466 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
5471 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5477 /*******************************************************************
5478 ********************************************************************/
5480 BOOL
spoolss_io_q_addform(char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
5482 uint32 useless_ptr
=0;
5483 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
5488 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5490 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5492 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5497 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5499 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5506 /*******************************************************************
5507 ********************************************************************/
5509 BOOL
spoolss_io_r_addform(char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
5511 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
5516 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5522 /*******************************************************************
5523 ********************************************************************/
5525 BOOL
spoolss_io_q_setform(char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
5527 uint32 useless_ptr
=0;
5528 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
5533 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5535 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
5541 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5543 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5548 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5550 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5557 /*******************************************************************
5558 ********************************************************************/
5560 BOOL
spoolss_io_r_setform(char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
5562 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
5567 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5573 /*******************************************************************
5574 Parse a SPOOL_R_GETJOB structure.
5575 ********************************************************************/
5577 BOOL
spoolss_io_r_getjob(char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
5579 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
5585 if (!new_spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5591 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5594 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5600 /*******************************************************************
5601 Parse a SPOOL_Q_GETJOB structure.
5602 ********************************************************************/
5604 BOOL
spoolss_io_q_getjob(char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
5606 prs_debug(ps
, depth
, desc
, "");
5612 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5614 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
5616 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5619 if(!new_spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5625 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5631 void free_devmode(DEVICEMODE
*devmode
)
5633 if (devmode
!=NULL
) {
5634 safe_free(devmode
->private);
5639 void free_printer_info_1(PRINTER_INFO_1
*printer
)
5644 void free_printer_info_2(PRINTER_INFO_2
*printer
)
5646 if (printer
!=NULL
) {
5647 free_devmode(printer
->devmode
);
5648 printer
->devmode
= NULL
;
5653 void free_printer_info_3(PRINTER_INFO_3
*printer
)
5655 if (printer
!=NULL
) {
5660 void free_job_info_2(JOB_INFO_2
*job
)
5663 free_devmode(job
->devmode
);
5666 /*******************************************************************
5668 ********************************************************************/
5670 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
5671 const fstring string
, uint32 printer
, uint32 type
)
5676 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
5678 q_u
->printer
=printer
;
5687 /*******************************************************************
5688 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
5689 ********************************************************************/
5691 BOOL
spoolss_io_q_replyopenprinter(char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5693 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
5699 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
5705 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
5707 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5710 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
5712 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
5718 /*******************************************************************
5719 Parse a SPOOL_R_REPLYOPENPRINTER structure.
5720 ********************************************************************/
5722 BOOL
spoolss_io_r_replyopenprinter(char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5724 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
5730 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5733 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5739 /*******************************************************************
5741 ********************************************************************/
5743 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
5748 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5753 /*******************************************************************
5754 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
5755 ********************************************************************/
5757 BOOL
spoolss_io_q_replycloseprinter(char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5759 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
5765 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5771 /*******************************************************************
5772 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
5773 ********************************************************************/
5775 BOOL
spoolss_io_r_replycloseprinter(char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5777 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
5783 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5786 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5792 /*******************************************************************
5794 ********************************************************************/
5796 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
5797 uint32 change_low
, uint32 change_high
)
5802 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5804 q_u
->change_low
=change_low
;
5805 q_u
->change_high
=change_high
;
5812 q_u
->info
.version
=2;
5813 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
5819 /*******************************************************************
5820 Parse a SPOOL_Q_REPLY_RRPCN structure.
5821 ********************************************************************/
5823 BOOL
spoolss_io_q_reply_rrpcn(char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
5825 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
5831 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5834 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
5837 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
5840 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
5843 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
5846 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
5849 if(q_u
->info_ptr
!=0)
5850 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
5856 /*******************************************************************
5857 Parse a SPOOL_R_REPLY_RRPCN structure.
5858 ********************************************************************/
5860 BOOL
spoolss_io_r_reply_rrpcn(char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
5862 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
5868 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
5871 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))