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 /*******************************************************************
28 return the length of a UNISTR string.
29 ********************************************************************/
31 static uint32
str_len_uni(UNISTR
*source
)
38 while (source
->buffer
[i
])
44 /*******************************************************************
45 This should be moved in a more generic lib.
46 ********************************************************************/
48 static BOOL
spoolss_io_system_time(char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
50 if(!prs_uint16("year", ps
, depth
, &(systime
->year
)))
52 if(!prs_uint16("month", ps
, depth
, &(systime
->month
)))
54 if(!prs_uint16("dayofweek", ps
, depth
, &(systime
->dayofweek
)))
56 if(!prs_uint16("day", ps
, depth
, &(systime
->day
)))
58 if(!prs_uint16("hour", ps
, depth
, &(systime
->hour
)))
60 if(!prs_uint16("minute", ps
, depth
, &(systime
->minute
)))
62 if(!prs_uint16("second", ps
, depth
, &(systime
->second
)))
64 if(!prs_uint16("milliseconds", ps
, depth
, &(systime
->milliseconds
)))
70 /*******************************************************************
71 ********************************************************************/
73 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
75 systime
->year
=unixtime
->tm_year
+1900;
76 systime
->month
=unixtime
->tm_mon
+1;
77 systime
->dayofweek
=unixtime
->tm_wday
;
78 systime
->day
=unixtime
->tm_mday
;
79 systime
->hour
=unixtime
->tm_hour
;
80 systime
->minute
=unixtime
->tm_min
;
81 systime
->second
=unixtime
->tm_sec
;
82 systime
->milliseconds
=0;
87 /*******************************************************************
88 reads or writes an DOC_INFO structure.
89 ********************************************************************/
91 static BOOL
smb_io_doc_info_1(char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
93 if (info_1
== NULL
) return False
;
95 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
101 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
103 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
105 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
108 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
110 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
112 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
118 /*******************************************************************
119 reads or writes an DOC_INFO structure.
120 ********************************************************************/
122 static BOOL
smb_io_doc_info(char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
124 uint32 useless_ptr
=0;
126 if (info
== NULL
) return False
;
128 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
134 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
137 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
140 switch (info
->switch_value
)
143 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
148 this is just a placeholder
150 MSDN July 1998 says doc_info_2 is only on
151 Windows 95, and as Win95 doesn't do RPC to print
152 this case is nearly impossible
154 Maybe one day with Windows for dishwasher 2037 ...
157 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
160 DEBUG(0,("Something is obviously wrong somewhere !\n"));
167 /*******************************************************************
168 reads or writes an DOC_INFO_CONTAINER structure.
169 ********************************************************************/
171 static BOOL
smb_io_doc_info_container(char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
173 if (cont
== NULL
) return False
;
175 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
181 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
184 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
190 /*******************************************************************
191 reads or writes an NOTIFY OPTION TYPE structure.
192 ********************************************************************/
194 static BOOL
smb_io_notify_option_type(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
196 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
202 if(!prs_uint16("type", ps
, depth
, &type
->type
))
204 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
206 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
208 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
210 if(!prs_uint32("count", ps
, depth
, &type
->count
))
212 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
218 /*******************************************************************
219 reads or writes an NOTIFY OPTION TYPE DATA.
220 ********************************************************************/
222 static BOOL
smb_io_notify_option_type_data(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
226 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
229 /* if there are no fields just return */
230 if (type
->fields_ptr
==0)
236 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
239 if (type
->count2
!= type
->count
)
240 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
242 /* parse the option type data */
243 for(i
=0;i
<type
->count2
;i
++)
244 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
249 /*******************************************************************
250 reads or writes an NOTIFY OPTION structure.
251 ********************************************************************/
253 static BOOL
smb_io_notify_option_type_ctr(char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
257 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
260 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
264 if (UNMARSHALLING(ps
))
265 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)prs_alloc_mem(ps
,ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
268 /* the option type struct */
269 for(i
=0;i
<ctr
->count
;i
++)
270 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
273 /* the type associated with the option type struct */
274 for(i
=0;i
<ctr
->count
;i
++)
275 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
281 /*******************************************************************
282 reads or writes an NOTIFY OPTION structure.
283 ********************************************************************/
285 static BOOL
smb_io_notify_option(char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
287 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
290 if(!prs_uint32("version", ps
, depth
, &option
->version
))
292 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
294 if(!prs_uint32("count", ps
, depth
, &option
->count
))
296 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
299 /* marshalling or unmarshalling, that would work */
300 if (option
->option_type_ptr
!=0) {
301 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
305 option
->ctr
.type
=NULL
;
312 /*******************************************************************
313 reads or writes an NOTIFY INFO DATA structure.
314 ********************************************************************/
316 static BOOL
smb_io_notify_info_data(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
318 uint32 useless_ptr
=0xADDE0FF0;
320 uint32 how_many_words
;
324 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
327 how_many_words
=data
->size
;
328 if (how_many_words
==POINTER
) {
329 how_many_words
=TWO_VALUE
;
332 isvalue
=data
->enc_type
;
336 if(!prs_uint16("type", ps
, depth
, &data
->type
))
338 if(!prs_uint16("field", ps
, depth
, &data
->field
))
342 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
344 if(!prs_uint32("id", ps
, depth
, &data
->id
))
346 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
353 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
355 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
360 /* length in ascii including \0 */
361 x
=2*(data
->notify_data
.data
.length
+1);
362 if(!prs_uint32("string length", ps
, depth
, &x
))
364 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
372 /*******************************************************************
373 reads or writes an NOTIFY INFO DATA structure.
374 ********************************************************************/
376 BOOL
smb_io_notify_info_data_strings(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
377 prs_struct
*ps
, int depth
)
382 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
388 isvalue
=data
->enc_type
;
390 if (isvalue
==False
) {
391 /* length of string in unicode include \0 */
392 x
=data
->notify_data
.data
.length
+1;
393 if(!prs_uint32("string length", ps
, depth
, &x
))
395 if (MARSHALLING(ps
)) {
396 /* These are already in little endian format. Don't byte swap. */
399 /* No memory allocated for this string
400 therefore following the data.string
401 pointer is a bad idea. Use a pointer to
402 the uint32 length union member to
403 provide a source for a unicode NULL */
405 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
408 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
413 /* Tallocate memory for string */
415 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
416 if (!data
->notify_data
.data
.string
)
419 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
429 /*******************************************************************
430 reads or writes an NOTIFY INFO structure.
431 ********************************************************************/
433 static BOOL
smb_io_notify_info(char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
437 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
443 if(!prs_uint32("count", ps
, depth
, &info
->count
))
445 if(!prs_uint32("version", ps
, depth
, &info
->version
))
447 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
449 if(!prs_uint32("count", ps
, depth
, &info
->count
))
452 for (i
=0;i
<info
->count
;i
++) {
453 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
457 /* now do the strings at the end of the stream */
458 for (i
=0;i
<info
->count
;i
++) {
459 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
466 /*******************************************************************
467 ********************************************************************/
469 static BOOL
spool_io_user_level_1(char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
471 prs_debug(ps
, depth
, desc
, "");
475 if (UNMARSHALLING(ps
))
480 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
482 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
484 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
486 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
488 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
490 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
492 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
495 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
499 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
505 /*******************************************************************
506 ********************************************************************/
508 static BOOL
spool_io_user_level(char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
513 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
518 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
520 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
523 switch (q_u
->level
) {
525 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
535 /*******************************************************************
536 * read or write a DEVICEMODE struct.
537 * on reading allocate memory for the private member
538 ********************************************************************/
540 BOOL
spoolss_io_devmode(char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
542 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
545 if (UNMARSHALLING(ps
)) {
546 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
547 if (devmode
->devicename
.buffer
== NULL
)
551 if (!prs_uint16uni(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, 32))
553 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
555 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
557 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
559 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
561 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
563 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
565 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
567 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
569 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
571 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
573 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
575 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
577 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
579 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
581 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
583 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
585 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
587 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
590 if (UNMARSHALLING(ps
)) {
591 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
592 if (devmode
->formname
.buffer
== NULL
)
596 if (!prs_uint16uni(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
598 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
600 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
602 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
604 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
606 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
608 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
610 if (!prs_uint32("icmmethod", ps
, depth
, &devmode
->icmmethod
))
612 if (!prs_uint32("icmintent", ps
, depth
, &devmode
->icmintent
))
614 if (!prs_uint32("mediatype", ps
, depth
, &devmode
->mediatype
))
616 if (!prs_uint32("dithertype", ps
, depth
, &devmode
->dithertype
))
618 if (!prs_uint32("reserved1", ps
, depth
, &devmode
->reserved1
))
620 if (!prs_uint32("reserved2", ps
, depth
, &devmode
->reserved2
))
622 if (!prs_uint32("panningwidth", ps
, depth
, &devmode
->panningwidth
))
624 if (!prs_uint32("panningheight", ps
, depth
, &devmode
->panningheight
))
627 if (devmode
->driverextra
!=0) {
628 if (UNMARSHALLING(ps
)) {
629 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
630 if(devmode
->private == NULL
)
632 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
635 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
636 if (!prs_uint8s(False
, "private", ps
, depth
,
637 devmode
->private, devmode
->driverextra
))
644 /*******************************************************************
645 Read or write a DEVICEMODE container
646 ********************************************************************/
648 static BOOL
spoolss_io_devmode_cont(char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
653 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
659 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
662 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
665 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
666 if (UNMARSHALLING(ps
))
667 /* if while reading there is no DEVMODE ... */
672 /* so we have a DEVICEMODE to follow */
673 if (UNMARSHALLING(ps
)) {
674 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
675 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
676 if(dm_c
->devmode
== NULL
)
680 /* this is bad code, shouldn't be there */
681 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
684 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
690 /*******************************************************************
691 ********************************************************************/
693 static BOOL
spoolss_io_printer_default(char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
698 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
701 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
704 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
710 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
713 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
719 /*******************************************************************
721 ********************************************************************/
723 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
724 const fstring printername
,
725 const fstring datatype
,
726 uint32 access_required
,
727 const fstring clientname
,
728 const fstring user_name
)
730 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
731 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
732 init_unistr2(&q_u
->printername
, printername
, strlen(printername
)+1);
734 q_u
->printer_default
.datatype_ptr
= 0;
736 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
737 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
739 q_u
->printer_default
.devmode_cont
.size
=0;
740 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
741 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
742 q_u
->printer_default
.access_required
=access_required
;
744 q_u
->user_ctr
.level
=1;
746 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
747 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
748 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
749 q_u
->user_ctr
.user1
.build
=1381;
750 q_u
->user_ctr
.user1
.major
=2;
751 q_u
->user_ctr
.user1
.minor
=0;
752 q_u
->user_ctr
.user1
.processor
=0;
753 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
754 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
759 /*******************************************************************
761 ********************************************************************/
762 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_spoolss_printer_info_2(mem_ctx
, &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_spoolss_printer_info_2(
822 SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
827 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
829 /* allocate the necessary memory */
830 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_2
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))))
832 DEBUG(0,("make_spoolss_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
);
868 inf
->secdesc
= inf
->secdesc
;
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 ********************************************************************/
913 BOOL
make_spoolss_q_deleteprinterdriver(
915 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
921 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
923 q_u
->server_ptr
= (server
!=NULL
)?1:0;
925 /* these must be NULL terminated or else NT4 will
926 complain about invalid parameters --jerry */
927 init_unistr2(&q_u
->server
, server
, strlen(server
)+1);
928 init_unistr2(&q_u
->arch
, arch
, strlen(arch
)+1);
929 init_unistr2(&q_u
->driver
, driver
, strlen(driver
)+1);
935 /*******************************************************************
937 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
938 * called from spoolss_open_printer_ex (cli_spoolss.c)
939 ********************************************************************/
941 BOOL
spoolss_io_r_open_printer_ex(char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
943 if (r_u
== NULL
) return False
;
945 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
951 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
954 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
960 /*******************************************************************
962 ********************************************************************/
964 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
965 const POLICY_HND
*handle
,
966 UNISTR2
*valuename
, uint32 size
)
968 if (q_u
== NULL
) return False
;
970 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
972 q_u
->handle
= *handle
;
973 copy_unistr2(&q_u
->valuename
, valuename
);
979 /*******************************************************************
981 * called from spoolss_q_getprinterdata (srv_spoolss.c)
982 ********************************************************************/
984 BOOL
spoolss_io_q_getprinterdata(char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
989 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
994 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
998 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1002 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1008 /*******************************************************************
1010 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1011 ********************************************************************/
1013 BOOL
spoolss_io_q_deleteprinterdata(char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1018 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1023 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1027 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1033 /*******************************************************************
1034 * write a structure.
1035 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1036 ********************************************************************/
1038 BOOL
spoolss_io_r_deleteprinterdata(char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1040 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1042 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1048 /*******************************************************************
1049 * write a structure.
1050 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1051 ********************************************************************/
1053 BOOL
spoolss_io_r_getprinterdata(char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1058 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1063 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1065 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1068 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
1074 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1076 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1082 /*******************************************************************
1084 ********************************************************************/
1086 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1088 if (q_u
== NULL
) return False
;
1090 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1092 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1097 /*******************************************************************
1099 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1100 * called from spoolss_abortprinter (cli_spoolss.c)
1101 ********************************************************************/
1103 BOOL
spoolss_io_q_abortprinter(char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1105 if (q_u
== NULL
) return False
;
1107 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1113 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1119 /*******************************************************************
1120 * write a structure.
1121 * called from spoolss_r_abortprinter (srv_spoolss.c)
1122 ********************************************************************/
1124 BOOL
spoolss_io_r_abortprinter(char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1126 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1128 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1134 /*******************************************************************
1136 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1137 * called from spoolss_deleteprinter (cli_spoolss.c)
1138 ********************************************************************/
1140 BOOL
spoolss_io_q_deleteprinter(char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1142 if (q_u
== NULL
) return False
;
1144 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1150 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1156 /*******************************************************************
1157 * write a structure.
1158 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1159 * called from spoolss_deleteprinter (cli_spoolss.c)
1160 ********************************************************************/
1162 BOOL
spoolss_io_r_deleteprinter(char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1164 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1170 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1172 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1179 /*******************************************************************
1181 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1182 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1183 ********************************************************************/
1185 BOOL
spoolss_io_q_deleteprinterdriver(char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1187 if (q_u
== NULL
) return False
;
1189 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1195 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1197 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1199 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1201 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1209 /*******************************************************************
1210 * write a structure.
1211 ********************************************************************/
1212 BOOL
spoolss_io_r_deleteprinterdriver(char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1214 if (r_u
== NULL
) return False
;
1216 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1222 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1230 /*******************************************************************
1232 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1233 * called from spoolss_closeprinter (cli_spoolss.c)
1234 ********************************************************************/
1236 BOOL
spoolss_io_q_closeprinter(char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1238 if (q_u
== NULL
) return False
;
1240 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1246 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1252 /*******************************************************************
1253 * write a structure.
1254 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1255 * called from spoolss_closeprinter (cli_spoolss.c)
1256 ********************************************************************/
1258 BOOL
spoolss_io_r_closeprinter(char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1260 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1266 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1268 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1274 /*******************************************************************
1276 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1277 ********************************************************************/
1279 BOOL
spoolss_io_q_startdocprinter(char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1281 if (q_u
== NULL
) return False
;
1283 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1289 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1292 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1298 /*******************************************************************
1299 * write a structure.
1300 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1301 ********************************************************************/
1303 BOOL
spoolss_io_r_startdocprinter(char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1305 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1307 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1309 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1315 /*******************************************************************
1317 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1318 ********************************************************************/
1320 BOOL
spoolss_io_q_enddocprinter(char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1322 if (q_u
== NULL
) return False
;
1324 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1330 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1336 /*******************************************************************
1337 * write a structure.
1338 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1339 ********************************************************************/
1341 BOOL
spoolss_io_r_enddocprinter(char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1343 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1345 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1351 /*******************************************************************
1353 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1354 ********************************************************************/
1356 BOOL
spoolss_io_q_startpageprinter(char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1358 if (q_u
== NULL
) return False
;
1360 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1366 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1372 /*******************************************************************
1373 * write a structure.
1374 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1375 ********************************************************************/
1377 BOOL
spoolss_io_r_startpageprinter(char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1379 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1381 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1387 /*******************************************************************
1389 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1390 ********************************************************************/
1392 BOOL
spoolss_io_q_endpageprinter(char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1394 if (q_u
== NULL
) return False
;
1396 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1402 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1408 /*******************************************************************
1409 * write a structure.
1410 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1411 ********************************************************************/
1413 BOOL
spoolss_io_r_endpageprinter(char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1415 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1417 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1423 /*******************************************************************
1425 * called from spoolss_q_writeprinter (srv_spoolss.c)
1426 ********************************************************************/
1428 BOOL
spoolss_io_q_writeprinter(char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1430 if (q_u
== NULL
) return False
;
1432 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1438 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1440 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1443 if (q_u
->buffer_size
!=0)
1445 if (UNMARSHALLING(ps
))
1446 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1447 if(q_u
->buffer
== NULL
)
1449 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1454 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1460 /*******************************************************************
1461 * write a structure.
1462 * called from spoolss_r_writeprinter (srv_spoolss.c)
1463 ********************************************************************/
1465 BOOL
spoolss_io_r_writeprinter(char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1467 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1469 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1471 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1477 /*******************************************************************
1479 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1480 ********************************************************************/
1482 BOOL
spoolss_io_q_rffpcnex(char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1484 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1490 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1492 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1494 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1496 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1498 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1504 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1507 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1510 if (q_u
->option_ptr
!=0) {
1512 if (UNMARSHALLING(ps
))
1513 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1516 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1523 /*******************************************************************
1524 * write a structure.
1525 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1526 ********************************************************************/
1528 BOOL
spoolss_io_r_rffpcnex(char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1530 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1533 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1539 /*******************************************************************
1541 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1542 ********************************************************************/
1544 BOOL
spoolss_io_q_rfnpcnex(char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1546 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1552 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1555 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1558 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1561 if (q_u
->option_ptr
!=0) {
1563 if (UNMARSHALLING(ps
))
1564 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1567 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1574 /*******************************************************************
1575 * write a structure.
1576 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1577 ********************************************************************/
1579 BOOL
spoolss_io_r_rfnpcnex(char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1581 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1587 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1590 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1595 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1601 /*******************************************************************
1602 * return the length of a uint16 (obvious, but the code is clean)
1603 ********************************************************************/
1605 static uint32
size_of_uint16(uint16
*value
)
1607 return (sizeof(*value
));
1610 /*******************************************************************
1611 * return the length of a uint32 (obvious, but the code is clean)
1612 ********************************************************************/
1614 static uint32
size_of_uint32(uint32
*value
)
1616 return (sizeof(*value
));
1619 /*******************************************************************
1620 * return the length of a NTTIME (obvious, but the code is clean)
1621 ********************************************************************/
1623 static uint32
size_of_nttime(NTTIME
*value
)
1625 return (sizeof(*value
));
1628 /*******************************************************************
1629 * return the length of a UNICODE string in number of char, includes:
1630 * - the leading zero
1631 * - the relative pointer size
1632 ********************************************************************/
1634 static uint32
size_of_relative_string(UNISTR
*string
)
1638 size
=str_len_uni(string
); /* the string length */
1639 size
=size
+1; /* add the leading zero */
1640 size
=size
*2; /* convert in char */
1641 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1642 size
+= ((4 - (size
& 3)) & 3);
1643 size
=size
+4; /* add the size of the ptr */
1648 /*******************************************************************
1649 * return the length of a uint32 (obvious, but the code is clean)
1650 ********************************************************************/
1652 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1657 return (4+devmode
->size
+devmode
->driverextra
);
1660 /*******************************************************************
1661 * return the length of a uint32 (obvious, but the code is clean)
1662 ********************************************************************/
1664 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1669 return (sizeof(SYSTEMTIME
) +4);
1672 /*******************************************************************
1673 * write a UNICODE string.
1674 * used by all the RPC structs passing a buffer
1675 ********************************************************************/
1677 static BOOL
spoolss_smb_io_unistr(char *desc
, UNISTR
*uni
, prs_struct
*ps
, int depth
)
1682 prs_debug(ps
, depth
, desc
, "spoolss_smb_io_unistr");
1685 /* there should be no align here as it can mess up
1686 parsing a NEW_BUFFER->prs */
1692 if (!prs_unistr("unistr", ps
, depth
, uni
))
1698 /*******************************************************************
1699 * write a UNICODE string and its relative pointer.
1700 * used by all the RPC structs passing a buffer
1702 * As I'm a nice guy, I'm forcing myself to explain this code.
1703 * MS did a good job in the overall spoolss code except in some
1704 * functions where they are passing the API buffer directly in the
1705 * RPC request/reply. That's to maintain compatiility at the API level.
1706 * They could have done it the good way the first time.
1708 * So what happen is: the strings are written at the buffer's end,
1709 * in the reverse order of the original structure. Some pointers to
1710 * the strings are also in the buffer. Those are relative to the
1713 * If you don't understand or want to change that function,
1714 * first get in touch with me: jfm@samba.org
1716 ********************************************************************/
1718 static BOOL
smb_io_relstr(char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
1720 prs_struct
*ps
=&buffer
->prs
;
1722 if (MARSHALLING(ps
)) {
1723 uint32 struct_offset
= prs_offset(ps
);
1724 uint32 relative_offset
;
1726 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
1727 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1731 buffer
->string_at_end
= prs_offset(ps
);
1733 /* write the string */
1734 if (!smb_io_unistr(desc
, string
, ps
, depth
))
1737 if(!prs_set_offset(ps
, struct_offset
))
1740 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1741 /* write its offset */
1742 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1748 /* read the offset */
1749 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
1752 old_offset
= prs_offset(ps
);
1753 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
1756 /* read the string */
1757 if (!spoolss_smb_io_unistr(desc
, string
, ps
, depth
))
1760 if(!prs_set_offset(ps
, old_offset
))
1766 /*******************************************************************
1767 * write a array of UNICODE strings and its relative pointer.
1768 * used by 2 RPC structs
1769 ********************************************************************/
1771 static BOOL
smb_io_relarraystr(char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
1775 prs_struct
*ps
=&buffer
->prs
;
1777 if (MARSHALLING(ps
)) {
1778 uint32 struct_offset
= prs_offset(ps
);
1779 uint32 relative_offset
;
1786 /* first write the last 0 */
1787 buffer
->string_at_end
-= 2;
1788 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1791 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
1794 while (p
&& (*p
!=0)) {
1798 /* Yes this should be malloc not talloc. Don't change. */
1800 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
1801 if (chaine
.buffer
== NULL
)
1804 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
1806 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
1808 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
1809 SAFE_FREE(chaine
.buffer
);
1813 /* write the string */
1814 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
1815 SAFE_FREE(chaine
.buffer
);
1821 SAFE_FREE(chaine
.buffer
);
1824 if(!prs_set_offset(ps
, struct_offset
))
1827 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1828 /* write its offset */
1829 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1837 uint16
*chaine2
=NULL
;
1840 size_t realloc_size
= 0;
1844 /* read the offset */
1845 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1848 old_offset
= prs_offset(ps
);
1849 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1853 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
))
1856 l_chaine
=str_len_uni(&chaine
);
1858 /* we're going to add two more bytes here in case this
1859 is the last string in the array and we need to add
1860 an extra NULL for termination */
1865 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
1867 /* Yes this should be realloc - it's freed below. JRA */
1869 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
1874 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
1875 l_chaine2
+=l_chaine
+1;
1878 } while(l_chaine
!=0);
1880 /* the end should be bould NULL terminated so add
1881 the second one here */
1884 chaine2
[l_chaine2
] = '\0';
1885 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
1889 if(!prs_set_offset(ps
, old_offset
))
1895 /*******************************************************************
1896 Parse a DEVMODE structure and its relative pointer.
1897 ********************************************************************/
1899 static BOOL
smb_io_relsecdesc(char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
1901 prs_struct
*ps
= &buffer
->prs
;
1903 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
1906 if (MARSHALLING(ps
)) {
1907 uint32 struct_offset
= prs_offset(ps
);
1908 uint32 relative_offset
;
1911 relative_offset
= 0;
1912 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1917 if (*secdesc
!= NULL
) {
1918 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
1920 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1922 /* write the secdesc */
1923 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1926 if(!prs_set_offset(ps
, struct_offset
))
1930 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1931 /* write its offset */
1933 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1938 /* read the offset */
1939 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1942 old_offset
= prs_offset(ps
);
1943 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1947 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1950 if(!prs_set_offset(ps
, old_offset
))
1956 /*******************************************************************
1957 Parse a DEVMODE structure and its relative pointer.
1958 ********************************************************************/
1960 static BOOL
smb_io_reldevmode(char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
1962 prs_struct
*ps
=&buffer
->prs
;
1964 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
1967 if (MARSHALLING(ps
)) {
1968 uint32 struct_offset
= prs_offset(ps
);
1969 uint32 relative_offset
;
1971 if (*devmode
== NULL
) {
1973 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1975 DEBUG(8, ("boing, the devmode was NULL\n"));
1980 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
1982 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1985 /* write the DEVMODE */
1986 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1989 if(!prs_set_offset(ps
, struct_offset
))
1992 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1993 /* write its offset */
1994 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2000 /* read the offset */
2001 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2004 old_offset
= prs_offset(ps
);
2005 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2008 /* read the string */
2009 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2011 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2014 if(!prs_set_offset(ps
, old_offset
))
2020 /*******************************************************************
2021 Parse a PRINTER_INFO_0 structure.
2022 ********************************************************************/
2024 BOOL
smb_io_printer_info_0(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2026 prs_struct
*ps
=&buffer
->prs
;
2028 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2031 buffer
->struct_start
=prs_offset(ps
);
2033 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2035 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2038 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2040 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2042 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2045 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2047 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2049 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2051 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2053 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2055 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2057 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2059 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2062 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2064 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2067 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2069 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2071 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2073 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2075 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2077 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2079 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2081 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2083 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2085 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2087 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2089 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2091 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2093 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2095 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2097 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2099 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2101 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2103 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2105 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2107 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2109 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2111 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2113 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2115 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2121 /*******************************************************************
2122 Parse a PRINTER_INFO_1 structure.
2123 ********************************************************************/
2125 BOOL
smb_io_printer_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2127 prs_struct
*ps
=&buffer
->prs
;
2129 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2132 buffer
->struct_start
=prs_offset(ps
);
2134 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2136 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2138 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2140 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2146 /*******************************************************************
2147 Parse a PRINTER_INFO_2 structure.
2148 ********************************************************************/
2150 BOOL
smb_io_printer_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2152 prs_struct
*ps
=&buffer
->prs
;
2154 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2157 buffer
->struct_start
=prs_offset(ps
);
2159 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2161 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2163 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2165 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2167 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2169 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2171 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2174 /* NT parses the DEVMODE at the end of the struct */
2175 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2178 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2180 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2182 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2184 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2187 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2190 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2192 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2194 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2196 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2198 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2200 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2202 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2204 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2208 if (!prs_uint32_post("secdesc_ptr", ps
, depth
, NULL
, sec_offset
, info
->secdesc
? prs_offset(ps
)-buffer
->struct_start
: 0 ))
2211 if (!sec_io_desc("secdesc", &info
->secdesc
, ps
, depth
))
2217 /*******************************************************************
2218 Parse a PRINTER_INFO_3 structure.
2219 ********************************************************************/
2221 BOOL
smb_io_printer_info_3(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2223 prs_struct
*ps
=&buffer
->prs
;
2225 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2228 buffer
->struct_start
=prs_offset(ps
);
2230 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2232 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2238 /*******************************************************************
2239 Parse a PORT_INFO_1 structure.
2240 ********************************************************************/
2242 BOOL
smb_io_port_info_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2244 prs_struct
*ps
=&buffer
->prs
;
2246 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2249 buffer
->struct_start
=prs_offset(ps
);
2251 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2257 /*******************************************************************
2258 Parse a PORT_INFO_2 structure.
2259 ********************************************************************/
2261 BOOL
smb_io_port_info_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2263 prs_struct
*ps
=&buffer
->prs
;
2265 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2268 buffer
->struct_start
=prs_offset(ps
);
2270 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2272 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2274 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2276 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2278 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2284 /*******************************************************************
2285 Parse a DRIVER_INFO_1 structure.
2286 ********************************************************************/
2288 BOOL
smb_io_printer_driver_info_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2290 prs_struct
*ps
=&buffer
->prs
;
2292 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2295 buffer
->struct_start
=prs_offset(ps
);
2297 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2303 /*******************************************************************
2304 Parse a DRIVER_INFO_2 structure.
2305 ********************************************************************/
2307 BOOL
smb_io_printer_driver_info_2(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2309 prs_struct
*ps
=&buffer
->prs
;
2311 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2314 buffer
->struct_start
=prs_offset(ps
);
2316 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2318 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2320 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2322 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2324 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2326 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2332 /*******************************************************************
2333 Parse a DRIVER_INFO_3 structure.
2334 ********************************************************************/
2336 BOOL
smb_io_printer_driver_info_3(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2338 prs_struct
*ps
=&buffer
->prs
;
2340 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2343 buffer
->struct_start
=prs_offset(ps
);
2345 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2347 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2349 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2351 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2353 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2355 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2357 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2360 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2363 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2365 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2371 /*******************************************************************
2372 Parse a DRIVER_INFO_6 structure.
2373 ********************************************************************/
2375 BOOL
smb_io_printer_driver_info_6(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2377 prs_struct
*ps
=&buffer
->prs
;
2379 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2382 buffer
->struct_start
=prs_offset(ps
);
2384 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2386 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2388 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2390 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2392 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2394 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2396 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2399 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2402 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2404 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2407 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2410 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2412 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2415 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2418 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2421 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2424 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2426 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2428 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2430 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2436 /*******************************************************************
2437 Parse a JOB_INFO_1 structure.
2438 ********************************************************************/
2440 BOOL
smb_io_job_info_1(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2442 prs_struct
*ps
=&buffer
->prs
;
2444 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2447 buffer
->struct_start
=prs_offset(ps
);
2449 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2451 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2453 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2455 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2457 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2459 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2461 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2463 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2465 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2467 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2469 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2471 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2473 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2479 /*******************************************************************
2480 Parse a JOB_INFO_2 structure.
2481 ********************************************************************/
2483 BOOL
smb_io_job_info_2(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2486 prs_struct
*ps
=&buffer
->prs
;
2488 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2491 buffer
->struct_start
=prs_offset(ps
);
2493 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2495 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2497 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2499 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2501 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2503 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2505 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2508 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2510 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2512 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2514 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2516 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2519 /* SEC_DESC sec_desc;*/
2520 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2523 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2525 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2527 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2529 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2531 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2533 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2535 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2537 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2539 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2541 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2547 /*******************************************************************
2548 ********************************************************************/
2550 BOOL
smb_io_form_1(char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2552 prs_struct
*ps
=&buffer
->prs
;
2554 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
2557 buffer
->struct_start
=prs_offset(ps
);
2559 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2562 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2565 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2567 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2569 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2571 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2573 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2575 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2581 /*******************************************************************
2582 Read/write a BUFFER struct.
2583 ********************************************************************/
2585 static BOOL
spoolss_io_buffer(char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
2587 NEW_BUFFER
*buffer
= *pp_buffer
;
2589 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
2592 if (UNMARSHALLING(ps
))
2593 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
2598 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2602 if (UNMARSHALLING(ps
)) {
2604 buffer
->string_at_end
=0;
2606 if (buffer
->ptr
==0) {
2608 * JRA. I'm not sure if the data in here is in big-endian format if
2609 * the client is big-endian. Leave as default (little endian) for now.
2612 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
2617 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2621 * JRA. I'm not sure if the data in here is in big-endian format if
2622 * the client is big-endian. Leave as default (little endian) for now.
2625 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
2628 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
2631 if (!prs_set_offset(&buffer
->prs
, 0))
2634 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
2637 buffer
->string_at_end
=buffer
->size
;
2645 if (buffer
->ptr
==0) {
2646 /* We have finished with the data in buffer->prs - free it. */
2647 prs_mem_free(&buffer
->prs
);
2651 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2654 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
2660 /* We have finished with the data in buffer->prs - free it. */
2661 prs_mem_free(&buffer
->prs
);
2667 /*******************************************************************
2668 move a BUFFER from the query to the reply.
2669 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2670 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2671 ********************************************************************/
2673 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
2675 prs_switch_type(&src
->prs
, MARSHALL
);
2676 if(!prs_set_offset(&src
->prs
, 0))
2678 prs_force_dynamic(&(src
->prs
));
2683 /*******************************************************************
2684 Get the size of a BUFFER struct.
2685 ********************************************************************/
2687 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
2689 return (buffer
->size
);
2692 /*******************************************************************
2693 Parse a DRIVER_DIRECTORY_1 structure.
2694 ********************************************************************/
2696 BOOL
smb_io_driverdir_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2698 prs_struct
*ps
=&buffer
->prs
;
2700 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
2703 buffer
->struct_start
=prs_offset(ps
);
2705 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2711 /*******************************************************************
2712 Parse a PORT_INFO_1 structure.
2713 ********************************************************************/
2715 BOOL
smb_io_port_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2717 prs_struct
*ps
=&buffer
->prs
;
2719 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
2722 buffer
->struct_start
=prs_offset(ps
);
2724 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2730 /*******************************************************************
2731 Parse a PORT_INFO_2 structure.
2732 ********************************************************************/
2734 BOOL
smb_io_port_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2736 prs_struct
*ps
=&buffer
->prs
;
2738 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
2741 buffer
->struct_start
=prs_offset(ps
);
2743 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2745 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2747 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2749 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2751 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2757 /*******************************************************************
2758 ********************************************************************/
2760 BOOL
smb_io_printprocessor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2762 prs_struct
*ps
=&buffer
->prs
;
2764 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2767 buffer
->struct_start
=prs_offset(ps
);
2769 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2775 /*******************************************************************
2776 ********************************************************************/
2778 BOOL
smb_io_printprocdatatype_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2780 prs_struct
*ps
=&buffer
->prs
;
2782 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2785 buffer
->struct_start
=prs_offset(ps
);
2787 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2793 /*******************************************************************
2794 ********************************************************************/
2796 BOOL
smb_io_printmonitor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2798 prs_struct
*ps
=&buffer
->prs
;
2800 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2803 buffer
->struct_start
=prs_offset(ps
);
2805 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2811 /*******************************************************************
2812 ********************************************************************/
2814 BOOL
smb_io_printmonitor_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
2816 prs_struct
*ps
=&buffer
->prs
;
2818 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
2821 buffer
->struct_start
=prs_offset(ps
);
2823 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2825 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
2827 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
2833 /*******************************************************************
2834 return the size required by a struct in the stream
2835 ********************************************************************/
2837 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
2841 size
+=size_of_relative_string( &info
->printername
);
2842 size
+=size_of_relative_string( &info
->servername
);
2844 size
+=size_of_uint32( &info
->cjobs
);
2845 size
+=size_of_uint32( &info
->total_jobs
);
2846 size
+=size_of_uint32( &info
->total_bytes
);
2848 size
+=size_of_uint16( &info
->year
);
2849 size
+=size_of_uint16( &info
->month
);
2850 size
+=size_of_uint16( &info
->dayofweek
);
2851 size
+=size_of_uint16( &info
->day
);
2852 size
+=size_of_uint16( &info
->hour
);
2853 size
+=size_of_uint16( &info
->minute
);
2854 size
+=size_of_uint16( &info
->second
);
2855 size
+=size_of_uint16( &info
->milliseconds
);
2857 size
+=size_of_uint32( &info
->global_counter
);
2858 size
+=size_of_uint32( &info
->total_pages
);
2860 size
+=size_of_uint16( &info
->major_version
);
2861 size
+=size_of_uint16( &info
->build_version
);
2863 size
+=size_of_uint32( &info
->unknown7
);
2864 size
+=size_of_uint32( &info
->unknown8
);
2865 size
+=size_of_uint32( &info
->unknown9
);
2866 size
+=size_of_uint32( &info
->session_counter
);
2867 size
+=size_of_uint32( &info
->unknown11
);
2868 size
+=size_of_uint32( &info
->printer_errors
);
2869 size
+=size_of_uint32( &info
->unknown13
);
2870 size
+=size_of_uint32( &info
->unknown14
);
2871 size
+=size_of_uint32( &info
->unknown15
);
2872 size
+=size_of_uint32( &info
->unknown16
);
2873 size
+=size_of_uint32( &info
->change_id
);
2874 size
+=size_of_uint32( &info
->unknown18
);
2875 size
+=size_of_uint32( &info
->status
);
2876 size
+=size_of_uint32( &info
->unknown20
);
2877 size
+=size_of_uint32( &info
->c_setprinter
);
2879 size
+=size_of_uint16( &info
->unknown22
);
2880 size
+=size_of_uint16( &info
->unknown23
);
2881 size
+=size_of_uint16( &info
->unknown24
);
2882 size
+=size_of_uint16( &info
->unknown25
);
2883 size
+=size_of_uint16( &info
->unknown26
);
2884 size
+=size_of_uint16( &info
->unknown27
);
2885 size
+=size_of_uint16( &info
->unknown28
);
2886 size
+=size_of_uint16( &info
->unknown29
);
2891 /*******************************************************************
2892 return the size required by a struct in the stream
2893 ********************************************************************/
2895 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
2899 size
+=size_of_uint32( &info
->flags
);
2900 size
+=size_of_relative_string( &info
->description
);
2901 size
+=size_of_relative_string( &info
->name
);
2902 size
+=size_of_relative_string( &info
->comment
);
2907 /*******************************************************************
2908 return the size required by a struct in the stream
2909 ********************************************************************/
2911 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
2916 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2917 size
+= sec_desc_size( info
->secdesc
);
2919 size
+=size_of_device_mode( info
->devmode
);
2921 size
+=size_of_relative_string( &info
->servername
);
2922 size
+=size_of_relative_string( &info
->printername
);
2923 size
+=size_of_relative_string( &info
->sharename
);
2924 size
+=size_of_relative_string( &info
->portname
);
2925 size
+=size_of_relative_string( &info
->drivername
);
2926 size
+=size_of_relative_string( &info
->comment
);
2927 size
+=size_of_relative_string( &info
->location
);
2929 size
+=size_of_relative_string( &info
->sepfile
);
2930 size
+=size_of_relative_string( &info
->printprocessor
);
2931 size
+=size_of_relative_string( &info
->datatype
);
2932 size
+=size_of_relative_string( &info
->parameters
);
2934 size
+=size_of_uint32( &info
->attributes
);
2935 size
+=size_of_uint32( &info
->priority
);
2936 size
+=size_of_uint32( &info
->defaultpriority
);
2937 size
+=size_of_uint32( &info
->starttime
);
2938 size
+=size_of_uint32( &info
->untiltime
);
2939 size
+=size_of_uint32( &info
->status
);
2940 size
+=size_of_uint32( &info
->cjobs
);
2941 size
+=size_of_uint32( &info
->averageppm
);
2945 /*******************************************************************
2946 return the size required by a struct in the stream
2947 ********************************************************************/
2949 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
2951 /* The 4 is for the self relative pointer.. */
2952 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2953 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
2956 /*******************************************************************
2957 return the size required by a struct in the stream
2958 ********************************************************************/
2960 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
2963 size
+=size_of_relative_string( &info
->name
);
2968 /*******************************************************************
2969 return the size required by a struct in the stream
2970 ********************************************************************/
2972 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
2975 size
+=size_of_uint32( &info
->version
);
2976 size
+=size_of_relative_string( &info
->name
);
2977 size
+=size_of_relative_string( &info
->architecture
);
2978 size
+=size_of_relative_string( &info
->driverpath
);
2979 size
+=size_of_relative_string( &info
->datafile
);
2980 size
+=size_of_relative_string( &info
->configfile
);
2985 /*******************************************************************
2986 return the size required by a string array.
2987 ********************************************************************/
2989 uint32
spoolss_size_string_array(uint16
*string
)
2994 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
2996 i
=i
+2; /* to count all chars including the leading zero */
2997 i
=2*i
; /* because we need the value in bytes */
2998 i
=i
+4; /* the offset pointer size */
3003 /*******************************************************************
3004 return the size required by a struct in the stream
3005 ********************************************************************/
3007 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3011 size
+=size_of_uint32( &info
->version
);
3012 size
+=size_of_relative_string( &info
->name
);
3013 size
+=size_of_relative_string( &info
->architecture
);
3014 size
+=size_of_relative_string( &info
->driverpath
);
3015 size
+=size_of_relative_string( &info
->datafile
);
3016 size
+=size_of_relative_string( &info
->configfile
);
3017 size
+=size_of_relative_string( &info
->helpfile
);
3018 size
+=size_of_relative_string( &info
->monitorname
);
3019 size
+=size_of_relative_string( &info
->defaultdatatype
);
3021 size
+=spoolss_size_string_array(info
->dependentfiles
);
3026 /*******************************************************************
3027 return the size required by a struct in the stream
3028 ********************************************************************/
3030 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3034 size
+=size_of_uint32( &info
->version
);
3035 size
+=size_of_relative_string( &info
->name
);
3036 size
+=size_of_relative_string( &info
->architecture
);
3037 size
+=size_of_relative_string( &info
->driverpath
);
3038 size
+=size_of_relative_string( &info
->datafile
);
3039 size
+=size_of_relative_string( &info
->configfile
);
3040 size
+=size_of_relative_string( &info
->helpfile
);
3042 size
+=spoolss_size_string_array(info
->dependentfiles
);
3044 size
+=size_of_relative_string( &info
->monitorname
);
3045 size
+=size_of_relative_string( &info
->defaultdatatype
);
3047 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3049 size
+=size_of_nttime(&info
->driver_date
);
3050 size
+=size_of_uint32( &info
->padding
);
3051 size
+=size_of_uint32( &info
->driver_version_low
);
3052 size
+=size_of_uint32( &info
->driver_version_high
);
3053 size
+=size_of_relative_string( &info
->mfgname
);
3054 size
+=size_of_relative_string( &info
->oem_url
);
3055 size
+=size_of_relative_string( &info
->hardware_id
);
3056 size
+=size_of_relative_string( &info
->provider
);
3061 /*******************************************************************
3062 return the size required by a struct in the stream
3063 ********************************************************************/
3065 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3068 size
+=size_of_uint32( &info
->jobid
);
3069 size
+=size_of_relative_string( &info
->printername
);
3070 size
+=size_of_relative_string( &info
->machinename
);
3071 size
+=size_of_relative_string( &info
->username
);
3072 size
+=size_of_relative_string( &info
->document
);
3073 size
+=size_of_relative_string( &info
->datatype
);
3074 size
+=size_of_relative_string( &info
->text_status
);
3075 size
+=size_of_uint32( &info
->status
);
3076 size
+=size_of_uint32( &info
->priority
);
3077 size
+=size_of_uint32( &info
->position
);
3078 size
+=size_of_uint32( &info
->totalpages
);
3079 size
+=size_of_uint32( &info
->pagesprinted
);
3080 size
+=size_of_systemtime( &info
->submitted
);
3085 /*******************************************************************
3086 return the size required by a struct in the stream
3087 ********************************************************************/
3089 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3093 size
+=4; /* size of sec desc ptr */
3095 size
+=size_of_uint32( &info
->jobid
);
3096 size
+=size_of_relative_string( &info
->printername
);
3097 size
+=size_of_relative_string( &info
->machinename
);
3098 size
+=size_of_relative_string( &info
->username
);
3099 size
+=size_of_relative_string( &info
->document
);
3100 size
+=size_of_relative_string( &info
->notifyname
);
3101 size
+=size_of_relative_string( &info
->datatype
);
3102 size
+=size_of_relative_string( &info
->printprocessor
);
3103 size
+=size_of_relative_string( &info
->parameters
);
3104 size
+=size_of_relative_string( &info
->drivername
);
3105 size
+=size_of_device_mode( info
->devmode
);
3106 size
+=size_of_relative_string( &info
->text_status
);
3107 /* SEC_DESC sec_desc;*/
3108 size
+=size_of_uint32( &info
->status
);
3109 size
+=size_of_uint32( &info
->priority
);
3110 size
+=size_of_uint32( &info
->position
);
3111 size
+=size_of_uint32( &info
->starttime
);
3112 size
+=size_of_uint32( &info
->untiltime
);
3113 size
+=size_of_uint32( &info
->totalpages
);
3114 size
+=size_of_uint32( &info
->size
);
3115 size
+=size_of_systemtime( &info
->submitted
);
3116 size
+=size_of_uint32( &info
->timeelapsed
);
3117 size
+=size_of_uint32( &info
->pagesprinted
);
3122 /*******************************************************************
3123 return the size required by a struct in the stream
3124 ********************************************************************/
3126 uint32
spoolss_size_form_1(FORM_1
*info
)
3130 size
+=size_of_uint32( &info
->flag
);
3131 size
+=size_of_relative_string( &info
->name
);
3132 size
+=size_of_uint32( &info
->width
);
3133 size
+=size_of_uint32( &info
->length
);
3134 size
+=size_of_uint32( &info
->left
);
3135 size
+=size_of_uint32( &info
->top
);
3136 size
+=size_of_uint32( &info
->right
);
3137 size
+=size_of_uint32( &info
->bottom
);
3142 /*******************************************************************
3143 return the size required by a struct in the stream
3144 ********************************************************************/
3146 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3150 size
+=size_of_relative_string( &info
->port_name
);
3155 /*******************************************************************
3156 return the size required by a struct in the stream
3157 ********************************************************************/
3159 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3163 size
=str_len_uni(&info
->name
); /* the string length */
3164 size
=size
+1; /* add the leading zero */
3165 size
=size
*2; /* convert in char */
3170 /*******************************************************************
3171 return the size required by a struct in the stream
3172 ********************************************************************/
3174 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3178 size
+=size_of_relative_string( &info
->port_name
);
3179 size
+=size_of_relative_string( &info
->monitor_name
);
3180 size
+=size_of_relative_string( &info
->description
);
3182 size
+=size_of_uint32( &info
->port_type
);
3183 size
+=size_of_uint32( &info
->reserved
);
3188 /*******************************************************************
3189 return the size required by a struct in the stream
3190 ********************************************************************/
3192 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3195 size
+=size_of_relative_string( &info
->name
);
3200 /*******************************************************************
3201 return the size required by a struct in the stream
3202 ********************************************************************/
3204 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3207 size
+=size_of_relative_string( &info
->name
);
3212 /*******************************************************************
3213 return the size required by a struct in the stream
3214 ********************************************************************/
3215 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3222 /* uint32(offset) + uint32(length) + length) */
3223 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3224 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
;
3226 size
+= size_of_uint32(&p
->type
);
3231 /*******************************************************************
3232 return the size required by a struct in the stream
3233 ********************************************************************/
3235 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3238 size
+=size_of_relative_string( &info
->name
);
3243 /*******************************************************************
3244 return the size required by a struct in the stream
3245 ********************************************************************/
3247 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3250 size
+=size_of_relative_string( &info
->name
);
3251 size
+=size_of_relative_string( &info
->environment
);
3252 size
+=size_of_relative_string( &info
->dll_name
);
3257 /*******************************************************************
3259 ********************************************************************/
3261 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3262 const POLICY_HND
*hnd
,
3263 const fstring architecture
,
3264 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3265 NEW_BUFFER
*buffer
, uint32 offered
)
3270 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3272 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3275 q_u
->clientmajorversion
=clientmajor
;
3276 q_u
->clientminorversion
=clientminor
;
3279 q_u
->offered
=offered
;
3284 /*******************************************************************
3286 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3287 ********************************************************************/
3289 BOOL
spoolss_io_q_getprinterdriver2(char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3291 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3297 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3299 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3301 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3306 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3309 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3315 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3318 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3320 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3326 /*******************************************************************
3328 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3329 ********************************************************************/
3331 BOOL
spoolss_io_r_getprinterdriver2(char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3333 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3339 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3344 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3346 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3348 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3350 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3356 /*******************************************************************
3358 ********************************************************************/
3360 BOOL
make_spoolss_q_enumprinters(
3361 SPOOL_Q_ENUMPRINTERS
*q_u
,
3371 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3372 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3376 q_u
->offered
=offered
;
3381 /*******************************************************************
3383 ********************************************************************/
3385 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3386 fstring servername
, uint32 level
,
3387 NEW_BUFFER
*buffer
, uint32 offered
)
3389 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3390 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3394 q_u
->offered
=offered
;
3399 /*******************************************************************
3401 * called from spoolss_enumprinters (srv_spoolss.c)
3402 ********************************************************************/
3404 BOOL
spoolss_io_q_enumprinters(char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3406 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3412 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3414 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3417 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3422 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3425 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3430 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3436 /*******************************************************************
3437 Parse a SPOOL_R_ENUMPRINTERS structure.
3438 ********************************************************************/
3440 BOOL
spoolss_io_r_enumprinters(char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3442 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3448 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3454 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3457 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3460 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3466 /*******************************************************************
3467 * write a structure.
3468 * called from spoolss_r_enum_printers (srv_spoolss.c)
3470 ********************************************************************/
3472 BOOL
spoolss_io_r_getprinter(char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3474 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3480 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3486 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3489 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3495 /*******************************************************************
3497 * called from spoolss_getprinter (srv_spoolss.c)
3498 ********************************************************************/
3500 BOOL
spoolss_io_q_getprinter(char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3502 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3508 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3510 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3513 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3518 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3524 /*******************************************************************
3526 ********************************************************************/
3528 BOOL
make_spoolss_q_getprinter(
3529 TALLOC_CTX
*mem_ctx
,
3530 SPOOL_Q_GETPRINTER
*q_u
,
3531 const POLICY_HND
*hnd
,
3541 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3545 q_u
->offered
=offered
;
3550 /*******************************************************************
3552 ********************************************************************/
3553 BOOL
make_spoolss_q_setprinter(
3554 TALLOC_CTX
*mem_ctx
,
3555 SPOOL_Q_SETPRINTER
*q_u
,
3556 const POLICY_HND
*hnd
,
3558 PRINTER_INFO_CTR
*info
,
3563 DEVICEMODE
*devmode
;
3570 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3573 q_u
->info
.level
= level
;
3574 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
3578 secdesc
= info
->printers_2
->secdesc
;
3579 devmode
= info
->printers_2
->devmode
;
3581 /* FIXMEE!! HACK ALERT!!! --jerry */
3582 info
->printers_2
->devmode
= NULL
;
3583 info
->printers_2
->secdesc
= NULL
;
3585 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
3586 #if 0 /* JERRY TEST */
3587 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
3588 if (!q_u
->secdesc_ctr
)
3590 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
3591 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3592 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3593 q_u
->secdesc_ctr
->sec
= secdesc
;
3595 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
3596 q_u
->devmode_ctr
.size
= sizeof(DEVICEMODE
) + (3*sizeof(uint32
));
3597 q_u
->devmode_ctr
.devmode
= devmode
;
3599 q_u
->secdesc_ctr
= NULL
;
3601 q_u
->devmode_ctr
.devmode_ptr
= 0;
3602 q_u
->devmode_ctr
.size
= 0;
3603 q_u
->devmode_ctr
.devmode
= NULL
;
3607 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
3612 q_u
->command
= command
;
3618 /*******************************************************************
3619 ********************************************************************/
3621 BOOL
spoolss_io_r_setprinter(char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3623 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3629 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3635 /*******************************************************************
3636 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3637 ********************************************************************/
3639 BOOL
spoolss_io_q_setprinter(char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3641 uint32 ptr_sec_desc
= 0;
3643 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3649 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3651 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3654 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3657 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3664 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3669 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3675 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3680 /* Parse a NULL security descriptor. This should really
3681 happen inside the sec_io_desc_buf() function. */
3683 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3684 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
)) return False
;
3685 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
3689 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3695 /*******************************************************************
3696 ********************************************************************/
3698 BOOL
spoolss_io_r_fcpn(char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
3700 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
3706 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3712 /*******************************************************************
3713 ********************************************************************/
3715 BOOL
spoolss_io_q_fcpn(char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
3718 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
3724 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3731 /*******************************************************************
3732 ********************************************************************/
3734 BOOL
spoolss_io_r_addjob(char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
3736 prs_debug(ps
, depth
, desc
, "");
3742 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3748 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3751 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3757 /*******************************************************************
3758 ********************************************************************/
3760 BOOL
spoolss_io_q_addjob(char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
3762 prs_debug(ps
, depth
, desc
, "");
3768 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3770 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3773 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3779 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3785 /*******************************************************************
3786 ********************************************************************/
3788 BOOL
spoolss_io_r_enumjobs(char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
3790 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
3796 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3802 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3805 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3808 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3814 /*******************************************************************
3815 ********************************************************************/
3817 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
3828 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3829 q_u
->firstjob
= firstjob
;
3830 q_u
->numofjobs
= numofjobs
;
3832 q_u
->buffer
= buffer
;
3833 q_u
->offered
= offered
;
3837 /*******************************************************************
3838 ********************************************************************/
3840 BOOL
spoolss_io_q_enumjobs(char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
3842 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
3848 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
3851 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
3853 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
3855 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3858 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3861 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3867 /*******************************************************************
3868 ********************************************************************/
3870 BOOL
spoolss_io_r_schedulejob(char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
3872 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
3878 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3884 /*******************************************************************
3885 ********************************************************************/
3887 BOOL
spoolss_io_q_schedulejob(char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
3889 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
3895 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3897 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3903 /*******************************************************************
3904 ********************************************************************/
3906 BOOL
spoolss_io_r_setjob(char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
3908 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
3914 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3920 /*******************************************************************
3921 ********************************************************************/
3923 BOOL
spoolss_io_q_setjob(char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
3925 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
3931 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3933 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3936 * level is usually 0. If (level!=0) then I'm in trouble !
3937 * I will try to generate setjob command with level!=0, one day.
3939 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3941 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3947 /*******************************************************************
3948 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
3949 ********************************************************************/
3951 BOOL
spoolss_io_r_enumprinterdrivers(char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
3953 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
3959 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3965 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3968 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3971 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3977 /*******************************************************************
3979 ********************************************************************/
3981 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
3983 const char *environment
,
3985 NEW_BUFFER
*buffer
, uint32 offered
)
3987 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
3988 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
3992 q_u
->offered
=offered
;
3997 /*******************************************************************
3998 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
3999 ********************************************************************/
4001 BOOL
spoolss_io_q_enumprinterdrivers(char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4004 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4010 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4012 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4017 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4019 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4024 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4027 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4033 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4039 /*******************************************************************
4040 ********************************************************************/
4042 BOOL
spoolss_io_q_enumforms(char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4045 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4050 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4052 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4055 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4060 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4066 /*******************************************************************
4067 ********************************************************************/
4069 BOOL
spoolss_io_r_enumforms(char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4071 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4077 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4083 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4086 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4089 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4095 /*******************************************************************
4096 ********************************************************************/
4098 BOOL
spoolss_io_q_getform(char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4101 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4106 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4108 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4114 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4117 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4122 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4128 /*******************************************************************
4129 ********************************************************************/
4131 BOOL
spoolss_io_r_getform(char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4133 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4139 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4145 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4148 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4154 /*******************************************************************
4155 Parse a SPOOL_R_ENUMPORTS structure.
4156 ********************************************************************/
4158 BOOL
spoolss_io_r_enumports(char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4160 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4166 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4172 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4175 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4178 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4184 /*******************************************************************
4185 ********************************************************************/
4187 BOOL
spoolss_io_q_enumports(char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4189 prs_debug(ps
, depth
, desc
, "");
4195 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4197 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4202 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4205 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4210 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4216 /*******************************************************************
4217 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4218 ********************************************************************/
4220 BOOL
spool_io_printer_info_level_1(char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4222 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4228 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4230 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4232 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4234 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4237 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4239 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4241 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4247 /*******************************************************************
4248 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4249 ********************************************************************/
4251 BOOL
spool_io_printer_info_level_3(char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4253 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4259 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4265 /*******************************************************************
4266 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4267 ********************************************************************/
4269 BOOL
spool_io_printer_info_level_2(char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4271 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4277 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4279 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4281 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4283 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4286 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4288 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4290 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4292 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4294 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4296 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4298 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4300 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4302 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4305 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4307 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4309 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4311 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4313 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4315 if(!prs_werror("status", ps
, depth
, &il
->status
))
4317 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4319 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4322 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4324 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4326 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4328 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4330 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4332 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4334 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4336 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4338 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4340 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4342 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4348 /*******************************************************************
4349 ********************************************************************/
4351 BOOL
spool_io_printer_info_level(char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4353 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4358 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4360 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4363 /* if no struct inside just return */
4364 if (il
->info_ptr
==0) {
4365 if (UNMARSHALLING(ps
)) {
4372 switch (il
->level
) {
4374 * level 0 is used by setprinter when managing the queue
4375 * (hold, stop, start a queue)
4379 /* DOCUMENT ME!!! What is level 1 used for? */
4382 if (UNMARSHALLING(ps
)) {
4383 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4386 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4391 * level 2 is used by addprinter
4392 * and by setprinter when updating printer's info
4395 if (UNMARSHALLING(ps
)) {
4396 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4399 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4402 /* DOCUMENT ME!!! What is level 3 used for? */
4405 if (UNMARSHALLING(ps
)) {
4406 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4409 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4418 /*******************************************************************
4419 ********************************************************************/
4421 BOOL
spoolss_io_q_addprinterex(char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4423 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4428 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4430 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4436 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4439 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4442 /* the 4 unknown are all 0 */
4445 * en fait ils sont pas inconnu
4446 * par recoupement avec rpcSetPrinter
4447 * c'est le devicemode
4448 * et le security descriptor.
4453 if(!prs_uint32("unk0", ps
, depth
, &q_u
->unk0
))
4455 if(!prs_uint32("unk1", ps
, depth
, &q_u
->unk1
))
4457 if(!prs_uint32("unk2", ps
, depth
, &q_u
->unk2
))
4459 if(!prs_uint32("unk3", ps
, depth
, &q_u
->unk3
))
4462 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4464 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4470 /*******************************************************************
4471 ********************************************************************/
4473 BOOL
spoolss_io_r_addprinterex(char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4474 prs_struct
*ps
, int depth
)
4476 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4479 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4482 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4488 /*******************************************************************
4489 ********************************************************************/
4491 BOOL
spool_io_printer_driver_info_level_3(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4492 prs_struct
*ps
, int depth
)
4494 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4496 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4500 if (UNMARSHALLING(ps
)) {
4501 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4513 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4515 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4517 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4519 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4521 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4523 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4525 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4527 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4529 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4531 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4533 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4539 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4541 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4543 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4545 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4547 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4549 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4551 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4553 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4559 if (il
->dependentfiles_ptr
)
4560 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
4565 /*******************************************************************
4566 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4567 ********************************************************************/
4569 BOOL
spool_io_printer_driver_info_level_6(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4570 prs_struct
*ps
, int depth
)
4572 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4574 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4578 if (UNMARSHALLING(ps
)) {
4579 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
4592 /* parse the main elements the packet */
4594 if(!prs_uint32("version", ps
, depth
, &il
->version
))
4597 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4600 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4601 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4602 * from W2K CDROM (which uses unidriver). JohnR 010205
4604 if (!il
->name_ptr
) {
4605 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4606 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4610 if(!prs_uint32("environment_ptr", ps
, depth
, &il
->environment_ptr
))
4612 if(!prs_uint32("driverpath_ptr", ps
, depth
, &il
->driverpath_ptr
))
4614 if(!prs_uint32("datafile_ptr", ps
, depth
, &il
->datafile_ptr
))
4616 if(!prs_uint32("configfile_ptr", ps
, depth
, &il
->configfile_ptr
))
4618 if(!prs_uint32("helpfile_ptr", ps
, depth
, &il
->helpfile_ptr
))
4620 if(!prs_uint32("monitorname_ptr", ps
, depth
, &il
->monitorname_ptr
))
4622 if(!prs_uint32("defaultdatatype_ptr", ps
, depth
, &il
->defaultdatatype_ptr
))
4624 if(!prs_uint32("dependentfiles_len", ps
, depth
, &il
->dependentfiles_len
))
4626 if(!prs_uint32("dependentfiles_ptr", ps
, depth
, &il
->dependentfiles_ptr
))
4628 if(!prs_uint32("previousnames_len", ps
, depth
, &il
->previousnames_len
))
4630 if(!prs_uint32("previousnames_ptr", ps
, depth
, &il
->previousnames_ptr
))
4632 if(!smb_io_time("driverdate", &il
->driverdate
, ps
, depth
))
4634 if(!prs_uint32("dummy4", ps
, depth
, &il
->dummy4
))
4636 if(!prs_uint64("driverversion", ps
, depth
, &il
->driverversion
))
4638 if(!prs_uint32("mfgname_ptr", ps
, depth
, &il
->mfgname_ptr
))
4640 if(!prs_uint32("oemurl_ptr", ps
, depth
, &il
->oemurl_ptr
))
4642 if(!prs_uint32("hardwareid_ptr", ps
, depth
, &il
->hardwareid_ptr
))
4644 if(!prs_uint32("provider_ptr", ps
, depth
, &il
->provider_ptr
))
4647 /* parse the structures in the packet */
4649 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4654 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4659 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4664 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4669 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4674 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4679 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4684 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4688 if (il
->dependentfiles_ptr
) {
4689 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
4694 if (il
->previousnames_ptr
) {
4695 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
4700 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
4704 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
4708 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
4712 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
4718 /*******************************************************************
4719 convert a buffer of UNICODE strings null terminated
4720 the buffer is terminated by a NULL
4722 convert to an dos codepage array (null terminated)
4724 dynamically allocate memory
4726 ********************************************************************/
4727 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
4736 src
= (char *)buf5
->buffer
;
4739 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
4740 unistr_to_dos(f
, src
, sizeof(f
)-1);
4741 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
4742 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
4747 fstrcpy((*ar
)[n
], f
);
4750 fstrcpy((*ar
)[n
], "");
4758 /*******************************************************************
4759 read a UNICODE array with null terminated strings
4760 and null terminated array
4761 and size of array at beginning
4762 ********************************************************************/
4764 BOOL
smb_io_unibuffer(char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
4766 if (buffer
==NULL
) return False
;
4769 buffer
->uni_str_len
=buffer
->uni_max_len
;
4771 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
4774 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
4780 /*******************************************************************
4781 ********************************************************************/
4783 BOOL
spool_io_printer_driver_info_level(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4785 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
4790 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4792 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
4798 switch (il
->level
) {
4800 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
4804 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
4814 /*******************************************************************
4815 init a SPOOL_Q_ADDPRINTERDRIVER struct
4816 ******************************************************************/
4818 BOOL
make_spoolss_q_addprinterdriver(
4819 TALLOC_CTX
*mem_ctx
,
4820 SPOOL_Q_ADDPRINTERDRIVER
*q_u
,
4821 const char* srv_name
,
4823 PRINTER_DRIVER_CTR
*info
)
4825 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
4827 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
4828 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
4832 q_u
->info
.level
= level
;
4833 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
4836 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
4838 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
4841 /* info level 6 is supported by WinME and Win2k */
4843 /* WRITEME!! will add later --jerry */
4847 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
4854 BOOL
make_spoolss_driver_info_3(
4855 TALLOC_CTX
*mem_ctx
,
4856 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
4857 DRIVER_INFO_3
*info3
4861 uint16
*ptr
= info3
->dependentfiles
;
4863 BOOL null_char
= False
;
4864 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
4866 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
4869 inf
->cversion
= info3
->version
;
4870 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
4871 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
4872 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
4873 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
4874 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
4875 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
4876 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
4877 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
4879 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
4880 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
4881 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
4882 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
4883 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
4884 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
4885 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
4886 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
4893 /* the null_char BOOL is used to help locate
4894 two '\0's back to back */
4909 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
4910 inf
->dependentfilessize
= len
;
4911 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
4917 *spool_drv_info
= inf
;
4922 /*******************************************************************
4923 make a BUFFER5 struct from a uint16*
4924 ******************************************************************/
4925 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
4928 buf5
->buf_len
= len
;
4929 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
4931 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
4938 /*******************************************************************
4939 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
4940 ********************************************************************/
4942 BOOL
spoolss_io_q_addprinterdriver(char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4944 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
4950 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
4952 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4957 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4960 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
4966 /*******************************************************************
4967 ********************************************************************/
4969 BOOL
spoolss_io_r_addprinterdriver(char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4971 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
4974 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
4980 /*******************************************************************
4981 ********************************************************************/
4983 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
4984 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
4986 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
4988 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
4992 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5000 d
->cversion
=uni
->cversion
;
5002 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5003 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5004 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5005 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5006 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5007 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5008 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5009 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5011 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5012 DEBUGADD(8,( "name: %s\n", d
->name
));
5013 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5014 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5015 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5016 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5017 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5018 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5019 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5021 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5028 /*******************************************************************
5029 ********************************************************************/
5030 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5031 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5033 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5035 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5039 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5047 d
->version
=uni
->version
;
5049 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5050 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5051 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5052 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5053 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5054 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5055 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5056 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5058 DEBUGADD(8,( "version: %d\n", d
->version
));
5059 DEBUGADD(8,( "name: %s\n", d
->name
));
5060 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5061 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5062 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5063 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5064 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5065 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5066 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5068 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5070 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5080 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5081 NT_PRINTER_INFO_LEVEL_2
**asc
)
5083 NT_PRINTER_INFO_LEVEL_2
*d
;
5086 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5087 time_unix
=time(NULL
);
5090 DEBUGADD(8,("allocating memory\n"));
5092 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5097 /* we allocate memory iff called from
5098 * addprinter(ex) so we can do one time stuff here.
5100 (*asc
)->setuptime
=time_unix
;
5103 DEBUGADD(8,("start converting\n"));
5107 d
->attributes
=uni
->attributes
;
5108 d
->priority
=uni
->priority
;
5109 d
->default_priority
=uni
->default_priority
;
5110 d
->starttime
=uni
->starttime
;
5111 d
->untiltime
=uni
->untiltime
;
5112 d
->status
=uni
->status
;
5113 d
->cjobs
=uni
->cjobs
;
5115 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5116 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5117 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5118 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5119 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5120 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5121 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5122 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5123 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5124 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5125 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5130 /*******************************************************************
5132 ********************************************************************/
5134 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5135 fstring servername
, fstring env_name
, uint32 level
,
5136 NEW_BUFFER
*buffer
, uint32 offered
)
5138 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5139 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5143 q_u
->offered
=offered
;
5148 /*******************************************************************
5149 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5150 ********************************************************************/
5152 BOOL
spoolss_io_q_getprinterdriverdir(char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5154 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5159 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5161 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5167 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5169 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5175 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5178 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5184 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5190 /*******************************************************************
5191 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5192 ********************************************************************/
5194 BOOL
spoolss_io_r_getprinterdriverdir(char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5196 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5202 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5208 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5211 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5217 /*******************************************************************
5218 ********************************************************************/
5220 BOOL
spoolss_io_r_enumprintprocessors(char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5222 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5228 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5234 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5237 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5240 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5246 /*******************************************************************
5247 ********************************************************************/
5249 BOOL
spoolss_io_q_enumprintprocessors(char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5251 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5257 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5259 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5265 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5267 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5273 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5276 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5282 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5288 /*******************************************************************
5289 ********************************************************************/
5291 BOOL
spoolss_io_q_addprintprocessor(char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5293 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5299 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5301 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5306 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5311 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5316 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5322 /*******************************************************************
5323 ********************************************************************/
5325 BOOL
spoolss_io_r_addprintprocessor(char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5327 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5333 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5339 /*******************************************************************
5340 ********************************************************************/
5342 BOOL
spoolss_io_r_enumprintprocdatatypes(char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5344 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5350 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5356 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5359 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5362 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5368 /*******************************************************************
5369 ********************************************************************/
5371 BOOL
spoolss_io_q_enumprintprocdatatypes(char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5373 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5379 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5381 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5387 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5389 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5395 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5398 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5404 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5410 /*******************************************************************
5411 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5412 ********************************************************************/
5414 BOOL
spoolss_io_q_enumprintmonitors(char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5416 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5422 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5424 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5430 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5433 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5439 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5445 /*******************************************************************
5446 ********************************************************************/
5448 BOOL
spoolss_io_r_enumprintmonitors(char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5450 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5456 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5462 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5465 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5468 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5474 /*******************************************************************
5475 ********************************************************************/
5477 BOOL
spoolss_io_r_enumprinterdata(char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5479 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5484 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5487 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5493 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5496 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5499 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5501 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
5506 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
5508 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5514 /*******************************************************************
5515 ********************************************************************/
5517 BOOL
spoolss_io_q_enumprinterdata(char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5519 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
5524 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5526 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
5528 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
5530 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
5536 /*******************************************************************
5537 ********************************************************************/
5539 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
5540 const POLICY_HND
*hnd
,
5541 uint32 idx
, uint32 valuelen
, uint32 datalen
)
5543 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5545 q_u
->valuesize
=valuelen
;
5546 q_u
->datasize
=datalen
;
5551 /*******************************************************************
5552 ********************************************************************/
5554 BOOL
spoolss_io_q_setprinterdata(char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5556 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
5561 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5563 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
5569 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5572 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
5582 if (UNMARSHALLING(ps
))
5583 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
5584 if(q_u
->data
== NULL
)
5586 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
5594 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
5600 /*******************************************************************
5601 ********************************************************************/
5603 BOOL
spoolss_io_r_setprinterdata(char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5605 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
5610 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5616 /*******************************************************************
5617 ********************************************************************/
5619 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
5620 uint32 type
, const uint8
*data
, uint32 len
)
5622 DEBUG(5,("converting a specific param struct\n"));
5626 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
5629 memset((char *)*param
, '\0', sizeof(NT_PRINTER_PARAM
));
5630 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5632 unistr2_to_ascii((*param
)->value
, value
, sizeof((*param
)->value
)-1);
5633 (*param
)->type
= type
;
5635 /* le champ data n'est pas NULL termine */
5636 /* on stocke donc la longueur */
5638 (*param
)->data_len
=len
;
5641 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
5642 if((*param
)->data
== NULL
)
5644 memcpy((*param
)->data
, data
, len
);
5647 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
5648 dump_data(10, (char *)(*param
)->data
, (*param
)->data_len
);
5653 /*******************************************************************
5654 ********************************************************************/
5656 static BOOL
spoolss_io_addform(char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
5658 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
5665 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
5667 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
5669 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
5671 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
5673 if(!prs_uint32("left", ps
, depth
, &f
->left
))
5675 if(!prs_uint32("top", ps
, depth
, &f
->top
))
5677 if(!prs_uint32("right", ps
, depth
, &f
->right
))
5679 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
5682 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
5689 /*******************************************************************
5690 ********************************************************************/
5692 BOOL
spoolss_io_q_deleteform(char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
5694 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
5699 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5701 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
5707 /*******************************************************************
5708 ********************************************************************/
5710 BOOL
spoolss_io_r_deleteform(char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
5712 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
5717 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5723 /*******************************************************************
5724 ********************************************************************/
5726 BOOL
spoolss_io_q_addform(char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
5728 uint32 useless_ptr
=0;
5729 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
5734 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5736 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5738 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5743 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5745 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5752 /*******************************************************************
5753 ********************************************************************/
5755 BOOL
spoolss_io_r_addform(char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
5757 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
5762 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5768 /*******************************************************************
5769 ********************************************************************/
5771 BOOL
spoolss_io_q_setform(char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
5773 uint32 useless_ptr
=0;
5774 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
5779 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5781 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
5787 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5789 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5794 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5796 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5803 /*******************************************************************
5804 ********************************************************************/
5806 BOOL
spoolss_io_r_setform(char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
5808 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
5813 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5819 /*******************************************************************
5820 Parse a SPOOL_R_GETJOB structure.
5821 ********************************************************************/
5823 BOOL
spoolss_io_r_getjob(char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
5825 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
5831 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5837 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5840 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5846 /*******************************************************************
5847 Parse a SPOOL_Q_GETJOB structure.
5848 ********************************************************************/
5850 BOOL
spoolss_io_q_getjob(char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
5852 prs_debug(ps
, depth
, desc
, "");
5858 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5860 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
5862 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5865 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5871 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5877 void free_devmode(DEVICEMODE
*devmode
)
5879 if (devmode
!=NULL
) {
5880 SAFE_FREE(devmode
->private);
5885 void free_printer_info_1(PRINTER_INFO_1
*printer
)
5890 void free_printer_info_2(PRINTER_INFO_2
*printer
)
5892 if (printer
!=NULL
) {
5893 free_devmode(printer
->devmode
);
5894 printer
->devmode
= NULL
;
5899 void free_printer_info_3(PRINTER_INFO_3
*printer
)
5904 void free_job_info_2(JOB_INFO_2
*job
)
5907 free_devmode(job
->devmode
);
5910 /*******************************************************************
5912 ********************************************************************/
5914 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
5915 const fstring string
, uint32 printer
, uint32 type
)
5920 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
5922 q_u
->printer
=printer
;
5931 /*******************************************************************
5932 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
5933 ********************************************************************/
5935 BOOL
spoolss_io_q_replyopenprinter(char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5937 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
5943 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
5949 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
5951 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5954 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
5956 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
5962 /*******************************************************************
5963 Parse a SPOOL_R_REPLYOPENPRINTER structure.
5964 ********************************************************************/
5966 BOOL
spoolss_io_r_replyopenprinter(char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5968 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
5974 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5977 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5983 /*******************************************************************
5985 ********************************************************************/
5987 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
5992 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5997 /*******************************************************************
5998 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
5999 ********************************************************************/
6001 BOOL
spoolss_io_q_replycloseprinter(char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6003 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6009 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6015 /*******************************************************************
6016 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6017 ********************************************************************/
6019 BOOL
spoolss_io_r_replycloseprinter(char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6021 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6027 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6030 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6036 /*******************************************************************
6038 ********************************************************************/
6040 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6041 uint32 change_low
, uint32 change_high
)
6046 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6048 q_u
->change_low
=change_low
;
6049 q_u
->change_high
=change_high
;
6056 q_u
->info
.version
=2;
6057 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6063 /*******************************************************************
6064 Parse a SPOOL_Q_REPLY_RRPCN structure.
6065 ********************************************************************/
6067 BOOL
spoolss_io_q_reply_rrpcn(char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6069 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6075 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6078 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6081 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6084 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6087 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6090 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6093 if(q_u
->info_ptr
!=0)
6094 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6100 /*******************************************************************
6101 Parse a SPOOL_R_REPLY_RRPCN structure.
6102 ********************************************************************/
6104 BOOL
spoolss_io_r_reply_rrpcn(char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6106 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6112 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6115 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6121 /*******************************************************************
6123 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6124 ********************************************************************/
6126 BOOL
spoolss_io_q_getprinterdataex(char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6131 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6136 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6140 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6144 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6148 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6154 /*******************************************************************
6155 * write a structure.
6156 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6157 ********************************************************************/
6159 BOOL
spoolss_io_r_getprinterdataex(char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6164 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6169 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6171 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6174 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
6180 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6182 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6188 /*******************************************************************
6190 ********************************************************************/
6192 BOOL
spoolss_io_q_setprinterdataex(char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6194 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
6199 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6201 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6207 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6213 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6216 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6226 if (UNMARSHALLING(ps
))
6227 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6228 if(q_u
->data
== NULL
)
6230 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6238 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6244 /*******************************************************************
6245 * write a structure.
6246 ********************************************************************/
6248 BOOL
spoolss_io_r_setprinterdataex(char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6250 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
6255 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6262 /*******************************************************************
6264 ********************************************************************/
6266 BOOL
spoolss_io_q_enumprinterkey(char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
6268 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
6273 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6276 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6282 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6288 /*******************************************************************
6289 * write a structure.
6290 ********************************************************************/
6292 BOOL
spoolss_io_r_enumprinterkey(char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
6294 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
6300 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
6306 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6309 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6316 /*******************************************************************
6318 ********************************************************************/
6320 BOOL
spoolss_io_q_enumprinterdataex(char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6322 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
6327 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6330 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6336 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6342 /*******************************************************************
6343 ********************************************************************/
6344 static BOOL
spoolss_io_printer_enum_values_ctr(char *desc
, prs_struct
*ps
,
6345 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
6348 uint32 valuename_offset
,
6352 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
6355 if (!prs_uint32("size", ps
, depth
, &ctr
->size
))
6358 /* offset data begins at 20 bytes per structure * size_of_array.
6359 Don't forget the uint32 at the beginning */
6361 current_offset
= 4 + (20*ctr
->size_of_array
);
6363 /* first loop to write basic enum_value information */
6365 for (i
=0; i
<ctr
->size_of_array
; i
++)
6367 valuename_offset
= current_offset
;
6368 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
6371 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
6374 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
6377 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
6378 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
6381 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
6384 current_offset
= data_offset
+ ctr
->values
[i
].data_len
;
6388 /* loop #2 for writing the dynamically size objects
6389 while viewing oncversations between Win2k -> Win2k,
6390 4-byte alignment does not seem to matter here --jerrty */
6392 for (i
=0; i
<ctr
->size_of_array
; i
++)
6395 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
6398 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
6408 /*******************************************************************
6409 * write a structure.
6410 ********************************************************************/
6412 BOOL
spoolss_io_r_enumprinterdataex(char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6414 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
6420 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
6426 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6429 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6432 if(!prs_werror("status", ps
, depth
, &r_u
->status
))