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,
9 * Copyright (C) Tim Potter 2001.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 /*******************************************************************
29 return the length of a UNISTR string.
30 ********************************************************************/
32 static uint32
str_len_uni(UNISTR
*source
)
39 while (source
->buffer
[i
])
45 /*******************************************************************
46 This should be moved in a more generic lib.
47 ********************************************************************/
49 static BOOL
spoolss_io_system_time(char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
51 if(!prs_uint16("year", ps
, depth
, &systime
->year
))
53 if(!prs_uint16("month", ps
, depth
, &systime
->month
))
55 if(!prs_uint16("dayofweek", ps
, depth
, &systime
->dayofweek
))
57 if(!prs_uint16("day", ps
, depth
, &systime
->day
))
59 if(!prs_uint16("hour", ps
, depth
, &systime
->hour
))
61 if(!prs_uint16("minute", ps
, depth
, &systime
->minute
))
63 if(!prs_uint16("second", ps
, depth
, &systime
->second
))
65 if(!prs_uint16("milliseconds", ps
, depth
, &systime
->milliseconds
))
71 /*******************************************************************
72 ********************************************************************/
74 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
76 systime
->year
=unixtime
->tm_year
+1900;
77 systime
->month
=unixtime
->tm_mon
+1;
78 systime
->dayofweek
=unixtime
->tm_wday
;
79 systime
->day
=unixtime
->tm_mday
;
80 systime
->hour
=unixtime
->tm_hour
;
81 systime
->minute
=unixtime
->tm_min
;
82 systime
->second
=unixtime
->tm_sec
;
83 systime
->milliseconds
=0;
88 /*******************************************************************
89 reads or writes an DOC_INFO structure.
90 ********************************************************************/
92 static BOOL
smb_io_doc_info_1(char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
94 if (info_1
== NULL
) return False
;
96 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
102 if(!prs_uint32("p_docname", ps
, depth
, &info_1
->p_docname
))
104 if(!prs_uint32("p_outputfile", ps
, depth
, &info_1
->p_outputfile
))
106 if(!prs_uint32("p_datatype", ps
, depth
, &info_1
->p_datatype
))
109 if(!smb_io_unistr2("", &info_1
->docname
, info_1
->p_docname
, ps
, depth
))
111 if(!smb_io_unistr2("", &info_1
->outputfile
, info_1
->p_outputfile
, ps
, depth
))
113 if(!smb_io_unistr2("", &info_1
->datatype
, info_1
->p_datatype
, ps
, depth
))
119 /*******************************************************************
120 reads or writes an DOC_INFO structure.
121 ********************************************************************/
123 static BOOL
smb_io_doc_info(char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
125 uint32 useless_ptr
=0;
127 if (info
== NULL
) return False
;
129 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
135 if(!prs_uint32("switch_value", ps
, depth
, &info
->switch_value
))
138 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &useless_ptr
))
141 switch (info
->switch_value
)
144 if(!smb_io_doc_info_1("",&info
->doc_info_1
, ps
, depth
))
149 this is just a placeholder
151 MSDN July 1998 says doc_info_2 is only on
152 Windows 95, and as Win95 doesn't do RPC to print
153 this case is nearly impossible
155 Maybe one day with Windows for dishwasher 2037 ...
158 /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */
161 DEBUG(0,("Something is obviously wrong somewhere !\n"));
168 /*******************************************************************
169 reads or writes an DOC_INFO_CONTAINER structure.
170 ********************************************************************/
172 static BOOL
smb_io_doc_info_container(char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
174 if (cont
== NULL
) return False
;
176 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
182 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
185 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
191 /*******************************************************************
192 reads or writes an NOTIFY OPTION TYPE structure.
193 ********************************************************************/
195 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
196 structure. The _TYPE structure is really the deferred referrants (i.e
197 the notify fields array) of the _TYPE structure. -tpot */
199 static BOOL
smb_io_notify_option_type(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
201 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
207 if(!prs_uint16("type", ps
, depth
, &type
->type
))
209 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
211 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
213 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
215 if(!prs_uint32("count", ps
, depth
, &type
->count
))
217 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
223 /*******************************************************************
224 reads or writes an NOTIFY OPTION TYPE DATA.
225 ********************************************************************/
227 static BOOL
smb_io_notify_option_type_data(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
231 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
234 /* if there are no fields just return */
235 if (type
->fields_ptr
==0)
241 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
244 if (type
->count2
!= type
->count
)
245 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
247 /* parse the option type data */
248 for(i
=0;i
<type
->count2
;i
++)
249 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
254 /*******************************************************************
255 reads or writes an NOTIFY OPTION structure.
256 ********************************************************************/
258 static BOOL
smb_io_notify_option_type_ctr(char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
262 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
265 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
269 if (UNMARSHALLING(ps
))
270 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)prs_alloc_mem(ps
,ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
273 /* the option type struct */
274 for(i
=0;i
<ctr
->count
;i
++)
275 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
278 /* the type associated with the option type struct */
279 for(i
=0;i
<ctr
->count
;i
++)
280 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
286 /*******************************************************************
287 reads or writes an NOTIFY OPTION structure.
288 ********************************************************************/
290 static BOOL
smb_io_notify_option(char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
292 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
295 if(!prs_uint32("version", ps
, depth
, &option
->version
))
297 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
299 if(!prs_uint32("count", ps
, depth
, &option
->count
))
301 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
304 /* marshalling or unmarshalling, that would work */
305 if (option
->option_type_ptr
!=0) {
306 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
310 option
->ctr
.type
=NULL
;
317 /*******************************************************************
318 reads or writes an NOTIFY INFO DATA structure.
319 ********************************************************************/
321 static BOOL
smb_io_notify_info_data(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
323 uint32 useless_ptr
=0xADDE0FF0;
325 uint32 how_many_words
;
329 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
332 how_many_words
=data
->size
;
333 if (how_many_words
==POINTER
) {
334 how_many_words
=TWO_VALUE
;
337 isvalue
=data
->enc_type
;
341 if(!prs_uint16("type", ps
, depth
, &data
->type
))
343 if(!prs_uint16("field", ps
, depth
, &data
->field
))
347 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
349 if(!prs_uint32("id", ps
, depth
, &data
->id
))
351 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
358 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
360 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
365 /* length in ascii including \0 */
366 x
=2*(data
->notify_data
.data
.length
+1);
367 if(!prs_uint32("string length", ps
, depth
, &x
))
369 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
377 /*******************************************************************
378 reads or writes an NOTIFY INFO DATA structure.
379 ********************************************************************/
381 BOOL
smb_io_notify_info_data_strings(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
382 prs_struct
*ps
, int depth
)
387 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
393 isvalue
=data
->enc_type
;
395 if (isvalue
==False
) {
396 /* length of string in unicode include \0 */
397 x
=data
->notify_data
.data
.length
+1;
398 if(!prs_uint32("string length", ps
, depth
, &x
))
400 if (MARSHALLING(ps
)) {
401 /* These are already in little endian format. Don't byte swap. */
404 /* No memory allocated for this string
405 therefore following the data.string
406 pointer is a bad idea. Use a pointer to
407 the uint32 length union member to
408 provide a source for a unicode NULL */
410 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
413 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
418 /* Tallocate memory for string */
420 data
->notify_data
.data
.string
= (uint16
*)prs_alloc_mem(ps
, x
* 2);
421 if (!data
->notify_data
.data
.string
)
424 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
430 /* Win2k does not seem to put this parse align here */
439 /*******************************************************************
440 reads or writes an NOTIFY INFO structure.
441 ********************************************************************/
443 static BOOL
smb_io_notify_info(char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
447 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
453 if(!prs_uint32("count", ps
, depth
, &info
->count
))
455 if(!prs_uint32("version", ps
, depth
, &info
->version
))
457 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
459 if(!prs_uint32("count", ps
, depth
, &info
->count
))
462 for (i
=0;i
<info
->count
;i
++) {
463 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
467 /* now do the strings at the end of the stream */
468 for (i
=0;i
<info
->count
;i
++) {
469 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
476 /*******************************************************************
477 ********************************************************************/
479 static BOOL
spool_io_user_level_1(char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
481 prs_debug(ps
, depth
, desc
, "");
485 if (UNMARSHALLING(ps
))
490 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
492 if (!prs_uint32("client_name_ptr", ps
, depth
, &q_u
->client_name_ptr
))
494 if (!prs_uint32("user_name_ptr", ps
, depth
, &q_u
->user_name_ptr
))
496 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
498 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
500 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
502 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
505 if (!smb_io_unistr2("", &q_u
->client_name
, q_u
->client_name_ptr
, ps
, depth
))
509 if (!smb_io_unistr2("", &q_u
->user_name
, q_u
->user_name_ptr
, ps
, depth
))
515 /*******************************************************************
516 ********************************************************************/
518 static BOOL
spool_io_user_level(char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
523 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
528 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
530 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
533 switch (q_u
->level
) {
535 if (!spool_io_user_level_1("", &q_u
->user1
, ps
, depth
))
545 /*******************************************************************
546 * read or write a DEVICEMODE struct.
547 * on reading allocate memory for the private member
548 ********************************************************************/
550 BOOL
spoolss_io_devmode(char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
552 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
555 if (UNMARSHALLING(ps
)) {
556 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
557 if (devmode
->devicename
.buffer
== NULL
)
561 if (!prs_uint16uni(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, 32))
563 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
565 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
567 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
569 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
571 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
573 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
575 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
577 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
579 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
581 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
583 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
585 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
587 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
589 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
591 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
593 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
595 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
597 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
600 if (UNMARSHALLING(ps
)) {
601 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
602 if (devmode
->formname
.buffer
== NULL
)
606 if (!prs_uint16uni(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
608 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
610 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
612 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
614 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
616 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
618 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
620 if (!prs_uint32("icmmethod", ps
, depth
, &devmode
->icmmethod
))
622 if (!prs_uint32("icmintent", ps
, depth
, &devmode
->icmintent
))
624 if (!prs_uint32("mediatype", ps
, depth
, &devmode
->mediatype
))
626 if (!prs_uint32("dithertype", ps
, depth
, &devmode
->dithertype
))
628 if (!prs_uint32("reserved1", ps
, depth
, &devmode
->reserved1
))
630 if (!prs_uint32("reserved2", ps
, depth
, &devmode
->reserved2
))
632 if (!prs_uint32("panningwidth", ps
, depth
, &devmode
->panningwidth
))
634 if (!prs_uint32("panningheight", ps
, depth
, &devmode
->panningheight
))
637 if (devmode
->driverextra
!=0) {
638 if (UNMARSHALLING(ps
)) {
639 devmode
->private=(uint8
*)prs_alloc_mem(ps
, devmode
->driverextra
*sizeof(uint8
));
640 if(devmode
->private == NULL
)
642 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
645 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
646 if (!prs_uint8s(False
, "private", ps
, depth
,
647 devmode
->private, devmode
->driverextra
))
654 /*******************************************************************
655 Read or write a DEVICEMODE container
656 ********************************************************************/
658 static BOOL
spoolss_io_devmode_cont(char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
663 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
669 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
672 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
675 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
676 if (UNMARSHALLING(ps
))
677 /* if while reading there is no DEVMODE ... */
682 /* so we have a DEVICEMODE to follow */
683 if (UNMARSHALLING(ps
)) {
684 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
685 dm_c
->devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
));
686 if(dm_c
->devmode
== NULL
)
690 /* this is bad code, shouldn't be there */
691 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
694 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
700 /*******************************************************************
701 ********************************************************************/
703 static BOOL
spoolss_io_printer_default(char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
708 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
711 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
714 if (!smb_io_unistr2("datatype", &pd
->datatype
, pd
->datatype_ptr
, ps
,depth
))
720 if (!spoolss_io_devmode_cont("", &pd
->devmode_cont
, ps
, depth
))
723 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
729 /*******************************************************************
731 ********************************************************************/
733 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
734 const fstring printername
,
735 const fstring datatype
,
736 uint32 access_required
,
737 const fstring clientname
,
738 const fstring user_name
)
740 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
741 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
742 init_unistr2(&q_u
->printername
, printername
, strlen(printername
)+1);
744 q_u
->printer_default
.datatype_ptr
= 0;
746 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
747 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
749 q_u
->printer_default
.devmode_cont
.size
=0;
750 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
751 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
752 q_u
->printer_default
.access_required
=access_required
;
754 q_u
->user_ctr
.level
=1;
756 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+10;
757 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
758 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
759 q_u
->user_ctr
.user1
.build
=1381;
760 q_u
->user_ctr
.user1
.major
=2;
761 q_u
->user_ctr
.user1
.minor
=0;
762 q_u
->user_ctr
.user1
.processor
=0;
763 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
764 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
769 /*******************************************************************
771 ********************************************************************/
773 BOOL
make_spoolss_q_addprinterex(
775 SPOOL_Q_ADDPRINTEREX
*q_u
,
776 const char *srv_name
,
777 const char* clientname
,
778 const char* user_name
,
780 PRINTER_INFO_CTR
*ctr
)
782 DEBUG(5,("make_spoolss_q_addprinterex\n"));
784 if (!ctr
) return False
;
788 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
789 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
));
793 q_u
->info
.level
= level
;
794 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
797 /* init q_u->info.info2 from *info */
798 if (!make_spoolss_printer_info_2(mem_ctx
, &q_u
->info
.info_2
, ctr
->printers_2
)) {
799 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
809 q_u
->user_ctr
.level
=1;
811 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
812 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
813 q_u
->user_ctr
.user1
.build
=1381;
814 q_u
->user_ctr
.user1
.major
=2;
815 q_u
->user_ctr
.user1
.minor
=0;
816 q_u
->user_ctr
.user1
.processor
=0;
817 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
)+1);
818 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
)+1);
819 q_u
->user_ctr
.user1
.size
=q_u
->user_ctr
.user1
.user_name
.uni_str_len
+
820 q_u
->user_ctr
.user1
.client_name
.uni_str_len
+ 2;
825 /*******************************************************************
826 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
827 *******************************************************************/
829 BOOL
make_spoolss_printer_info_2(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
830 PRINTER_INFO_2
*info
)
833 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
835 /* allocate the necessary memory */
836 if (!(inf
=(SPOOL_PRINTER_INFO_LEVEL_2
*)talloc(mem_ctx
, sizeof(SPOOL_PRINTER_INFO_LEVEL_2
)))) {
837 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
841 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
842 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
843 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
844 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
845 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
846 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
847 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
848 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
849 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
850 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
851 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
852 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
853 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
854 inf
->attributes
= info
->attributes
;
855 inf
->priority
= info
->priority
;
856 inf
->default_priority
= info
->defaultpriority
;
857 inf
->starttime
= info
->starttime
;
858 inf
->untiltime
= info
->untiltime
;
859 inf
->cjobs
= info
->cjobs
;
860 inf
->averageppm
= info
->averageppm
;
861 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
862 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
863 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
864 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
865 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
866 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
867 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
868 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
869 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
870 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
871 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
872 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
879 /*******************************************************************
881 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
882 ********************************************************************/
884 BOOL
spoolss_io_q_open_printer_ex(char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
889 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
895 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
897 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
903 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
906 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
908 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
914 /*******************************************************************
916 ********************************************************************/
917 BOOL
make_spoolss_q_deleteprinterdriver(
919 SPOOL_Q_DELETEPRINTERDRIVER
*q_u
,
925 DEBUG(5,("make_spoolss_q_deleteprinterdriver\n"));
927 q_u
->server_ptr
= (server
!=NULL
)?1:0;
929 /* these must be NULL terminated or else NT4 will
930 complain about invalid parameters --jerry */
931 init_unistr2(&q_u
->server
, server
, strlen(server
)+1);
932 init_unistr2(&q_u
->arch
, arch
, strlen(arch
)+1);
933 init_unistr2(&q_u
->driver
, driver
, strlen(driver
)+1);
939 /*******************************************************************
941 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
942 * called from spoolss_open_printer_ex (cli_spoolss.c)
943 ********************************************************************/
945 BOOL
spoolss_io_r_open_printer_ex(char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
947 if (r_u
== NULL
) return False
;
949 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
955 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
958 if (!prs_werror("status code", ps
, depth
, &(r_u
->status
)))
964 /*******************************************************************
966 ********************************************************************/
968 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
969 const POLICY_HND
*handle
,
970 UNISTR2
*valuename
, uint32 size
)
972 if (q_u
== NULL
) return False
;
974 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
976 q_u
->handle
= *handle
;
977 copy_unistr2(&q_u
->valuename
, valuename
);
983 /*******************************************************************
985 * called from spoolss_q_getprinterdata (srv_spoolss.c)
986 ********************************************************************/
988 BOOL
spoolss_io_q_getprinterdata(char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
993 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
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
))
1006 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
1012 /*******************************************************************
1014 * called from spoolss_q_deleteprinterdata (srv_spoolss.c)
1015 ********************************************************************/
1017 BOOL
spoolss_io_q_deleteprinterdata(char *desc
, SPOOL_Q_DELETEPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
1022 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdata");
1027 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1031 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
1037 /*******************************************************************
1038 * write a structure.
1039 * called from spoolss_r_deleteprinterdata (srv_spoolss.c)
1040 ********************************************************************/
1042 BOOL
spoolss_io_r_deleteprinterdata(char *desc
, SPOOL_R_DELETEPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1044 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdata");
1046 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1052 /*******************************************************************
1053 * write a structure.
1054 * called from spoolss_r_getprinterdata (srv_spoolss.c)
1055 ********************************************************************/
1057 BOOL
spoolss_io_r_getprinterdata(char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
1062 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
1067 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
1069 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
1072 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
1078 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1080 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1086 /*******************************************************************
1088 ********************************************************************/
1090 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
1092 if (q_u
== NULL
) return False
;
1094 DEBUG(5,("make_spoolss_q_closeprinter\n"));
1096 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
1101 /*******************************************************************
1103 * called from static spoolss_q_abortprinter (srv_spoolss.c)
1104 * called from spoolss_abortprinter (cli_spoolss.c)
1105 ********************************************************************/
1107 BOOL
spoolss_io_q_abortprinter(char *desc
, SPOOL_Q_ABORTPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1109 if (q_u
== NULL
) return False
;
1111 prs_debug(ps
, depth
, desc
, "spoolss_io_q_abortprinter");
1117 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1123 /*******************************************************************
1124 * write a structure.
1125 * called from spoolss_r_abortprinter (srv_spoolss.c)
1126 ********************************************************************/
1128 BOOL
spoolss_io_r_abortprinter(char *desc
, SPOOL_R_ABORTPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1130 prs_debug(ps
, depth
, desc
, "spoolss_io_r_abortprinter");
1132 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1138 /*******************************************************************
1140 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
1141 * called from spoolss_deleteprinter (cli_spoolss.c)
1142 ********************************************************************/
1144 BOOL
spoolss_io_q_deleteprinter(char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1146 if (q_u
== NULL
) return False
;
1148 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1154 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1160 /*******************************************************************
1161 * write a structure.
1162 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1163 * called from spoolss_deleteprinter (cli_spoolss.c)
1164 ********************************************************************/
1166 BOOL
spoolss_io_r_deleteprinter(char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1168 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1174 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1176 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1183 /*******************************************************************
1185 * called from api_spoolss_deleteprinterdriver (srv_spoolss.c)
1186 * called from spoolss_deleteprinterdriver (cli_spoolss.c)
1187 ********************************************************************/
1189 BOOL
spoolss_io_q_deleteprinterdriver(char *desc
, SPOOL_Q_DELETEPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
1191 if (q_u
== NULL
) return False
;
1193 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinterdriver");
1199 if(!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
1201 if(!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
1203 if(!smb_io_unistr2("arch", &q_u
->arch
, True
, ps
, depth
))
1205 if(!smb_io_unistr2("driver", &q_u
->driver
, True
, ps
, depth
))
1213 /*******************************************************************
1214 * write a structure.
1215 ********************************************************************/
1216 BOOL
spoolss_io_r_deleteprinterdriver(char *desc
, SPOOL_R_DELETEPRINTERDRIVER
*r_u
, prs_struct
*ps
, int depth
)
1218 if (r_u
== NULL
) return False
;
1220 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinterdriver");
1226 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1234 /*******************************************************************
1236 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1237 * called from spoolss_closeprinter (cli_spoolss.c)
1238 ********************************************************************/
1240 BOOL
spoolss_io_q_closeprinter(char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1242 if (q_u
== NULL
) return False
;
1244 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1250 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1256 /*******************************************************************
1257 * write a structure.
1258 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1259 * called from spoolss_closeprinter (cli_spoolss.c)
1260 ********************************************************************/
1262 BOOL
spoolss_io_r_closeprinter(char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1264 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1270 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1272 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1278 /*******************************************************************
1280 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1281 ********************************************************************/
1283 BOOL
spoolss_io_q_startdocprinter(char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1285 if (q_u
== NULL
) return False
;
1287 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1293 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1296 if(!smb_io_doc_info_container("",&q_u
->doc_info_container
, ps
, depth
))
1302 /*******************************************************************
1303 * write a structure.
1304 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1305 ********************************************************************/
1307 BOOL
spoolss_io_r_startdocprinter(char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1309 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1311 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1313 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1319 /*******************************************************************
1321 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1322 ********************************************************************/
1324 BOOL
spoolss_io_q_enddocprinter(char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1326 if (q_u
== NULL
) return False
;
1328 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1334 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1340 /*******************************************************************
1341 * write a structure.
1342 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1343 ********************************************************************/
1345 BOOL
spoolss_io_r_enddocprinter(char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1347 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1349 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1355 /*******************************************************************
1357 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1358 ********************************************************************/
1360 BOOL
spoolss_io_q_startpageprinter(char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1362 if (q_u
== NULL
) return False
;
1364 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1370 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1376 /*******************************************************************
1377 * write a structure.
1378 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1379 ********************************************************************/
1381 BOOL
spoolss_io_r_startpageprinter(char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1383 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1385 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1391 /*******************************************************************
1393 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1394 ********************************************************************/
1396 BOOL
spoolss_io_q_endpageprinter(char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1398 if (q_u
== NULL
) return False
;
1400 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1406 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1412 /*******************************************************************
1413 * write a structure.
1414 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1415 ********************************************************************/
1417 BOOL
spoolss_io_r_endpageprinter(char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1419 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1421 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1427 /*******************************************************************
1429 * called from spoolss_q_writeprinter (srv_spoolss.c)
1430 ********************************************************************/
1432 BOOL
spoolss_io_q_writeprinter(char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1434 if (q_u
== NULL
) return False
;
1436 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1442 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1444 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1447 if (q_u
->buffer_size
!=0)
1449 if (UNMARSHALLING(ps
))
1450 q_u
->buffer
=(uint8
*)prs_alloc_mem(ps
,q_u
->buffer_size
*sizeof(uint8
));
1451 if(q_u
->buffer
== NULL
)
1453 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1458 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1464 /*******************************************************************
1465 * write a structure.
1466 * called from spoolss_r_writeprinter (srv_spoolss.c)
1467 ********************************************************************/
1469 BOOL
spoolss_io_r_writeprinter(char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1471 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1473 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1475 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1481 /*******************************************************************
1483 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1484 ********************************************************************/
1486 BOOL
spoolss_io_q_rffpcnex(char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1488 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1494 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1496 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1498 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1500 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1502 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1508 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1511 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1514 if (q_u
->option_ptr
!=0) {
1516 if (UNMARSHALLING(ps
))
1517 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1520 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1527 /*******************************************************************
1528 * write a structure.
1529 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1530 ********************************************************************/
1532 BOOL
spoolss_io_r_rffpcnex(char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1534 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1537 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1543 /*******************************************************************
1545 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1546 ********************************************************************/
1548 BOOL
spoolss_io_q_rfnpcnex(char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1550 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1556 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1559 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1562 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1565 if (q_u
->option_ptr
!=0) {
1567 if (UNMARSHALLING(ps
))
1568 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)prs_alloc_mem(ps
,sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1571 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1578 /*******************************************************************
1579 * write a structure.
1580 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1581 ********************************************************************/
1583 BOOL
spoolss_io_r_rfnpcnex(char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1585 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1591 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1594 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1599 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1605 /*******************************************************************
1606 * return the length of a uint16 (obvious, but the code is clean)
1607 ********************************************************************/
1609 static uint32
size_of_uint16(uint16
*value
)
1611 return (sizeof(*value
));
1614 /*******************************************************************
1615 * return the length of a uint32 (obvious, but the code is clean)
1616 ********************************************************************/
1618 static uint32
size_of_uint32(uint32
*value
)
1620 return (sizeof(*value
));
1623 /*******************************************************************
1624 * return the length of a NTTIME (obvious, but the code is clean)
1625 ********************************************************************/
1627 static uint32
size_of_nttime(NTTIME
*value
)
1629 return (sizeof(*value
));
1632 /*******************************************************************
1633 * return the length of a UNICODE string in number of char, includes:
1634 * - the leading zero
1635 * - the relative pointer size
1636 ********************************************************************/
1638 static uint32
size_of_relative_string(UNISTR
*string
)
1642 size
=str_len_uni(string
); /* the string length */
1643 size
=size
+1; /* add the leading zero */
1644 size
=size
*2; /* convert in char */
1645 /* Ensure size is 4 byte multiple (prs_align is being called...). */
1646 size
+= ((4 - (size
& 3)) & 3);
1647 size
=size
+4; /* add the size of the ptr */
1652 /*******************************************************************
1653 * return the length of a uint32 (obvious, but the code is clean)
1654 ********************************************************************/
1656 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1661 return (4+devmode
->size
+devmode
->driverextra
);
1664 /*******************************************************************
1665 * return the length of a uint32 (obvious, but the code is clean)
1666 ********************************************************************/
1668 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1673 return (sizeof(SYSTEMTIME
) +4);
1676 /*******************************************************************
1677 * write a UNICODE string.
1678 * used by all the RPC structs passing a buffer
1679 ********************************************************************/
1681 static BOOL
spoolss_smb_io_unistr(char *desc
, UNISTR
*uni
, prs_struct
*ps
, int depth
)
1686 prs_debug(ps
, depth
, desc
, "spoolss_smb_io_unistr");
1689 /* there should be no align here as it can mess up
1690 parsing a NEW_BUFFER->prs */
1696 if (!prs_unistr("unistr", ps
, depth
, uni
))
1702 /*******************************************************************
1703 * write a UNICODE string and its relative pointer.
1704 * used by all the RPC structs passing a buffer
1706 * As I'm a nice guy, I'm forcing myself to explain this code.
1707 * MS did a good job in the overall spoolss code except in some
1708 * functions where they are passing the API buffer directly in the
1709 * RPC request/reply. That's to maintain compatiility at the API level.
1710 * They could have done it the good way the first time.
1712 * So what happen is: the strings are written at the buffer's end,
1713 * in the reverse order of the original structure. Some pointers to
1714 * the strings are also in the buffer. Those are relative to the
1717 * If you don't understand or want to change that function,
1718 * first get in touch with me: jfm@samba.org
1720 ********************************************************************/
1722 static BOOL
smb_io_relstr(char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
1724 prs_struct
*ps
=&buffer
->prs
;
1726 if (MARSHALLING(ps
)) {
1727 uint32 struct_offset
= prs_offset(ps
);
1728 uint32 relative_offset
;
1730 buffer
->string_at_end
-= (size_of_relative_string(string
) - 4);
1731 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1735 buffer
->string_at_end
= prs_offset(ps
);
1737 /* write the string */
1738 if (!smb_io_unistr(desc
, string
, ps
, depth
))
1741 if(!prs_set_offset(ps
, struct_offset
))
1744 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1745 /* write its offset */
1746 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1752 /* read the offset */
1753 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
1756 old_offset
= prs_offset(ps
);
1757 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
1760 /* read the string */
1761 if (!spoolss_smb_io_unistr(desc
, string
, ps
, depth
))
1764 if(!prs_set_offset(ps
, old_offset
))
1770 /*******************************************************************
1771 * write a array of UNICODE strings and its relative pointer.
1772 * used by 2 RPC structs
1773 ********************************************************************/
1775 static BOOL
smb_io_relarraystr(char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
1779 prs_struct
*ps
=&buffer
->prs
;
1781 if (MARSHALLING(ps
)) {
1782 uint32 struct_offset
= prs_offset(ps
);
1783 uint32 relative_offset
;
1790 /* first write the last 0 */
1791 buffer
->string_at_end
-= 2;
1792 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1795 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
1798 while (p
&& (*p
!=0)) {
1802 /* Yes this should be malloc not talloc. Don't change. */
1804 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
1805 if (chaine
.buffer
== NULL
)
1808 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
1810 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
1812 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
1813 SAFE_FREE(chaine
.buffer
);
1817 /* write the string */
1818 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
1819 SAFE_FREE(chaine
.buffer
);
1825 SAFE_FREE(chaine
.buffer
);
1828 if(!prs_set_offset(ps
, struct_offset
))
1831 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1832 /* write its offset */
1833 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1841 uint16
*chaine2
=NULL
;
1844 size_t realloc_size
= 0;
1848 /* read the offset */
1849 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1852 old_offset
= prs_offset(ps
);
1853 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1857 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
))
1860 l_chaine
=str_len_uni(&chaine
);
1862 /* we're going to add two more bytes here in case this
1863 is the last string in the array and we need to add
1864 an extra NULL for termination */
1869 realloc_size
= (l_chaine2
+l_chaine
+2)*sizeof(uint16
);
1871 /* Yes this should be realloc - it's freed below. JRA */
1873 if((tc2
=(uint16
*)Realloc(chaine2
, realloc_size
)) == NULL
) {
1878 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
1879 l_chaine2
+=l_chaine
+1;
1882 } while(l_chaine
!=0);
1884 /* the end should be bould NULL terminated so add
1885 the second one here */
1888 chaine2
[l_chaine2
] = '\0';
1889 *string
=(uint16
*)talloc_memdup(prs_get_mem_context(ps
),chaine2
,realloc_size
);
1893 if(!prs_set_offset(ps
, old_offset
))
1899 /*******************************************************************
1900 Parse a DEVMODE structure and its relative pointer.
1901 ********************************************************************/
1903 static BOOL
smb_io_relsecdesc(char *desc
, NEW_BUFFER
*buffer
, int depth
, SEC_DESC
**secdesc
)
1905 prs_struct
*ps
= &buffer
->prs
;
1907 prs_debug(ps
, depth
, desc
, "smb_io_relsecdesc");
1910 if (MARSHALLING(ps
)) {
1911 uint32 struct_offset
= prs_offset(ps
);
1912 uint32 relative_offset
;
1915 relative_offset
= 0;
1916 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1921 if (*secdesc
!= NULL
) {
1922 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
1924 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1926 /* write the secdesc */
1927 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1930 if(!prs_set_offset(ps
, struct_offset
))
1934 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1935 /* write its offset */
1937 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1942 /* read the offset */
1943 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1946 old_offset
= prs_offset(ps
);
1947 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1951 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1954 if(!prs_set_offset(ps
, old_offset
))
1960 /*******************************************************************
1961 Parse a DEVMODE structure and its relative pointer.
1962 ********************************************************************/
1964 static BOOL
smb_io_reldevmode(char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
1966 prs_struct
*ps
=&buffer
->prs
;
1968 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
1971 if (MARSHALLING(ps
)) {
1972 uint32 struct_offset
= prs_offset(ps
);
1973 uint32 relative_offset
;
1975 if (*devmode
== NULL
) {
1977 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1979 DEBUG(8, ("boing, the devmode was NULL\n"));
1984 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
1986 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1989 /* write the DEVMODE */
1990 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1993 if(!prs_set_offset(ps
, struct_offset
))
1996 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1997 /* write its offset */
1998 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
2004 /* read the offset */
2005 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
2008 old_offset
= prs_offset(ps
);
2009 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
2012 /* read the string */
2013 if((*devmode
=(DEVICEMODE
*)prs_alloc_mem(ps
,sizeof(DEVICEMODE
))) == NULL
)
2015 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
2018 if(!prs_set_offset(ps
, old_offset
))
2024 /*******************************************************************
2025 Parse a PRINTER_INFO_0 structure.
2026 ********************************************************************/
2028 BOOL
smb_io_printer_info_0(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
2030 prs_struct
*ps
=&buffer
->prs
;
2032 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
2035 buffer
->struct_start
=prs_offset(ps
);
2037 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2039 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2042 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
2044 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
2046 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
2049 if(!prs_uint16("year", ps
, depth
, &info
->year
))
2051 if(!prs_uint16("month", ps
, depth
, &info
->month
))
2053 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
2055 if(!prs_uint16("day", ps
, depth
, &info
->day
))
2057 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
2059 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
2061 if(!prs_uint16("second", ps
, depth
, &info
->second
))
2063 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
2066 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
2068 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
2071 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
2073 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
2075 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2077 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2079 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
2081 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
2083 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
2085 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
2087 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
2089 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
2091 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
2093 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
2095 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
2097 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
2099 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
2101 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
2103 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
2105 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
2107 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
2109 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
2111 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
2113 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
2115 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
2117 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
2119 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
2125 /*******************************************************************
2126 Parse a PRINTER_INFO_1 structure.
2127 ********************************************************************/
2129 BOOL
smb_io_printer_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
2131 prs_struct
*ps
=&buffer
->prs
;
2133 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
2136 buffer
->struct_start
=prs_offset(ps
);
2138 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2140 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2142 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2144 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2150 /*******************************************************************
2151 Parse a PRINTER_INFO_2 structure.
2152 ********************************************************************/
2154 BOOL
smb_io_printer_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
2156 prs_struct
*ps
=&buffer
->prs
;
2158 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
2161 buffer
->struct_start
=prs_offset(ps
);
2163 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2165 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2167 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
2169 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2171 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2173 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
2175 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
2178 /* NT parses the DEVMODE at the end of the struct */
2179 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2182 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
2184 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2186 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2188 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2191 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
2194 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2196 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2198 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
2200 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
2202 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
2204 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2206 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
2208 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
2212 if (!prs_uint32_post("secdesc_ptr", ps
, depth
, NULL
, sec_offset
, info
->secdesc
? prs_offset(ps
)-buffer
->struct_start
: 0 ))
2215 if (!sec_io_desc("secdesc", &info
->secdesc
, ps
, depth
))
2221 /*******************************************************************
2222 Parse a PRINTER_INFO_3 structure.
2223 ********************************************************************/
2225 BOOL
smb_io_printer_info_3(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
2227 prs_struct
*ps
=&buffer
->prs
;
2229 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
2232 buffer
->struct_start
=prs_offset(ps
);
2234 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
2236 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
2242 /*******************************************************************
2243 Parse a PRINTER_INFO_4 structure.
2244 ********************************************************************/
2246 BOOL
smb_io_printer_info_4(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
2248 prs_struct
*ps
=&buffer
->prs
;
2250 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
2253 buffer
->struct_start
=prs_offset(ps
);
2255 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2257 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
2259 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2264 /*******************************************************************
2265 Parse a PRINTER_INFO_5 structure.
2266 ********************************************************************/
2268 BOOL
smb_io_printer_info_5(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
2270 prs_struct
*ps
=&buffer
->prs
;
2272 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
2275 buffer
->struct_start
=prs_offset(ps
);
2277 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2279 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
2281 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
2283 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
2285 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
2290 /*******************************************************************
2291 Parse a PORT_INFO_1 structure.
2292 ********************************************************************/
2294 BOOL
smb_io_port_info_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2296 prs_struct
*ps
=&buffer
->prs
;
2298 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
2301 buffer
->struct_start
=prs_offset(ps
);
2303 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2309 /*******************************************************************
2310 Parse a PORT_INFO_2 structure.
2311 ********************************************************************/
2313 BOOL
smb_io_port_info_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2315 prs_struct
*ps
=&buffer
->prs
;
2317 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
2320 buffer
->struct_start
=prs_offset(ps
);
2322 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2324 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2326 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2328 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2330 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2336 /*******************************************************************
2337 Parse a DRIVER_INFO_1 structure.
2338 ********************************************************************/
2340 BOOL
smb_io_printer_driver_info_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2342 prs_struct
*ps
=&buffer
->prs
;
2344 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
2347 buffer
->struct_start
=prs_offset(ps
);
2349 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2355 /*******************************************************************
2356 Parse a DRIVER_INFO_2 structure.
2357 ********************************************************************/
2359 BOOL
smb_io_printer_driver_info_2(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2361 prs_struct
*ps
=&buffer
->prs
;
2363 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
2366 buffer
->struct_start
=prs_offset(ps
);
2368 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2370 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2372 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2374 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2376 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2378 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2384 /*******************************************************************
2385 Parse a DRIVER_INFO_3 structure.
2386 ********************************************************************/
2388 BOOL
smb_io_printer_driver_info_3(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2390 prs_struct
*ps
=&buffer
->prs
;
2392 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
2395 buffer
->struct_start
=prs_offset(ps
);
2397 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2399 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2401 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2403 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2405 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2407 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2409 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2412 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2415 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2417 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2423 /*******************************************************************
2424 Parse a DRIVER_INFO_6 structure.
2425 ********************************************************************/
2427 BOOL
smb_io_printer_driver_info_6(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
2429 prs_struct
*ps
=&buffer
->prs
;
2431 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
2434 buffer
->struct_start
=prs_offset(ps
);
2436 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2438 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2440 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2442 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2444 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2446 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2448 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2451 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2454 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2456 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2459 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
2462 if (!prs_uint32("date.low", ps
, depth
, &info
->driver_date
.low
))
2464 if (!prs_uint32("date.high", ps
, depth
, &info
->driver_date
.high
))
2467 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
2470 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
2473 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
2476 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
2478 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
2480 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
2482 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
2488 /*******************************************************************
2489 Parse a JOB_INFO_1 structure.
2490 ********************************************************************/
2492 BOOL
smb_io_job_info_1(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2494 prs_struct
*ps
=&buffer
->prs
;
2496 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
2499 buffer
->struct_start
=prs_offset(ps
);
2501 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2503 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2505 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2507 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2509 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2511 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2513 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2515 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2517 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2519 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2521 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2523 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2525 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2531 /*******************************************************************
2532 Parse a JOB_INFO_2 structure.
2533 ********************************************************************/
2535 BOOL
smb_io_job_info_2(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2538 prs_struct
*ps
=&buffer
->prs
;
2540 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
2543 buffer
->struct_start
=prs_offset(ps
);
2545 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2547 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2549 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2551 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
2553 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
2555 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2557 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2560 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2562 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2564 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2566 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2568 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2571 /* SEC_DESC sec_desc;*/
2572 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2575 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2577 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2579 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2581 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2583 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2585 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2587 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2589 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2591 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2593 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2599 /*******************************************************************
2600 ********************************************************************/
2602 BOOL
smb_io_form_1(char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2604 prs_struct
*ps
=&buffer
->prs
;
2606 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
2609 buffer
->struct_start
=prs_offset(ps
);
2611 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2614 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2617 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2619 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2621 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2623 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2625 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2627 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2633 /*******************************************************************
2634 Read/write a BUFFER struct.
2635 ********************************************************************/
2637 static BOOL
spoolss_io_buffer(char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
**pp_buffer
)
2639 NEW_BUFFER
*buffer
= *pp_buffer
;
2641 prs_debug(ps
, depth
, desc
, "spoolss_io_buffer");
2644 if (UNMARSHALLING(ps
))
2645 buffer
= *pp_buffer
= (NEW_BUFFER
*)prs_alloc_mem(ps
, sizeof(NEW_BUFFER
));
2650 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2654 if (UNMARSHALLING(ps
)) {
2656 buffer
->string_at_end
=0;
2658 if (buffer
->ptr
==0) {
2660 * JRA. I'm not sure if the data in here is in big-endian format if
2661 * the client is big-endian. Leave as default (little endian) for now.
2664 if (!prs_init(&buffer
->prs
, 0, prs_get_mem_context(ps
), UNMARSHALL
))
2669 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2673 * JRA. I'm not sure if the data in here is in big-endian format if
2674 * the client is big-endian. Leave as default (little endian) for now.
2677 if (!prs_init(&buffer
->prs
, buffer
->size
, prs_get_mem_context(ps
), UNMARSHALL
))
2680 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
2683 if (!prs_set_offset(&buffer
->prs
, 0))
2686 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
2689 buffer
->string_at_end
=buffer
->size
;
2697 if (buffer
->ptr
==0) {
2698 /* We have finished with the data in buffer->prs - free it. */
2699 prs_mem_free(&buffer
->prs
);
2703 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2706 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
2712 /* We have finished with the data in buffer->prs - free it. */
2713 prs_mem_free(&buffer
->prs
);
2719 /*******************************************************************
2720 move a BUFFER from the query to the reply.
2721 As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed,
2722 this is ok. This is an OPTIMIZATION and is not strictly neccessary.
2723 Clears the memory to zero also.
2724 ********************************************************************/
2726 void spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
2728 prs_switch_type(&src
->prs
, MARSHALL
);
2729 if(!prs_set_offset(&src
->prs
, 0))
2731 prs_force_dynamic(&src
->prs
);
2732 prs_mem_clear(&src
->prs
);
2736 /*******************************************************************
2737 Get the size of a BUFFER struct.
2738 ********************************************************************/
2740 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
2742 return (buffer
->size
);
2745 /*******************************************************************
2746 Parse a DRIVER_DIRECTORY_1 structure.
2747 ********************************************************************/
2749 BOOL
smb_io_driverdir_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2751 prs_struct
*ps
=&buffer
->prs
;
2753 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
2756 buffer
->struct_start
=prs_offset(ps
);
2758 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2764 /*******************************************************************
2765 Parse a PORT_INFO_1 structure.
2766 ********************************************************************/
2768 BOOL
smb_io_port_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2770 prs_struct
*ps
=&buffer
->prs
;
2772 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
2775 buffer
->struct_start
=prs_offset(ps
);
2777 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2783 /*******************************************************************
2784 Parse a PORT_INFO_2 structure.
2785 ********************************************************************/
2787 BOOL
smb_io_port_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2789 prs_struct
*ps
=&buffer
->prs
;
2791 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
2794 buffer
->struct_start
=prs_offset(ps
);
2796 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2798 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2800 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2802 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2804 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2810 /*******************************************************************
2811 ********************************************************************/
2813 BOOL
smb_io_printprocessor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2815 prs_struct
*ps
=&buffer
->prs
;
2817 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2820 buffer
->struct_start
=prs_offset(ps
);
2822 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2828 /*******************************************************************
2829 ********************************************************************/
2831 BOOL
smb_io_printprocdatatype_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2833 prs_struct
*ps
=&buffer
->prs
;
2835 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2838 buffer
->struct_start
=prs_offset(ps
);
2840 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2846 /*******************************************************************
2847 ********************************************************************/
2849 BOOL
smb_io_printmonitor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2851 prs_struct
*ps
=&buffer
->prs
;
2853 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2856 buffer
->struct_start
=prs_offset(ps
);
2858 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2864 /*******************************************************************
2865 ********************************************************************/
2867 BOOL
smb_io_printmonitor_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
2869 prs_struct
*ps
=&buffer
->prs
;
2871 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
2874 buffer
->struct_start
=prs_offset(ps
);
2876 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2878 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
2880 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
2886 /*******************************************************************
2887 return the size required by a struct in the stream
2888 ********************************************************************/
2890 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
2894 size
+=size_of_relative_string( &info
->printername
);
2895 size
+=size_of_relative_string( &info
->servername
);
2897 size
+=size_of_uint32( &info
->cjobs
);
2898 size
+=size_of_uint32( &info
->total_jobs
);
2899 size
+=size_of_uint32( &info
->total_bytes
);
2901 size
+=size_of_uint16( &info
->year
);
2902 size
+=size_of_uint16( &info
->month
);
2903 size
+=size_of_uint16( &info
->dayofweek
);
2904 size
+=size_of_uint16( &info
->day
);
2905 size
+=size_of_uint16( &info
->hour
);
2906 size
+=size_of_uint16( &info
->minute
);
2907 size
+=size_of_uint16( &info
->second
);
2908 size
+=size_of_uint16( &info
->milliseconds
);
2910 size
+=size_of_uint32( &info
->global_counter
);
2911 size
+=size_of_uint32( &info
->total_pages
);
2913 size
+=size_of_uint16( &info
->major_version
);
2914 size
+=size_of_uint16( &info
->build_version
);
2916 size
+=size_of_uint32( &info
->unknown7
);
2917 size
+=size_of_uint32( &info
->unknown8
);
2918 size
+=size_of_uint32( &info
->unknown9
);
2919 size
+=size_of_uint32( &info
->session_counter
);
2920 size
+=size_of_uint32( &info
->unknown11
);
2921 size
+=size_of_uint32( &info
->printer_errors
);
2922 size
+=size_of_uint32( &info
->unknown13
);
2923 size
+=size_of_uint32( &info
->unknown14
);
2924 size
+=size_of_uint32( &info
->unknown15
);
2925 size
+=size_of_uint32( &info
->unknown16
);
2926 size
+=size_of_uint32( &info
->change_id
);
2927 size
+=size_of_uint32( &info
->unknown18
);
2928 size
+=size_of_uint32( &info
->status
);
2929 size
+=size_of_uint32( &info
->unknown20
);
2930 size
+=size_of_uint32( &info
->c_setprinter
);
2932 size
+=size_of_uint16( &info
->unknown22
);
2933 size
+=size_of_uint16( &info
->unknown23
);
2934 size
+=size_of_uint16( &info
->unknown24
);
2935 size
+=size_of_uint16( &info
->unknown25
);
2936 size
+=size_of_uint16( &info
->unknown26
);
2937 size
+=size_of_uint16( &info
->unknown27
);
2938 size
+=size_of_uint16( &info
->unknown28
);
2939 size
+=size_of_uint16( &info
->unknown29
);
2944 /*******************************************************************
2945 return the size required by a struct in the stream
2946 ********************************************************************/
2948 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
2952 size
+=size_of_uint32( &info
->flags
);
2953 size
+=size_of_relative_string( &info
->description
);
2954 size
+=size_of_relative_string( &info
->name
);
2955 size
+=size_of_relative_string( &info
->comment
);
2960 /*******************************************************************
2961 return the size required by a struct in the stream
2962 ********************************************************************/
2964 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
2969 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2970 size
+= sec_desc_size( info
->secdesc
);
2972 size
+=size_of_device_mode( info
->devmode
);
2974 size
+=size_of_relative_string( &info
->servername
);
2975 size
+=size_of_relative_string( &info
->printername
);
2976 size
+=size_of_relative_string( &info
->sharename
);
2977 size
+=size_of_relative_string( &info
->portname
);
2978 size
+=size_of_relative_string( &info
->drivername
);
2979 size
+=size_of_relative_string( &info
->comment
);
2980 size
+=size_of_relative_string( &info
->location
);
2982 size
+=size_of_relative_string( &info
->sepfile
);
2983 size
+=size_of_relative_string( &info
->printprocessor
);
2984 size
+=size_of_relative_string( &info
->datatype
);
2985 size
+=size_of_relative_string( &info
->parameters
);
2987 size
+=size_of_uint32( &info
->attributes
);
2988 size
+=size_of_uint32( &info
->priority
);
2989 size
+=size_of_uint32( &info
->defaultpriority
);
2990 size
+=size_of_uint32( &info
->starttime
);
2991 size
+=size_of_uint32( &info
->untiltime
);
2992 size
+=size_of_uint32( &info
->status
);
2993 size
+=size_of_uint32( &info
->cjobs
);
2994 size
+=size_of_uint32( &info
->averageppm
);
2998 /*******************************************************************
2999 return the size required by a struct in the stream
3000 ********************************************************************/
3002 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
3006 size
+=size_of_relative_string( &info
->printername
);
3007 size
+=size_of_relative_string( &info
->servername
);
3009 size
+=size_of_uint32( &info
->attributes
);
3013 /*******************************************************************
3014 return the size required by a struct in the stream
3015 ********************************************************************/
3017 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
3021 size
+=size_of_relative_string( &info
->printername
);
3022 size
+=size_of_relative_string( &info
->portname
);
3024 size
+=size_of_uint32( &info
->attributes
);
3025 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
3026 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
3031 /*******************************************************************
3032 return the size required by a struct in the stream
3033 ********************************************************************/
3035 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
3037 /* The 4 is for the self relative pointer.. */
3038 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
3039 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
3042 /*******************************************************************
3043 return the size required by a struct in the stream
3044 ********************************************************************/
3046 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
3049 size
+=size_of_relative_string( &info
->name
);
3054 /*******************************************************************
3055 return the size required by a struct in the stream
3056 ********************************************************************/
3058 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
3061 size
+=size_of_uint32( &info
->version
);
3062 size
+=size_of_relative_string( &info
->name
);
3063 size
+=size_of_relative_string( &info
->architecture
);
3064 size
+=size_of_relative_string( &info
->driverpath
);
3065 size
+=size_of_relative_string( &info
->datafile
);
3066 size
+=size_of_relative_string( &info
->configfile
);
3071 /*******************************************************************
3072 return the size required by a string array.
3073 ********************************************************************/
3075 uint32
spoolss_size_string_array(uint16
*string
)
3080 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
3082 i
=i
+2; /* to count all chars including the leading zero */
3083 i
=2*i
; /* because we need the value in bytes */
3084 i
=i
+4; /* the offset pointer size */
3089 /*******************************************************************
3090 return the size required by a struct in the stream
3091 ********************************************************************/
3093 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
3097 size
+=size_of_uint32( &info
->version
);
3098 size
+=size_of_relative_string( &info
->name
);
3099 size
+=size_of_relative_string( &info
->architecture
);
3100 size
+=size_of_relative_string( &info
->driverpath
);
3101 size
+=size_of_relative_string( &info
->datafile
);
3102 size
+=size_of_relative_string( &info
->configfile
);
3103 size
+=size_of_relative_string( &info
->helpfile
);
3104 size
+=size_of_relative_string( &info
->monitorname
);
3105 size
+=size_of_relative_string( &info
->defaultdatatype
);
3107 size
+=spoolss_size_string_array(info
->dependentfiles
);
3112 /*******************************************************************
3113 return the size required by a struct in the stream
3114 ********************************************************************/
3116 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
3120 size
+=size_of_uint32( &info
->version
);
3121 size
+=size_of_relative_string( &info
->name
);
3122 size
+=size_of_relative_string( &info
->architecture
);
3123 size
+=size_of_relative_string( &info
->driverpath
);
3124 size
+=size_of_relative_string( &info
->datafile
);
3125 size
+=size_of_relative_string( &info
->configfile
);
3126 size
+=size_of_relative_string( &info
->helpfile
);
3128 size
+=spoolss_size_string_array(info
->dependentfiles
);
3130 size
+=size_of_relative_string( &info
->monitorname
);
3131 size
+=size_of_relative_string( &info
->defaultdatatype
);
3133 size
+=spoolss_size_string_array(info
->previousdrivernames
);
3135 size
+=size_of_nttime(&info
->driver_date
);
3136 size
+=size_of_uint32( &info
->padding
);
3137 size
+=size_of_uint32( &info
->driver_version_low
);
3138 size
+=size_of_uint32( &info
->driver_version_high
);
3139 size
+=size_of_relative_string( &info
->mfgname
);
3140 size
+=size_of_relative_string( &info
->oem_url
);
3141 size
+=size_of_relative_string( &info
->hardware_id
);
3142 size
+=size_of_relative_string( &info
->provider
);
3147 /*******************************************************************
3148 return the size required by a struct in the stream
3149 ********************************************************************/
3151 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
3154 size
+=size_of_uint32( &info
->jobid
);
3155 size
+=size_of_relative_string( &info
->printername
);
3156 size
+=size_of_relative_string( &info
->machinename
);
3157 size
+=size_of_relative_string( &info
->username
);
3158 size
+=size_of_relative_string( &info
->document
);
3159 size
+=size_of_relative_string( &info
->datatype
);
3160 size
+=size_of_relative_string( &info
->text_status
);
3161 size
+=size_of_uint32( &info
->status
);
3162 size
+=size_of_uint32( &info
->priority
);
3163 size
+=size_of_uint32( &info
->position
);
3164 size
+=size_of_uint32( &info
->totalpages
);
3165 size
+=size_of_uint32( &info
->pagesprinted
);
3166 size
+=size_of_systemtime( &info
->submitted
);
3171 /*******************************************************************
3172 return the size required by a struct in the stream
3173 ********************************************************************/
3175 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
3179 size
+=4; /* size of sec desc ptr */
3181 size
+=size_of_uint32( &info
->jobid
);
3182 size
+=size_of_relative_string( &info
->printername
);
3183 size
+=size_of_relative_string( &info
->machinename
);
3184 size
+=size_of_relative_string( &info
->username
);
3185 size
+=size_of_relative_string( &info
->document
);
3186 size
+=size_of_relative_string( &info
->notifyname
);
3187 size
+=size_of_relative_string( &info
->datatype
);
3188 size
+=size_of_relative_string( &info
->printprocessor
);
3189 size
+=size_of_relative_string( &info
->parameters
);
3190 size
+=size_of_relative_string( &info
->drivername
);
3191 size
+=size_of_device_mode( info
->devmode
);
3192 size
+=size_of_relative_string( &info
->text_status
);
3193 /* SEC_DESC sec_desc;*/
3194 size
+=size_of_uint32( &info
->status
);
3195 size
+=size_of_uint32( &info
->priority
);
3196 size
+=size_of_uint32( &info
->position
);
3197 size
+=size_of_uint32( &info
->starttime
);
3198 size
+=size_of_uint32( &info
->untiltime
);
3199 size
+=size_of_uint32( &info
->totalpages
);
3200 size
+=size_of_uint32( &info
->size
);
3201 size
+=size_of_systemtime( &info
->submitted
);
3202 size
+=size_of_uint32( &info
->timeelapsed
);
3203 size
+=size_of_uint32( &info
->pagesprinted
);
3208 /*******************************************************************
3209 return the size required by a struct in the stream
3210 ********************************************************************/
3212 uint32
spoolss_size_form_1(FORM_1
*info
)
3216 size
+=size_of_uint32( &info
->flag
);
3217 size
+=size_of_relative_string( &info
->name
);
3218 size
+=size_of_uint32( &info
->width
);
3219 size
+=size_of_uint32( &info
->length
);
3220 size
+=size_of_uint32( &info
->left
);
3221 size
+=size_of_uint32( &info
->top
);
3222 size
+=size_of_uint32( &info
->right
);
3223 size
+=size_of_uint32( &info
->bottom
);
3228 /*******************************************************************
3229 return the size required by a struct in the stream
3230 ********************************************************************/
3232 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
3236 size
+=size_of_relative_string( &info
->port_name
);
3241 /*******************************************************************
3242 return the size required by a struct in the stream
3243 ********************************************************************/
3245 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
3249 size
=str_len_uni(&info
->name
); /* the string length */
3250 size
=size
+1; /* add the leading zero */
3251 size
=size
*2; /* convert in char */
3256 /*******************************************************************
3257 return the size required by a struct in the stream
3258 ********************************************************************/
3260 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
3264 size
=str_len_uni(&info
->name
); /* the string length */
3265 size
=size
+1; /* add the leading zero */
3266 size
=size
*2; /* convert in char */
3271 /*******************************************************************
3272 return the size required by a struct in the stream
3273 ********************************************************************/
3275 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
3279 size
+=size_of_relative_string( &info
->port_name
);
3280 size
+=size_of_relative_string( &info
->monitor_name
);
3281 size
+=size_of_relative_string( &info
->description
);
3283 size
+=size_of_uint32( &info
->port_type
);
3284 size
+=size_of_uint32( &info
->reserved
);
3289 /*******************************************************************
3290 return the size required by a struct in the stream
3291 ********************************************************************/
3293 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
3296 size
+=size_of_relative_string( &info
->name
);
3301 /*******************************************************************
3302 return the size required by a struct in the stream
3303 ********************************************************************/
3305 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
3308 size
+=size_of_relative_string( &info
->name
);
3313 /*******************************************************************
3314 return the size required by a struct in the stream
3315 ********************************************************************/
3316 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
3323 /* uint32(offset) + uint32(length) + length) */
3324 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
3325 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
;
3327 size
+= size_of_uint32(&p
->type
);
3332 /*******************************************************************
3333 return the size required by a struct in the stream
3334 ********************************************************************/
3336 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
3339 size
+=size_of_relative_string( &info
->name
);
3344 /*******************************************************************
3345 return the size required by a struct in the stream
3346 ********************************************************************/
3348 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
3351 size
+=size_of_relative_string( &info
->name
);
3352 size
+=size_of_relative_string( &info
->environment
);
3353 size
+=size_of_relative_string( &info
->dll_name
);
3358 /*******************************************************************
3360 ********************************************************************/
3362 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
3363 const POLICY_HND
*hnd
,
3364 const fstring architecture
,
3365 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
3366 NEW_BUFFER
*buffer
, uint32 offered
)
3371 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3373 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
3376 q_u
->clientmajorversion
=clientmajor
;
3377 q_u
->clientminorversion
=clientminor
;
3380 q_u
->offered
=offered
;
3385 /*******************************************************************
3387 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3388 ********************************************************************/
3390 BOOL
spoolss_io_q_getprinterdriver2(char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
3392 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
3398 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3400 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
3402 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
3407 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3410 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3416 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3419 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
3421 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
3427 /*******************************************************************
3429 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
3430 ********************************************************************/
3432 BOOL
spoolss_io_r_getprinterdriver2(char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
3434 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
3440 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3445 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3447 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
3449 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
3451 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3457 /*******************************************************************
3459 ********************************************************************/
3461 BOOL
make_spoolss_q_enumprinters(
3462 SPOOL_Q_ENUMPRINTERS
*q_u
,
3472 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
3473 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
3477 q_u
->offered
=offered
;
3482 /*******************************************************************
3484 ********************************************************************/
3486 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
3487 fstring servername
, uint32 level
,
3488 NEW_BUFFER
*buffer
, uint32 offered
)
3490 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
3491 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
3495 q_u
->offered
=offered
;
3500 /*******************************************************************
3502 * called from spoolss_enumprinters (srv_spoolss.c)
3503 ********************************************************************/
3505 BOOL
spoolss_io_q_enumprinters(char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
3507 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
3513 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
3515 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
3518 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3523 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3526 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3531 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3537 /*******************************************************************
3538 Parse a SPOOL_R_ENUMPRINTERS structure.
3539 ********************************************************************/
3541 BOOL
spoolss_io_r_enumprinters(char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3543 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
3549 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3555 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3558 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3561 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3567 /*******************************************************************
3568 * write a structure.
3569 * called from spoolss_r_enum_printers (srv_spoolss.c)
3571 ********************************************************************/
3573 BOOL
spoolss_io_r_getprinter(char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3575 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3581 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3587 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3590 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3596 /*******************************************************************
3598 * called from spoolss_getprinter (srv_spoolss.c)
3599 ********************************************************************/
3601 BOOL
spoolss_io_q_getprinter(char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3603 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3609 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3611 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3614 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3619 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3625 /*******************************************************************
3627 ********************************************************************/
3629 BOOL
make_spoolss_q_getprinter(
3630 TALLOC_CTX
*mem_ctx
,
3631 SPOOL_Q_GETPRINTER
*q_u
,
3632 const POLICY_HND
*hnd
,
3642 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3646 q_u
->offered
=offered
;
3651 /*******************************************************************
3653 ********************************************************************/
3654 BOOL
make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
3655 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
3659 DEVICEMODE
*devmode
;
3664 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3667 q_u
->info
.level
= level
;
3668 q_u
->info
.info_ptr
= (info
!= NULL
) ? 1 : 0;
3671 secdesc
= info
->printers_2
->secdesc
;
3672 devmode
= info
->printers_2
->devmode
;
3674 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
3675 #if 1 /* JERRY TEST */
3676 q_u
->secdesc_ctr
= (SEC_DESC_BUF
*)malloc(sizeof(SEC_DESC_BUF
));
3677 if (!q_u
->secdesc_ctr
)
3679 q_u
->secdesc_ctr
->ptr
= (secdesc
!= NULL
) ? 1: 0;
3680 q_u
->secdesc_ctr
->max_len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3681 q_u
->secdesc_ctr
->len
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
3682 q_u
->secdesc_ctr
->sec
= secdesc
;
3684 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
3685 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
3686 q_u
->devmode_ctr
.devmode
= devmode
;
3688 q_u
->secdesc_ctr
= NULL
;
3690 q_u
->devmode_ctr
.devmode_ptr
= 0;
3691 q_u
->devmode_ctr
.size
= 0;
3692 q_u
->devmode_ctr
.devmode
= NULL
;
3696 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
3701 q_u
->command
= command
;
3707 /*******************************************************************
3708 ********************************************************************/
3710 BOOL
spoolss_io_r_setprinter(char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3712 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3718 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3724 /*******************************************************************
3725 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3726 ********************************************************************/
3728 BOOL
spoolss_io_q_setprinter(char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3730 uint32 ptr_sec_desc
= 0;
3732 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3738 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3740 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3743 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3746 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3753 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3758 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3764 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3769 /* Parse a NULL security descriptor. This should really
3770 happen inside the sec_io_desc_buf() function. */
3772 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3773 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
3775 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
)) return
3779 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3785 /*******************************************************************
3786 ********************************************************************/
3788 BOOL
spoolss_io_r_fcpn(char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
3790 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
3796 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3802 /*******************************************************************
3803 ********************************************************************/
3805 BOOL
spoolss_io_q_fcpn(char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
3808 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
3814 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3821 /*******************************************************************
3822 ********************************************************************/
3824 BOOL
spoolss_io_r_addjob(char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
3826 prs_debug(ps
, depth
, desc
, "");
3832 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3838 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3841 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3847 /*******************************************************************
3848 ********************************************************************/
3850 BOOL
spoolss_io_q_addjob(char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
3852 prs_debug(ps
, depth
, desc
, "");
3858 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3860 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3863 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3869 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3875 /*******************************************************************
3876 ********************************************************************/
3878 BOOL
spoolss_io_r_enumjobs(char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
3880 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
3886 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
3892 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3895 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3898 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3904 /*******************************************************************
3905 ********************************************************************/
3907 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
3918 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3919 q_u
->firstjob
= firstjob
;
3920 q_u
->numofjobs
= numofjobs
;
3922 q_u
->buffer
= buffer
;
3923 q_u
->offered
= offered
;
3927 /*******************************************************************
3928 ********************************************************************/
3930 BOOL
spoolss_io_q_enumjobs(char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
3932 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
3938 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
3941 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
3943 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
3945 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3948 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
3951 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3957 /*******************************************************************
3958 ********************************************************************/
3960 BOOL
spoolss_io_r_schedulejob(char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
3962 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
3968 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3974 /*******************************************************************
3975 ********************************************************************/
3977 BOOL
spoolss_io_q_schedulejob(char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
3979 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
3985 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3987 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3993 /*******************************************************************
3994 ********************************************************************/
3996 BOOL
spoolss_io_r_setjob(char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
3998 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
4004 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4010 /*******************************************************************
4011 ********************************************************************/
4013 BOOL
spoolss_io_q_setjob(char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
4015 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
4021 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4023 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4026 * level is usually 0. If (level!=0) then I'm in trouble !
4027 * I will try to generate setjob command with level!=0, one day.
4029 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4031 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
4037 /*******************************************************************
4038 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
4039 ********************************************************************/
4041 BOOL
spoolss_io_r_enumprinterdrivers(char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
4043 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
4049 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4055 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4058 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4061 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4067 /*******************************************************************
4069 ********************************************************************/
4071 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
4073 const char *environment
,
4075 NEW_BUFFER
*buffer
, uint32 offered
)
4077 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
4078 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
4082 q_u
->offered
=offered
;
4087 /*******************************************************************
4088 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
4089 ********************************************************************/
4091 BOOL
spoolss_io_q_enumprinterdrivers(char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
4094 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
4100 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4102 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
4107 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
4109 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4114 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4117 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4123 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4129 /*******************************************************************
4130 ********************************************************************/
4132 BOOL
spoolss_io_q_enumforms(char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
4135 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
4140 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4142 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4145 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4150 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4156 /*******************************************************************
4157 ********************************************************************/
4159 BOOL
spoolss_io_r_enumforms(char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
4161 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
4167 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4173 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4176 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
4179 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4185 /*******************************************************************
4186 ********************************************************************/
4188 BOOL
spoolss_io_q_getform(char *desc
, SPOOL_Q_GETFORM
*q_u
, prs_struct
*ps
, int depth
)
4191 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getform");
4196 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4198 if (!smb_io_unistr2("", &q_u
->formname
,True
,ps
,depth
))
4204 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4207 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4212 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4218 /*******************************************************************
4219 ********************************************************************/
4221 BOOL
spoolss_io_r_getform(char *desc
, SPOOL_R_GETFORM
*r_u
, prs_struct
*ps
, int depth
)
4223 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getform");
4229 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4235 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
4238 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4244 /*******************************************************************
4245 Parse a SPOOL_R_ENUMPORTS structure.
4246 ********************************************************************/
4248 BOOL
spoolss_io_r_enumports(char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
4250 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
4256 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
4262 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4265 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4268 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4274 /*******************************************************************
4275 ********************************************************************/
4277 BOOL
spoolss_io_q_enumports(char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
4279 prs_debug(ps
, depth
, desc
, "");
4285 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
4287 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
4292 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4295 if (!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
4300 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4306 /*******************************************************************
4307 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
4308 ********************************************************************/
4310 BOOL
spool_io_printer_info_level_1(char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
4312 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
4318 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
4320 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
4322 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4324 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4327 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
4329 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4331 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4337 /*******************************************************************
4338 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
4339 ********************************************************************/
4341 BOOL
spool_io_printer_info_level_3(char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
4343 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
4349 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4355 /*******************************************************************
4356 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
4357 ********************************************************************/
4359 BOOL
spool_io_printer_info_level_2(char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
4361 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
4367 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
4369 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
4371 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
4373 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
4376 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
4378 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
4380 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
4382 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
4384 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
4386 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
4388 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
4390 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
4392 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
4395 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
4397 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
4399 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
4401 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
4403 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
4405 if(!prs_uint32("status", ps
, depth
, &il
->status
))
4407 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
4409 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
4412 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
4414 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
4416 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
4418 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
4420 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
4422 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
4424 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
4426 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
4428 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
4430 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
4432 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
4438 /*******************************************************************
4439 ********************************************************************/
4441 BOOL
spool_io_printer_info_level(char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4443 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
4448 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4450 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
4453 /* if no struct inside just return */
4454 if (il
->info_ptr
==0) {
4455 if (UNMARSHALLING(ps
)) {
4462 switch (il
->level
) {
4464 * level 0 is used by setprinter when managing the queue
4465 * (hold, stop, start a queue)
4469 /* DOCUMENT ME!!! What is level 1 used for? */
4472 if (UNMARSHALLING(ps
)) {
4473 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
4476 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
4481 * level 2 is used by addprinter
4482 * and by setprinter when updating printer's info
4485 if (UNMARSHALLING(ps
)) {
4486 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
4489 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
4492 /* DOCUMENT ME!!! What is level 3 used for? */
4495 if (UNMARSHALLING(ps
)) {
4496 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
4499 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
4508 /*******************************************************************
4509 ********************************************************************/
4511 BOOL
spoolss_io_q_addprinterex(char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
4513 uint32 ptr_sec_desc
= 0;
4515 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
4520 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
4522 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4528 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4531 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
4534 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4537 switch (q_u
->level
) {
4539 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
4542 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
4546 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
4551 /* Parse a NULL security descriptor. This should really
4552 happen inside the sec_io_desc_buf() function. */
4554 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
4555 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
4557 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
4561 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
4563 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
4569 /*******************************************************************
4570 ********************************************************************/
4572 BOOL
spoolss_io_r_addprinterex(char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
4573 prs_struct
*ps
, int depth
)
4575 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
4578 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
4581 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4587 /*******************************************************************
4588 ********************************************************************/
4590 BOOL
spool_io_printer_driver_info_level_3(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
4591 prs_struct
*ps
, int depth
)
4593 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
4595 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
4599 if (UNMARSHALLING(ps
)) {
4600 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
4612 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
4614 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
4616 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
4618 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
4620 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
4622 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
4624 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
4626 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
4628 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
4630 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
4632 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
4638 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4640 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4642 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4644 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4646 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4648 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4650 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4652 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4658 if (il
->dependentfiles_ptr
)
4659 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
4664 /*******************************************************************
4665 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4666 ********************************************************************/
4668 BOOL
spool_io_printer_driver_info_level_6(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4669 prs_struct
*ps
, int depth
)
4671 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4673 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4677 if (UNMARSHALLING(ps
)) {
4678 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)prs_alloc_mem(ps
,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
4691 /* parse the main elements the packet */
4693 if(!prs_uint32("version", ps
, depth
, &il
->version
))
4696 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4699 * If name_ptr is NULL then the next 4 bytes are the name_ptr. A driver
4700 * with a NULL name just isn't a driver For example: "HP LaserJet 4si"
4701 * from W2K CDROM (which uses unidriver). JohnR 010205
4703 if (!il
->name_ptr
) {
4704 DEBUG(5,("spool_io_printer_driver_info_level_6: name_ptr is NULL! Get next value\n"));
4705 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4709 if(!prs_uint32("environment_ptr", ps
, depth
, &il
->environment_ptr
))
4711 if(!prs_uint32("driverpath_ptr", ps
, depth
, &il
->driverpath_ptr
))
4713 if(!prs_uint32("datafile_ptr", ps
, depth
, &il
->datafile_ptr
))
4715 if(!prs_uint32("configfile_ptr", ps
, depth
, &il
->configfile_ptr
))
4717 if(!prs_uint32("helpfile_ptr", ps
, depth
, &il
->helpfile_ptr
))
4719 if(!prs_uint32("monitorname_ptr", ps
, depth
, &il
->monitorname_ptr
))
4721 if(!prs_uint32("defaultdatatype_ptr", ps
, depth
, &il
->defaultdatatype_ptr
))
4723 if(!prs_uint32("dependentfiles_len", ps
, depth
, &il
->dependentfiles_len
))
4725 if(!prs_uint32("dependentfiles_ptr", ps
, depth
, &il
->dependentfiles_ptr
))
4727 if(!prs_uint32("previousnames_len", ps
, depth
, &il
->previousnames_len
))
4729 if(!prs_uint32("previousnames_ptr", ps
, depth
, &il
->previousnames_ptr
))
4731 if(!smb_io_time("driverdate", &il
->driverdate
, ps
, depth
))
4733 if(!prs_uint32("dummy4", ps
, depth
, &il
->dummy4
))
4735 if(!prs_uint64("driverversion", ps
, depth
, &il
->driverversion
))
4737 if(!prs_uint32("mfgname_ptr", ps
, depth
, &il
->mfgname_ptr
))
4739 if(!prs_uint32("oemurl_ptr", ps
, depth
, &il
->oemurl_ptr
))
4741 if(!prs_uint32("hardwareid_ptr", ps
, depth
, &il
->hardwareid_ptr
))
4743 if(!prs_uint32("provider_ptr", ps
, depth
, &il
->provider_ptr
))
4746 /* parse the structures in the packet */
4748 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4753 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4758 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4763 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4768 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4773 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4778 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4783 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4787 if (il
->dependentfiles_ptr
) {
4788 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
4793 if (il
->previousnames_ptr
) {
4794 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
4799 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
4803 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
4807 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
4811 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
4817 /*******************************************************************
4818 convert a buffer of UNICODE strings null terminated
4819 the buffer is terminated by a NULL
4821 convert to an dos codepage array (null terminated)
4823 dynamically allocate memory
4825 ********************************************************************/
4826 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
4835 src
= (char *)buf5
->buffer
;
4838 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
4839 unistr_to_dos(f
, src
, sizeof(f
)-1);
4840 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
4841 tar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
4846 fstrcpy((*ar
)[n
], f
);
4849 fstrcpy((*ar
)[n
], "");
4857 /*******************************************************************
4858 read a UNICODE array with null terminated strings
4859 and null terminated array
4860 and size of array at beginning
4861 ********************************************************************/
4863 BOOL
smb_io_unibuffer(char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
4865 if (buffer
==NULL
) return False
;
4868 buffer
->uni_str_len
=buffer
->uni_max_len
;
4870 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
4873 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
4879 /*******************************************************************
4880 ********************************************************************/
4882 BOOL
spool_io_printer_driver_info_level(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4884 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
4889 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4891 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
4897 switch (il
->level
) {
4899 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
4903 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
4913 /*******************************************************************
4914 init a SPOOL_Q_ADDPRINTERDRIVER struct
4915 ******************************************************************/
4917 BOOL
make_spoolss_q_addprinterdriver(
4918 TALLOC_CTX
*mem_ctx
,
4919 SPOOL_Q_ADDPRINTERDRIVER
*q_u
,
4920 const char* srv_name
,
4922 PRINTER_DRIVER_CTR
*info
)
4924 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
4926 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
4927 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
)+1);
4931 q_u
->info
.level
= level
;
4932 q_u
->info
.ptr
= (info
!=NULL
)?1:0;
4935 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
4937 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
4940 /* info level 6 is supported by WinME and Win2k */
4942 /* WRITEME!! will add later --jerry */
4946 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
4953 BOOL
make_spoolss_driver_info_3(
4954 TALLOC_CTX
*mem_ctx
,
4955 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
4956 DRIVER_INFO_3
*info3
4960 uint16
*ptr
= info3
->dependentfiles
;
4962 BOOL null_char
= False
;
4963 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
4965 if (!(inf
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)talloc_zero(mem_ctx
, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
))))
4968 inf
->cversion
= info3
->version
;
4969 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
4970 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
4971 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
4972 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
4973 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
4974 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
4975 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
4976 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
4978 init_unistr2_from_unistr(&inf
->name
, &info3
->name
);
4979 init_unistr2_from_unistr(&inf
->environment
, &info3
->architecture
);
4980 init_unistr2_from_unistr(&inf
->driverpath
, &info3
->driverpath
);
4981 init_unistr2_from_unistr(&inf
->datafile
, &info3
->datafile
);
4982 init_unistr2_from_unistr(&inf
->configfile
, &info3
->configfile
);
4983 init_unistr2_from_unistr(&inf
->helpfile
, &info3
->helpfile
);
4984 init_unistr2_from_unistr(&inf
->monitorname
, &info3
->monitorname
);
4985 init_unistr2_from_unistr(&inf
->defaultdatatype
, &info3
->defaultdatatype
);
4992 /* the null_char BOOL is used to help locate
4993 two '\0's back to back */
5008 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
5009 inf
->dependentfilessize
= len
;
5010 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
))
5016 *spool_drv_info
= inf
;
5021 /*******************************************************************
5022 make a BUFFER5 struct from a uint16*
5023 ******************************************************************/
5024 BOOL
make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
5027 buf5
->buf_len
= len
;
5028 if((buf5
->buffer
=(uint16
*)talloc_memdup(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
)
5030 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
5037 /*******************************************************************
5038 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
5039 ********************************************************************/
5041 BOOL
spoolss_io_q_addprinterdriver(char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5043 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
5049 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
5051 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
5056 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
5059 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
5065 /*******************************************************************
5066 ********************************************************************/
5068 BOOL
spoolss_io_r_addprinterdriver(char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
5070 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
5073 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
5079 /*******************************************************************
5080 ********************************************************************/
5082 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
5083 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
5085 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
5087 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
5091 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
5099 d
->cversion
=uni
->cversion
;
5101 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5102 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5103 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5104 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5105 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5106 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5107 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5108 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5110 DEBUGADD(8,( "version: %d\n", d
->cversion
));
5111 DEBUGADD(8,( "name: %s\n", d
->name
));
5112 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5113 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5114 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5115 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5116 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5117 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5118 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5120 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5127 /*******************************************************************
5128 ********************************************************************/
5129 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
5130 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
5132 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
5134 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
5138 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
5146 d
->version
=uni
->version
;
5148 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
5149 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
5150 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
5151 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
5152 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
5153 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
5154 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
5155 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
5157 DEBUGADD(8,( "version: %d\n", d
->version
));
5158 DEBUGADD(8,( "name: %s\n", d
->name
));
5159 DEBUGADD(8,( "environment: %s\n", d
->environment
));
5160 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
5161 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
5162 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
5163 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
5164 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
5165 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
5167 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
5169 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
5179 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
5180 NT_PRINTER_INFO_LEVEL_2
**asc
)
5182 NT_PRINTER_INFO_LEVEL_2
*d
;
5185 DEBUG(7,("Converting from UNICODE to ASCII\n"));
5186 time_unix
=time(NULL
);
5189 DEBUGADD(8,("allocating memory\n"));
5191 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
5196 /* we allocate memory iff called from
5197 * addprinter(ex) so we can do one time stuff here.
5199 (*asc
)->setuptime
=time_unix
;
5201 DEBUGADD(8,("start converting\n"));
5205 d
->attributes
=uni
->attributes
;
5206 d
->priority
=uni
->priority
;
5207 d
->default_priority
=uni
->default_priority
;
5208 d
->starttime
=uni
->starttime
;
5209 d
->untiltime
=uni
->untiltime
;
5210 d
->status
=uni
->status
;
5211 d
->cjobs
=uni
->cjobs
;
5213 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
5214 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
5215 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
5216 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
5217 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
5218 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
5219 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
5220 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
5221 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
5222 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
5223 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
5228 /*******************************************************************
5230 ********************************************************************/
5232 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
5233 fstring servername
, fstring env_name
, uint32 level
,
5234 NEW_BUFFER
*buffer
, uint32 offered
)
5236 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
5237 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
5241 q_u
->offered
=offered
;
5246 /*******************************************************************
5247 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
5248 ********************************************************************/
5250 BOOL
spoolss_io_q_getprinterdriverdir(char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
5252 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
5257 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5259 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
5265 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5267 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5273 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5276 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5282 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5288 /*******************************************************************
5289 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
5290 ********************************************************************/
5292 BOOL
spoolss_io_r_getprinterdriverdir(char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
5294 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
5300 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5306 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5309 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5315 /*******************************************************************
5316 ********************************************************************/
5318 BOOL
spoolss_io_r_enumprintprocessors(char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
5320 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
5326 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5332 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5335 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5338 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5344 /*******************************************************************
5345 ********************************************************************/
5347 BOOL
spoolss_io_q_enumprintprocessors(char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
5349 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
5355 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5357 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5363 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
5365 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
5371 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5374 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5380 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5386 /*******************************************************************
5387 ********************************************************************/
5389 BOOL
spoolss_io_q_addprintprocessor(char *desc
, SPOOL_Q_ADDPRINTPROCESSOR
*q_u
, prs_struct
*ps
, int depth
)
5391 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprintprocessor");
5397 if (!prs_uint32("server_ptr", ps
, depth
, &q_u
->server_ptr
))
5399 if (!smb_io_unistr2("server", &q_u
->server
, q_u
->server_ptr
, ps
, depth
))
5404 if (!smb_io_unistr2("environment", &q_u
->environment
, True
, ps
, depth
))
5409 if (!smb_io_unistr2("path", &q_u
->path
, True
, ps
, depth
))
5414 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5420 /*******************************************************************
5421 ********************************************************************/
5423 BOOL
spoolss_io_r_addprintprocessor(char *desc
, SPOOL_R_ADDPRINTPROCESSOR
*r_u
, prs_struct
*ps
, int depth
)
5425 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprintproicessor");
5431 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5437 /*******************************************************************
5438 ********************************************************************/
5440 BOOL
spoolss_io_r_enumprintprocdatatypes(char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
5442 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
5448 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5454 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5457 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5460 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5466 /*******************************************************************
5467 ********************************************************************/
5469 BOOL
spoolss_io_q_enumprintprocdatatypes(char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
5471 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
5477 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5479 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5485 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
5487 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
5493 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5496 if(!spoolss_io_buffer("buffer", ps
, depth
, &q_u
->buffer
))
5502 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5508 /*******************************************************************
5509 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
5510 ********************************************************************/
5512 BOOL
spoolss_io_q_enumprintmonitors(char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
5514 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
5520 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
5522 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5528 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
5531 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
5537 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5543 /*******************************************************************
5544 ********************************************************************/
5546 BOOL
spoolss_io_r_enumprintmonitors(char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
5548 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
5554 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5560 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5563 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5566 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5572 /*******************************************************************
5573 ********************************************************************/
5575 BOOL
spoolss_io_r_enumprinterdata(char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5577 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
5582 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
5585 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
5591 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
5594 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
5597 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
5599 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
5604 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
5606 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5612 /*******************************************************************
5613 ********************************************************************/
5615 BOOL
spoolss_io_q_enumprinterdata(char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5617 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
5622 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5624 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
5626 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
5628 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
5634 /*******************************************************************
5635 ********************************************************************/
5637 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
5638 const POLICY_HND
*hnd
,
5639 uint32 idx
, uint32 valuelen
, uint32 datalen
)
5641 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5643 q_u
->valuesize
=valuelen
;
5644 q_u
->datasize
=datalen
;
5649 /*******************************************************************
5650 ********************************************************************/
5651 BOOL
make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, TALLOC_CTX
*ctx
, const POLICY_HND
*hnd
,
5652 char* value
, char* data
)
5656 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5658 init_unistr2(&q_u
->value
, value
, strlen(value
)+1);
5660 init_unistr2(&tmp
, data
, strlen(data
)+1);
5661 q_u
->max_len
= q_u
->real_len
= tmp
.uni_max_len
*2;
5662 q_u
->data
= talloc(ctx
, q_u
->real_len
);
5663 memcpy(q_u
->data
, tmp
.buffer
, q_u
->real_len
);
5667 /*******************************************************************
5668 ********************************************************************/
5670 BOOL
spoolss_io_q_setprinterdata(char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
5672 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
5677 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5679 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
5685 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5688 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
5698 if (UNMARSHALLING(ps
))
5699 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
5700 if(q_u
->data
== NULL
)
5702 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
5710 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
5716 /*******************************************************************
5717 ********************************************************************/
5719 BOOL
spoolss_io_r_setprinterdata(char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
5721 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
5726 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5732 /*******************************************************************
5733 ********************************************************************/
5734 BOOL
spoolss_io_q_resetprinter(char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5736 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
5741 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5744 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
5747 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
5754 /*******************************************************************
5755 ********************************************************************/
5756 BOOL
spoolss_io_r_resetprinter(char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5758 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
5763 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5769 /*******************************************************************
5770 ********************************************************************/
5771 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
5772 uint32 type
, const uint8
*data
, uint32 len
)
5774 DEBUG(5,("converting a specific param struct\n"));
5778 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
5781 memset((char *)*param
, '\0', sizeof(NT_PRINTER_PARAM
));
5782 DEBUGADD(6,("Allocated a new PARAM struct\n"));
5784 unistr2_to_ascii((*param
)->value
, value
, sizeof((*param
)->value
)-1);
5785 (*param
)->type
= type
;
5787 /* le champ data n'est pas NULL termine */
5788 /* on stocke donc la longueur */
5790 (*param
)->data_len
=len
;
5793 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
5794 if((*param
)->data
== NULL
)
5796 memcpy((*param
)->data
, data
, len
);
5799 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
5800 dump_data(10, (char *)(*param
)->data
, (*param
)->data_len
);
5805 /*******************************************************************
5806 ********************************************************************/
5808 static BOOL
spoolss_io_addform(char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
5810 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
5817 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
5819 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
5821 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
5823 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
5825 if(!prs_uint32("left", ps
, depth
, &f
->left
))
5827 if(!prs_uint32("top", ps
, depth
, &f
->top
))
5829 if(!prs_uint32("right", ps
, depth
, &f
->right
))
5831 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
5834 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
5841 /*******************************************************************
5842 ********************************************************************/
5844 BOOL
spoolss_io_q_deleteform(char *desc
, SPOOL_Q_DELETEFORM
*q_u
, prs_struct
*ps
, int depth
)
5846 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteform");
5851 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5853 if(!smb_io_unistr2("form name", &q_u
->name
, True
, ps
, depth
))
5859 /*******************************************************************
5860 ********************************************************************/
5862 BOOL
spoolss_io_r_deleteform(char *desc
, SPOOL_R_DELETEFORM
*r_u
, prs_struct
*ps
, int depth
)
5864 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteform");
5869 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5875 /*******************************************************************
5876 ********************************************************************/
5878 BOOL
spoolss_io_q_addform(char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
5880 uint32 useless_ptr
=0;
5881 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
5886 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5888 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5890 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5895 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5897 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5904 /*******************************************************************
5905 ********************************************************************/
5907 BOOL
spoolss_io_r_addform(char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
5909 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
5914 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5920 /*******************************************************************
5921 ********************************************************************/
5923 BOOL
spoolss_io_q_setform(char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
5925 uint32 useless_ptr
=0;
5926 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
5931 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5933 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
5939 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5941 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
5946 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
5948 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5955 /*******************************************************************
5956 ********************************************************************/
5958 BOOL
spoolss_io_r_setform(char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
5960 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
5965 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5971 /*******************************************************************
5972 Parse a SPOOL_R_GETJOB structure.
5973 ********************************************************************/
5975 BOOL
spoolss_io_r_getjob(char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
5977 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
5983 if (!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
5989 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5992 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5998 /*******************************************************************
5999 Parse a SPOOL_Q_GETJOB structure.
6000 ********************************************************************/
6002 BOOL
spoolss_io_q_getjob(char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
6004 prs_debug(ps
, depth
, desc
, "");
6010 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6012 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
6014 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6017 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6023 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6029 void free_devmode(DEVICEMODE
*devmode
)
6031 if (devmode
!=NULL
) {
6032 SAFE_FREE(devmode
->private);
6037 void free_printer_info_1(PRINTER_INFO_1
*printer
)
6042 void free_printer_info_2(PRINTER_INFO_2
*printer
)
6044 if (printer
!=NULL
) {
6045 free_devmode(printer
->devmode
);
6046 printer
->devmode
= NULL
;
6051 void free_printer_info_3(PRINTER_INFO_3
*printer
)
6056 void free_printer_info_4(PRINTER_INFO_4
*printer
)
6061 void free_printer_info_5(PRINTER_INFO_5
*printer
)
6066 void free_job_info_2(JOB_INFO_2
*job
)
6069 free_devmode(job
->devmode
);
6072 /*******************************************************************
6074 ********************************************************************/
6076 BOOL
make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER
*q_u
,
6077 const fstring string
, uint32 printer
, uint32 type
)
6082 init_unistr2(&q_u
->string
, string
, strlen(string
)+1);
6084 q_u
->printer
=printer
;
6093 /*******************************************************************
6094 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
6095 ********************************************************************/
6097 BOOL
spoolss_io_q_replyopenprinter(char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6099 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
6105 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
6111 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
6113 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6116 if(!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6118 if(!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6124 /*******************************************************************
6125 Parse a SPOOL_R_REPLYOPENPRINTER structure.
6126 ********************************************************************/
6128 BOOL
spoolss_io_r_replyopenprinter(char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6130 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
6136 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6139 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6145 /*******************************************************************
6147 ********************************************************************/
6148 BOOL
make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, POLICY_HND
*hnd
,
6149 uint32 condition
, uint32 change_id
)
6152 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6154 q_u
->condition
= condition
;
6155 q_u
->change_id
= change_id
;
6158 q_u
->unknown1
= 0x1;
6159 memset(q_u
->unknown2
, 0x0, 5);
6160 q_u
->unknown2
[0] = 0x1;
6165 /*******************************************************************
6166 Parse a SPOOL_Q_ROUTERREPLYPRINTER structure.
6167 ********************************************************************/
6168 BOOL
spoolss_io_q_routerreplyprinter (char *desc
, SPOOL_Q_ROUTERREPLYPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6171 prs_debug(ps
, depth
, desc
, "spoolss_io_q_routerreplyprinter");
6177 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6180 if (!prs_uint32("condition", ps
, depth
, &q_u
->condition
))
6183 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6186 if (!prs_uint32("change_id", ps
, depth
, &q_u
->change_id
))
6189 if (!prs_uint8s(False
, "private", ps
, depth
, q_u
->unknown2
, 5))
6195 /*******************************************************************
6196 Parse a SPOOL_R_ROUTERREPLYPRINTER structure.
6197 ********************************************************************/
6198 BOOL
spoolss_io_r_routerreplyprinter (char *desc
, SPOOL_R_ROUTERREPLYPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6200 prs_debug(ps
, depth
, desc
, "spoolss_io_r_routerreplyprinter");
6206 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6212 /*******************************************************************
6214 ********************************************************************/
6216 BOOL
make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
6221 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6226 /*******************************************************************
6227 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
6228 ********************************************************************/
6230 BOOL
spoolss_io_q_replycloseprinter(char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
6232 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
6238 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6244 /*******************************************************************
6245 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
6246 ********************************************************************/
6248 BOOL
spoolss_io_r_replycloseprinter(char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
6250 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
6256 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
6259 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6265 #if 0 /* JERRY - not currently used but could be :-) */
6267 /*******************************************************************
6268 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
6269 ******************************************************************/
6270 static BOOL
copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
6271 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
6275 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
6277 for (i
=0; i
<n
; i
++) {
6281 if (src
->size
!= POINTER
)
6283 len
= src
->notify_data
.data
.length
;
6284 s
= malloc(sizeof(uint16
)*len
);
6286 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
6290 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
6291 dst
->notify_data
.data
.string
= s
;
6297 /*******************************************************************
6298 Deep copy a SPOOL_NOTIFY_INFO structure
6299 ******************************************************************/
6300 static BOOL
copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
6303 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
6307 dst
->version
= src
->version
;
6308 dst
->flags
= src
->flags
;
6309 dst
->count
= src
->count
;
6313 dst
->data
= malloc(dst
->count
* sizeof(SPOOL_NOTIFY_INFO_DATA
));
6315 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
6318 if (dst
->data
== NULL
) {
6319 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
6324 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
6331 /*******************************************************************
6333 ********************************************************************/
6335 BOOL
make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
6336 uint32 change_low
, uint32 change_high
,
6337 SPOOL_NOTIFY_INFO
*info
)
6342 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
6344 q_u
->change_low
=change_low
;
6345 q_u
->change_high
=change_high
;
6350 q_u
->info_ptr
=0xaddee11e;
6352 q_u
->info
.version
=2;
6355 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
6357 q_u
->info
.version
= info
->version
;
6358 q_u
->info
.flags
= info
->flags
;
6359 q_u
->info
.count
= info
->count
;
6360 /* pointer field - be careful! */
6361 q_u
->info
.data
= info
->data
;
6364 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
6371 /*******************************************************************
6372 Parse a SPOOL_Q_REPLY_RRPCN structure.
6373 ********************************************************************/
6375 BOOL
spoolss_io_q_reply_rrpcn(char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
6377 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
6383 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6386 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
6389 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
6392 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
6395 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
6398 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
6401 if(q_u
->info_ptr
!=0)
6402 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
6408 /*******************************************************************
6409 Parse a SPOOL_R_REPLY_RRPCN structure.
6410 ********************************************************************/
6412 BOOL
spoolss_io_r_reply_rrpcn(char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
6414 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
6420 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
6423 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6429 /*******************************************************************
6431 * called from spoolss_q_getprinterdataex (srv_spoolss.c)
6432 ********************************************************************/
6434 BOOL
spoolss_io_q_getprinterdataex(char *desc
, SPOOL_Q_GETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6439 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdataex");
6444 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
6448 if (!smb_io_unistr2("keyname", &q_u
->keyname
,True
,ps
,depth
))
6452 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
6456 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
6462 /*******************************************************************
6463 * write a structure.
6464 * called from spoolss_r_getprinterdataex (srv_spoolss.c)
6465 ********************************************************************/
6467 BOOL
spoolss_io_r_getprinterdataex(char *desc
, SPOOL_R_GETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6472 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdataex");
6477 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
6479 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
6482 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
6488 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6490 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
6496 /*******************************************************************
6498 ********************************************************************/
6500 BOOL
spoolss_io_q_setprinterdataex(char *desc
, SPOOL_Q_SETPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6502 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdataex");
6507 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6509 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6515 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
6521 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
6524 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
6534 if (UNMARSHALLING(ps
))
6535 q_u
->data
=(uint8
*)prs_alloc_mem(ps
, q_u
->max_len
* sizeof(uint8
));
6536 if(q_u
->data
== NULL
)
6538 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
6546 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
6552 /*******************************************************************
6553 * write a structure.
6554 ********************************************************************/
6556 BOOL
spoolss_io_r_setprinterdataex(char *desc
, SPOOL_R_SETPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6558 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdataex");
6563 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6570 /*******************************************************************
6572 ********************************************************************/
6574 BOOL
spoolss_io_q_enumprinterkey(char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
6576 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
6581 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6584 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6590 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6596 /*******************************************************************
6597 * write a structure.
6598 ********************************************************************/
6600 BOOL
spoolss_io_r_enumprinterkey(char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
6602 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
6608 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
6614 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6617 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6624 /*******************************************************************
6626 ********************************************************************/
6628 BOOL
spoolss_io_q_enumprinterdataex(char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
6630 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
6635 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
6638 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
6644 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
6650 /*******************************************************************
6651 ********************************************************************/
6652 static BOOL
spoolss_io_printer_enum_values_ctr(char *desc
, prs_struct
*ps
,
6653 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
6656 uint32 valuename_offset
,
6659 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
6661 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
6664 if (!prs_uint32("size", ps
, depth
, &ctr
->size
))
6667 /* offset data begins at 20 bytes per structure * size_of_array.
6668 Don't forget the uint32 at the beginning */
6670 current_offset
= basic_unit
* ctr
->size_of_array
;
6672 /* first loop to write basic enum_value information */
6674 for (i
=0; i
<ctr
->size_of_array
; i
++)
6676 valuename_offset
= current_offset
;
6677 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
6680 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
6683 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
6686 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
6687 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
6690 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
6693 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
6696 /* loop #2 for writing the dynamically size objects
6697 while viewing conversations between Win2k -> Win2k,
6698 4-byte alignment does not seem to matter here --jerry */
6700 for (i
=0; i
<ctr
->size_of_array
; i
++)
6703 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
6706 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
6716 /*******************************************************************
6717 * write a structure.
6718 ********************************************************************/
6720 BOOL
spoolss_io_r_enumprinterdataex(char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
6722 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
6728 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
6734 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6737 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
6740 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6747 /*******************************************************************
6748 * write a structure.
6749 ********************************************************************/
6752 uint32 GetPrintProcessorDirectory(
6754 [in] unistr2 *environment,
6756 [in,out] NEW_BUFFER buffer,
6757 [in] uint32 offered,
6758 [out] uint32 needed,
6759 [out] uint32 returned
6764 BOOL
make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, NEW_BUFFER
*buffer
, uint32 offered
)
6766 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
6768 init_unistr2(&q_u
->name
, name
, strlen(name
)+1);
6769 init_unistr2(&q_u
->environment
, environment
, strlen(environment
)+1);
6773 q_u
->buffer
= buffer
;
6774 q_u
->offered
= offered
;
6779 BOOL
spoolss_io_q_getprintprocessordirectory(char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
6783 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
6789 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
6793 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
6800 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
6804 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
6812 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6815 if(!spoolss_io_buffer("", ps
, depth
, &q_u
->buffer
))
6821 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
6827 /*******************************************************************
6828 * write a structure.
6829 ********************************************************************/
6831 BOOL
spoolss_io_r_getprintprocessordirectory(char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
6833 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
6839 if(!spoolss_io_buffer("", ps
, depth
, &r_u
->buffer
))
6845 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
6848 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
6854 BOOL
smb_io_printprocessordirectory_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
6856 prs_struct
*ps
=&buffer
->prs
;
6858 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
6861 buffer
->struct_start
=prs_offset(ps
);
6863 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))