2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Jean François Micouleau 1998-2000.
8 * Copyright (C) Gerald Carter 2000
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 extern int DEBUGLEVEL
;
29 /*******************************************************************
30 return the length of a UNISTR string.
31 ********************************************************************/
32 static uint32
str_len_uni(UNISTR
*source
)
36 if (!source
->buffer
) return 0;
38 while (source
->buffer
[i
]!=0x0000)
45 /*******************************************************************
46 This should be moved in a more generic lib.
47 ********************************************************************/
48 static BOOL
spoolss_io_system_time(char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
50 if(!prs_uint16("year", ps
, depth
, &(systime
->year
)))
52 if(!prs_uint16("month", ps
, depth
, &(systime
->month
)))
54 if(!prs_uint16("dayofweek", ps
, depth
, &(systime
->dayofweek
)))
56 if(!prs_uint16("day", ps
, depth
, &(systime
->day
)))
58 if(!prs_uint16("hour", ps
, depth
, &(systime
->hour
)))
60 if(!prs_uint16("minute", ps
, depth
, &(systime
->minute
)))
62 if(!prs_uint16("second", ps
, depth
, &(systime
->second
)))
64 if(!prs_uint16("milliseconds", ps
, depth
, &(systime
->milliseconds
)))
70 /*******************************************************************
71 ********************************************************************/
72 BOOL
make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
74 systime
->year
=unixtime
->tm_year
+1900;
75 systime
->month
=unixtime
->tm_mon
+1;
76 systime
->dayofweek
=unixtime
->tm_wday
;
77 systime
->day
=unixtime
->tm_mday
;
78 systime
->hour
=unixtime
->tm_hour
;
79 systime
->minute
=unixtime
->tm_min
;
80 systime
->second
=unixtime
->tm_sec
;
81 systime
->milliseconds
=0;
86 /*******************************************************************
87 reads or writes an DOC_INFO structure.
88 ********************************************************************/
89 static BOOL
smb_io_doc_info_1(char *desc
, DOC_INFO_1
*info_1
, prs_struct
*ps
, int depth
)
91 if (info_1
== NULL
) return False
;
93 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_1");
99 if(!prs_uint32("p_docname", ps
, depth
, &(info_1
->p_docname
)))
101 if(!prs_uint32("p_outputfile", ps
, depth
, &(info_1
->p_outputfile
)))
103 if(!prs_uint32("p_datatype", ps
, depth
, &(info_1
->p_datatype
)))
106 if(!smb_io_unistr2("", &(info_1
->docname
), info_1
->p_docname
, ps
, depth
))
108 if(!smb_io_unistr2("", &(info_1
->outputfile
), info_1
->p_outputfile
, ps
, depth
))
110 if(!smb_io_unistr2("", &(info_1
->datatype
), info_1
->p_datatype
, ps
, depth
))
116 /*******************************************************************
117 reads or writes an DOC_INFO structure.
118 ********************************************************************/
119 static BOOL
smb_io_doc_info(char *desc
, DOC_INFO
*info
, prs_struct
*ps
, int depth
)
121 uint32 useless_ptr
=0;
123 if (info
== NULL
) return False
;
125 prs_debug(ps
, depth
, desc
, "smb_io_doc_info");
131 if(!prs_uint32("switch_value", ps
, depth
, &(info
->switch_value
)))
134 if(!prs_uint32("doc_info_X ptr", ps
, depth
, &(useless_ptr
)))
137 switch (info
->switch_value
)
140 if(!smb_io_doc_info_1("",&(info
->doc_info_1
), ps
, depth
))
145 this is just a placeholder
147 MSDN July 1998 says doc_info_2 is only on
148 Windows 95, and as Win95 doesn't do RPC to print
149 this case is nearly impossible
151 Maybe one day with Windows for dishwasher 2037 ...
154 /* smb_io_doc_info_2("",&(info->doc_info_2), ps, depth); */
157 DEBUG(0,("Something is obviously wrong somewhere !\n"));
164 /*******************************************************************
165 reads or writes an DOC_INFO_CONTAINER structure.
166 ********************************************************************/
167 static BOOL
smb_io_doc_info_container(char *desc
, DOC_INFO_CONTAINER
*cont
, prs_struct
*ps
, int depth
)
169 if (cont
== NULL
) return False
;
171 prs_debug(ps
, depth
, desc
, "smb_io_doc_info_container");
177 if(!prs_uint32("level", ps
, depth
, &cont
->level
))
180 if(!smb_io_doc_info("",&cont
->docinfo
, ps
, depth
))
186 /*******************************************************************
187 reads or writes an NOTIFY OPTION TYPE structure.
188 ********************************************************************/
189 static BOOL
smb_io_notify_option_type(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
191 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
197 if(!prs_uint16("type", ps
, depth
, &type
->type
))
199 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
201 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
203 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
205 if(!prs_uint32("count", ps
, depth
, &type
->count
))
207 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
213 /*******************************************************************
214 reads or writes an NOTIFY OPTION TYPE DATA.
215 ********************************************************************/
216 static BOOL
smb_io_notify_option_type_data(char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
220 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
223 /* if there are no fields just return */
224 if (type
->fields_ptr
==0)
230 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
233 if (type
->count2
!= type
->count
)
234 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
236 /* parse the option type data */
237 for(i
=0;i
<type
->count2
;i
++)
238 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
243 /*******************************************************************
244 reads or writes an NOTIFY OPTION structure.
245 ********************************************************************/
246 static BOOL
smb_io_notify_option_type_ctr(char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
250 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
253 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
257 if (UNMARSHALLING(ps
))
258 if((ctr
->type
=(SPOOL_NOTIFY_OPTION_TYPE
*)malloc(ctr
->count
*sizeof(SPOOL_NOTIFY_OPTION_TYPE
))) == NULL
)
261 /* the option type struct */
262 for(i
=0;i
<ctr
->count
;i
++)
263 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
266 /* the type associated with the option type struct */
267 for(i
=0;i
<ctr
->count
;i
++)
268 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
274 /*******************************************************************
275 reads or writes an NOTIFY OPTION structure.
276 ********************************************************************/
277 static BOOL
smb_io_notify_option(char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
279 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
282 if(!prs_uint32("version", ps
, depth
, &option
->version
))
284 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
286 if(!prs_uint32("count", ps
, depth
, &option
->count
))
288 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
291 /* marshalling or unmarshalling, that would work */
292 if (option
->option_type_ptr
!=0) {
293 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
297 option
->ctr
.type
=NULL
;
304 /*******************************************************************
305 reads or writes an NOTIFY INFO DATA structure.
306 ********************************************************************/
307 static BOOL
smb_io_notify_info_data(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
309 uint32 useless_ptr
=0xADDE0FF0;
311 uint32 how_many_words
;
315 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
318 how_many_words
=data
->size
;
319 if (how_many_words
==POINTER
) {
320 how_many_words
=TWO_VALUE
;
323 isvalue
=data
->enc_type
;
327 if(!prs_uint16("type", ps
, depth
, &data
->type
))
329 if(!prs_uint16("field", ps
, depth
, &data
->field
))
333 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
335 if(!prs_uint32("id", ps
, depth
, &data
->id
))
337 if(!prs_uint32("how many words", ps
, depth
, &how_many_words
))
344 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
346 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
351 /* length in ascii including \0 */
352 x
=2*(data
->notify_data
.data
.length
+1);
353 if(!prs_uint32("string length", ps
, depth
, &x
))
355 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
363 /*******************************************************************
364 reads or writes an NOTIFY INFO DATA structure.
365 ********************************************************************/
366 BOOL
smb_io_notify_info_data_strings(char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
367 prs_struct
*ps
, int depth
)
372 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
378 isvalue
=data
->enc_type
;
380 if (isvalue
==False
) {
381 /* length of string in unicode include \0 */
382 x
=data
->notify_data
.data
.length
+1;
383 if(!prs_uint32("string length", ps
, depth
, &x
))
385 if(!prs_uint16s(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
394 /*******************************************************************
395 reads or writes an NOTIFY INFO structure.
396 ********************************************************************/
397 static BOOL
smb_io_notify_info(char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
401 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
407 if(!prs_uint32("count", ps
, depth
, &info
->count
))
409 if(!prs_uint32("version", ps
, depth
, &info
->version
))
411 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
413 if(!prs_uint32("count", ps
, depth
, &info
->count
))
416 for (i
=0;i
<info
->count
;i
++) {
417 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
421 /* now do the strings at the end of the stream */
422 for (i
=0;i
<info
->count
;i
++) {
423 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
431 /*******************************************************************
432 ********************************************************************/
433 static BOOL
spool_io_user_level_1(char *desc
, SPOOL_USER_1
*q_u
, prs_struct
*ps
, int depth
)
435 prs_debug(ps
, depth
, desc
, "");
444 if (!prs_uint32("size", ps
, depth
, &(q_u
->size
)))
446 if (!prs_uint32("client_name_ptr", ps
, depth
, &(q_u
->client_name_ptr
)))
448 if (!prs_uint32("user_name_ptr", ps
, depth
, &(q_u
->user_name_ptr
)))
450 if (!prs_uint32("build", ps
, depth
, &(q_u
->build
)))
452 if (!prs_uint32("major", ps
, depth
, &(q_u
->major
)))
454 if (!prs_uint32("minor", ps
, depth
, &(q_u
->minor
)))
456 if (!prs_uint32("processor", ps
, depth
, &(q_u
->processor
)))
459 if (!smb_io_unistr2("", &(q_u
->client_name
), q_u
->client_name_ptr
, ps
, depth
))
463 if (!smb_io_unistr2("", &(q_u
->user_name
), q_u
->user_name_ptr
, ps
, depth
))
469 /*******************************************************************
470 ********************************************************************/
471 static BOOL
spool_io_user_level(char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
476 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
481 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
483 if (!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
486 switch (q_u
->level
) {
488 if (!spool_io_user_level_1("", &(q_u
->user1
), ps
, depth
))
498 /*******************************************************************
499 * read or write a DEVICEMODE struct.
500 * on reading allocate memory for the private member
501 ********************************************************************/
502 static BOOL
spoolss_io_devmode(char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
504 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
507 if (UNMARSHALLING(ps
)) {
508 devmode
->devicename
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
509 if (devmode
->devicename
.buffer
== NULL
)
513 if (!prs_uint16s(True
,"devicename", ps
, depth
, devmode
->devicename
.buffer
, 32))
515 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
517 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
519 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
521 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
523 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
525 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
527 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
529 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
531 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
533 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
535 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
537 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
539 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
541 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
543 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
545 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
547 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
549 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
552 if (UNMARSHALLING(ps
)) {
553 devmode
->formname
.buffer
= (uint16
*)prs_alloc_mem(ps
, 32 * sizeof(uint16
) );
554 if (devmode
->formname
.buffer
== NULL
)
558 if (!prs_uint16s(True
, "formname", ps
, depth
, devmode
->formname
.buffer
, 32))
560 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
562 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
564 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
566 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
568 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
570 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
572 if (!prs_uint32("icmmethod", ps
, depth
, &devmode
->icmmethod
))
574 if (!prs_uint32("icmintent", ps
, depth
, &devmode
->icmintent
))
576 if (!prs_uint32("mediatype", ps
, depth
, &devmode
->mediatype
))
578 if (!prs_uint32("dithertype", ps
, depth
, &devmode
->dithertype
))
580 if (!prs_uint32("reserved1", ps
, depth
, &devmode
->reserved1
))
582 if (!prs_uint32("reserved2", ps
, depth
, &devmode
->reserved2
))
584 if (!prs_uint32("panningwidth", ps
, depth
, &devmode
->panningwidth
))
586 if (!prs_uint32("panningheight", ps
, depth
, &devmode
->panningheight
))
589 if (devmode
->driverextra
!=0) {
590 if (UNMARSHALLING(ps
)) {
591 devmode
->private=(uint8
*)malloc(devmode
->driverextra
*sizeof(uint8
));
592 if(devmode
->private == NULL
)
594 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode
->driverextra
));
597 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode
->driverextra
));
598 if (!prs_uint8s(True
, "private", ps
, depth
, devmode
->private, devmode
->driverextra
))
605 void free_spoolss_devmode(DEVICEMODE
*devmode
)
610 safe_free(devmode
->private);
614 /*******************************************************************
615 Read or write a DEVICEMODE container
616 ********************************************************************/
617 static BOOL
spoolss_io_devmode_cont(char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
622 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
628 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
631 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
634 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
635 if (UNMARSHALLING(ps
))
636 /* if while reading there is no DEVMODE ... */
641 /* so we have a DEVICEMODE to follow */
642 if (UNMARSHALLING(ps
)) {
643 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
644 dm_c
->devmode
=(DEVICEMODE
*)malloc(sizeof(DEVICEMODE
));
645 if(dm_c
->devmode
== NULL
)
647 ZERO_STRUCTP(dm_c
->devmode
);
650 /* this is bad code, shouldn't be there */
651 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
654 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
660 /*******************************************************************
661 ********************************************************************/
662 static BOOL
spoolss_io_printer_default(char *desc
, PRINTER_DEFAULT
*pd
, prs_struct
*ps
, int depth
)
667 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_default");
670 if (!prs_uint32("datatype_ptr", ps
, depth
, &pd
->datatype_ptr
))
673 if (!smb_io_unistr2("datatype", &(pd
->datatype
), pd
->datatype_ptr
, ps
,depth
))
679 if (!spoolss_io_devmode_cont("", &(pd
->devmode_cont
), ps
, depth
))
682 if (!prs_uint32("access_required", ps
, depth
, &pd
->access_required
))
688 /*******************************************************************
690 ********************************************************************/
691 BOOL
make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
,
692 const fstring printername
,
693 const fstring datatype
,
694 uint32 access_required
,
695 const fstring clientname
,
696 const fstring user_name
)
698 DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
699 q_u
->printername_ptr
= (printername
!=NULL
)?1:0;
700 init_unistr2(&q_u
->printername
, printername
, strlen(printername
));
702 q_u
->printer_default
.datatype_ptr
= 0;
704 q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
705 init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
707 q_u
->printer_default
.devmode_cont
.size
=0;
708 q_u
->printer_default
.devmode_cont
.devmode_ptr
=0;
709 q_u
->printer_default
.devmode_cont
.devmode
=NULL
;
710 q_u
->printer_default
.access_required
=access_required
;
712 q_u
->user_ctr
.level
=1;
714 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+8;
715 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
716 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
717 q_u
->user_ctr
.user1
.build
=1381;
718 q_u
->user_ctr
.user1
.major
=2;
719 q_u
->user_ctr
.user1
.minor
=0;
720 q_u
->user_ctr
.user1
.processor
=0;
721 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
));
722 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
));
727 /*******************************************************************
729 ********************************************************************/
730 BOOL
make_spoolss_q_addprinterex(SPOOL_Q_ADDPRINTEREX
*q_u
, const char *srv_name
,
731 const char* clientname
, const char* user_name
,
732 uint32 level
, PRINTER_INFO_2
*info
)
734 DEBUG(5,("make_spoolss_q_addprinterex\n"));
736 q_u
->server_name_ptr
= (srv_name
!=NULL
)?1:0;
737 init_unistr2(&q_u
->server_name
, srv_name
, strlen(srv_name
));
741 q_u
->info
.level
= level
;
742 q_u
->info
.info_ptr
= (info
!=NULL
)?1:0;
746 /* init q_u->info.info2 from *info */
747 if (!make_spool_printer_info_2( &q_u
->info
.info_2
, info
))
749 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
757 q_u
->unk0
= q_u
->unk1
= q_u
->unk2
= q_u
->unk3
= 0;
761 q_u
->user_ctr
.level
=1;
763 q_u
->user_ctr
.user1
.size
=strlen(clientname
)+strlen(user_name
)+8;
764 q_u
->user_ctr
.user1
.client_name_ptr
= (clientname
!=NULL
)?1:0;
765 q_u
->user_ctr
.user1
.user_name_ptr
= (user_name
!=NULL
)?1:0;
766 q_u
->user_ctr
.user1
.build
=1381;
767 q_u
->user_ctr
.user1
.major
=2;
768 q_u
->user_ctr
.user1
.minor
=0;
769 q_u
->user_ctr
.user1
.processor
=0;
770 init_unistr2(&q_u
->user_ctr
.user1
.client_name
, clientname
, strlen(clientname
));
771 init_unistr2(&q_u
->user_ctr
.user1
.user_name
, user_name
, strlen(user_name
));
775 /*******************************************************************
776 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
777 *******************************************************************/
778 BOOL
make_spool_printer_info_2(SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
779 PRINTER_INFO_2
*info
)
782 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
784 /* allocate the necessary memory */
785 inf
= (SPOOL_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_2
));
786 if (spool_info2
== NULL
)
788 DEBUG(0,("make_spool_printer_info_2: Unable to malloc SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
794 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
795 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
796 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
797 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
798 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
799 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
800 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
801 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
802 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
803 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
804 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
805 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
806 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
807 inf
->attributes
= info
->attributes
;
808 inf
->priority
= info
->priority
;
809 inf
->default_priority
= info
->defaultpriority
;
810 inf
->starttime
= info
->starttime
;
811 inf
->untiltime
= info
->untiltime
;
812 inf
->cjobs
= info
->cjobs
;
813 inf
->averageppm
= info
->averageppm
;
814 init_unistr2_from_unistr(&inf
->servername
, &info
->servername
);
815 init_unistr2_from_unistr(&inf
->printername
, &info
->printername
);
816 init_unistr2_from_unistr(&inf
->sharename
, &info
->sharename
);
817 init_unistr2_from_unistr(&inf
->portname
, &info
->portname
);
818 init_unistr2_from_unistr(&inf
->drivername
, &info
->drivername
);
819 init_unistr2_from_unistr(&inf
->comment
, &info
->comment
);
820 init_unistr2_from_unistr(&inf
->location
, &info
->location
);
821 init_unistr2_from_unistr(&inf
->sepfile
, &info
->sepfile
);
822 init_unistr2_from_unistr(&inf
->printprocessor
, &info
->printprocessor
);
823 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
824 init_unistr2_from_unistr(&inf
->parameters
, &info
->parameters
);
825 init_unistr2_from_unistr(&inf
->datatype
, &info
->datatype
);
833 /*******************************************************************
835 * called from spoolss_q_open_printer_ex (srv_spoolss.c)
836 ********************************************************************/
837 BOOL
spoolss_io_q_open_printer_ex(char *desc
, SPOOL_Q_OPEN_PRINTER_EX
*q_u
, prs_struct
*ps
, int depth
)
842 prs_debug(ps
, depth
, desc
, "spoolss_io_q_open_printer_ex");
848 if (!prs_uint32("printername_ptr", ps
, depth
, &q_u
->printername_ptr
))
850 if (!smb_io_unistr2("", &q_u
->printername
, q_u
->printername_ptr
, ps
,depth
))
856 if (!spoolss_io_printer_default("", &q_u
->printer_default
, ps
, depth
))
859 if (!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
861 if (!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
867 void free_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX
*q_u
)
869 free_spoolss_devmode(q_u
->printer_default
.devmode_cont
.devmode
);
872 /*******************************************************************
874 * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
875 * called from spoolss_open_printer_ex (cli_spoolss.c)
876 ********************************************************************/
877 BOOL
spoolss_io_r_open_printer_ex(char *desc
, SPOOL_R_OPEN_PRINTER_EX
*r_u
, prs_struct
*ps
, int depth
)
879 if (r_u
== NULL
) return False
;
881 prs_debug(ps
, depth
, desc
, "spoolss_io_r_open_printer_ex");
887 if (!smb_io_pol_hnd("printer handle",&(r_u
->handle
),ps
,depth
))
890 if (!prs_uint32("status code", ps
, depth
, &(r_u
->status
)))
896 /*******************************************************************
898 ********************************************************************/
899 BOOL
make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
900 const POLICY_HND
*handle
,
901 const UNISTR2
*valuename
,
904 if (q_u
== NULL
) return False
;
906 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
908 q_u
->handle
= *handle
;
909 copy_unistr2(&q_u
->valuename
, valuename
);
916 /*******************************************************************
918 * called from spoolss_q_getprinterdata (srv_spoolss.c)
919 ********************************************************************/
920 BOOL
spoolss_io_q_getprinterdata(char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
922 if (q_u
== NULL
) return False
;
924 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
929 if (!smb_io_pol_hnd("printer handle",&(q_u
->handle
),ps
,depth
))
933 if (!smb_io_unistr2("valuename", &(q_u
->valuename
),True
,ps
,depth
))
937 if (!prs_uint32("size", ps
, depth
, &(q_u
->size
)))
943 /*******************************************************************
945 * called from spoolss_r_getprinterdata (srv_spoolss.c)
946 ********************************************************************/
947 BOOL
spoolss_io_r_getprinterdata(char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
952 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
957 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
959 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
962 if (!prs_uint8s(False
,"data", ps
, depth
, r_u
->data
, r_u
->size
))
968 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
970 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
976 /*******************************************************************
978 ********************************************************************/
979 BOOL
make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER
*q_u
, POLICY_HND
*hnd
)
981 if (q_u
== NULL
) return False
;
983 DEBUG(5,("make_spoolss_q_closeprinter\n"));
985 memcpy(&(q_u
->handle
), hnd
, sizeof(q_u
->handle
));
990 /*******************************************************************
992 * called from static spoolss_q_deleteprinter (srv_spoolss.c)
993 * called from spoolss_deleteprinter (cli_spoolss.c)
994 ********************************************************************/
995 BOOL
spoolss_io_q_deleteprinter(char *desc
, SPOOL_Q_DELETEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
997 if (q_u
== NULL
) return False
;
999 prs_debug(ps
, depth
, desc
, "spoolss_io_q_deleteprinter");
1005 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1011 /*******************************************************************
1012 * write a structure.
1013 * called from static spoolss_r_deleteprinter (srv_spoolss.c)
1014 * called from spoolss_deleteprinter (cli_spoolss.c)
1015 ********************************************************************/
1016 BOOL
spoolss_io_r_deleteprinter(char *desc
, SPOOL_R_DELETEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1018 prs_debug(ps
, depth
, desc
, "spoolss_io_r_deleteprinter");
1024 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1026 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1033 /*******************************************************************
1035 * called from static spoolss_q_closeprinter (srv_spoolss.c)
1036 * called from spoolss_closeprinter (cli_spoolss.c)
1037 ********************************************************************/
1038 BOOL
spoolss_io_q_closeprinter(char *desc
, SPOOL_Q_CLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1040 if (q_u
== NULL
) return False
;
1042 prs_debug(ps
, depth
, desc
, "spoolss_io_q_closeprinter");
1048 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1054 /*******************************************************************
1055 * write a structure.
1056 * called from static spoolss_r_closeprinter (srv_spoolss.c)
1057 * called from spoolss_closeprinter (cli_spoolss.c)
1058 ********************************************************************/
1059 BOOL
spoolss_io_r_closeprinter(char *desc
, SPOOL_R_CLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1061 prs_debug(ps
, depth
, desc
, "spoolss_io_r_closeprinter");
1067 if (!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
1069 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
1075 /*******************************************************************
1077 * called from spoolss_q_startdocprinter (srv_spoolss.c)
1078 ********************************************************************/
1079 BOOL
spoolss_io_q_startdocprinter(char *desc
, SPOOL_Q_STARTDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1081 if (q_u
== NULL
) return False
;
1083 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startdocprinter");
1089 if(!smb_io_pol_hnd("printer handle",&(q_u
->handle
),ps
,depth
))
1092 if(!smb_io_doc_info_container("",&(q_u
->doc_info_container
), ps
, depth
))
1098 /*******************************************************************
1099 * write a structure.
1100 * called from spoolss_r_startdocprinter (srv_spoolss.c)
1101 ********************************************************************/
1102 BOOL
spoolss_io_r_startdocprinter(char *desc
, SPOOL_R_STARTDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1104 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startdocprinter");
1106 if(!prs_uint32("jobid", ps
, depth
, &r_u
->jobid
))
1108 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1114 /*******************************************************************
1116 * called from spoolss_q_enddocprinter (srv_spoolss.c)
1117 ********************************************************************/
1118 BOOL
spoolss_io_q_enddocprinter(char *desc
, SPOOL_Q_ENDDOCPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1120 if (q_u
== NULL
) return False
;
1122 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enddocprinter");
1128 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1134 /*******************************************************************
1135 * write a structure.
1136 * called from spoolss_r_enddocprinter (srv_spoolss.c)
1137 ********************************************************************/
1138 BOOL
spoolss_io_r_enddocprinter(char *desc
, SPOOL_R_ENDDOCPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1140 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enddocprinter");
1142 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1148 /*******************************************************************
1150 * called from spoolss_q_startpageprinter (srv_spoolss.c)
1151 ********************************************************************/
1152 BOOL
spoolss_io_q_startpageprinter(char *desc
, SPOOL_Q_STARTPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1154 if (q_u
== NULL
) return False
;
1156 prs_debug(ps
, depth
, desc
, "spoolss_io_q_startpageprinter");
1162 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1168 /*******************************************************************
1169 * write a structure.
1170 * called from spoolss_r_startpageprinter (srv_spoolss.c)
1171 ********************************************************************/
1172 BOOL
spoolss_io_r_startpageprinter(char *desc
, SPOOL_R_STARTPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1174 prs_debug(ps
, depth
, desc
, "spoolss_io_r_startpageprinter");
1176 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1182 /*******************************************************************
1184 * called from spoolss_q_endpageprinter (srv_spoolss.c)
1185 ********************************************************************/
1186 BOOL
spoolss_io_q_endpageprinter(char *desc
, SPOOL_Q_ENDPAGEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1188 if (q_u
== NULL
) return False
;
1190 prs_debug(ps
, depth
, desc
, "spoolss_io_q_endpageprinter");
1196 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1202 /*******************************************************************
1203 * write a structure.
1204 * called from spoolss_r_endpageprinter (srv_spoolss.c)
1205 ********************************************************************/
1206 BOOL
spoolss_io_r_endpageprinter(char *desc
, SPOOL_R_ENDPAGEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1208 prs_debug(ps
, depth
, desc
, "spoolss_io_r_endpageprinter");
1210 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1216 /*******************************************************************
1218 * called from spoolss_q_writeprinter (srv_spoolss.c)
1219 ********************************************************************/
1220 BOOL
spoolss_io_q_writeprinter(char *desc
, SPOOL_Q_WRITEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
1222 if (q_u
== NULL
) return False
;
1224 prs_debug(ps
, depth
, desc
, "spoolss_io_q_writeprinter");
1230 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1232 if(!prs_uint32("buffer_size", ps
, depth
, &q_u
->buffer_size
))
1235 if (q_u
->buffer_size
!=0)
1237 q_u
->buffer
=(uint8
*)malloc(q_u
->buffer_size
*sizeof(uint8
));
1238 if(q_u
->buffer
== NULL
)
1240 if(!prs_uint8s(True
, "buffer", ps
, depth
, q_u
->buffer
, q_u
->buffer_size
))
1245 if(!prs_uint32("buffer_size2", ps
, depth
, &q_u
->buffer_size2
))
1251 /*******************************************************************
1252 * write a structure.
1253 * called from spoolss_r_writeprinter (srv_spoolss.c)
1254 ********************************************************************/
1255 BOOL
spoolss_io_r_writeprinter(char *desc
, SPOOL_R_WRITEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
1257 prs_debug(ps
, depth
, desc
, "spoolss_io_r_writeprinter");
1259 if(!prs_uint32("buffer_written", ps
, depth
, &r_u
->buffer_written
))
1261 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1267 /*******************************************************************
1269 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1270 ********************************************************************/
1271 BOOL
spoolss_io_q_rffpcnex(char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1273 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1279 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1281 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1283 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1285 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1287 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1293 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1296 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1299 if (q_u
->option_ptr
!=0) {
1301 if (UNMARSHALLING(ps
))
1302 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)malloc(sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1305 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1312 /*******************************************************************
1313 * write a structure.
1314 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1315 ********************************************************************/
1316 BOOL
spoolss_io_r_rffpcnex(char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1318 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1321 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1327 /*******************************************************************
1329 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1330 ********************************************************************/
1331 BOOL
spoolss_io_q_rfnpcnex(char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1333 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1339 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1342 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1345 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1348 if (q_u
->option_ptr
!=0) {
1350 if (UNMARSHALLING(ps
))
1351 if((q_u
->option
=(SPOOL_NOTIFY_OPTION
*)malloc(sizeof(SPOOL_NOTIFY_OPTION
))) == NULL
)
1354 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1361 /*******************************************************************
1362 * write a structure.
1363 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1364 ********************************************************************/
1365 BOOL
spoolss_io_r_rfnpcnex(char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1367 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1373 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1376 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1381 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
1387 /*******************************************************************
1388 * return the length of a uint16 (obvious, but the code is clean)
1389 ********************************************************************/
1390 static uint32
size_of_uint16(uint16
*value
)
1392 return (sizeof(*value
));
1395 /*******************************************************************
1396 * return the length of a uint32 (obvious, but the code is clean)
1397 ********************************************************************/
1398 static uint32
size_of_uint32(uint32
*value
)
1400 return (sizeof(*value
));
1402 /*******************************************************************
1403 * return the length of a UNICODE string in number of char, includes:
1404 * - the leading zero
1405 * - the relative pointer size
1406 ********************************************************************/
1407 static uint32
size_of_relative_string(UNISTR
*string
)
1411 size
=str_len_uni(string
); /* the string length */
1412 size
=size
+1; /* add the leading zero */
1413 size
=size
*2; /* convert in char */
1414 size
=size
+4; /* add the size of the ptr */
1419 /*******************************************************************
1420 * return the length of a uint32 (obvious, but the code is clean)
1421 ********************************************************************/
1422 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1427 return (4+devmode
->size
+devmode
->driverextra
);
1430 /*******************************************************************
1431 * return the length of a uint32 (obvious, but the code is clean)
1432 ********************************************************************/
1433 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1438 return (sizeof(SYSTEMTIME
) +4);
1441 /*******************************************************************
1442 * write a UNICODE string.
1443 * used by all the RPC structs passing a buffer
1444 ********************************************************************/
1445 static BOOL
spoolss_smb_io_unistr(char *desc
, UNISTR
*uni
, prs_struct
*ps
, int depth
)
1450 prs_debug(ps
, depth
, desc
, "spoolss_smb_io_unistr");
1452 if (!prs_unistr("unistr", ps
, depth
, uni
))
1459 /*******************************************************************
1460 * write a UNICODE string and its relative pointer.
1461 * used by all the RPC structs passing a buffer
1463 * As I'm a nice guy, I'm forcing myself to explain this code.
1464 * MS did a good job in the overall spoolss code except in some
1465 * functions where they are passing the API buffer directly in the
1466 * RPC request/reply. That's to maintain compatiility at the API level.
1467 * They could have done it the good way the first time.
1469 * So what happen is: the strings are written at the buffer's end,
1470 * in the reverse order of the original structure. Some pointers to
1471 * the strings are also in the buffer. Those are relative to the
1474 * If you don't understand or want to change that function,
1475 * first get in touch with me: jfm@samba.org
1477 ********************************************************************/
1478 static BOOL
new_smb_io_relstr(char *desc
, NEW_BUFFER
*buffer
, int depth
, UNISTR
*string
)
1480 prs_struct
*ps
=&buffer
->prs
;
1482 if (MARSHALLING(ps
)) {
1483 uint32 struct_offset
= prs_offset(ps
);
1484 uint32 relative_offset
;
1486 buffer
->string_at_end
-= 2*(str_len_uni(string
)+1);
1487 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1490 /* write the string */
1491 if (!spoolss_smb_io_unistr(desc
, string
, ps
, depth
))
1494 if(!prs_set_offset(ps
, struct_offset
))
1497 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1498 /* write its offset */
1499 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1505 /* read the offset */
1506 if (!prs_uint32("offset", ps
, depth
, &(buffer
->string_at_end
)))
1509 old_offset
= prs_offset(ps
);
1510 if(!prs_set_offset(ps
, buffer
->string_at_end
+buffer
->struct_start
))
1513 /* read the string */
1514 if (!spoolss_smb_io_unistr(desc
, string
, ps
, depth
))
1517 if(!prs_set_offset(ps
, old_offset
))
1524 /*******************************************************************
1525 * write a array of UNICODE strings and its relative pointer.
1526 * used by 2 RPC structs
1527 ********************************************************************/
1528 static BOOL
new_smb_io_relarraystr(char *desc
, NEW_BUFFER
*buffer
, int depth
, uint16
**string
)
1532 prs_struct
*ps
=&buffer
->prs
;
1534 if (MARSHALLING(ps
)) {
1535 uint32 struct_offset
= prs_offset(ps
);
1536 uint32 relative_offset
;
1543 /* first write the last 0 */
1544 buffer
->string_at_end
-= 2;
1545 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1548 if(!prs_uint16("leading zero", ps
, depth
, &zero
))
1551 while (p
&& (*p
!=0)) {
1555 chaine
.buffer
= malloc((q
-p
+1)*sizeof(uint16
));
1556 if (chaine
.buffer
== NULL
)
1559 memcpy(chaine
.buffer
, p
, (q
-p
+1)*sizeof(uint16
));
1561 buffer
->string_at_end
-= (q
-p
+1)*sizeof(uint16
);
1563 if(!prs_set_offset(ps
, buffer
->string_at_end
)) {
1564 free(chaine
.buffer
);
1568 /* write the string */
1569 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
)) {
1570 free(chaine
.buffer
);
1576 free(chaine
.buffer
);
1579 if(!prs_set_offset(ps
, struct_offset
))
1582 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1583 /* write its offset */
1584 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1589 uint16
*chaine2
=NULL
;
1595 /* read the offset */
1596 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1599 old_offset
= prs_offset(ps
);
1600 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1604 if (!spoolss_smb_io_unistr(desc
, &chaine
, ps
, depth
))
1607 l_chaine
=str_len_uni(&chaine
);
1608 if((chaine2
=(uint16
*)Realloc(chaine2
, (l_chaine2
+l_chaine
+1)*sizeof(uint16
))) == NULL
)
1610 memcpy(chaine2
+l_chaine2
, chaine
.buffer
, (l_chaine
+1)*sizeof(uint16
));
1611 l_chaine2
+=l_chaine
+1;
1613 } while(l_chaine
!=0);
1617 if(!prs_set_offset(ps
, old_offset
))
1624 /*******************************************************************
1625 Parse a DEVMODE structure and its relative pointer.
1626 ********************************************************************/
1627 static BOOL
new_smb_io_relsecdesc(char *desc
, NEW_BUFFER
*buffer
, int depth
,
1630 prs_struct
*ps
= &buffer
->prs
;
1632 prs_debug(ps
, depth
, desc
, "new_smb_io_relsecdesc");
1635 if (MARSHALLING(ps
)) {
1636 uint32 struct_offset
= prs_offset(ps
);
1637 uint32 relative_offset
;
1640 relative_offset
= 0;
1641 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1646 if (*secdesc
!= NULL
) {
1648 if(!prs_set_offset(ps
, 0x54))
1651 buffer
->string_at_end
-= sec_desc_size(*secdesc
);
1653 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1656 /* write the secdesc */
1657 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1660 if(!prs_set_offset(ps
, struct_offset
))
1664 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1665 /* write its offset */
1667 relative_offset
= 0x54;
1670 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1675 /* read the offset */
1676 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1679 old_offset
= prs_offset(ps
);
1680 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1684 if (!sec_io_desc(desc
, secdesc
, ps
, depth
))
1687 if(!prs_set_offset(ps
, old_offset
))
1693 /*******************************************************************
1694 Parse a DEVMODE structure and its relative pointer.
1695 ********************************************************************/
1696 static BOOL
new_smb_io_reldevmode(char *desc
, NEW_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
1698 prs_struct
*ps
=&buffer
->prs
;
1700 prs_debug(ps
, depth
, desc
, "new_smb_io_reldevmode");
1703 if (MARSHALLING(ps
)) {
1704 uint32 struct_offset
= prs_offset(ps
);
1705 uint32 relative_offset
;
1707 if (*devmode
== NULL
) {
1709 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1711 DEBUG(8, ("boing, the devmode was NULL\n"));
1716 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
1718 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1721 /* write the DEVMODE */
1722 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1725 if(!prs_set_offset(ps
, struct_offset
))
1728 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1729 /* write its offset */
1730 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1736 /* read the offset */
1737 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1740 old_offset
= prs_offset(ps
);
1741 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1744 /* read the string */
1745 if((*devmode
=(DEVICEMODE
*)malloc(sizeof(DEVICEMODE
))) == NULL
)
1747 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1750 if(!prs_set_offset(ps
, old_offset
))
1757 /*******************************************************************
1758 Parse a PRINTER_INFO_0 structure.
1759 ********************************************************************/
1760 BOOL
new_smb_io_printer_info_0(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
1762 prs_struct
*ps
=&(buffer
->prs
);
1764 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
1767 buffer
->struct_start
=prs_offset(ps
);
1769 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1771 if (!new_smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
1774 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
1776 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
1778 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
1781 if(!prs_uint16("year", ps
, depth
, &info
->year
))
1783 if(!prs_uint16("month", ps
, depth
, &info
->month
))
1785 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
1787 if(!prs_uint16("day", ps
, depth
, &info
->day
))
1789 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
1791 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
1793 if(!prs_uint16("second", ps
, depth
, &info
->second
))
1795 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
1798 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
1800 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
1803 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
1805 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
1807 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
1809 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
1811 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
1813 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
1815 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
1817 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
1819 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
1821 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
1823 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
1825 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
1827 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
1829 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
1831 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
1833 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
1835 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
1837 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
1839 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
1841 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
1843 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
1845 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
1847 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
1849 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
1851 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
1857 /*******************************************************************
1858 Parse a PRINTER_INFO_1 structure.
1859 ********************************************************************/
1860 BOOL
new_smb_io_printer_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
1862 prs_struct
*ps
=&buffer
->prs
;
1864 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_info_1");
1867 buffer
->struct_start
=prs_offset(ps
);
1869 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
1871 if (!new_smb_io_relstr("description", buffer
, depth
, &info
->description
))
1873 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
1875 if (!new_smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
1881 /*******************************************************************
1882 Parse a PRINTER_INFO_2 structure.
1883 ********************************************************************/
1884 BOOL
new_smb_io_printer_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
1887 prs_struct
*ps
=&buffer
->prs
;
1890 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_info_2");
1893 buffer
->struct_start
=prs_offset(ps
);
1895 if (!new_smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
1897 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1899 if (!new_smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
1901 if (!new_smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
1903 if (!new_smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
1905 if (!new_smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
1907 if (!new_smb_io_relstr("location", buffer
, depth
, &info
->location
))
1910 /* NT parses the DEVMODE at the end of the struct */
1911 if (!new_smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
1914 if (!new_smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
1916 if (!new_smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
1918 if (!new_smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
1920 if (!new_smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
1924 if (!prs_uint32_pre("secdesc_ptr ", ps
, depth
, &dummy
, &sec_offset
))
1927 if (!new_smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
1931 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
1933 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
1935 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
1937 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
1939 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
1941 if (!prs_uint32("status", ps
, depth
, &info
->status
))
1943 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
1945 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
1949 if (!prs_uint32_post("secdesc_ptr", ps
, depth
, NULL
, sec_offset
, info
->secdesc
? prs_offset(ps
)-buffer
->struct_start
: 0 ))
1952 if (!sec_io_desc("secdesc", &info
->secdesc
, ps
, depth
))
1958 /*******************************************************************
1959 Parse a PRINTER_INFO_3 structure.
1960 ********************************************************************/
1961 BOOL
new_smb_io_printer_info_3(char *desc
, NEW_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
1963 prs_struct
*ps
=&(buffer
->prs
);
1965 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_info_3");
1968 buffer
->struct_start
=prs_offset(ps
);
1970 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
1972 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
1978 /*******************************************************************
1979 Parse a PORT_INFO_1 structure.
1980 ********************************************************************/
1981 BOOL
new_smb_io_port_info_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
1983 prs_struct
*ps
=&(buffer
->prs
);
1985 prs_debug(ps
, depth
, desc
, "new_smb_io_port_info_1");
1988 buffer
->struct_start
=prs_offset(ps
);
1990 if (!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
1996 /*******************************************************************
1997 Parse a PORT_INFO_2 structure.
1998 ********************************************************************/
1999 BOOL
new_smb_io_port_info_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2001 prs_struct
*ps
=&(buffer
->prs
);
2003 prs_debug(ps
, depth
, desc
, "new_smb_io_port_info_2");
2006 buffer
->struct_start
=prs_offset(ps
);
2008 if (!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2010 if (!new_smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2012 if (!new_smb_io_relstr("description", buffer
, depth
, &info
->description
))
2014 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2016 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2022 /*******************************************************************
2023 Parse a DRIVER_INFO_1 structure.
2024 ********************************************************************/
2025 BOOL
new_smb_io_printer_driver_info_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
2027 prs_struct
*ps
=&(buffer
->prs
);
2029 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_driver_info_1");
2032 buffer
->struct_start
=prs_offset(ps
);
2034 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2041 /*******************************************************************
2042 Parse a DRIVER_INFO_2 structure.
2043 ********************************************************************/
2044 BOOL
new_smb_io_printer_driver_info_2(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
2046 prs_struct
*ps
=&(buffer
->prs
);
2048 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_driver_info_2");
2051 buffer
->struct_start
=prs_offset(ps
);
2053 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2055 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2057 if (!new_smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2059 if (!new_smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2061 if (!new_smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2063 if (!new_smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2070 /*******************************************************************
2071 Parse a DRIVER_INFO_3 structure.
2072 ********************************************************************/
2073 BOOL
new_smb_io_printer_driver_info_3(char *desc
, NEW_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
2075 prs_struct
*ps
=&(buffer
->prs
);
2077 prs_debug(ps
, depth
, desc
, "new_smb_io_printer_driver_info_3");
2080 buffer
->struct_start
=prs_offset(ps
);
2082 if (!prs_uint32("version", ps
, depth
, &info
->version
))
2084 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2086 if (!new_smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
2088 if (!new_smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
2090 if (!new_smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
2092 if (!new_smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
2094 if (!new_smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
2097 if (!new_smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
2100 if (!new_smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
2102 if (!new_smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
2109 /*******************************************************************
2110 Parse a JOB_INFO_1 structure.
2111 ********************************************************************/
2112 BOOL
new_smb_io_job_info_1(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
2114 prs_struct
*ps
=&(buffer
->prs
);
2116 prs_debug(ps
, depth
, desc
, "new_smb_io_job_info_1");
2119 buffer
->struct_start
=prs_offset(ps
);
2121 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
2123 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2125 if (!new_smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2127 if (!new_smb_io_relstr("username", buffer
, depth
, &info
->username
))
2129 if (!new_smb_io_relstr("document", buffer
, depth
, &info
->document
))
2131 if (!new_smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2133 if (!new_smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2135 if (!prs_uint32("status", ps
, depth
, &info
->status
))
2137 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
2139 if (!prs_uint32("position", ps
, depth
, &info
->position
))
2141 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
2143 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
2145 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
2151 /*******************************************************************
2152 Parse a JOB_INFO_2 structure.
2153 ********************************************************************/
2154 BOOL
new_smb_io_job_info_2(char *desc
, NEW_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
2157 prs_struct
*ps
=&(buffer
->prs
);
2159 prs_debug(ps
, depth
, desc
, "new_smb_io_job_info_2");
2162 buffer
->struct_start
=prs_offset(ps
);
2164 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
2166 if (!new_smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
2168 if (!new_smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
2170 if (!new_smb_io_relstr("username", buffer
, depth
, &info
->username
))
2172 if (!new_smb_io_relstr("document", buffer
, depth
, &info
->document
))
2174 if (!new_smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
2176 if (!new_smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
2179 if (!new_smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
2181 if (!new_smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
2183 if (!new_smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
2185 if (!new_smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
2187 if (!new_smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
2190 /* SEC_DESC sec_desc;*/
2191 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
2194 if (!prs_uint32("status",ps
, depth
, &info
->status
))
2196 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
2198 if (!prs_uint32("position",ps
, depth
, &info
->position
))
2200 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
2202 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
2204 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
2206 if (!prs_uint32("size",ps
, depth
, &info
->size
))
2208 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
2210 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
2212 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
2218 /*******************************************************************
2219 ********************************************************************/
2220 BOOL
new_smb_io_form_1(char *desc
, NEW_BUFFER
*buffer
, FORM_1
*info
, int depth
)
2222 prs_struct
*ps
=&(buffer
->prs
);
2224 prs_debug(ps
, depth
, desc
, "new_smb_io_form_1");
2227 buffer
->struct_start
=prs_offset(ps
);
2229 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
2232 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2235 if (!prs_uint32("width", ps
, depth
, &info
->width
))
2237 if (!prs_uint32("length", ps
, depth
, &info
->length
))
2239 if (!prs_uint32("left", ps
, depth
, &info
->left
))
2241 if (!prs_uint32("top", ps
, depth
, &info
->top
))
2243 if (!prs_uint32("right", ps
, depth
, &info
->right
))
2245 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
2251 /*******************************************************************
2252 Read/write a BUFFER struct.
2253 ********************************************************************/
2254 static BOOL
new_spoolss_io_buffer(char *desc
, prs_struct
*ps
, int depth
, NEW_BUFFER
*buffer
)
2259 prs_debug(ps
, depth
, desc
, "new_spoolss_io_buffer");
2262 if (!prs_uint32("ptr", ps
, depth
, &buffer
->ptr
))
2266 if (UNMARSHALLING(ps
)) {
2268 buffer
->string_at_end
=0;
2270 if (buffer
->ptr
==0) {
2271 if (!prs_init(&buffer
->prs
, 0, 4, prs_get_mem_context(ps
), UNMARSHALL
))
2276 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2279 if (!prs_init(&buffer
->prs
, buffer
->size
, 4, prs_get_mem_context(ps
), UNMARSHALL
))
2282 if (!prs_append_some_prs_data(&buffer
->prs
, ps
, prs_offset(ps
), buffer
->size
))
2285 if (!prs_set_offset(&buffer
->prs
, 0))
2288 if (!prs_set_offset(ps
, buffer
->size
+prs_offset(ps
)))
2291 buffer
->string_at_end
=buffer
->size
;
2300 if (!prs_uint32("size", ps
, depth
, &buffer
->size
))
2302 if (!prs_append_some_prs_data(ps
, &buffer
->prs
, 0, buffer
->size
))
2309 /*******************************************************************
2310 move a BUFFER from the query to the reply.
2311 ********************************************************************/
2312 void new_spoolss_move_buffer(NEW_BUFFER
*src
, NEW_BUFFER
**dest
)
2314 prs_switch_type(&src
->prs
, MARSHALL
);
2315 if(!prs_set_offset(&src
->prs
, 0))
2317 prs_force_dynamic(&(src
->prs
));
2322 /*******************************************************************
2323 create a BUFFER struct.
2324 ********************************************************************/
2325 BOOL
new_spoolss_allocate_buffer(NEW_BUFFER
**buffer
)
2330 if((*buffer
=(NEW_BUFFER
*)malloc(sizeof(NEW_BUFFER
))) == NULL
) {
2331 DEBUG(0,("new_spoolss_allocate_buffer: malloc fail for size %u.\n",
2332 (unsigned int)sizeof(NEW_BUFFER
) ));
2338 (*buffer
)->string_at_end
=0;
2342 /*******************************************************************
2343 Destroy a BUFFER struct.
2344 ********************************************************************/
2345 void new_spoolss_free_buffer(NEW_BUFFER
*buffer
)
2350 prs_mem_free(&buffer
->prs
);
2353 buffer
->string_at_end
=0;
2358 /*******************************************************************
2359 Get the size of a BUFFER struct.
2360 ********************************************************************/
2361 uint32
new_get_buffer_size(NEW_BUFFER
*buffer
)
2363 return (buffer
->size
);
2367 /*******************************************************************
2368 Parse a DRIVER_DIRECTORY_1 structure.
2369 ********************************************************************/
2370 BOOL
new_smb_io_driverdir_1(char *desc
, NEW_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
2372 prs_struct
*ps
=&(buffer
->prs
);
2374 prs_debug(ps
, depth
, desc
, "new_smb_io_driverdir_1");
2377 buffer
->struct_start
=prs_offset(ps
);
2379 if (!spoolss_smb_io_unistr(desc
, &info
->name
, ps
, depth
))
2385 /*******************************************************************
2386 Parse a PORT_INFO_1 structure.
2387 ********************************************************************/
2388 BOOL
new_smb_io_port_1(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
2390 prs_struct
*ps
=&(buffer
->prs
);
2392 prs_debug(ps
, depth
, desc
, "new_smb_io_port_1");
2395 buffer
->struct_start
=prs_offset(ps
);
2397 if(!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2403 /*******************************************************************
2404 Parse a PORT_INFO_2 structure.
2405 ********************************************************************/
2406 BOOL
new_smb_io_port_2(char *desc
, NEW_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2408 prs_struct
*ps
=&(buffer
->prs
);
2410 prs_debug(ps
, depth
, desc
, "new_smb_io_port_2");
2413 buffer
->struct_start
=prs_offset(ps
);
2415 if(!new_smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2417 if(!new_smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2419 if(!new_smb_io_relstr("description", buffer
, depth
, &info
->description
))
2421 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2423 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2430 /*******************************************************************
2431 ********************************************************************/
2432 BOOL
smb_io_printprocessor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2434 prs_struct
*ps
=&(buffer
->prs
);
2436 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2439 buffer
->struct_start
=prs_offset(ps
);
2441 if (new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2447 /*******************************************************************
2448 ********************************************************************/
2449 BOOL
smb_io_printprocdatatype_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2451 prs_struct
*ps
=&(buffer
->prs
);
2453 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2456 buffer
->struct_start
=prs_offset(ps
);
2458 if (new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2464 /*******************************************************************
2465 ********************************************************************/
2466 BOOL
smb_io_printmonitor_info_1(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2468 prs_struct
*ps
=&buffer
->prs
;
2470 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2473 buffer
->struct_start
=prs_offset(ps
);
2475 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2481 /*******************************************************************
2482 ********************************************************************/
2483 BOOL
smb_io_printmonitor_info_2(char *desc
, NEW_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
2485 prs_struct
*ps
=&(buffer
->prs
);
2487 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
2490 buffer
->struct_start
=prs_offset(ps
);
2492 if (!new_smb_io_relstr("name", buffer
, depth
, &info
->name
))
2494 if (!new_smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
2496 if (!new_smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
2502 /*******************************************************************
2503 return the size required by a struct in the stream
2504 ********************************************************************/
2505 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
2509 size
+=size_of_relative_string( &info
->printername
);
2510 size
+=size_of_relative_string( &info
->servername
);
2512 size
+=size_of_uint32( &info
->cjobs
);
2513 size
+=size_of_uint32( &info
->total_jobs
);
2514 size
+=size_of_uint32( &info
->total_bytes
);
2516 size
+=size_of_uint16( &info
->year
);
2517 size
+=size_of_uint16( &info
->month
);
2518 size
+=size_of_uint16( &info
->dayofweek
);
2519 size
+=size_of_uint16( &info
->day
);
2520 size
+=size_of_uint16( &info
->hour
);
2521 size
+=size_of_uint16( &info
->minute
);
2522 size
+=size_of_uint16( &info
->second
);
2523 size
+=size_of_uint16( &info
->milliseconds
);
2525 size
+=size_of_uint32( &info
->global_counter
);
2526 size
+=size_of_uint32( &info
->total_pages
);
2528 size
+=size_of_uint16( &info
->major_version
);
2529 size
+=size_of_uint16( &info
->build_version
);
2531 size
+=size_of_uint32( &info
->unknown7
);
2532 size
+=size_of_uint32( &info
->unknown8
);
2533 size
+=size_of_uint32( &info
->unknown9
);
2534 size
+=size_of_uint32( &info
->session_counter
);
2535 size
+=size_of_uint32( &info
->unknown11
);
2536 size
+=size_of_uint32( &info
->printer_errors
);
2537 size
+=size_of_uint32( &info
->unknown13
);
2538 size
+=size_of_uint32( &info
->unknown14
);
2539 size
+=size_of_uint32( &info
->unknown15
);
2540 size
+=size_of_uint32( &info
->unknown16
);
2541 size
+=size_of_uint32( &info
->change_id
);
2542 size
+=size_of_uint32( &info
->unknown18
);
2543 size
+=size_of_uint32( &info
->status
);
2544 size
+=size_of_uint32( &info
->unknown20
);
2545 size
+=size_of_uint32( &info
->c_setprinter
);
2547 size
+=size_of_uint16( &info
->unknown22
);
2548 size
+=size_of_uint16( &info
->unknown23
);
2549 size
+=size_of_uint16( &info
->unknown24
);
2550 size
+=size_of_uint16( &info
->unknown25
);
2551 size
+=size_of_uint16( &info
->unknown26
);
2552 size
+=size_of_uint16( &info
->unknown27
);
2553 size
+=size_of_uint16( &info
->unknown28
);
2554 size
+=size_of_uint16( &info
->unknown29
);
2559 /*******************************************************************
2560 return the size required by a struct in the stream
2561 ********************************************************************/
2562 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
2566 size
+=size_of_uint32( &info
->flags
);
2567 size
+=size_of_relative_string( &info
->description
);
2568 size
+=size_of_relative_string( &info
->name
);
2569 size
+=size_of_relative_string( &info
->comment
);
2574 /*******************************************************************
2575 return the size required by a struct in the stream
2576 ********************************************************************/
2577 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
2582 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2583 size
+= sec_desc_size( info
->secdesc
);
2585 size
+=size_of_device_mode( info
->devmode
);
2587 size
+=size_of_relative_string( &info
->servername
);
2588 size
+=size_of_relative_string( &info
->printername
);
2589 size
+=size_of_relative_string( &info
->sharename
);
2590 size
+=size_of_relative_string( &info
->portname
);
2591 size
+=size_of_relative_string( &info
->drivername
);
2592 size
+=size_of_relative_string( &info
->comment
);
2593 size
+=size_of_relative_string( &info
->location
);
2595 size
+=size_of_relative_string( &info
->sepfile
);
2596 size
+=size_of_relative_string( &info
->printprocessor
);
2597 size
+=size_of_relative_string( &info
->datatype
);
2598 size
+=size_of_relative_string( &info
->parameters
);
2600 size
+=size_of_uint32( &info
->attributes
);
2601 size
+=size_of_uint32( &info
->priority
);
2602 size
+=size_of_uint32( &info
->defaultpriority
);
2603 size
+=size_of_uint32( &info
->starttime
);
2604 size
+=size_of_uint32( &info
->untiltime
);
2605 size
+=size_of_uint32( &info
->status
);
2606 size
+=size_of_uint32( &info
->cjobs
);
2607 size
+=size_of_uint32( &info
->averageppm
);
2611 /*******************************************************************
2612 return the size required by a struct in the stream
2613 ********************************************************************/
2614 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
2616 /* The 4 is for the self relative pointer.. */
2617 /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */
2618 return 4 + (uint32
)sec_desc_size( info
->secdesc
);
2621 /*******************************************************************
2622 return the size required by a struct in the stream
2623 ********************************************************************/
2624 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
2627 size
+=size_of_relative_string( &info
->name
);
2632 /*******************************************************************
2633 return the size required by a struct in the stream
2634 ********************************************************************/
2635 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
2638 size
+=size_of_uint32( &info
->version
);
2639 size
+=size_of_relative_string( &info
->name
);
2640 size
+=size_of_relative_string( &info
->architecture
);
2641 size
+=size_of_relative_string( &info
->driverpath
);
2642 size
+=size_of_relative_string( &info
->datafile
);
2643 size
+=size_of_relative_string( &info
->configfile
);
2648 /*******************************************************************
2649 return the size required by a struct in the stream
2650 ********************************************************************/
2651 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
2657 size
+=size_of_uint32( &info
->version
);
2658 size
+=size_of_relative_string( &info
->name
);
2659 size
+=size_of_relative_string( &info
->architecture
);
2660 size
+=size_of_relative_string( &info
->driverpath
);
2661 size
+=size_of_relative_string( &info
->datafile
);
2662 size
+=size_of_relative_string( &info
->configfile
);
2663 size
+=size_of_relative_string( &info
->helpfile
);
2664 size
+=size_of_relative_string( &info
->monitorname
);
2665 size
+=size_of_relative_string( &info
->defaultdatatype
);
2667 string
=info
->dependentfiles
;
2669 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
2672 i
=i
+2; /* to count all chars including the leading zero */
2673 i
=2*i
; /* because we need the value in bytes */
2674 i
=i
+4; /* the offset pointer size */
2681 /*******************************************************************
2682 return the size required by a struct in the stream
2683 ********************************************************************/
2684 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
2687 size
+=size_of_uint32( &info
->jobid
);
2688 size
+=size_of_relative_string( &info
->printername
);
2689 size
+=size_of_relative_string( &info
->machinename
);
2690 size
+=size_of_relative_string( &info
->username
);
2691 size
+=size_of_relative_string( &info
->document
);
2692 size
+=size_of_relative_string( &info
->datatype
);
2693 size
+=size_of_relative_string( &info
->text_status
);
2694 size
+=size_of_uint32( &info
->status
);
2695 size
+=size_of_uint32( &info
->priority
);
2696 size
+=size_of_uint32( &info
->position
);
2697 size
+=size_of_uint32( &info
->totalpages
);
2698 size
+=size_of_uint32( &info
->pagesprinted
);
2699 size
+=size_of_systemtime( &info
->submitted
);
2704 /*******************************************************************
2705 return the size required by a struct in the stream
2706 ********************************************************************/
2707 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
2711 size
+=4; /* size of sec desc ptr */
2713 size
+=size_of_uint32( &info
->jobid
);
2714 size
+=size_of_relative_string( &info
->printername
);
2715 size
+=size_of_relative_string( &info
->machinename
);
2716 size
+=size_of_relative_string( &info
->username
);
2717 size
+=size_of_relative_string( &info
->document
);
2718 size
+=size_of_relative_string( &info
->notifyname
);
2719 size
+=size_of_relative_string( &info
->datatype
);
2720 size
+=size_of_relative_string( &info
->printprocessor
);
2721 size
+=size_of_relative_string( &info
->parameters
);
2722 size
+=size_of_relative_string( &info
->drivername
);
2723 size
+=size_of_device_mode( info
->devmode
);
2724 size
+=size_of_relative_string( &info
->text_status
);
2725 /* SEC_DESC sec_desc;*/
2726 size
+=size_of_uint32( &info
->status
);
2727 size
+=size_of_uint32( &info
->priority
);
2728 size
+=size_of_uint32( &info
->position
);
2729 size
+=size_of_uint32( &info
->starttime
);
2730 size
+=size_of_uint32( &info
->untiltime
);
2731 size
+=size_of_uint32( &info
->totalpages
);
2732 size
+=size_of_uint32( &info
->size
);
2733 size
+=size_of_systemtime( &info
->submitted
);
2734 size
+=size_of_uint32( &info
->timeelapsed
);
2735 size
+=size_of_uint32( &info
->pagesprinted
);
2740 /*******************************************************************
2741 return the size required by a struct in the stream
2742 ********************************************************************/
2743 uint32
spoolss_size_form_1(FORM_1
*info
)
2747 size
+=size_of_uint32( &info
->flag
);
2748 size
+=size_of_relative_string( &info
->name
);
2749 size
+=size_of_uint32( &info
->width
);
2750 size
+=size_of_uint32( &info
->length
);
2751 size
+=size_of_uint32( &info
->left
);
2752 size
+=size_of_uint32( &info
->top
);
2753 size
+=size_of_uint32( &info
->right
);
2754 size
+=size_of_uint32( &info
->bottom
);
2759 /*******************************************************************
2760 return the size required by a struct in the stream
2761 ********************************************************************/
2762 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
2766 size
+=size_of_relative_string( &info
->port_name
);
2771 /*******************************************************************
2772 return the size required by a struct in the stream
2773 ********************************************************************/
2774 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
2778 size
=str_len_uni(&info
->name
); /* the string length */
2779 size
=size
+1; /* add the leading zero */
2780 size
=size
*2; /* convert in char */
2785 /*******************************************************************
2786 return the size required by a struct in the stream
2787 ********************************************************************/
2788 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
2792 size
+=size_of_relative_string( &info
->port_name
);
2793 size
+=size_of_relative_string( &info
->monitor_name
);
2794 size
+=size_of_relative_string( &info
->description
);
2796 size
+=size_of_uint32( &info
->port_type
);
2797 size
+=size_of_uint32( &info
->reserved
);
2802 /*******************************************************************
2803 return the size required by a struct in the stream
2804 ********************************************************************/
2805 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
2808 size
+=size_of_relative_string( &info
->name
);
2813 /*******************************************************************
2814 return the size required by a struct in the stream
2815 ********************************************************************/
2816 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
2819 size
+=size_of_relative_string( &info
->name
);
2824 /*******************************************************************
2825 return the size required by a struct in the stream
2826 ********************************************************************/
2827 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
2830 size
+=size_of_relative_string( &info
->name
);
2835 /*******************************************************************
2836 return the size required by a struct in the stream
2837 ********************************************************************/
2838 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
2841 size
+=size_of_relative_string( &info
->name
);
2842 size
+=size_of_relative_string( &info
->environment
);
2843 size
+=size_of_relative_string( &info
->dll_name
);
2848 /*******************************************************************
2850 ********************************************************************/
2851 BOOL
make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
2852 const POLICY_HND
*hnd
,
2853 const fstring architecture
,
2854 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
2855 NEW_BUFFER
*buffer
, uint32 offered
)
2860 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
2862 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
2865 q_u
->clientmajorversion
=clientmajor
;
2866 q_u
->clientminorversion
=clientminor
;
2869 q_u
->offered
=offered
;
2874 /*******************************************************************
2876 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
2877 ********************************************************************/
2878 BOOL
spoolss_io_q_getprinterdriver2(char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
2880 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
2886 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
2888 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
2890 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
2895 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
2898 if(!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
2904 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
2907 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
2909 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
2915 /*******************************************************************
2917 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
2918 ********************************************************************/
2919 BOOL
spoolss_io_r_getprinterdriver2(char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
2921 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
2927 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
2932 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
2934 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
2936 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
2938 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
2944 /*******************************************************************
2946 ********************************************************************/
2947 BOOL
make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS
*q_u
, uint32 flags
,
2948 fstring servername
, uint32 level
,
2949 NEW_BUFFER
*buffer
, uint32 offered
)
2953 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
2954 init_unistr2(&q_u
->servername
, servername
, strlen(servername
));
2958 q_u
->offered
=offered
;
2963 /*******************************************************************
2965 ********************************************************************/
2966 BOOL
make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
2967 fstring servername
, uint32 level
,
2968 NEW_BUFFER
*buffer
, uint32 offered
)
2970 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
2971 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
2975 q_u
->offered
=offered
;
2980 /*******************************************************************
2982 * called from spoolss_enumprinters (srv_spoolss.c)
2983 ********************************************************************/
2984 BOOL
spoolss_io_q_enumprinters(char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
2986 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
2992 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
2994 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
2997 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
3002 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3005 if (!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
3010 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3016 /*******************************************************************
3017 Parse a SPOOL_R_ENUMPRINTERS structure.
3018 ********************************************************************/
3019 BOOL
new_spoolss_io_r_enumprinters(char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
3021 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_enumprinters");
3027 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
3033 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3036 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3039 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3045 /*******************************************************************
3046 * write a structure.
3047 * called from spoolss_r_enum_printers (srv_spoolss.c)
3049 ********************************************************************/
3050 BOOL
spoolss_io_r_getprinter(char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3052 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
3058 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
3064 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3067 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3073 /*******************************************************************
3075 * called from spoolss_getprinter (srv_spoolss.c)
3076 ********************************************************************/
3077 BOOL
spoolss_io_q_getprinter(char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3079 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
3085 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3087 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3090 if (!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
3095 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3101 /*******************************************************************
3103 ********************************************************************/
3104 BOOL
make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER
*q_u
, const POLICY_HND
*hnd
, uint32 level
,
3105 NEW_BUFFER
*buffer
, uint32 offered
)
3111 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3115 q_u
->offered
=offered
;
3120 /*******************************************************************
3121 ********************************************************************/
3122 BOOL
spoolss_io_r_setprinter(char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
3124 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
3130 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3136 /*******************************************************************
3137 Delete the dynamic parts of a SPOOL_Q_SETPRINTER struct.
3138 ********************************************************************/
3140 void free_spoolss_q_setprinter(SPOOL_Q_SETPRINTER
*q_u
)
3142 free_spool_printer_info_level(&q_u
->info
);
3143 free_sec_desc_buf( &q_u
->secdesc_ctr
);
3144 free_devmode( q_u
->devmode_ctr
.devmode
);
3147 /*******************************************************************
3148 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
3149 ********************************************************************/
3151 BOOL
spoolss_io_q_setprinter(char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
3153 uint32 ptr_sec_desc
= 0;
3155 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3161 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3163 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3166 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3169 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3176 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3181 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3187 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3191 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3197 /*******************************************************************
3198 ********************************************************************/
3199 BOOL
spoolss_io_r_fcpn(char *desc
, SPOOL_R_FCPN
*r_u
, prs_struct
*ps
, int depth
)
3201 prs_debug(ps
, depth
, desc
, "spoolss_io_r_fcpn");
3207 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3213 /*******************************************************************
3214 ********************************************************************/
3215 BOOL
spoolss_io_q_fcpn(char *desc
, SPOOL_Q_FCPN
*q_u
, prs_struct
*ps
, int depth
)
3218 prs_debug(ps
, depth
, desc
, "spoolss_io_q_fcpn");
3224 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3231 /*******************************************************************
3232 ********************************************************************/
3233 BOOL
spoolss_io_r_addjob(char *desc
, SPOOL_R_ADDJOB
*r_u
, prs_struct
*ps
, int depth
)
3235 prs_debug(ps
, depth
, desc
, "");
3241 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3247 /*******************************************************************
3248 ********************************************************************/
3249 BOOL
spoolss_io_q_addjob(char *desc
, SPOOL_Q_ADDJOB
*q_u
, prs_struct
*ps
, int depth
)
3251 prs_debug(ps
, depth
, desc
, "");
3257 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
3259 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3262 if(!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
3268 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3274 /*******************************************************************
3275 ********************************************************************/
3276 BOOL
spoolss_io_r_enumjobs(char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
3278 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
3284 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
3290 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3293 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3296 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3303 /*******************************************************************
3304 ********************************************************************/
3305 BOOL
make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
3316 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3317 q_u
->firstjob
= firstjob
;
3318 q_u
->numofjobs
= numofjobs
;
3320 q_u
->buffer
= buffer
;
3321 q_u
->offered
= offered
;
3325 /*******************************************************************
3326 ********************************************************************/
3327 BOOL
spoolss_io_q_enumjobs(char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
3329 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
3335 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
3338 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
3340 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
3342 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3345 if (!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
3348 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3354 /*******************************************************************
3355 ********************************************************************/
3356 BOOL
spoolss_io_r_schedulejob(char *desc
, SPOOL_R_SCHEDULEJOB
*r_u
, prs_struct
*ps
, int depth
)
3358 prs_debug(ps
, depth
, desc
, "spoolss_io_r_schedulejob");
3364 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3370 /*******************************************************************
3371 ********************************************************************/
3372 BOOL
spoolss_io_q_schedulejob(char *desc
, SPOOL_Q_SCHEDULEJOB
*q_u
, prs_struct
*ps
, int depth
)
3374 prs_debug(ps
, depth
, desc
, "spoolss_io_q_schedulejob");
3380 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3382 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3388 /*******************************************************************
3389 ********************************************************************/
3390 BOOL
spoolss_io_r_setjob(char *desc
, SPOOL_R_SETJOB
*r_u
, prs_struct
*ps
, int depth
)
3392 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setjob");
3398 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3404 /*******************************************************************
3405 ********************************************************************/
3406 BOOL
spoolss_io_q_setjob(char *desc
, SPOOL_Q_SETJOB
*q_u
, prs_struct
*ps
, int depth
)
3408 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setjob");
3414 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3416 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
3419 * level is usually 0. If (level!=0) then I'm in trouble !
3420 * I will try to generate setjob command with level!=0, one day.
3422 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3424 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3430 /*******************************************************************
3431 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
3432 ********************************************************************/
3433 BOOL
new_spoolss_io_r_enumprinterdrivers(char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
3435 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_enumprinterdrivers");
3441 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
3447 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3450 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3453 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3459 /*******************************************************************
3461 ********************************************************************/
3462 BOOL
make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
3464 const char *environment
,
3466 NEW_BUFFER
*buffer
, uint32 offered
)
3468 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
3469 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
3473 q_u
->offered
=offered
;
3478 /*******************************************************************
3479 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
3480 ********************************************************************/
3481 BOOL
spoolss_io_q_enumprinterdrivers(char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
3484 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
3490 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
3492 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
3497 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
3499 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
3504 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3507 if (!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
3513 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3519 /*******************************************************************
3520 ********************************************************************/
3521 BOOL
spoolss_io_q_enumforms(char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
3524 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
3529 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3531 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3534 if (!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
3539 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3545 /*******************************************************************
3546 ********************************************************************/
3547 BOOL
new_spoolss_io_r_enumforms(char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
3549 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_enumforms");
3555 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
3561 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
3564 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
3567 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3574 /*******************************************************************
3575 Parse a SPOOL_R_ENUMPORTS structure.
3576 ********************************************************************/
3577 BOOL
new_spoolss_io_r_enumports(char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
3579 prs_debug(ps
, depth
, desc
, "new_spoolss_io_r_enumports");
3585 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
3591 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3594 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3597 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
3603 /*******************************************************************
3604 ********************************************************************/
3605 BOOL
spoolss_io_q_enumports(char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
3607 prs_debug(ps
, depth
, desc
, "");
3613 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
3615 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
3620 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3623 if (!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
3628 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3634 /*******************************************************************
3635 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
3636 ********************************************************************/
3637 BOOL
spool_io_printer_info_level_1(char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
3639 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
3645 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
3647 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
3649 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
3651 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
3654 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
3656 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
3658 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
3664 /*******************************************************************
3665 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
3666 ********************************************************************/
3667 BOOL
spool_io_printer_info_level_3(char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
3669 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
3675 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
3681 /*******************************************************************
3682 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
3683 ********************************************************************/
3684 BOOL
spool_io_printer_info_level_2(char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
3686 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
3692 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
3694 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
3696 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
3698 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
3701 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
3703 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
3705 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
3707 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
3709 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
3711 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
3713 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
3715 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
3717 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
3720 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
3722 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
3724 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
3726 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
3728 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
3730 if(!prs_uint32("status", ps
, depth
, &il
->status
))
3732 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
3734 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
3737 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
3739 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
3741 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
3743 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
3745 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
3747 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
3749 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
3751 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
3753 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
3755 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
3757 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
3763 /*******************************************************************
3764 ********************************************************************/
3765 BOOL
spool_io_printer_info_level(char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
3767 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
3772 if(!prs_uint32("level", ps
, depth
, &il
->level
))
3774 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
3777 /* if no struct inside just return */
3778 if (il
->info_ptr
==0) {
3779 if (UNMARSHALLING(ps
)) {
3786 switch (il
->level
) {
3788 * level 0 is used by setprinter when managing the queue
3789 * (hold, stop, start a queue)
3793 /* DOCUMENT ME!!! What is level 1 used for? */
3796 if (UNMARSHALLING(ps
)) {
3797 if ((il
->info_1
=(SPOOL_PRINTER_INFO_LEVEL_1
*)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_1
))) == NULL
)
3799 ZERO_STRUCTP(il
->info_1
);
3801 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
)) {
3802 if (UNMARSHALLING(ps
))
3803 safe_free(il
->info_1
);
3809 * level 2 is used by addprinter
3810 * and by setprinter when updating printer's info
3813 if (UNMARSHALLING(ps
)) {
3814 if ((il
->info_2
=(SPOOL_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_2
))) == NULL
)
3816 ZERO_STRUCTP(il
->info_2
);
3818 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
)) {
3819 if (UNMARSHALLING(ps
))
3820 safe_free(il
->info_2
);
3824 /* DOCUMENT ME!!! What is level 3 used for? */
3827 if (UNMARSHALLING(ps
)) {
3828 if ((il
->info_3
=(SPOOL_PRINTER_INFO_LEVEL_3
*)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_3
))) == NULL
)
3830 ZERO_STRUCTP(il
->info_3
);
3832 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
)) {
3833 if (UNMARSHALLING(ps
))
3834 safe_free(il
->info_3
);
3844 /*******************************************************************
3845 ********************************************************************/
3846 BOOL
spoolss_io_q_addprinterex(char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
3848 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
3853 if(!prs_uint32("", ps
, depth
, &q_u
->server_name_ptr
))
3855 if(!smb_io_unistr2("", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
3861 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
3864 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3867 /* the 4 unknown are all 0 */
3870 * en fait ils sont pas inconnu
3871 * par recoupement avec rpcSetPrinter
3872 * c'est le devicemode
3873 * et le security descriptor.
3878 if(!prs_uint32("unk0", ps
, depth
, &q_u
->unk0
))
3880 if(!prs_uint32("unk1", ps
, depth
, &q_u
->unk1
))
3882 if(!prs_uint32("unk2", ps
, depth
, &q_u
->unk2
))
3884 if(!prs_uint32("unk3", ps
, depth
, &q_u
->unk3
))
3887 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
3889 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
3895 /*******************************************************************
3896 ********************************************************************/
3897 BOOL
spoolss_io_r_addprinterex(char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
3898 prs_struct
*ps
, int depth
)
3900 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
3903 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
3906 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
3912 /*******************************************************************
3913 ********************************************************************/
3914 BOOL
spool_io_printer_driver_info_level_3(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
3915 prs_struct
*ps
, int depth
)
3917 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
3919 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
3923 if (UNMARSHALLING(ps
)) {
3924 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
));
3937 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
3939 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
3941 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
3943 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
3945 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
3947 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
3949 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
3951 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
3953 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
3955 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
3957 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
3963 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
3965 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
3967 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
3969 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
3971 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
3973 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
3975 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
3977 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
3983 if (il
->dependentfiles_ptr
)
3984 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
3989 void free_spool_printer_driver_info_level_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
)
3991 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
= *q_u
;
3999 /*******************************************************************
4000 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
4001 ********************************************************************/
4002 BOOL
spool_io_printer_driver_info_level_6(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
4003 prs_struct
*ps
, int depth
)
4005 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
4007 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
4011 if (UNMARSHALLING(ps
)) {
4012 il
=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
));
4026 /* parse the main elements the packet */
4028 if(!prs_uint32("version", ps
, depth
, &il
->version
))
4030 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
4032 if(!prs_uint32("environment_ptr", ps
, depth
, &il
->environment_ptr
))
4034 if(!prs_uint32("driverpath_ptr", ps
, depth
, &il
->driverpath_ptr
))
4036 if(!prs_uint32("datafile_ptr", ps
, depth
, &il
->datafile_ptr
))
4038 if(!prs_uint32("configfile_ptr", ps
, depth
, &il
->configfile_ptr
))
4040 if(!prs_uint32("helpfile_ptr", ps
, depth
, &il
->helpfile_ptr
))
4042 if(!prs_uint32("monitorname_ptr", ps
, depth
, &il
->monitorname_ptr
))
4044 if(!prs_uint32("defaultdatatype_ptr", ps
, depth
, &il
->defaultdatatype_ptr
))
4046 if(!prs_uint32("dependentfiles_len", ps
, depth
, &il
->dependentfiles_len
))
4048 if(!prs_uint32("dependentfiles_ptr", ps
, depth
, &il
->dependentfiles_ptr
))
4050 if(!prs_uint32("previousnames_len", ps
, depth
, &il
->previousnames_len
))
4052 if(!prs_uint32("previousnames_ptr", ps
, depth
, &il
->previousnames_ptr
))
4054 if(!smb_io_time("driverdate", &il
->driverdate
, ps
, depth
))
4056 if(!prs_uint32("dummy4", ps
, depth
, &il
->dummy4
))
4058 if(!prs_uint64("driverversion", ps
, depth
, &il
->driverversion
))
4060 if(!prs_uint32("mfgname_ptr", ps
, depth
, &il
->mfgname_ptr
))
4062 if(!prs_uint32("oemurl_ptr", ps
, depth
, &il
->oemurl_ptr
))
4064 if(!prs_uint32("hardwareid_ptr", ps
, depth
, &il
->hardwareid_ptr
))
4066 if(!prs_uint32("provider_ptr", ps
, depth
, &il
->provider_ptr
))
4069 /* parse the structures in the packet */
4071 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
4075 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
4079 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
4083 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
4087 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
4091 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
4095 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
4099 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
4103 if (il
->dependentfiles_ptr
) {
4104 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
4109 if (il
->previousnames_ptr
) {
4110 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
4115 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
4119 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
4123 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
4127 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
4133 void free_spool_printer_driver_info_level_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
)
4135 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
= *q_u
;
4144 /*******************************************************************
4145 convert a buffer of UNICODE strings null terminated
4146 the buffer is terminated by a NULL
4148 convert to an dos codepage array (null terminated)
4150 dynamically allocate memory
4152 ********************************************************************/
4153 static BOOL
uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
4159 if (buf5
==NULL
) return False
;
4161 src
= (char *)buf5
->buffer
;
4164 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
4165 unistr_to_dos(f
, src
, sizeof(f
)-1);
4166 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
4167 *ar
= (fstring
*)Realloc(*ar
, sizeof(fstring
)*(n
+2));
4168 fstrcpy((*ar
)[n
], f
);
4171 fstrcpy((*ar
)[n
], "");
4176 /*******************************************************************
4177 read a UNICODE array with null terminated strings
4178 and null terminated array
4179 and size of array at beginning
4180 ********************************************************************/
4181 BOOL
smb_io_unibuffer(char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
4183 if (buffer
==NULL
) return False
;
4186 buffer
->uni_str_len
=buffer
->uni_max_len
;
4188 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
4191 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
4197 /*******************************************************************
4198 ********************************************************************/
4199 BOOL
spool_io_printer_driver_info_level(char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
4201 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
4206 if(!prs_uint32("level", ps
, depth
, &il
->level
))
4208 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
4214 switch (il
->level
) {
4216 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
4220 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
4230 void free_spool_printer_driver_info_level(SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
)
4235 switch (il
->level
) {
4237 free_spool_printer_driver_info_level_3(&il
->info_3
);
4240 free_spool_printer_driver_info_level_6(&il
->info_6
);
4245 /*******************************************************************
4246 ********************************************************************/
4247 BOOL
spoolss_io_q_addprinterdriver(char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4249 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
4255 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
4257 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4262 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4265 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
4271 /*******************************************************************
4272 Free the dynamic parts of a printer driver.
4273 ********************************************************************/
4275 void free_spoolss_q_addprinterdriver(SPOOL_Q_ADDPRINTERDRIVER
*q_u
)
4277 free_spool_printer_driver_info_level(&q_u
->info
);
4280 /*******************************************************************
4281 ********************************************************************/
4282 BOOL
spoolss_io_r_addprinterdriver(char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4284 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
4287 if(!prs_uint32("status", ps
, depth
, &q_u
->status
))
4294 /*******************************************************************
4295 ********************************************************************/
4296 BOOL
uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
4297 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
4299 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
4301 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
4305 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_3
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3
));
4313 d
->cversion
=uni
->cversion
;
4315 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
4316 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
4317 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
4318 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
4319 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
4320 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
4321 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
4322 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
4324 DEBUGADD(8,( "version: %d\n", d
->cversion
));
4325 DEBUGADD(8,( "name: %s\n", d
->name
));
4326 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4327 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4328 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4329 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4330 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4331 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4332 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4334 uniarray_2_dosarray(&(uni
->dependentfiles
), &(d
->dependentfiles
) );
4339 /*******************************************************************
4340 ********************************************************************/
4341 BOOL
uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
4342 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
4344 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
4346 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
4350 *asc
=(NT_PRINTER_DRIVER_INFO_LEVEL_6
*)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6
));
4358 d
->version
=uni
->version
;
4360 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
)-1);
4361 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
)-1);
4362 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
)-1);
4363 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
)-1);
4364 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
)-1);
4365 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
)-1);
4366 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
)-1);
4367 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
)-1);
4369 DEBUGADD(8,( "version: %d\n", d
->version
));
4370 DEBUGADD(8,( "name: %s\n", d
->name
));
4371 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4372 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4373 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4374 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4375 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4376 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4377 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4379 uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
);
4380 uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
);
4385 BOOL
uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
4386 NT_PRINTER_INFO_LEVEL_2
**asc
)
4388 NT_PRINTER_INFO_LEVEL_2
*d
;
4391 DEBUG(7,("Converting from UNICODE to ASCII\n"));
4392 time_unix
=time(NULL
);
4395 DEBUGADD(8,("allocating memory\n"));
4397 *asc
=(NT_PRINTER_INFO_LEVEL_2
*)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2
));
4402 /* we allocate memory iff called from
4403 * addprinter(ex) so we can do one time stuff here.
4405 (*asc
)->setuptime
=time_unix
;
4408 DEBUGADD(8,("start converting\n"));
4412 d
->attributes
=uni
->attributes
;
4413 d
->priority
=uni
->priority
;
4414 d
->default_priority
=uni
->default_priority
;
4415 d
->starttime
=uni
->starttime
;
4416 d
->untiltime
=uni
->untiltime
;
4417 d
->status
=uni
->status
;
4418 d
->cjobs
=uni
->cjobs
;
4420 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
)-1);
4421 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
)-1);
4422 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
)-1);
4423 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
)-1);
4424 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
)-1);
4425 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
)-1);
4426 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
)-1);
4427 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
)-1);
4428 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
)-1);
4429 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
)-1);
4430 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
)-1);
4435 /*******************************************************************
4437 ********************************************************************/
4438 BOOL
make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
4439 fstring servername
, fstring env_name
, uint32 level
,
4440 NEW_BUFFER
*buffer
, uint32 offered
)
4442 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
4443 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
4447 q_u
->offered
=offered
;
4453 /*******************************************************************
4454 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
4455 ********************************************************************/
4456 BOOL
spoolss_io_q_getprinterdriverdir(char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
4458 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
4463 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4465 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
4471 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
4473 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4479 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4482 if(!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
4488 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4494 /*******************************************************************
4495 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
4496 ********************************************************************/
4497 BOOL
spoolss_io_r_getprinterdriverdir(char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
4499 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
4505 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
4511 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4514 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
4520 /*******************************************************************
4521 ********************************************************************/
4522 BOOL
spoolss_io_r_enumprintprocessors(char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
4524 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
4530 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
4536 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4539 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4542 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
4548 /*******************************************************************
4549 ********************************************************************/
4550 BOOL
spoolss_io_q_enumprintprocessors(char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
4552 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
4558 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4560 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
4566 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
4568 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4574 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4577 if(!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
4583 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4589 /*******************************************************************
4590 ********************************************************************/
4591 BOOL
spoolss_io_r_enumprintprocdatatypes(char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
4593 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
4599 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
4605 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4608 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4611 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
4617 /*******************************************************************
4618 ********************************************************************/
4619 BOOL
spoolss_io_q_enumprintprocdatatypes(char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
4621 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
4627 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4629 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
4635 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
4637 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
4643 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4646 if(!new_spoolss_io_buffer("buffer", ps
, depth
, q_u
->buffer
))
4652 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4658 /*******************************************************************
4659 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
4660 ********************************************************************/
4661 BOOL
spoolss_io_q_enumprintmonitors(char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
4663 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
4669 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4671 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
4677 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4680 if(!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
4686 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4692 /*******************************************************************
4693 ********************************************************************/
4694 BOOL
spoolss_io_r_enumprintmonitors(char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
4696 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
4702 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
4708 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4711 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4714 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
4720 /*******************************************************************
4721 ********************************************************************/
4722 BOOL
spoolss_io_r_enumprinterdata(char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
4724 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
4729 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
4731 if(!prs_uint16s(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
4737 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
4740 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
4743 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
4745 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
4750 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
4752 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
4758 /*******************************************************************
4759 ********************************************************************/
4760 BOOL
spoolss_io_q_enumprinterdata(char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
4762 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
4767 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4769 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
4771 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
4773 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
4779 /*******************************************************************
4780 ********************************************************************/
4781 BOOL
make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
4782 const POLICY_HND
*hnd
,
4783 uint32 idx
, uint32 valuelen
, uint32 datalen
)
4785 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4787 q_u
->valuesize
=valuelen
;
4788 q_u
->datasize
=datalen
;
4793 /*******************************************************************
4794 ********************************************************************/
4795 BOOL
spoolss_io_q_setprinterdata(char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
4797 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
4802 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4804 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
4810 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
4813 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
4822 q_u
->data
=(uint8
*)malloc(q_u
->max_len
* sizeof(uint8
));
4823 if(q_u
->data
== NULL
)
4825 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
4832 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
4838 void free_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
)
4840 safe_free(q_u
->data
);
4843 /*******************************************************************
4844 ********************************************************************/
4845 BOOL
spoolss_io_r_setprinterdata(char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
4847 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
4852 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
4858 /*******************************************************************
4859 ********************************************************************/
4860 BOOL
convert_specific_param(NT_PRINTER_PARAM
**param
, const UNISTR2
*value
,
4861 uint32 type
, const uint8
*data
, uint32 len
)
4863 DEBUG(5,("converting a specific param struct\n"));
4867 *param
=(NT_PRINTER_PARAM
*)malloc(sizeof(NT_PRINTER_PARAM
));
4870 ZERO_STRUCTP(*param
);
4871 DEBUGADD(6,("Allocated a new PARAM struct\n"));
4873 unistr2_to_ascii((*param
)->value
, value
, sizeof((*param
)->value
)-1);
4874 (*param
)->type
= type
;
4876 /* le champ data n'est pas NULL termine */
4877 /* on stocke donc la longueur */
4879 (*param
)->data_len
=len
;
4881 (*param
)->data
=(uint8
*)malloc(len
* sizeof(uint8
));
4882 if((*param
)->data
== NULL
)
4885 memcpy((*param
)->data
, data
, len
);
4887 DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param
)->value
, (*param
)->data_len
));
4892 /*******************************************************************
4893 ********************************************************************/
4894 static BOOL
spoolss_io_addform(char *desc
, FORM
*f
, uint32 ptr
, prs_struct
*ps
, int depth
)
4896 prs_debug(ps
, depth
, desc
, "spoolss_io_addform");
4903 if(!prs_uint32("flags", ps
, depth
, &f
->flags
))
4905 if(!prs_uint32("name_ptr", ps
, depth
, &f
->name_ptr
))
4907 if(!prs_uint32("size_x", ps
, depth
, &f
->size_x
))
4909 if(!prs_uint32("size_y", ps
, depth
, &f
->size_y
))
4911 if(!prs_uint32("left", ps
, depth
, &f
->left
))
4913 if(!prs_uint32("top", ps
, depth
, &f
->top
))
4915 if(!prs_uint32("right", ps
, depth
, &f
->right
))
4917 if(!prs_uint32("bottom", ps
, depth
, &f
->bottom
))
4920 if(!smb_io_unistr2("", &f
->name
, f
->name_ptr
, ps
, depth
))
4927 /*******************************************************************
4928 ********************************************************************/
4929 BOOL
spoolss_io_q_addform(char *desc
, SPOOL_Q_ADDFORM
*q_u
, prs_struct
*ps
, int depth
)
4931 uint32 useless_ptr
=0;
4932 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addform");
4937 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4939 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4941 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
4946 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
4948 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
4955 /*******************************************************************
4956 ********************************************************************/
4957 BOOL
spoolss_io_r_addform(char *desc
, SPOOL_R_ADDFORM
*r_u
, prs_struct
*ps
, int depth
)
4959 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addform");
4964 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
4970 /*******************************************************************
4971 ********************************************************************/
4972 BOOL
spoolss_io_q_setform(char *desc
, SPOOL_Q_SETFORM
*q_u
, prs_struct
*ps
, int depth
)
4974 uint32 useless_ptr
=0;
4975 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setform");
4980 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4982 if(!smb_io_unistr2("", &q_u
->name
, True
, ps
, depth
))
4988 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4990 if(!prs_uint32("level2", ps
, depth
, &q_u
->level2
))
4995 if(!prs_uint32("useless_ptr", ps
, depth
, &useless_ptr
))
4997 if(!spoolss_io_addform("", &q_u
->form
, useless_ptr
, ps
, depth
))
5004 /*******************************************************************
5005 ********************************************************************/
5006 BOOL
spoolss_io_r_setform(char *desc
, SPOOL_R_SETFORM
*r_u
, prs_struct
*ps
, int depth
)
5008 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setform");
5013 if(!prs_uint32("status", ps
, depth
, &r_u
->status
))
5019 /*******************************************************************
5020 Parse a SPOOL_R_GETJOB structure.
5021 ********************************************************************/
5022 BOOL
spoolss_io_r_getjob(char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
5024 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
5030 if (!new_spoolss_io_buffer("", ps
, depth
, r_u
->buffer
))
5036 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5039 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5045 /*******************************************************************
5046 Parse a SPOOL_Q_GETJOB structure.
5047 ********************************************************************/
5048 BOOL
spoolss_io_q_getjob(char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
5050 prs_debug(ps
, depth
, desc
, "");
5056 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5058 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
5060 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5063 if(!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
5069 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5075 void free_devmode(DEVICEMODE
*devmode
)
5077 if (devmode
!=NULL
) {
5078 safe_free(devmode
->private);
5083 void free_printer_info_1(PRINTER_INFO_1
*printer
)
5088 void free_printer_info_2(PRINTER_INFO_2
*printer
)
5090 if (printer
!=NULL
) {
5091 free_devmode(printer
->devmode
);
5092 printer
->devmode
= NULL
;
5093 if (printer
->secdesc
!= NULL
)
5094 free_sec_desc(&printer
->secdesc
);
5099 void free_printer_info_3(PRINTER_INFO_3
*printer
)
5101 if (printer
!=NULL
) {
5102 if (printer
->secdesc
!= NULL
)
5103 free_sec_desc(&printer
->secdesc
);
5108 void free_spool_printer_info_1(SPOOL_PRINTER_INFO_LEVEL_1
*printer
)
5113 void free_spool_printer_info_2(SPOOL_PRINTER_INFO_LEVEL_2
*printer
)
5115 if (printer
!=NULL
) {
5116 if (printer
->secdesc
!= NULL
)
5117 free_sec_desc_buf(&printer
->secdesc
);
5122 void free_spool_printer_info_3(SPOOL_PRINTER_INFO_LEVEL_3
*printer
)
5127 void free_spool_printer_info_level(SPOOL_PRINTER_INFO_LEVEL
*pil
)
5132 switch (pil
->level
) {
5134 free_spool_printer_info_1(pil
->info_1
);
5137 free_spool_printer_info_2(pil
->info_2
);
5140 free_spool_printer_info_3(pil
->info_3
);
5147 static PRINTER_INFO_2
*prt2_dup(const PRINTER_INFO_2
* from
)
5149 PRINTER_INFO_2
*copy
= (PRINTER_INFO_2
*)malloc(sizeof(PRINTER_INFO_2
));
5152 memcpy(copy
, from
, sizeof(*copy
));
5159 void free_print2_array(uint32 num_entries
, PRINTER_INFO_2
**entries
)
5161 void(*fn
)(void*) = (void(*)(void*))&free_printer_info_2
;
5162 free_void_array(num_entries
, (void**)entries
, *fn
);
5165 PRINTER_INFO_2
*add_print2_to_array(uint32
*len
, PRINTER_INFO_2
***array
,
5166 const PRINTER_INFO_2
*prt
)
5168 void*(*fn
)(const void*) = (void*(*)(const void*))&prt2_dup
;
5169 return (PRINTER_INFO_2
*)add_copy_to_array(len
,
5170 (void***)array
, (const void*)prt
, *fn
, True
);
5173 static PRINTER_INFO_1
*prt1_dup(const PRINTER_INFO_1
* from
)
5175 PRINTER_INFO_1
*copy
= (PRINTER_INFO_1
*)malloc(sizeof(PRINTER_INFO_1
));
5178 memcpy(copy
, from
, sizeof(*copy
));
5185 void free_print1_array(uint32 num_entries
, PRINTER_INFO_1
**entries
)
5187 void(*fn
)(void*) = (void(*)(void*))&free
;
5188 free_void_array(num_entries
, (void**)entries
, *fn
);
5191 PRINTER_INFO_1
*add_print1_to_array(uint32
*len
, PRINTER_INFO_1
***array
,
5192 const PRINTER_INFO_1
*prt
)
5194 void*(*fn
)(const void*) = (void*(*)(const void*))&prt1_dup
;
5195 return (PRINTER_INFO_1
*)add_copy_to_array(len
,
5196 (void***)array
, (const void*)prt
, *fn
, True
);
5199 static JOB_INFO_1
*job1_dup(const JOB_INFO_1
* from
)
5201 JOB_INFO_1
*copy
= (JOB_INFO_1
*)malloc(sizeof(JOB_INFO_1
));
5206 memcpy(copy
, from
, sizeof(*copy
));
5216 void free_job1_array(uint32 num_entries
, JOB_INFO_1
**entries
)
5218 void(*fn
)(void*) = (void(*)(void*))&free
;
5219 free_void_array(num_entries
, (void**)entries
, *fn
);
5222 JOB_INFO_1
*add_job1_to_array(uint32
*len
, JOB_INFO_1
***array
,
5223 const JOB_INFO_1
*job
)
5225 void*(*fn
)(const void*) = (void*(*)(const void*))&job1_dup
;
5226 return (JOB_INFO_1
*)add_copy_to_array(len
,
5227 (void***)array
, (const void*)job
, *fn
, True
);
5230 static JOB_INFO_2
*job2_dup(const JOB_INFO_2
* from
)
5232 JOB_INFO_2
*copy
= (JOB_INFO_2
*)malloc(sizeof(JOB_INFO_2
));
5237 memcpy(copy
, from
, sizeof(*copy
));
5247 void free_job_info_2(JOB_INFO_2
*job
)
5251 free_devmode(job
->devmode
);
5256 void free_job2_array(uint32 num_entries
, JOB_INFO_2
**entries
)
5258 void(*fn
)(void*) = (void(*)(void*))&free_job_info_2
;
5259 free_void_array(num_entries
, (void**)entries
, *fn
);
5262 JOB_INFO_2
*add_job2_to_array(uint32
*len
, JOB_INFO_2
***array
,
5263 const JOB_INFO_2
*job
)
5265 void*(*fn
)(const void*) = (void*(*)(const void*))&job2_dup
;
5266 return (JOB_INFO_2
*)add_copy_to_array(len
,
5267 (void***)array
, (const void*)job
, *fn
, True
);
5270 /*******************************************************************
5271 Parse a SPOOL_Q_REPLYOPENPRINTER structure.
5272 ********************************************************************/
5273 BOOL
spoolss_io_q_replyopenprinter(char *desc
, SPOOL_Q_REPLYOPENPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5275 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replyopenprinter");
5281 if(!smb_io_unistr2("", &q_u
->string
, True
, ps
, depth
))
5287 if(!prs_uint32("printer", ps
, depth
, &q_u
->printer
))
5289 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
5292 if(!new_spoolss_io_buffer("", ps
, depth
, q_u
->buffer
))
5298 /*******************************************************************
5299 Parse a SPOOL_R_REPLYOPENPRINTER structure.
5300 ********************************************************************/
5301 BOOL
spoolss_io_r_replyopenprinter(char *desc
, SPOOL_R_REPLYOPENPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5303 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replyopenprinter");
5309 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5312 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))
5318 /*******************************************************************
5319 Parse a SPOOL_Q_REPLYCLOSEPRINTER structure.
5320 ********************************************************************/
5321 BOOL
spoolss_io_q_replycloseprinter(char *desc
, SPOOL_Q_REPLYCLOSEPRINTER
*q_u
, prs_struct
*ps
, int depth
)
5323 prs_debug(ps
, depth
, desc
, "spoolss_io_q_replycloseprinter");
5329 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5335 /*******************************************************************
5336 Parse a SPOOL_R_REPLYCLOSEPRINTER structure.
5337 ********************************************************************/
5338 BOOL
spoolss_io_r_replycloseprinter(char *desc
, SPOOL_R_REPLYCLOSEPRINTER
*r_u
, prs_struct
*ps
, int depth
)
5340 prs_debug(ps
, depth
, desc
, "spoolss_io_r_replycloseprinter");
5346 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
5349 if (!prs_uint32("status", ps
, depth
, &r_u
->status
))