2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Jean François Micouleau 1998-2000.
8 * Copyright (C) Gerald Carter 2000
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 extern int DEBUGLEVEL
;
29 /*******************************************************************
30 return the length of a UNISTR string.
31 ********************************************************************/
33 static uint32
str_len_uni(UNISTR
*source
)
40 while (source
->buffer
[i
])
46 /*******************************************************************
47 This should be moved in a more generic lib.
48 ********************************************************************/
50 static BOOL
spoolss_io_system_time(char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
52 if(!prs_uint16("year", ps
, depth
, &(systime
->year
)))
54 if(!prs_uint16("month", ps
, depth
, &(systime
->month
)))
56 if(!prs_uint16("dayofweek", ps
, depth
, &(systime
->dayofweek
)))
58 if(!prs_uint16("day", ps
, depth
, &(systime
->day
)))
60 if(!prs_uint16("hour", ps
, depth
, &(systime
->hour
)))
62 if(!prs_uint16("minute", ps
, depth
, &(systime
->minute
)))
64 if(!prs_uint16("second", ps
, depth
, &(systime
->second
)))
66 if(!prs_uint16("milliseconds", ps
, depth
, &(systime
->milliseconds
)))
72 /*******************************************************************
73 ********************************************************************/
75 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
77 systime
->year
=unixtime
->tm_year
+1900;
78 systime
->month
=unixtime
->tm_mon
+1;
79 systime
->dayofweek
=unixtime
->tm_wday
;
80 systime
->day
=unixtime
->tm_mday
;
81 systime
->hour
=unixtime
->tm_hour
;
82 systime
->minute
=unixtime
->tm_min
;
83 systime
->second
=unixtime
->tm_sec
;
84 systime
->milliseconds
=0;
89 /*******************************************************************
90 reads or writes an DOC_INFO structure.
91 ********************************************************************/
93 static BOOL
smb_io_doc_info_1(char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
95 if (info_1
== NULL
) return False
;
97 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
103 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
105 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
107 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
110 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
112 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
114 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
120 /*******************************************************************
121 reads or writes an DOC_INFO structure.
122 ********************************************************************/
124 static BOOL
smb_io_doc_info(char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
126 uint32 useless_ptr
=0;
128 if (info
== NULL
) return False
;
130 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
136 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
139 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
142 switch (info
->switch_value
)
145 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
150 this is just a placeholder
152 MSDN July 1998 says doc_info_2 is only on
153 Windows 95, and as Win95 doesn't do RPC to print
154 this case is nearly impossible
156 Maybe one day with Windows for dishwasher 2037 ...
159 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
162 DEBUG(0,("Something is obviously wrong somewhere !\n"));
169 /*******************************************************************
170 reads or writes an DOC_INFO_CONTAINER structure.
171 ********************************************************************/
173 static BOOL
smb_io_doc_info_container(char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
175 if (cont
== NULL
) return False
;
177 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
183 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
186 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
192 /*******************************************************************
193 reads or writes an NOTIFY OPTION TYPE structure.
194 ********************************************************************/
196 static BOOL
smb_io_notify_option_type(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
198 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
204 if(!prs_uint16("type", ps
, depth
, &type
->type
))
206 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
208 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
210 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
212 if(!prs_uint32("count", ps
, depth
, &type
->count
))
214 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
220 /*******************************************************************
221 reads or writes an NOTIFY OPTION TYPE DATA.
222 ********************************************************************/
224 static BOOL
smb_io_notify_option_type_data(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
228 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
231 /* if there are no fields just return */
232 if (type
->fields_ptr
==0)
238 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
241 if (type
->count2
!= type
->count
)
242 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
244 /* parse the option type data */
245 for(i
=0;i
<type
->count2
;i
++)
246 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
251 /*******************************************************************
252 reads or writes an NOTIFY OPTION structure.
253 ********************************************************************/
255 static BOOL
smb_io_notify_option_type_ctr(char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
259 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
262 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
266 if (UNMARSHALLING(ps
))
267 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)prs_alloc_mem(ps
,ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
270 /* the option type struct */
271 for(i
=0;i
<ctr
->count
;i
++)
272 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
275 /* the type associated with the option type struct */
276 for(i
=0;i
<ctr
->count
;i
++)
277 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
283 /*******************************************************************
284 reads or writes an NOTIFY OPTION structure.
285 ********************************************************************/
287 static BOOL
smb_io_notify_option(char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
289 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
292 if(!prs_uint32("version", ps
, depth
, &option
->version
))
294 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
296 if(!prs_uint32("count", ps
, depth
, &option
->count
))
298 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
301 /* marshalling or unmarshalling, that would work */
302 if (option
->option_type_ptr
!=0) {
303 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
307 option
->ctr
.type
=NULL
;
314 /*******************************************************************
315 reads or writes an NOTIFY INFO DATA structure.
316 ********************************************************************/
318 static BOOL
smb_io_notify_info_data(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
320 uint32 useless_ptr
=0xADDE0FF0;
322 uint32 how_many_words
;
326 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
329 how_many_words
=data
->size
;
330 if (how_many_words
==POINTER
) {
331 how_many_words
=TWO_VALUE
;
334 isvalue
=data
->enc_type
;
338 if(!prs_uint16("type", ps
, depth
, &data
->type
))
340 if(!prs_uint16("field", ps
, depth
, &data
->field
))
344 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
346 if(!prs_uint32("id", ps
, depth
, &data
->id
))
348 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
355 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
357 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
362 /* length in ascii including \0 */
363 x
=2*(data
->notify_data
.data
.length
+1);
364 if(!prs_uint32("string length", ps
, depth
, &x
))
366 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
374 /*******************************************************************
375 reads or writes an NOTIFY INFO DATA structure.
376 ********************************************************************/
378 BOOL
smb_io_notify_info_data_strings(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
379 prs_struct
*ps
, int depth
)
384 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
390 isvalue
=data
->enc_type
;
392 if (isvalue
==False
) {
393 /* length of string in unicode include \0 */
394 x
=data
->notify_data
.data
.length
+1;
395 if(!prs_uint32("string length", ps
, depth
, &x
))
397 if (MARSHALLING(ps
)) {
398 /* These are already in little endian format. Don't byte swap. */
401 /* No memory allocated for this string
402 therefore following the data.string
403 pointer is a bad idea. Use a pointer to
404 the uint32 length union member to
405 provide a source for a unicode NULL */
407 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
410 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
415 /* Tallocate memory for string */
417 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
418 if (!data
->notify_data
.data
.string
)
421 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
431 /*******************************************************************
432 reads or writes an NOTIFY INFO structure.
433 ********************************************************************/
435 static BOOL
smb_io_notify_info(char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
439 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
445 if(!prs_uint32("count", ps
, depth
, &info
->count
))
447 if(!prs_uint32("version", ps
, depth
, &info
->version
))
449 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
451 if(!prs_uint32("count", ps
, depth
, &info
->count
))
454 for (i
=0;i
<info
->count
;i
++) {
455 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
459 /* now do the strings at the end of the stream */
460 for (i
=0;i
<info
->count
;i
++) {
461 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
468 /*******************************************************************
469 ********************************************************************/
471 static BOOL
spool_io_user_level_1(char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
473 prs_debug(ps
, depth
, desc
, "");
477 if (UNMARSHALLING(ps
))
482 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
484 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
486 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
488 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
490 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
492 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
494 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
497 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
501 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
507 /*******************************************************************
508 ********************************************************************/
510 static BOOL
spool_io_user_level(char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
515 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
520 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
522 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
525 switch (q_u
->level
) {
527 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
537 /*******************************************************************
538 * read or write a DEVICEMODE struct.
539 * on reading allocate memory for the private member
540 ********************************************************************/
542 static BOOL
spoolss_io_devmode(char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
544 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
547 if (UNMARSHALLING(ps
)) {
548 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
549 if (devmode
->devicename
.buffer
== NULL
)
553 if (!prs_uint16uni(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, 32))
555 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
557 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
559 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
561 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
563 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
565 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
567 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
569 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
571 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
573 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
575 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
577 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
579 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
581 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
583 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
585 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
587 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
589 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
592 if (UNMARSHALLING(ps
)) {
593 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
594 if (devmode
->formname
.buffer
== NULL
)
598 if (!prs_uint16uni(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
600 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
602 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
604 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
606 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
608 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
610 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
612 if (!prs_uint32("icmmethod", ps
, depth
, &devmode
->icmmethod
))
614 if (!prs_uint32("icmintent", ps
, depth
, &devmode
->icmintent
))
616 if (!prs_uint32("mediatype", ps
, depth
, &devmode
->mediatype
))
618 if (!prs_uint32("dithertype", ps
, depth
, &devmode
->dithertype
))
620 if (!prs_uint32("reserved1", ps
, depth
, &devmode
->reserved1
))
622 if (!prs_uint32("reserved2", ps
, depth
, &devmode
->reserved2
))
624 if (!prs_uint32("panningwidth", ps
, depth
, &devmode
->panningwidth
))
626 if (!prs_uint32("panningheight", ps
, depth
, &devmode
->panningheight
))
629 if (devmode
->driverextra
!=0) {
630 if (UNMARSHALLING(ps
)) {
631 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
632 if(devmode
->private == NULL
)
634 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
637 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
638 if (!prs_uint8s(True
, "private", ps
, depth
, devmode
->private, devmode
->driverextra
))
645 /*******************************************************************
646 Read or write a DEVICEMODE container
647 ********************************************************************/
649 static BOOL
spoolss_io_devmode_cont(char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
654 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
660 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
663 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
666 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
667 if (UNMARSHALLING(ps
))
668 /* if while reading there is no DEVMODE ... */
673 /* so we have a DEVICEMODE to follow */
674 if (UNMARSHALLING(ps
)) {
675 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
676 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
677 if(dm_c
->devmode
== NULL
)
681 /* this is bad code, shouldn't be there */
682 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
685 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
691 /*******************************************************************
692 ********************************************************************/
694 static BOOL
spoolss_io_printer_default(char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
699 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
702 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
705 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
711 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
714 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
720 /*******************************************************************
722 ********************************************************************/
724 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
725 const fstring printername
,
726 const fstring datatype
,
727 uint32 access_required
,
728 const fstring clientname
,
729 const fstring user_name
)
731 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
732 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
733 init_unistr2(&q_u
->printername
, printername
, strlen(printername
)+1);
735 q_u
->printer_default
.datatype_ptr
= 0;
737 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
738 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
740 q_u
->printer_default
.devmode_cont
.size
=0;
741 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
742 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
743 q_u
->printer_default
.access_required
=access_required
;
745 q_u
->user_ctr
.level
=1;
747 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
748 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
749 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
750 q_u
->user_ctr
.user1
.build
=1381;
751 q_u
->user_ctr
.user1
.major
=2;
752 q_u
->user_ctr
.user1
.minor
=0;
753 q_u
->user_ctr
.user1
.processor
=0;
754 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
755 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
760 /*******************************************************************
762 ********************************************************************/
763 BOOL
make_spoolss_q_addprinterex(
764 SPOOL_Q_ADDPRINTEREX
*q_u
,
765 const char *srv_name
,
766 const char* clientname
,
767 const char* user_name
,
769 PRINTER_INFO_CTR
*ctr
)
771 DEBUG(5,("make_spoolss_q_addprinterex\n"));
773 if (!ctr
) return False
;
775 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
776 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
));
780 q_u
->info
.level
= level
;
781 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
785 /* init q_u->info.info2 from *info */
786 if (!make_spoolss_printer_info_2(&q_u
->info
.info_2
, ctr
->printers_2
))
788 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
796 q_u
->unk0
= q_u
->unk1
= q_u
->unk2
= q_u
->unk3
= 0;
800 q_u
->user_ctr
.level
=1;
802 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
803 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
804 q_u
->user_ctr
.user1
.build
=1381;
805 q_u
->user_ctr
.user1
.major
=2;
806 q_u
->user_ctr
.user1
.minor
=0;
807 q_u
->user_ctr
.user1
.processor
=0;
808 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
809 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
810 q_u
->user_ctr
.user1
.size
=q_u
->user_ctr
.user1
.user_name
.uni_str_len
+
811 q_u
->user_ctr
.user1
.client_name
.uni_str_len
+ 2;
816 /*******************************************************************
817 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
818 *******************************************************************/
820 BOOL
make_spoolss_printer_info_2(
821 SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
826 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
828 /* allocate the necessary memory */
829 inf
= (SPOOL_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_2
));
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 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
913 * called from spoolss_open_printer_ex (cli_spoolss.c)
914 ********************************************************************/
916 BOOL
spoolss_io_r_open_printer_ex(char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
918 if (r_u
== NULL
) return False
;
920 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
926 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
929 if (!prs_uint32("status code", ps
, depth
, &(r_u
->status
)))
935 /*******************************************************************
937 ********************************************************************/
939 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
940 const POLICY_HND
*handle
,
941 UNISTR2
*valuename
, uint32 size
)
943 if (q_u
== NULL
) return False
;
945 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
947 q_u
->handle
= *handle
;
948 copy_unistr2(&q_u
->valuename
, valuename
);
954 /*******************************************************************
956 * called from spoolss_q_getprinterdata (srv_spoolss.c)
957 ********************************************************************/
959 BOOL
spoolss_io_q_getprinterdata(char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
964 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
969 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
973 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
977 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
983 /*******************************************************************
985 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
986 ********************************************************************/
988 BOOL
spoolss_io_q_deleteprinterdata(char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
993 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
998 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1002 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1008 /*******************************************************************
1009 * write a structure.
1010 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1011 ********************************************************************/
1013 BOOL
spoolss_io_r_deleteprinterdata(char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1015 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1017 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1023 /*******************************************************************
1024 * write a structure.
1025 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1026 ********************************************************************/
1028 BOOL
spoolss_io_r_getprinterdata(char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1033 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1038 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1040 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1043 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
1049 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1051 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1057 /*******************************************************************
1059 ********************************************************************/
1061 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1063 if (q_u
== NULL
) return False
;
1065 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1067 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1072 /*******************************************************************
1074 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1075 * called from spoolss_abortprinter (cli_spoolss.c)
1076 ********************************************************************/
1078 BOOL
spoolss_io_q_abortprinter(char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1080 if (q_u
== NULL
) return False
;
1082 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1088 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1094 /*******************************************************************
1095 * write a structure.
1096 * called from spoolss_r_abortprinter (srv_spoolss.c)
1097 ********************************************************************/
1099 BOOL
spoolss_io_r_abortprinter(char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1101 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1103 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1109 /*******************************************************************
1111 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1112 * called from spoolss_deleteprinter (cli_spoolss.c)
1113 ********************************************************************/
1115 BOOL
spoolss_io_q_deleteprinter(char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1117 if (q_u
== NULL
) return False
;
1119 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1125 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1131 /*******************************************************************
1132 * write a structure.
1133 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1134 * called from spoolss_deleteprinter (cli_spoolss.c)
1135 ********************************************************************/
1137 BOOL
spoolss_io_r_deleteprinter(char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1139 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1145 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1147 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1153 /*******************************************************************
1155 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1156 * called from spoolss_closeprinter (cli_spoolss.c)
1157 ********************************************************************/
1159 BOOL
spoolss_io_q_closeprinter(char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1161 if (q_u
== NULL
) return False
;
1163 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1169 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1175 /*******************************************************************
1176 * write a structure.
1177 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1178 * called from spoolss_closeprinter (cli_spoolss.c)
1179 ********************************************************************/
1181 BOOL
spoolss_io_r_closeprinter(char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1183 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1189 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1191 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1197 /*******************************************************************
1199 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1200 ********************************************************************/
1202 BOOL
spoolss_io_q_startdocprinter(char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1204 if (q_u
== NULL
) return False
;
1206 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1212 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1215 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1221 /*******************************************************************
1222 * write a structure.
1223 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1224 ********************************************************************/
1226 BOOL
spoolss_io_r_startdocprinter(char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1228 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1230 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1232 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1238 /*******************************************************************
1240 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1241 ********************************************************************/
1243 BOOL
spoolss_io_q_enddocprinter(char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1245 if (q_u
== NULL
) return False
;
1247 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1253 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1259 /*******************************************************************
1260 * write a structure.
1261 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1262 ********************************************************************/
1264 BOOL
spoolss_io_r_enddocprinter(char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1266 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1268 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1274 /*******************************************************************
1276 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1277 ********************************************************************/
1279 BOOL
spoolss_io_q_startpageprinter(char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1281 if (q_u
== NULL
) return False
;
1283 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1289 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1295 /*******************************************************************
1296 * write a structure.
1297 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1298 ********************************************************************/
1300 BOOL
spoolss_io_r_startpageprinter(char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1302 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1304 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1310 /*******************************************************************
1312 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1313 ********************************************************************/
1315 BOOL
spoolss_io_q_endpageprinter(char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1317 if (q_u
== NULL
) return False
;
1319 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1325 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1331 /*******************************************************************
1332 * write a structure.
1333 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1334 ********************************************************************/
1336 BOOL
spoolss_io_r_endpageprinter(char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1338 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1340 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1346 /*******************************************************************
1348 * called from spoolss_q_writeprinter (srv_spoolss.c)
1349 ********************************************************************/
1351 BOOL
spoolss_io_q_writeprinter(char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1353 if (q_u
== NULL
) return False
;
1355 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1361 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1363 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1366 if (q_u
->buffer_size
!=0)
1368 if (UNMARSHALLING(ps
))
1369 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1370 if(q_u
->buffer
== NULL
)
1372 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1377 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1383 /*******************************************************************
1384 * write a structure.
1385 * called from spoolss_r_writeprinter (srv_spoolss.c)
1386 ********************************************************************/
1388 BOOL
spoolss_io_r_writeprinter(char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1390 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1392 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1394 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1400 /*******************************************************************
1402 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1403 ********************************************************************/
1405 BOOL
spoolss_io_q_rffpcnex(char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1407 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1413 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1415 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1417 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1419 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1421 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1427 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1430 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1433 if (q_u
->option_ptr
!=0) {
1435 if (UNMARSHALLING(ps
))
1436 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1439 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1446 /*******************************************************************
1447 * write a structure.
1448 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1449 ********************************************************************/
1451 BOOL
spoolss_io_r_rffpcnex(char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1453 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1456 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1462 /*******************************************************************
1464 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1465 ********************************************************************/
1467 BOOL
spoolss_io_q_rfnpcnex(char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1469 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1475 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1478 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1481 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1484 if (q_u
->option_ptr
!=0) {
1486 if (UNMARSHALLING(ps
))
1487 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1490 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1497 /*******************************************************************
1498 * write a structure.
1499 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1500 ********************************************************************/
1502 BOOL
spoolss_io_r_rfnpcnex(char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1504 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1510 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1513 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1518 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1524 /*******************************************************************
1525 * return the length of a uint16 (obvious, but the code is clean)
1526 ********************************************************************/
1528 static uint32
size_of_uint16(uint16
*value
)
1530 return (sizeof(*value
));
1533 /*******************************************************************
1534 * return the length of a uint32 (obvious, but the code is clean)
1535 ********************************************************************/
1537 static uint32
size_of_uint32(uint32
*value
)
1539 return (sizeof(*value
));
1542 /*******************************************************************
1543 * return the length of a NTTIME (obvious, but the code is clean)
1544 ********************************************************************/
1546 static uint32
size_of_nttime(NTTIME
*value
)
1548 return (sizeof(*value
));
1551 /*******************************************************************
1552 * return the length of a UNICODE string in number of char, includes:
1553 * - the leading zero
1554 * - the relative pointer size
1555 ********************************************************************/
1557 static uint32
size_of_relative_string(UNISTR
*string
)
1561 size
=str_len_uni(string
); /* the string length */
1562 size
=size
+1; /* add the leading zero */
1563 size
=size
*2; /* convert in char */
1564 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1565 size
+= ((4 - (size
& 3)) & 3);
1566 size
=size
+4; /* add the size of the ptr */
1571 /*******************************************************************
1572 * return the length of a uint32 (obvious, but the code is clean)
1573 ********************************************************************/
1575 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1580 return (4+devmode
->size
+devmode
->driverextra
);
1583 /*******************************************************************
1584 * return the length of a uint32 (obvious, but the code is clean)
1585 ********************************************************************/
1587 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1592 return (sizeof(SYSTEMTIME
) +4);
1595 /*******************************************************************
1596 * write a UNICODE string.
1597 * used by all the RPC structs passing a buffer
1598 ********************************************************************/
1600 static BOOL
spoolss_smb_io_unistr(char *desc
, UNISTR
*uni
, prs_struct
*ps
, int depth
)
1605 prs_debug(ps
, depth
, desc
, "spoolss_smb_io_unistr");
1608 /* there should be no align here as it can mess up
1609 parsing a NEW_BUFFER->prs */
1615 if (!prs_unistr("unistr", ps
, depth
, uni
))
1621 /*******************************************************************
1622 * write a UNICODE string and its relative pointer.
1623 * used by all the RPC structs passing a buffer
1625 * As I'm a nice guy, I'm forcing myself to explain this code.
1626 * MS did a good job in the overall spoolss code except in some
1627 * functions where they are passing the API buffer directly in the
1628 * RPC request/reply. That's to maintain compatiility at the API level.
1629 * They could have done it the good way the first time.
1631 * So what happen is: the strings are written at the buffer's end,
1632 * in the reverse order of the original structure. Some pointers to
1633 * the strings are also in the buffer. Those are relative to the
1636 * If you don't understand or want to change that function,
1637 * first get in touch with me: jfm@samba.org
1639 ********************************************************************/
1641 static BOOL
smb_io_relstr(char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
1643 prs_struct
*ps
=&buffer
->prs
;
1645 if (MARSHALLING(ps
)) {
1646 uint32 struct_offset
= prs_offset(ps
);
1647 uint32 relative_offset
;
1649 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
1650 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1654 buffer
->string_at_end
= prs_offset(ps
);
1656 /* write the string */
1657 if (!smb_io_unistr(desc
, string
, ps
, depth
))
1660 if(!prs_set_offset(ps
, struct_offset
))
1663 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1664 /* write its offset */
1665 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1671 /* read the offset */
1672 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
1675 old_offset
= prs_offset(ps
);
1676 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
1679 /* read the string */
1680 if (!spoolss_smb_io_unistr(desc
, string
, ps
, depth
))
1683 if(!prs_set_offset(ps
, old_offset
))
1689 /*******************************************************************
1690 * write a array of UNICODE strings and its relative pointer.
1691 * used by 2 RPC structs
1692 ********************************************************************/
1694 static BOOL
smb_io_relarraystr(char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
1698 prs_struct
*ps
=&buffer
->prs
;
1700 if (MARSHALLING(ps
)) {
1701 uint32 struct_offset
= prs_offset(ps
);
1702 uint32 relative_offset
;
1709 /* first write the last 0 */
1710 buffer
->string_at_end
-= 2;
1711 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1714 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
1717 while (p
&& (*p
!=0)) {
1721 /* Yes this should be malloc not talloc. Don't change. */
1723 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
1724 if (chaine
.buffer
== NULL
)
1727 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
1729 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
1731 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
1732 free(chaine
.buffer
);
1736 /* write the string */
1737 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
1738 free(chaine
.buffer
);
1744 free(chaine
.buffer
);
1747 if(!prs_set_offset(ps
, struct_offset
))
1750 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1751 /* write its offset */
1752 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1760 uint16
*chaine2
=NULL
;
1763 size_t realloc_size
= 0;
1767 /* read the offset */
1768 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1771 old_offset
= prs_offset(ps
);
1772 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1776 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
))
1779 l_chaine
=str_len_uni(&chaine
);
1781 /* we're going to add two more bytes here in case this
1782 is the last string in the array and we need to add
1783 an extra NULL for termination */
1786 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
1788 /* Yes this should be realloc - it's freed below. JRA */
1790 if((chaine2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
)
1792 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
1793 l_chaine2
+=l_chaine
+1;
1796 } while(l_chaine
!=0);
1798 /* the end should be bould NULL terminated so add
1799 the second one here */
1802 chaine2
[l_chaine2
] = '\0';
1803 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
1807 if(!prs_set_offset(ps
, old_offset
))
1813 /*******************************************************************
1814 Parse a DEVMODE structure and its relative pointer.
1815 ********************************************************************/
1817 static BOOL
smb_io_relsecdesc(char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
1819 prs_struct
*ps
= &buffer
->prs
;
1821 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
1824 if (MARSHALLING(ps
)) {
1825 uint32 struct_offset
= prs_offset(ps
);
1826 uint32 relative_offset
;
1829 relative_offset
= 0;
1830 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1835 if (*secdesc
!= NULL
) {
1836 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
1838 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1840 /* write the secdesc */
1841 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1844 if(!prs_set_offset(ps
, struct_offset
))
1848 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1849 /* write its offset */
1851 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1856 /* read the offset */
1857 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1860 old_offset
= prs_offset(ps
);
1861 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1865 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1868 if(!prs_set_offset(ps
, old_offset
))
1874 /*******************************************************************
1875 Parse a DEVMODE structure and its relative pointer.
1876 ********************************************************************/
1878 static BOOL
smb_io_reldevmode(char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
1880 prs_struct
*ps
=&buffer
->prs
;
1882 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
1885 if (MARSHALLING(ps
)) {
1886 uint32 struct_offset
= prs_offset(ps
);
1887 uint32 relative_offset
;
1889 if (*devmode
== NULL
) {
1891 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1893 DEBUG(8, ("boing, the devmode was NULL\n"));
1898 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
1900 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1903 /* write the DEVMODE */
1904 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1907 if(!prs_set_offset(ps
, struct_offset
))
1910 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1911 /* write its offset */
1912 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1918 /* read the offset */
1919 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1922 old_offset
= prs_offset(ps
);
1923 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1926 /* read the string */
1927 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
1929 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1932 if(!prs_set_offset(ps
, old_offset
))
1938 /*******************************************************************
1939 Parse a PRINTER_INFO_0 structure.
1940 ********************************************************************/
1942 BOOL
smb_io_printer_info_0(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
1944 prs_struct
*ps
=&buffer
->prs
;
1946 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
1949 buffer
->struct_start
=prs_offset(ps
);
1951 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1953 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
1956 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
1958 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
1960 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
1963 if(!prs_uint16("year", ps
, depth
, &info
->year
))
1965 if(!prs_uint16("month", ps
, depth
, &info
->month
))
1967 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
1969 if(!prs_uint16("day", ps
, depth
, &info
->day
))
1971 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
1973 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
1975 if(!prs_uint16("second", ps
, depth
, &info
->second
))
1977 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
1980 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
1982 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
1985 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
1987 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
1989 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
1991 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
1993 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
1995 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
1997 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
1999 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2001 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2003 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2005 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2007 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2009 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2011 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2013 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2015 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2017 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2019 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2021 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2023 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2025 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2027 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2029 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2031 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2033 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2039 /*******************************************************************
2040 Parse a PRINTER_INFO_1 structure.
2041 ********************************************************************/
2043 BOOL
smb_io_printer_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2045 prs_struct
*ps
=&buffer
->prs
;
2047 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2050 buffer
->struct_start
=prs_offset(ps
);
2052 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2054 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2056 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2058 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2064 /*******************************************************************
2065 Parse a PRINTER_INFO_2 structure.
2066 ********************************************************************/
2068 BOOL
smb_io_printer_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2070 prs_struct
*ps
=&buffer
->prs
;
2072 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2075 buffer
->struct_start
=prs_offset(ps
);
2077 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2079 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2081 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2083 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2085 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2087 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2089 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2092 /* NT parses the DEVMODE at the end of the struct */
2093 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2096 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2098 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2100 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2102 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2105 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2108 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2110 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2112 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2114 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2116 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2118 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2120 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2122 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2126 if (!prs_uint32_post("secdesc_ptr", ps
, depth
, NULL
, sec_offset
, info
->secdesc
? prs_offset(ps
)-buffer
->struct_start
: 0 ))
2129 if (!sec_io_desc("secdesc", &info
->secdesc
, ps
, depth
))
2135 /*******************************************************************
2136 Parse a PRINTER_INFO_3 structure.
2137 ********************************************************************/
2139 BOOL
smb_io_printer_info_3(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2141 prs_struct
*ps
=&buffer
->prs
;
2143 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2146 buffer
->struct_start
=prs_offset(ps
);
2148 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2150 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2156 /*******************************************************************
2157 Parse a PORT_INFO_1 structure.
2158 ********************************************************************/
2160 BOOL
smb_io_port_info_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2162 prs_struct
*ps
=&buffer
->prs
;
2164 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2167 buffer
->struct_start
=prs_offset(ps
);
2169 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2175 /*******************************************************************
2176 Parse a PORT_INFO_2 structure.
2177 ********************************************************************/
2179 BOOL
smb_io_port_info_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2181 prs_struct
*ps
=&buffer
->prs
;
2183 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2186 buffer
->struct_start
=prs_offset(ps
);
2188 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2190 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2192 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2194 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2196 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2202 /*******************************************************************
2203 Parse a DRIVER_INFO_1 structure.
2204 ********************************************************************/
2206 BOOL
smb_io_printer_driver_info_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2208 prs_struct
*ps
=&buffer
->prs
;
2210 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2213 buffer
->struct_start
=prs_offset(ps
);
2215 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2221 /*******************************************************************
2222 Parse a DRIVER_INFO_2 structure.
2223 ********************************************************************/
2225 BOOL
smb_io_printer_driver_info_2(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2227 prs_struct
*ps
=&buffer
->prs
;
2229 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2232 buffer
->struct_start
=prs_offset(ps
);
2234 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2236 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2238 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2240 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2242 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2244 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2250 /*******************************************************************
2251 Parse a DRIVER_INFO_3 structure.
2252 ********************************************************************/
2254 BOOL
smb_io_printer_driver_info_3(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2256 prs_struct
*ps
=&buffer
->prs
;
2258 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2261 buffer
->struct_start
=prs_offset(ps
);
2263 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2265 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2267 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2269 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2271 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2273 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2275 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2278 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2281 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2283 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2289 /*******************************************************************
2290 Parse a DRIVER_INFO_6 structure.
2291 ********************************************************************/
2293 BOOL
smb_io_printer_driver_info_6(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2295 prs_struct
*ps
=&buffer
->prs
;
2297 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2300 buffer
->struct_start
=prs_offset(ps
);
2302 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2304 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2306 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2308 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2310 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2312 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2314 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2317 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2320 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2322 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2325 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2328 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2330 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2333 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2336 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2339 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2342 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2344 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2346 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2348 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2354 /*******************************************************************
2355 Parse a JOB_INFO_1 structure.
2356 ********************************************************************/
2358 BOOL
smb_io_job_info_1(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2360 prs_struct
*ps
=&buffer
->prs
;
2362 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2365 buffer
->struct_start
=prs_offset(ps
);
2367 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2369 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2371 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2373 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2375 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2377 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2379 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2381 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2383 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2385 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2387 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2389 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2391 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2397 /*******************************************************************
2398 Parse a JOB_INFO_2 structure.
2399 ********************************************************************/
2401 BOOL
smb_io_job_info_2(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2404 prs_struct
*ps
=&buffer
->prs
;
2406 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2409 buffer
->struct_start
=prs_offset(ps
);
2411 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2413 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2415 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2417 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2419 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2421 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2423 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2426 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2428 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2430 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2432 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2434 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2437 /* SEC_DESC sec_desc;*/
2438 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2441 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2443 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2445 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2447 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2449 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2451 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2453 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2455 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2457 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2459 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2465 /*******************************************************************
2466 ********************************************************************/
2468 BOOL
smb_io_form_1(char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2470 prs_struct
*ps
=&buffer
->prs
;
2472 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
2475 buffer
->struct_start
=prs_offset(ps
);
2477 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2480 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2483 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2485 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2487 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2489 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2491 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2493 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2499 /*******************************************************************
2500 Read/write a BUFFER struct.
2501 ********************************************************************/
2503 static BOOL
spoolss_io_buffer(char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
2505 NEW_BUFFER
*buffer
= *pp_buffer
;
2507 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
2510 if (UNMARSHALLING(ps
))
2511 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
2516 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2520 if (UNMARSHALLING(ps
)) {
2522 buffer
->string_at_end
=0;
2524 if (buffer
->ptr
==0) {
2526 * JRA. I'm not sure if the data in here is in big-endian format if
2527 * the client is big-endian. Leave as default (little endian) for now.
2530 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
2535 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2539 * JRA. I'm not sure if the data in here is in big-endian format if
2540 * the client is big-endian. Leave as default (little endian) for now.
2543 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
2546 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
2549 if (!prs_set_offset(&buffer
->prs
, 0))
2552 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
2555 buffer
->string_at_end
=buffer
->size
;
2563 if (buffer
->ptr
==0) {
2564 /* We have finished with the data in buffer->prs - free it. */
2565 prs_mem_free(&buffer
->prs
);
2569 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2572 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
2578 /* We have finished with the data in buffer->prs - free it. */
2579 prs_mem_free(&buffer
->prs
);
2585 /*******************************************************************
2586 move a BUFFER from the query to the reply.
2587 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2588 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2589 ********************************************************************/
2591 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
2593 prs_switch_type(&src
->prs
, MARSHALL
);
2594 if(!prs_set_offset(&src
->prs
, 0))
2596 prs_force_dynamic(&(src
->prs
));
2601 /*******************************************************************
2602 Get the size of a BUFFER struct.
2603 ********************************************************************/
2605 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
2607 return (buffer
->size
);
2610 /*******************************************************************
2611 Parse a DRIVER_DIRECTORY_1 structure.
2612 ********************************************************************/
2614 BOOL
smb_io_driverdir_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2616 prs_struct
*ps
=&buffer
->prs
;
2618 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
2621 buffer
->struct_start
=prs_offset(ps
);
2623 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2629 /*******************************************************************
2630 Parse a PORT_INFO_1 structure.
2631 ********************************************************************/
2633 BOOL
smb_io_port_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2635 prs_struct
*ps
=&buffer
->prs
;
2637 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
2640 buffer
->struct_start
=prs_offset(ps
);
2642 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2648 /*******************************************************************
2649 Parse a PORT_INFO_2 structure.
2650 ********************************************************************/
2652 BOOL
smb_io_port_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2654 prs_struct
*ps
=&buffer
->prs
;
2656 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
2659 buffer
->struct_start
=prs_offset(ps
);
2661 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2663 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2665 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2667 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2669 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2675 /*******************************************************************
2676 ********************************************************************/
2678 BOOL
smb_io_printprocessor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2680 prs_struct
*ps
=&buffer
->prs
;
2682 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2685 buffer
->struct_start
=prs_offset(ps
);
2687 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2693 /*******************************************************************
2694 ********************************************************************/
2696 BOOL
smb_io_printprocdatatype_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2698 prs_struct
*ps
=&buffer
->prs
;
2700 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2703 buffer
->struct_start
=prs_offset(ps
);
2705 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2711 /*******************************************************************
2712 ********************************************************************/
2714 BOOL
smb_io_printmonitor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2716 prs_struct
*ps
=&buffer
->prs
;
2718 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2721 buffer
->struct_start
=prs_offset(ps
);
2723 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2729 /*******************************************************************
2730 ********************************************************************/
2732 BOOL
smb_io_printmonitor_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
2734 prs_struct
*ps
=&buffer
->prs
;
2736 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
2739 buffer
->struct_start
=prs_offset(ps
);
2741 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2743 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
2745 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
2751 /*******************************************************************
2752 return the size required by a struct in the stream
2753 ********************************************************************/
2755 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
2759 size
+=size_of_relative_string( &info
->printername
);
2760 size
+=size_of_relative_string( &info
->servername
);
2762 size
+=size_of_uint32( &info
->cjobs
);
2763 size
+=size_of_uint32( &info
->total_jobs
);
2764 size
+=size_of_uint32( &info
->total_bytes
);
2766 size
+=size_of_uint16( &info
->year
);
2767 size
+=size_of_uint16( &info
->month
);
2768 size
+=size_of_uint16( &info
->dayofweek
);
2769 size
+=size_of_uint16( &info
->day
);
2770 size
+=size_of_uint16( &info
->hour
);
2771 size
+=size_of_uint16( &info
->minute
);
2772 size
+=size_of_uint16( &info
->second
);
2773 size
+=size_of_uint16( &info
->milliseconds
);
2775 size
+=size_of_uint32( &info
->global_counter
);
2776 size
+=size_of_uint32( &info
->total_pages
);
2778 size
+=size_of_uint16( &info
->major_version
);
2779 size
+=size_of_uint16( &info
->build_version
);
2781 size
+=size_of_uint32( &info
->unknown7
);
2782 size
+=size_of_uint32( &info
->unknown8
);
2783 size
+=size_of_uint32( &info
->unknown9
);
2784 size
+=size_of_uint32( &info
->session_counter
);
2785 size
+=size_of_uint32( &info
->unknown11
);
2786 size
+=size_of_uint32( &info
->printer_errors
);
2787 size
+=size_of_uint32( &info
->unknown13
);
2788 size
+=size_of_uint32( &info
->unknown14
);
2789 size
+=size_of_uint32( &info
->unknown15
);
2790 size
+=size_of_uint32( &info
->unknown16
);
2791 size
+=size_of_uint32( &info
->change_id
);
2792 size
+=size_of_uint32( &info
->unknown18
);
2793 size
+=size_of_uint32( &info
->status
);
2794 size
+=size_of_uint32( &info
->unknown20
);
2795 size
+=size_of_uint32( &info
->c_setprinter
);
2797 size
+=size_of_uint16( &info
->unknown22
);
2798 size
+=size_of_uint16( &info
->unknown23
);
2799 size
+=size_of_uint16( &info
->unknown24
);
2800 size
+=size_of_uint16( &info
->unknown25
);
2801 size
+=size_of_uint16( &info
->unknown26
);
2802 size
+=size_of_uint16( &info
->unknown27
);
2803 size
+=size_of_uint16( &info
->unknown28
);
2804 size
+=size_of_uint16( &info
->unknown29
);
2809 /*******************************************************************
2810 return the size required by a struct in the stream
2811 ********************************************************************/
2813 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
2817 size
+=size_of_uint32( &info
->flags
);
2818 size
+=size_of_relative_string( &info
->description
);
2819 size
+=size_of_relative_string( &info
->name
);
2820 size
+=size_of_relative_string( &info
->comment
);
2825 /*******************************************************************
2826 return the size required by a struct in the stream
2827 ********************************************************************/
2829 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
2834 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2835 size
+= sec_desc_size( info
->secdesc
);
2837 size
+=size_of_device_mode( info
->devmode
);
2839 size
+=size_of_relative_string( &info
->servername
);
2840 size
+=size_of_relative_string( &info
->printername
);
2841 size
+=size_of_relative_string( &info
->sharename
);
2842 size
+=size_of_relative_string( &info
->portname
);
2843 size
+=size_of_relative_string( &info
->drivername
);
2844 size
+=size_of_relative_string( &info
->comment
);
2845 size
+=size_of_relative_string( &info
->location
);
2847 size
+=size_of_relative_string( &info
->sepfile
);
2848 size
+=size_of_relative_string( &info
->printprocessor
);
2849 size
+=size_of_relative_string( &info
->datatype
);
2850 size
+=size_of_relative_string( &info
->parameters
);
2852 size
+=size_of_uint32( &info
->attributes
);
2853 size
+=size_of_uint32( &info
->priority
);
2854 size
+=size_of_uint32( &info
->defaultpriority
);
2855 size
+=size_of_uint32( &info
->starttime
);
2856 size
+=size_of_uint32( &info
->untiltime
);
2857 size
+=size_of_uint32( &info
->status
);
2858 size
+=size_of_uint32( &info
->cjobs
);
2859 size
+=size_of_uint32( &info
->averageppm
);
2863 /*******************************************************************
2864 return the size required by a struct in the stream
2865 ********************************************************************/
2867 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
2869 /* The 4 is for the self relative pointer.. */
2870 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2871 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
2874 /*******************************************************************
2875 return the size required by a struct in the stream
2876 ********************************************************************/
2878 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
2881 size
+=size_of_relative_string( &info
->name
);
2886 /*******************************************************************
2887 return the size required by a struct in the stream
2888 ********************************************************************/
2890 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
2893 size
+=size_of_uint32( &info
->version
);
2894 size
+=size_of_relative_string( &info
->name
);
2895 size
+=size_of_relative_string( &info
->architecture
);
2896 size
+=size_of_relative_string( &info
->driverpath
);
2897 size
+=size_of_relative_string( &info
->datafile
);
2898 size
+=size_of_relative_string( &info
->configfile
);
2903 /*******************************************************************
2904 return the size required by a string array.
2905 ********************************************************************/
2907 uint32
spoolss_size_string_array(uint16
*string
)
2912 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
2914 i
=i
+2; /* to count all chars including the leading zero */
2915 i
=2*i
; /* because we need the value in bytes */
2916 i
=i
+4; /* the offset pointer size */
2921 /*******************************************************************
2922 return the size required by a struct in the stream
2923 ********************************************************************/
2925 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
2929 size
+=size_of_uint32( &info
->version
);
2930 size
+=size_of_relative_string( &info
->name
);
2931 size
+=size_of_relative_string( &info
->architecture
);
2932 size
+=size_of_relative_string( &info
->driverpath
);
2933 size
+=size_of_relative_string( &info
->datafile
);
2934 size
+=size_of_relative_string( &info
->configfile
);
2935 size
+=size_of_relative_string( &info
->helpfile
);
2936 size
+=size_of_relative_string( &info
->monitorname
);
2937 size
+=size_of_relative_string( &info
->defaultdatatype
);
2939 size
+=spoolss_size_string_array(info
->dependentfiles
);
2944 /*******************************************************************
2945 return the size required by a struct in the stream
2946 ********************************************************************/
2948 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
2952 size
+=size_of_uint32( &info
->version
);
2953 size
+=size_of_relative_string( &info
->name
);
2954 size
+=size_of_relative_string( &info
->architecture
);
2955 size
+=size_of_relative_string( &info
->driverpath
);
2956 size
+=size_of_relative_string( &info
->datafile
);
2957 size
+=size_of_relative_string( &info
->configfile
);
2958 size
+=size_of_relative_string( &info
->helpfile
);
2960 size
+=spoolss_size_string_array(info
->dependentfiles
);
2962 size
+=size_of_relative_string( &info
->monitorname
);
2963 size
+=size_of_relative_string( &info
->defaultdatatype
);
2965 size
+=spoolss_size_string_array(info
->previousdrivernames
);
2967 size
+=size_of_nttime(&info
->driver_date
);
2968 size
+=size_of_uint32( &info
->padding
);
2969 size
+=size_of_uint32( &info
->driver_version_low
);
2970 size
+=size_of_uint32( &info
->driver_version_high
);
2971 size
+=size_of_relative_string( &info
->mfgname
);
2972 size
+=size_of_relative_string( &info
->oem_url
);
2973 size
+=size_of_relative_string( &info
->hardware_id
);
2974 size
+=size_of_relative_string( &info
->provider
);
2979 /*******************************************************************
2980 return the size required by a struct in the stream
2981 ********************************************************************/
2983 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
2986 size
+=size_of_uint32( &info
->jobid
);
2987 size
+=size_of_relative_string( &info
->printername
);
2988 size
+=size_of_relative_string( &info
->machinename
);
2989 size
+=size_of_relative_string( &info
->username
);
2990 size
+=size_of_relative_string( &info
->document
);
2991 size
+=size_of_relative_string( &info
->datatype
);
2992 size
+=size_of_relative_string( &info
->text_status
);
2993 size
+=size_of_uint32( &info
->status
);
2994 size
+=size_of_uint32( &info
->priority
);
2995 size
+=size_of_uint32( &info
->position
);
2996 size
+=size_of_uint32( &info
->totalpages
);
2997 size
+=size_of_uint32( &info
->pagesprinted
);
2998 size
+=size_of_systemtime( &info
->submitted
);
3003 /*******************************************************************
3004 return the size required by a struct in the stream
3005 ********************************************************************/
3007 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3011 size
+=4; /* size of sec desc ptr */
3013 size
+=size_of_uint32( &info
->jobid
);
3014 size
+=size_of_relative_string( &info
->printername
);
3015 size
+=size_of_relative_string( &info
->machinename
);
3016 size
+=size_of_relative_string( &info
->username
);
3017 size
+=size_of_relative_string( &info
->document
);
3018 size
+=size_of_relative_string( &info
->notifyname
);
3019 size
+=size_of_relative_string( &info
->datatype
);
3020 size
+=size_of_relative_string( &info
->printprocessor
);
3021 size
+=size_of_relative_string( &info
->parameters
);
3022 size
+=size_of_relative_string( &info
->drivername
);
3023 size
+=size_of_device_mode( info
->devmode
);
3024 size
+=size_of_relative_string( &info
->text_status
);
3025 /* SEC_DESC sec_desc;*/
3026 size
+=size_of_uint32( &info
->status
);
3027 size
+=size_of_uint32( &info
->priority
);
3028 size
+=size_of_uint32( &info
->position
);
3029 size
+=size_of_uint32( &info
->starttime
);
3030 size
+=size_of_uint32( &info
->untiltime
);
3031 size
+=size_of_uint32( &info
->totalpages
);
3032 size
+=size_of_uint32( &info
->size
);
3033 size
+=size_of_systemtime( &info
->submitted
);
3034 size
+=size_of_uint32( &info
->timeelapsed
);
3035 size
+=size_of_uint32( &info
->pagesprinted
);
3040 /*******************************************************************
3041 return the size required by a struct in the stream
3042 ********************************************************************/
3044 uint32
spoolss_size_form_1(FORM_1
*info
)
3048 size
+=size_of_uint32( &info
->flag
);
3049 size
+=size_of_relative_string( &info
->name
);
3050 size
+=size_of_uint32( &info
->width
);
3051 size
+=size_of_uint32( &info
->length
);
3052 size
+=size_of_uint32( &info
->left
);
3053 size
+=size_of_uint32( &info
->top
);
3054 size
+=size_of_uint32( &info
->right
);
3055 size
+=size_of_uint32( &info
->bottom
);
3060 /*******************************************************************
3061 return the size required by a struct in the stream
3062 ********************************************************************/
3064 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3068 size
+=size_of_relative_string( &info
->port_name
);
3073 /*******************************************************************
3074 return the size required by a struct in the stream
3075 ********************************************************************/
3077 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3081 size
=str_len_uni(&info
->name
); /* the string length */
3082 size
=size
+1; /* add the leading zero */
3083 size
=size
*2; /* convert in char */
3088 /*******************************************************************
3089 return the size required by a struct in the stream
3090 ********************************************************************/
3092 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3096 size
+=size_of_relative_string( &info
->port_name
);
3097 size
+=size_of_relative_string( &info
->monitor_name
);
3098 size
+=size_of_relative_string( &info
->description
);
3100 size
+=size_of_uint32( &info
->port_type
);
3101 size
+=size_of_uint32( &info
->reserved
);
3106 /*******************************************************************
3107 return the size required by a struct in the stream
3108 ********************************************************************/
3110 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3113 size
+=size_of_relative_string( &info
->name
);
3118 /*******************************************************************
3119 return the size required by a struct in the stream
3120 ********************************************************************/
3122 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3125 size
+=size_of_relative_string( &info
->name
);
3130 /*******************************************************************
3131 return the size required by a struct in the stream
3132 ********************************************************************/
3134 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3137 size
+=size_of_relative_string( &info
->name
);
3142 /*******************************************************************
3143 return the size required by a struct in the stream
3144 ********************************************************************/
3146 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3149 size
+=size_of_relative_string( &info
->name
);
3150 size
+=size_of_relative_string( &info
->environment
);
3151 size
+=size_of_relative_string( &info
->dll_name
);
3156 /*******************************************************************
3158 ********************************************************************/
3160 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3161 const POLICY_HND
*hnd
,
3162 const fstring architecture
,
3163 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3164 NEW_BUFFER
*buffer
, uint32 offered
)
3169 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3171 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3174 q_u
->clientmajorversion
=clientmajor
;
3175 q_u
->clientminorversion
=clientminor
;
3178 q_u
->offered
=offered
;
3183 /*******************************************************************
3185 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3186 ********************************************************************/
3188 BOOL
spoolss_io_q_getprinterdriver2(char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3190 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3196 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3198 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3200 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3205 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3208 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3214 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3217 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3219 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3225 /*******************************************************************
3227 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3228 ********************************************************************/
3230 BOOL
spoolss_io_r_getprinterdriver2(char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3232 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3238 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3243 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3245 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3247 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3249 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3255 /*******************************************************************
3257 ********************************************************************/
3259 BOOL
make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS
*q_u
, uint32 flags
,
3260 fstring servername
, uint32 level
,
3261 NEW_BUFFER
*buffer
, uint32 offered
)
3265 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3266 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3270 q_u
->offered
=offered
;
3275 /*******************************************************************
3277 ********************************************************************/
3279 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3280 fstring servername
, uint32 level
,
3281 NEW_BUFFER
*buffer
, uint32 offered
)
3283 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3284 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3288 q_u
->offered
=offered
;
3293 /*******************************************************************
3295 * called from spoolss_enumprinters (srv_spoolss.c)
3296 ********************************************************************/
3298 BOOL
spoolss_io_q_enumprinters(char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3300 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3306 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3308 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3311 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3316 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3319 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3324 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3330 /*******************************************************************
3331 Parse a SPOOL_R_ENUMPRINTERS structure.
3332 ********************************************************************/
3334 BOOL
spoolss_io_r_enumprinters(char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3336 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3342 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3348 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3351 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3354 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3360 /*******************************************************************
3361 * write a structure.
3362 * called from spoolss_r_enum_printers (srv_spoolss.c)
3364 ********************************************************************/
3366 BOOL
spoolss_io_r_getprinter(char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3368 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3374 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3380 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3383 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3389 /*******************************************************************
3391 * called from spoolss_getprinter (srv_spoolss.c)
3392 ********************************************************************/
3394 BOOL
spoolss_io_q_getprinter(char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3396 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3402 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3404 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3407 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3412 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3418 /*******************************************************************
3420 ********************************************************************/
3422 BOOL
make_spoolss_q_getprinter(
3423 SPOOL_Q_GETPRINTER
*q_u
,
3424 const POLICY_HND
*hnd
,
3434 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3438 q_u
->offered
=offered
;
3443 /*******************************************************************
3445 ********************************************************************/
3446 BOOL
make_spoolss_q_setprinter(
3447 SPOOL_Q_SETPRINTER
*q_u
,
3448 const POLICY_HND
*hnd
,
3450 PRINTER_INFO_CTR
*info
,
3455 DEVICEMODE
*devmode
;
3462 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3465 q_u
->info
.level
= level
;
3466 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
3470 secdesc
= info
->printers_2
->secdesc
;
3471 devmode
= info
->printers_2
->devmode
;
3473 /* FIXMEE!! HACK ALERT!!! --jerry */
3474 info
->printers_2
->devmode
= NULL
;
3475 info
->printers_2
->secdesc
= NULL
;
3477 make_spoolss_printer_info_2 (&q_u
->info
.info_2
, info
->printers_2
);
3478 #if 0 /* JERRY TEST */
3479 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
3480 if (!q_u
->secdesc_ctr
)
3482 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
3483 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3484 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3485 q_u
->secdesc_ctr
->sec
= secdesc
;
3487 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
3488 q_u
->devmode_ctr
.size
= sizeof(DEVICEMODE
) + (3*sizeof(uint32
));
3489 q_u
->devmode_ctr
.devmode
= devmode
;
3491 q_u
->secdesc_ctr
= NULL
;
3493 q_u
->devmode_ctr
.devmode_ptr
= 0;
3494 q_u
->devmode_ctr
.size
= 0;
3495 q_u
->devmode_ctr
.devmode
= NULL
;
3499 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
3504 q_u
->command
= command
;
3510 /*******************************************************************
3511 ********************************************************************/
3513 BOOL
spoolss_io_r_setprinter(char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3515 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3521 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3527 /*******************************************************************
3528 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3529 ********************************************************************/
3531 BOOL
spoolss_io_q_setprinter(char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3533 uint32 ptr_sec_desc
= 0;
3535 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3541 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3543 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3546 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3549 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3556 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3561 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3567 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3572 /* Parse a NULL security descriptor. This should really
3573 happen inside the sec_io_desc_buf() function. */
3575 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3576 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
)) return False
;
3577 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
3581 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3587 /*******************************************************************
3588 ********************************************************************/
3590 BOOL
spoolss_io_r_fcpn(char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
3592 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
3598 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3604 /*******************************************************************
3605 ********************************************************************/
3607 BOOL
spoolss_io_q_fcpn(char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
3610 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
3616 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3623 /*******************************************************************
3624 ********************************************************************/
3626 BOOL
spoolss_io_r_addjob(char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
3628 prs_debug(ps
, depth
, desc
, "");
3634 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3640 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3643 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3649 /*******************************************************************
3650 ********************************************************************/
3652 BOOL
spoolss_io_q_addjob(char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
3654 prs_debug(ps
, depth
, desc
, "");
3660 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3662 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3665 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3671 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3677 /*******************************************************************
3678 ********************************************************************/
3680 BOOL
spoolss_io_r_enumjobs(char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
3682 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
3688 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3694 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3697 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3700 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3706 /*******************************************************************
3707 ********************************************************************/
3709 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
3720 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3721 q_u
->firstjob
= firstjob
;
3722 q_u
->numofjobs
= numofjobs
;
3724 q_u
->buffer
= buffer
;
3725 q_u
->offered
= offered
;
3729 /*******************************************************************
3730 ********************************************************************/
3732 BOOL
spoolss_io_q_enumjobs(char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
3734 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
3740 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
3743 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
3745 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
3747 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3750 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3753 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3759 /*******************************************************************
3760 ********************************************************************/
3762 BOOL
spoolss_io_r_schedulejob(char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
3764 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
3770 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3776 /*******************************************************************
3777 ********************************************************************/
3779 BOOL
spoolss_io_q_schedulejob(char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
3781 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
3787 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3789 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3795 /*******************************************************************
3796 ********************************************************************/
3798 BOOL
spoolss_io_r_setjob(char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
3800 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
3806 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3812 /*******************************************************************
3813 ********************************************************************/
3815 BOOL
spoolss_io_q_setjob(char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
3817 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
3823 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3825 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3828 * level is usually 0. If (level!=0) then I'm in trouble !
3829 * I will try to generate setjob command with level!=0, one day.
3831 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3833 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3839 /*******************************************************************
3840 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
3841 ********************************************************************/
3843 BOOL
spoolss_io_r_enumprinterdrivers(char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
3845 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
3851 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3857 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3860 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3863 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3869 /*******************************************************************
3871 ********************************************************************/
3873 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
3875 const char *environment
,
3877 NEW_BUFFER
*buffer
, uint32 offered
)
3879 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
3880 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
3884 q_u
->offered
=offered
;
3889 /*******************************************************************
3890 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
3891 ********************************************************************/
3893 BOOL
spoolss_io_q_enumprinterdrivers(char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
3896 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
3902 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
3904 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
3909 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
3911 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
3916 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3919 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3925 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3931 /*******************************************************************
3932 ********************************************************************/
3934 BOOL
spoolss_io_q_enumforms(char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
3937 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
3942 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3944 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3947 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3952 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3958 /*******************************************************************
3959 ********************************************************************/
3961 BOOL
spoolss_io_r_enumforms(char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
3963 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
3969 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3975 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
3978 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
3981 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3987 /*******************************************************************
3988 ********************************************************************/
3990 BOOL
spoolss_io_q_getform(char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
3993 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
3998 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4000 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4006 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4009 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4014 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4020 /*******************************************************************
4021 ********************************************************************/
4023 BOOL
spoolss_io_r_getform(char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4025 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4031 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4037 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4040 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
4046 /*******************************************************************
4047 Parse a SPOOL_R_ENUMPORTS structure.
4048 ********************************************************************/
4050 BOOL
spoolss_io_r_enumports(char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4052 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4058 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4064 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4067 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4070 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
4076 /*******************************************************************
4077 ********************************************************************/
4079 BOOL
spoolss_io_q_enumports(char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4081 prs_debug(ps
, depth
, desc
, "");
4087 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4089 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4094 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4097 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4102 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4108 /*******************************************************************
4109 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4110 ********************************************************************/
4112 BOOL
spool_io_printer_info_level_1(char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4114 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4120 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4122 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4124 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4126 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4129 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4131 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4133 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4139 /*******************************************************************
4140 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4141 ********************************************************************/
4143 BOOL
spool_io_printer_info_level_3(char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4145 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4151 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4157 /*******************************************************************
4158 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4159 ********************************************************************/
4161 BOOL
spool_io_printer_info_level_2(char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4163 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4169 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4171 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4173 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4175 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4178 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4180 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4182 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4184 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4186 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4188 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4190 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4192 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4194 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4197 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4199 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4201 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4203 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4205 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4207 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4209 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4211 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4214 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4216 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4218 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4220 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4222 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4224 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4226 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4228 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4230 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4232 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4234 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4240 /*******************************************************************
4241 ********************************************************************/
4243 BOOL
spool_io_printer_info_level(char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4245 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4250 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4252 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4255 /* if no struct inside just return */
4256 if (il
->info_ptr
==0) {
4257 if (UNMARSHALLING(ps
)) {
4264 switch (il
->level
) {
4266 * level 0 is used by setprinter when managing the queue
4267 * (hold, stop, start a queue)
4271 /* DOCUMENT ME!!! What is level 1 used for? */
4274 if (UNMARSHALLING(ps
)) {
4275 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4278 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4283 * level 2 is used by addprinter
4284 * and by setprinter when updating printer's info
4287 if (UNMARSHALLING(ps
)) {
4288 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4291 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4294 /* DOCUMENT ME!!! What is level 3 used for? */
4297 if (UNMARSHALLING(ps
)) {
4298 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4301 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4310 /*******************************************************************
4311 ********************************************************************/
4313 BOOL
spoolss_io_q_addprinterex(char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4315 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4320 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4322 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4328 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4331 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4334 /* the 4 unknown are all 0 */
4337 * en fait ils sont pas inconnu
4338 * par recoupement avec rpcSetPrinter
4339 * c'est le devicemode
4340 * et le security descriptor.
4345 if(!prs_uint32("unk0", ps
, depth
, &q_u
->unk0
))
4347 if(!prs_uint32("unk1", ps
, depth
, &q_u
->unk1
))
4349 if(!prs_uint32("unk2", ps
, depth
, &q_u
->unk2
))
4351 if(!prs_uint32("unk3", ps
, depth
, &q_u
->unk3
))
4354 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4356 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4362 /*******************************************************************
4363 ********************************************************************/
4365 BOOL
spoolss_io_r_addprinterex(char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4366 prs_struct
*ps
, int depth
)
4368 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4371 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4374 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
4380 /*******************************************************************
4381 ********************************************************************/
4383 BOOL
spool_io_printer_driver_info_level_3(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4384 prs_struct
*ps
, int depth
)
4386 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4388 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4392 if (UNMARSHALLING(ps
)) {
4393 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4405 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4407 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4409 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4411 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4413 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4415 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4417 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4419 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4421 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4423 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4425 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4431 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4433 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4435 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4437 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4439 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4441 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4443 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4445 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4451 if (il
->dependentfiles_ptr
)
4452 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
4457 /*******************************************************************
4458 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4459 ********************************************************************/
4461 BOOL
spool_io_printer_driver_info_level_6(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4462 prs_struct
*ps
, int depth
)
4464 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4466 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4470 if (UNMARSHALLING(ps
)) {
4471 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
4484 /* parse the main elements the packet */
4486 if(!prs_uint32("version", ps
, depth
, &il
->version
))
4489 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4492 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4493 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4494 * from W2K CDROM (which uses unidriver). JohnR 010205
4496 if (!il
->name_ptr
) {
4497 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4498 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4502 if(!prs_uint32("environment_ptr", ps
, depth
, &il
->environment_ptr
))
4504 if(!prs_uint32("driverpath_ptr", ps
, depth
, &il
->driverpath_ptr
))
4506 if(!prs_uint32("datafile_ptr", ps
, depth
, &il
->datafile_ptr
))
4508 if(!prs_uint32("configfile_ptr", ps
, depth
, &il
->configfile_ptr
))
4510 if(!prs_uint32("helpfile_ptr", ps
, depth
, &il
->helpfile_ptr
))
4512 if(!prs_uint32("monitorname_ptr", ps
, depth
, &il
->monitorname_ptr
))
4514 if(!prs_uint32("defaultdatatype_ptr", ps
, depth
, &il
->defaultdatatype_ptr
))
4516 if(!prs_uint32("dependentfiles_len", ps
, depth
, &il
->dependentfiles_len
))
4518 if(!prs_uint32("dependentfiles_ptr", ps
, depth
, &il
->dependentfiles_ptr
))
4520 if(!prs_uint32("previousnames_len", ps
, depth
, &il
->previousnames_len
))
4522 if(!prs_uint32("previousnames_ptr", ps
, depth
, &il
->previousnames_ptr
))
4524 if(!smb_io_time("driverdate", &il
->driverdate
, ps
, depth
))
4526 if(!prs_uint32("dummy4", ps
, depth
, &il
->dummy4
))
4528 if(!prs_uint64("driverversion", ps
, depth
, &il
->driverversion
))
4530 if(!prs_uint32("mfgname_ptr", ps
, depth
, &il
->mfgname_ptr
))
4532 if(!prs_uint32("oemurl_ptr", ps
, depth
, &il
->oemurl_ptr
))
4534 if(!prs_uint32("hardwareid_ptr", ps
, depth
, &il
->hardwareid_ptr
))
4536 if(!prs_uint32("provider_ptr", ps
, depth
, &il
->provider_ptr
))
4539 /* parse the structures in the packet */
4541 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4546 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4551 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4556 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4561 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4566 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4571 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4576 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4580 if (il
->dependentfiles_ptr
) {
4581 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
4586 if (il
->previousnames_ptr
) {
4587 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
4592 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
4596 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
4600 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
4604 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
4610 /*******************************************************************
4611 convert a buffer of UNICODE strings null terminated
4612 the buffer is terminated by a NULL
4614 convert to an dos codepage array (null terminated)
4616 dynamically allocate memory
4618 ********************************************************************/
4619 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
4625 if (buf5
==NULL
) return False
;
4627 src
= (char *)buf5
->buffer
;
4630 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
4631 unistr_to_dos(f
, src
, sizeof(f
)-1);
4632 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
4633 *ar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
4634 fstrcpy((*ar
)[n
], f
);
4637 fstrcpy((*ar
)[n
], "");
4642 /*******************************************************************
4643 read a UNICODE array with null terminated strings
4644 and null terminated array
4645 and size of array at beginning
4646 ********************************************************************/
4648 BOOL
smb_io_unibuffer(char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
4650 if (buffer
==NULL
) return False
;
4653 buffer
->uni_str_len
=buffer
->uni_max_len
;
4655 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
4658 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
4664 /*******************************************************************
4665 ********************************************************************/
4667 BOOL
spool_io_printer_driver_info_level(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4669 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
4674 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4676 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
4682 switch (il
->level
) {
4684 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
4688 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
4698 /*******************************************************************
4699 init a SPOOL_Q_ADDPRINTERDRIVER struct
4700 ******************************************************************/
4702 BOOL
make_spoolss_q_addprinterdriver(
4703 SPOOL_Q_ADDPRINTERDRIVER
*q_u
,
4704 const char* srv_name
,
4706 PRINTER_DRIVER_CTR
*info
)
4708 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
4710 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
4711 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
4715 q_u
->info
.level
= level
;
4716 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
4719 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
4721 make_spoolss_driver_info_3(&q_u
->info
.info_3
, info
->info3
);
4724 /* info level 6 is supported by WinME and Win2k */
4726 /* WRITEME!! will add later --jerry */
4730 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
4737 BOOL
make_spoolss_driver_info_3(
4738 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
4739 DRIVER_INFO_3
*info3
4743 uint16
*ptr
= info3
->dependentfiles
;
4745 BOOL null_char
= False
;
4746 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
4748 inf
= (SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)
4749 malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4752 memset (inf
, 0x0, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4754 inf
->cversion
= info3
->version
;
4755 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
4756 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
4757 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
4758 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
4759 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
4760 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
4761 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
4762 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
4764 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
4765 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
4766 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
4767 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
4768 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
4769 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
4770 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
4771 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
4778 /* the null_char BOOL is used to help locate
4779 two '\0's back to back */
4794 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
4795 inf
->dependentfilessize
= len
;
4796 if(!make_spoolss_buffer5(&inf
->dependentfiles
, len
, info3
->dependentfiles
))
4802 *spool_drv_info
= inf
;
4807 /*******************************************************************
4808 make a BUFFER5 struct from a uint16*
4809 ******************************************************************/
4811 BOOL
make_spoolss_buffer5(BUFFER5
*buf5
, uint32 len
, uint16
*src
)
4814 buf5
->buf_len
= len
;
4815 if((buf5
->buffer
=(uint16
*)malloc(sizeof(uint16
)*len
)) == NULL
)
4817 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
4821 memcpy(buf5
->buffer
, src
, sizeof(uint16
)*len
);
4826 /*******************************************************************
4827 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
4828 ********************************************************************/
4830 BOOL
spoolss_io_q_addprinterdriver(char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4832 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
4838 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
4840 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4845 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4848 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
4854 /*******************************************************************
4855 ********************************************************************/
4857 BOOL
spoolss_io_r_addprinterdriver(char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4859 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
4862 if(!prs_uint32("status", ps
, depth
, &q_u
->status
))
4868 /*******************************************************************
4869 ********************************************************************/
4871 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
4872 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
4874 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
4876 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
4880 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
4888 d
->cversion
=uni
->cversion
;
4890 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
4891 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
4892 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
4893 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
4894 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
4895 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
4896 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
4897 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
4899 DEBUGADD(8,( "version: %d\n", d
->cversion
));
4900 DEBUGADD(8,( "name: %s\n", d
->name
));
4901 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4902 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4903 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4904 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4905 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4906 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4907 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4909 uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
);
4914 /*******************************************************************
4915 ********************************************************************/
4916 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
4917 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
4919 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
4921 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
4925 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
4933 d
->version
=uni
->version
;
4935 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
4936 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
4937 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
4938 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
4939 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
4940 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
4941 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
4942 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
4944 DEBUGADD(8,( "version: %d\n", d
->version
));
4945 DEBUGADD(8,( "name: %s\n", d
->name
));
4946 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4947 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4948 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4949 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4950 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4951 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4952 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4954 uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
);
4955 uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
);
4960 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
4961 NT_PRINTER_INFO_LEVEL_2
**asc
)
4963 NT_PRINTER_INFO_LEVEL_2
*d
;
4966 DEBUG(7,("Converting from UNICODE to ASCII\n"));
4967 time_unix
=time(NULL
);
4970 DEBUGADD(8,("allocating memory\n"));
4972 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
4977 /* we allocate memory iff called from
4978 * addprinter(ex) so we can do one time stuff here.
4980 (*asc
)->setuptime
=time_unix
;
4983 DEBUGADD(8,("start converting\n"));
4987 d
->attributes
=uni
->attributes
;
4988 d
->priority
=uni
->priority
;
4989 d
->default_priority
=uni
->default_priority
;
4990 d
->starttime
=uni
->starttime
;
4991 d
->untiltime
=uni
->untiltime
;
4992 d
->status
=uni
->status
;
4993 d
->cjobs
=uni
->cjobs
;
4995 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
4996 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
4997 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
4998 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
4999 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5000 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5001 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5002 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5003 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5004 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5005 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5010 /*******************************************************************
5012 ********************************************************************/
5014 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5015 fstring servername
, fstring env_name
, uint32 level
,
5016 NEW_BUFFER
*buffer
, uint32 offered
)
5018 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5019 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5023 q_u
->offered
=offered
;
5028 /*******************************************************************
5029 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5030 ********************************************************************/
5032 BOOL
spoolss_io_q_getprinterdriverdir(char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5034 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5039 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5041 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5047 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5049 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5055 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5058 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5064 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5070 /*******************************************************************
5071 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5072 ********************************************************************/
5074 BOOL
spoolss_io_r_getprinterdriverdir(char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5076 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5082 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5088 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5091 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5097 /*******************************************************************
5098 ********************************************************************/
5100 BOOL
spoolss_io_r_enumprintprocessors(char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5102 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5108 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5114 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5117 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5120 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5126 /*******************************************************************
5127 ********************************************************************/
5129 BOOL
spoolss_io_q_enumprintprocessors(char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5131 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5137 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5139 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5145 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5147 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5153 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5156 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5162 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5168 /*******************************************************************
5169 ********************************************************************/
5171 BOOL
spoolss_io_r_enumprintprocdatatypes(char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5173 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5179 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5185 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5188 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5191 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5197 /*******************************************************************
5198 ********************************************************************/
5200 BOOL
spoolss_io_q_enumprintprocdatatypes(char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5202 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5208 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5210 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5216 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5218 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5224 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5227 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5233 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5239 /*******************************************************************
5240 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5241 ********************************************************************/
5243 BOOL
spoolss_io_q_enumprintmonitors(char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5245 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5251 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5253 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5259 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5262 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5268 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5274 /*******************************************************************
5275 ********************************************************************/
5277 BOOL
spoolss_io_r_enumprintmonitors(char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5279 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5285 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5291 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5294 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5297 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5303 /*******************************************************************
5304 ********************************************************************/
5306 BOOL
spoolss_io_r_enumprinterdata(char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5308 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5313 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5316 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5322 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5325 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5328 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5330 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
5335 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
5337 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5343 /*******************************************************************
5344 ********************************************************************/
5346 BOOL
spoolss_io_q_enumprinterdata(char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5348 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
5353 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5355 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
5357 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
5359 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
5365 /*******************************************************************
5366 ********************************************************************/
5368 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
5369 const POLICY_HND
*hnd
,
5370 uint32 idx
, uint32 valuelen
, uint32 datalen
)
5372 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5374 q_u
->valuesize
=valuelen
;
5375 q_u
->datasize
=datalen
;
5380 /*******************************************************************
5381 ********************************************************************/
5383 BOOL
spoolss_io_q_setprinterdata(char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5385 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
5390 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5392 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
5398 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5401 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
5410 if (UNMARSHALLING(ps
))
5411 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
5412 if(q_u
->data
== NULL
)
5414 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
5421 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
5427 /*******************************************************************
5428 ********************************************************************/
5430 BOOL
spoolss_io_r_setprinterdata(char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5432 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
5437 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5443 /*******************************************************************
5444 ********************************************************************/
5446 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
5447 uint32 type
, const uint8
*data
, uint32 len
)
5449 DEBUG(5,("converting a specific param struct\n"));
5453 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
5456 memset((char *)*param
, '\0', sizeof(NT_PRINTER_PARAM
));
5457 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5459 unistr2_to_ascii((*param
)->value
, value
, sizeof((*param
)->value
)-1);
5460 (*param
)->type
= type
;
5462 /* le champ data n'est pas NULL termine */
5463 /* on stocke donc la longueur */
5465 (*param
)->data_len
=len
;
5468 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
5469 if((*param
)->data
== NULL
)
5471 memcpy((*param
)->data
, data
, len
);
5474 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
5475 dump_data(10, (char *)(*param
)->data
, (*param
)->data_len
);
5480 /*******************************************************************
5481 ********************************************************************/
5483 static BOOL
spoolss_io_addform(char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
5485 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
5492 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
5494 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
5496 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
5498 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
5500 if(!prs_uint32("left", ps
, depth
, &f
->left
))
5502 if(!prs_uint32("top", ps
, depth
, &f
->top
))
5504 if(!prs_uint32("right", ps
, depth
, &f
->right
))
5506 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
5509 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
5516 /*******************************************************************
5517 ********************************************************************/
5519 BOOL
spoolss_io_q_deleteform(char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
5521 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
5526 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5528 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
5534 /*******************************************************************
5535 ********************************************************************/
5537 BOOL
spoolss_io_r_deleteform(char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
5539 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
5544 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5550 /*******************************************************************
5551 ********************************************************************/
5553 BOOL
spoolss_io_q_addform(char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
5555 uint32 useless_ptr
=0;
5556 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
5561 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5563 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5565 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5570 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5572 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5579 /*******************************************************************
5580 ********************************************************************/
5582 BOOL
spoolss_io_r_addform(char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
5584 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
5589 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5595 /*******************************************************************
5596 ********************************************************************/
5598 BOOL
spoolss_io_q_setform(char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
5600 uint32 useless_ptr
=0;
5601 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
5606 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5608 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
5614 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5616 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5621 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5623 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5630 /*******************************************************************
5631 ********************************************************************/
5633 BOOL
spoolss_io_r_setform(char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
5635 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
5640 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5646 /*******************************************************************
5647 Parse a SPOOL_R_GETJOB structure.
5648 ********************************************************************/
5650 BOOL
spoolss_io_r_getjob(char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
5652 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
5658 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5664 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5667 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5673 /*******************************************************************
5674 Parse a SPOOL_Q_GETJOB structure.
5675 ********************************************************************/
5677 BOOL
spoolss_io_q_getjob(char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
5679 prs_debug(ps
, depth
, desc
, "");
5685 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5687 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
5689 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5692 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5698 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5704 void free_devmode(DEVICEMODE
*devmode
)
5706 if (devmode
!=NULL
) {
5707 safe_free(devmode
->private);
5712 void free_printer_info_1(PRINTER_INFO_1
*printer
)
5717 void free_printer_info_2(PRINTER_INFO_2
*printer
)
5719 if (printer
!=NULL
) {
5720 free_devmode(printer
->devmode
);
5721 printer
->devmode
= NULL
;
5726 void free_printer_info_3(PRINTER_INFO_3
*printer
)
5728 if (printer
!=NULL
) {
5733 void free_job_info_2(JOB_INFO_2
*job
)
5736 free_devmode(job
->devmode
);
5739 /*******************************************************************
5741 ********************************************************************/
5743 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
5744 const fstring string
, uint32 printer
, uint32 type
)
5749 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
5751 q_u
->printer
=printer
;
5760 /*******************************************************************
5761 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
5762 ********************************************************************/
5764 BOOL
spoolss_io_q_replyopenprinter(char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5766 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
5772 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
5778 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
5780 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5783 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
5785 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
5791 /*******************************************************************
5792 Parse a SPOOL_R_REPLYOPENPRINTER structure.
5793 ********************************************************************/
5795 BOOL
spoolss_io_r_replyopenprinter(char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5797 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
5803 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5806 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5812 /*******************************************************************
5814 ********************************************************************/
5816 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
5821 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5826 /*******************************************************************
5827 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
5828 ********************************************************************/
5830 BOOL
spoolss_io_q_replycloseprinter(char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5832 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
5838 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5844 /*******************************************************************
5845 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
5846 ********************************************************************/
5848 BOOL
spoolss_io_r_replycloseprinter(char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5850 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
5856 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5859 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5865 /*******************************************************************
5867 ********************************************************************/
5869 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
5870 uint32 change_low
, uint32 change_high
)
5875 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5877 q_u
->change_low
=change_low
;
5878 q_u
->change_high
=change_high
;
5885 q_u
->info
.version
=2;
5886 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
5892 /*******************************************************************
5893 Parse a SPOOL_Q_REPLY_RRPCN structure.
5894 ********************************************************************/
5896 BOOL
spoolss_io_q_reply_rrpcn(char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
5898 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
5904 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5907 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
5910 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
5913 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
5916 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
5919 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
5922 if(q_u
->info_ptr
!=0)
5923 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
5929 /*******************************************************************
5930 Parse a SPOOL_R_REPLY_RRPCN structure.
5931 ********************************************************************/
5933 BOOL
spoolss_io_r_reply_rrpcn(char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
5935 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
5941 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
5944 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))