2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Jean François Micouleau 1998-2000,
7 * Copyright (C) Gerald Carter 2000-2002,
8 * Copyright (C) Tim Potter 2001-2002.
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 3 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, see <http://www.gnu.org/licenses/>.
27 #define DBGC_CLASS DBGC_RPC_PARSE
30 /*******************************************************************
31 This should be moved in a more generic lib.
32 ********************************************************************/
34 bool spoolss_io_system_time(const char *desc
, prs_struct
*ps
, int depth
, SYSTEMTIME
*systime
)
36 if(!prs_uint16("year", ps
, depth
, &systime
->year
))
38 if(!prs_uint16("month", ps
, depth
, &systime
->month
))
40 if(!prs_uint16("dayofweek", ps
, depth
, &systime
->dayofweek
))
42 if(!prs_uint16("day", ps
, depth
, &systime
->day
))
44 if(!prs_uint16("hour", ps
, depth
, &systime
->hour
))
46 if(!prs_uint16("minute", ps
, depth
, &systime
->minute
))
48 if(!prs_uint16("second", ps
, depth
, &systime
->second
))
50 if(!prs_uint16("milliseconds", ps
, depth
, &systime
->milliseconds
))
56 /*******************************************************************
57 ********************************************************************/
59 bool make_systemtime(SYSTEMTIME
*systime
, struct tm
*unixtime
)
61 systime
->year
=unixtime
->tm_year
+1900;
62 systime
->month
=unixtime
->tm_mon
+1;
63 systime
->dayofweek
=unixtime
->tm_wday
;
64 systime
->day
=unixtime
->tm_mday
;
65 systime
->hour
=unixtime
->tm_hour
;
66 systime
->minute
=unixtime
->tm_min
;
67 systime
->second
=unixtime
->tm_sec
;
68 systime
->milliseconds
=0;
73 /*******************************************************************
74 reads or writes an NOTIFY OPTION TYPE structure.
75 ********************************************************************/
77 /* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one
78 structure. The _TYPE structure is really the deferred referrants (i.e
79 the notify fields array) of the _TYPE structure. -tpot */
81 static bool smb_io_notify_option_type(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
83 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type");
89 if(!prs_uint16("type", ps
, depth
, &type
->type
))
91 if(!prs_uint16("reserved0", ps
, depth
, &type
->reserved0
))
93 if(!prs_uint32("reserved1", ps
, depth
, &type
->reserved1
))
95 if(!prs_uint32("reserved2", ps
, depth
, &type
->reserved2
))
97 if(!prs_uint32("count", ps
, depth
, &type
->count
))
99 if(!prs_uint32("fields_ptr", ps
, depth
, &type
->fields_ptr
))
105 /*******************************************************************
106 reads or writes an NOTIFY OPTION TYPE DATA.
107 ********************************************************************/
109 static bool smb_io_notify_option_type_data(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE
*type
, prs_struct
*ps
, int depth
)
113 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_data");
116 /* if there are no fields just return */
117 if (type
->fields_ptr
==0)
123 if(!prs_uint32("count2", ps
, depth
, &type
->count2
))
126 if (type
->count2
!= type
->count
)
127 DEBUG(4,("What a mess, count was %x now is %x !\n", type
->count
, type
->count2
));
129 if (type
->count2
> MAX_NOTIFY_TYPE_FOR_NOW
) {
133 /* parse the option type data */
134 for(i
=0;i
<type
->count2
;i
++)
135 if(!prs_uint16("fields",ps
,depth
,&type
->fields
[i
]))
140 /*******************************************************************
141 reads or writes an NOTIFY OPTION structure.
142 ********************************************************************/
144 static bool smb_io_notify_option_type_ctr(const char *desc
, SPOOL_NOTIFY_OPTION_TYPE_CTR
*ctr
, prs_struct
*ps
, int depth
)
148 prs_debug(ps
, depth
, desc
, "smb_io_notify_option_type_ctr");
151 if(!prs_uint32("count", ps
, depth
, &ctr
->count
))
155 if (UNMARSHALLING(ps
) && ctr
->count
)
156 if((ctr
->type
=PRS_ALLOC_MEM(ps
,SPOOL_NOTIFY_OPTION_TYPE
,ctr
->count
)) == NULL
)
159 /* the option type struct */
160 for(i
=0;i
<ctr
->count
;i
++)
161 if(!smb_io_notify_option_type("", &ctr
->type
[i
] , ps
, depth
))
164 /* the type associated with the option type struct */
165 for(i
=0;i
<ctr
->count
;i
++)
166 if(!smb_io_notify_option_type_data("", &ctr
->type
[i
] , ps
, depth
))
172 /*******************************************************************
173 reads or writes an NOTIFY OPTION structure.
174 ********************************************************************/
176 static bool smb_io_notify_option(const char *desc
, SPOOL_NOTIFY_OPTION
*option
, prs_struct
*ps
, int depth
)
178 prs_debug(ps
, depth
, desc
, "smb_io_notify_option");
181 if(!prs_uint32("version", ps
, depth
, &option
->version
))
183 if(!prs_uint32("flags", ps
, depth
, &option
->flags
))
185 if(!prs_uint32("count", ps
, depth
, &option
->count
))
187 if(!prs_uint32("option_type_ptr", ps
, depth
, &option
->option_type_ptr
))
190 /* marshalling or unmarshalling, that would work */
191 if (option
->option_type_ptr
!=0) {
192 if(!smb_io_notify_option_type_ctr("", &option
->ctr
,ps
, depth
))
196 option
->ctr
.type
=NULL
;
203 /*******************************************************************
204 reads or writes an NOTIFY INFO DATA structure.
205 ********************************************************************/
207 static bool smb_io_notify_info_data(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
, prs_struct
*ps
, int depth
)
209 uint32 useless_ptr
=0x0FF0ADDE;
211 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data");
216 if(!prs_uint16("type", ps
, depth
, &data
->type
))
218 if(!prs_uint16("field", ps
, depth
, &data
->field
))
221 if(!prs_uint32("how many words", ps
, depth
, &data
->size
))
223 if(!prs_uint32("id", ps
, depth
, &data
->id
))
225 if(!prs_uint32("how many words", ps
, depth
, &data
->size
))
228 switch (data
->enc_type
) {
230 /* One and two value data has two uint32 values */
232 case NOTIFY_ONE_VALUE
:
233 case NOTIFY_TWO_VALUE
:
235 if(!prs_uint32("value[0]", ps
, depth
, &data
->notify_data
.value
[0]))
237 if(!prs_uint32("value[1]", ps
, depth
, &data
->notify_data
.value
[1]))
241 /* Pointers and strings have a string length and a
242 pointer. For a string the length is expressed as
243 the number of uint16 characters plus a trailing
248 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
250 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
257 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
260 if(!prs_uint32("pointer", ps
, depth
, &useless_ptr
))
266 if( !prs_uint32( "sd size", ps
, depth
, &data
->notify_data
.sd
.size
) )
268 if( !prs_uint32( "pointer", ps
, depth
, &useless_ptr
) )
274 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data\n",
282 /*******************************************************************
283 reads or writes an NOTIFY INFO DATA structure.
284 ********************************************************************/
286 bool smb_io_notify_info_data_strings(const char *desc
,SPOOL_NOTIFY_INFO_DATA
*data
,
287 prs_struct
*ps
, int depth
)
289 prs_debug(ps
, depth
, desc
, "smb_io_notify_info_data_strings");
295 switch(data
->enc_type
) {
297 /* No data for values */
299 case NOTIFY_ONE_VALUE
:
300 case NOTIFY_TWO_VALUE
:
304 /* Strings start with a length in uint16s */
309 data
->notify_data
.data
.length
/= 2;
311 if(!prs_uint32("string length", ps
, depth
, &data
->notify_data
.data
.length
))
314 if (UNMARSHALLING(ps
) && data
->notify_data
.data
.length
) {
315 data
->notify_data
.data
.string
= PRS_ALLOC_MEM(ps
, uint16
,
316 data
->notify_data
.data
.length
);
318 if (!data
->notify_data
.data
.string
)
322 if (!prs_uint16uni(True
, "string", ps
, depth
, data
->notify_data
.data
.string
,
323 data
->notify_data
.data
.length
))
327 data
->notify_data
.data
.length
*= 2;
333 if (UNMARSHALLING(ps
) && data
->notify_data
.data
.length
) {
334 data
->notify_data
.data
.string
= PRS_ALLOC_MEM(ps
, uint16
,
335 data
->notify_data
.data
.length
);
337 if (!data
->notify_data
.data
.string
)
341 if(!prs_uint8s(True
,"buffer",ps
,depth
,(uint8
*)data
->notify_data
.data
.string
,data
->notify_data
.data
.length
))
347 if( !prs_uint32("secdesc size ", ps
, depth
, &data
->notify_data
.sd
.size
) )
349 if ( !sec_io_desc( "sec_desc", &data
->notify_data
.sd
.desc
, ps
, depth
) )
354 DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data_strings\n",
360 if (isvalue
==False
) {
362 /* length of string in unicode include \0 */
363 x
=data
->notify_data
.data
.length
+1;
365 if (data
->field
!= 16)
366 if(!prs_uint32("string length", ps
, depth
, &x
))
369 if (MARSHALLING(ps
)) {
370 /* These are already in little endian format. Don't byte swap. */
373 /* No memory allocated for this string
374 therefore following the data.string
375 pointer is a bad idea. Use a pointer to
376 the uint32 length union member to
377 provide a source for a unicode NULL */
379 if(!prs_uint8s(True
,"string",ps
,depth
, (uint8
*)&data
->notify_data
.data
.length
,x
*2))
383 if (data
->field
== 16)
386 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
391 /* Tallocate memory for string */
394 data
->notify_data
.data
.string
= PRS_ALLOC_MEM(ps
, uint16
, x
* 2);
395 if (!data
->notify_data
.data
.string
)
398 data
->notify_data
.data
.string
= NULL
;
401 if(!prs_uint16uni(True
,"string",ps
,depth
,data
->notify_data
.data
.string
,x
))
409 /* Win2k does not seem to put this parse align here */
417 /*******************************************************************
418 reads or writes an NOTIFY INFO structure.
419 ********************************************************************/
421 static bool smb_io_notify_info(const char *desc
, SPOOL_NOTIFY_INFO
*info
, prs_struct
*ps
, int depth
)
425 prs_debug(ps
, depth
, desc
, "smb_io_notify_info");
431 if(!prs_uint32("count", ps
, depth
, &info
->count
))
433 if(!prs_uint32("version", ps
, depth
, &info
->version
))
435 if(!prs_uint32("flags", ps
, depth
, &info
->flags
))
437 if(!prs_uint32("count", ps
, depth
, &info
->count
))
440 for (i
=0;i
<info
->count
;i
++) {
441 if(!smb_io_notify_info_data(desc
, &info
->data
[i
], ps
, depth
))
445 /* now do the strings at the end of the stream */
446 for (i
=0;i
<info
->count
;i
++) {
447 if(!smb_io_notify_info_data_strings(desc
, &info
->data
[i
], ps
, depth
))
454 /*******************************************************************
455 ********************************************************************/
457 bool spool_io_user_level_1( const char *desc
, prs_struct
*ps
, int depth
, SPOOL_USER_1
*q_u
)
459 prs_debug(ps
, depth
, desc
, "");
465 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
468 if (!prs_io_unistr2_p("", ps
, depth
, &q_u
->client_name
))
470 if (!prs_io_unistr2_p("", ps
, depth
, &q_u
->user_name
))
473 if (!prs_uint32("build", ps
, depth
, &q_u
->build
))
475 if (!prs_uint32("major", ps
, depth
, &q_u
->major
))
477 if (!prs_uint32("minor", ps
, depth
, &q_u
->minor
))
479 if (!prs_uint32("processor", ps
, depth
, &q_u
->processor
))
482 if (!prs_io_unistr2("", ps
, depth
, q_u
->client_name
))
487 if (!prs_io_unistr2("", ps
, depth
, q_u
->user_name
))
493 /*******************************************************************
494 ********************************************************************/
496 static bool spool_io_user_level(const char *desc
, SPOOL_USER_CTR
*q_u
, prs_struct
*ps
, int depth
)
501 prs_debug(ps
, depth
, desc
, "spool_io_user_level");
507 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
510 switch ( q_u
->level
)
513 if ( !prs_pointer( "" , ps
, depth
, (void*)&q_u
->user
.user1
,
514 sizeof(SPOOL_USER_1
), (PRS_POINTER_CAST
)spool_io_user_level_1
))
526 /*******************************************************************
527 * read or write a DEVICEMODE struct.
528 * on reading allocate memory for the private member
529 ********************************************************************/
531 #define DM_NUM_OPTIONAL_FIELDS 8
533 bool spoolss_io_devmode(const char *desc
, prs_struct
*ps
, int depth
, DEVICEMODE
*devmode
)
535 int available_space
; /* size of the device mode left to parse */
536 /* only important on unmarshalling */
538 uint16
*unistr_buffer
;
541 struct optional_fields
{
544 } opt_fields
[DM_NUM_OPTIONAL_FIELDS
] = {
545 { "icmmethod", NULL
},
546 { "icmintent", NULL
},
547 { "mediatype", NULL
},
548 { "dithertype", NULL
},
549 { "reserved1", NULL
},
550 { "reserved2", NULL
},
551 { "panningwidth", NULL
},
552 { "panningheight", NULL
}
555 /* assign at run time to keep non-gcc compilers happy */
557 opt_fields
[0].field
= &devmode
->icmmethod
;
558 opt_fields
[1].field
= &devmode
->icmintent
;
559 opt_fields
[2].field
= &devmode
->mediatype
;
560 opt_fields
[3].field
= &devmode
->dithertype
;
561 opt_fields
[4].field
= &devmode
->reserved1
;
562 opt_fields
[5].field
= &devmode
->reserved2
;
563 opt_fields
[6].field
= &devmode
->panningwidth
;
564 opt_fields
[7].field
= &devmode
->panningheight
;
567 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode");
570 if (UNMARSHALLING(ps
)) {
571 devmode
->devicename
.buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
572 if (devmode
->devicename
.buffer
== NULL
)
574 unistr_buffer
= devmode
->devicename
.buffer
;
577 /* devicename is a static sized string but the buffer we set is not */
578 unistr_buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
579 memset( unistr_buffer
, 0x0, MAXDEVICENAME
);
580 for ( j
=0; devmode
->devicename
.buffer
[j
]; j
++ )
581 unistr_buffer
[j
] = devmode
->devicename
.buffer
[j
];
584 if (!prs_uint16uni(True
,"devicename", ps
, depth
, unistr_buffer
, MAXDEVICENAME
))
587 if (!prs_uint16("specversion", ps
, depth
, &devmode
->specversion
))
590 if (!prs_uint16("driverversion", ps
, depth
, &devmode
->driverversion
))
592 if (!prs_uint16("size", ps
, depth
, &devmode
->size
))
594 if (!prs_uint16("driverextra", ps
, depth
, &devmode
->driverextra
))
596 if (!prs_uint32("fields", ps
, depth
, &devmode
->fields
))
598 if (!prs_uint16("orientation", ps
, depth
, &devmode
->orientation
))
600 if (!prs_uint16("papersize", ps
, depth
, &devmode
->papersize
))
602 if (!prs_uint16("paperlength", ps
, depth
, &devmode
->paperlength
))
604 if (!prs_uint16("paperwidth", ps
, depth
, &devmode
->paperwidth
))
606 if (!prs_uint16("scale", ps
, depth
, &devmode
->scale
))
608 if (!prs_uint16("copies", ps
, depth
, &devmode
->copies
))
610 if (!prs_uint16("defaultsource", ps
, depth
, &devmode
->defaultsource
))
612 if (!prs_uint16("printquality", ps
, depth
, &devmode
->printquality
))
614 if (!prs_uint16("color", ps
, depth
, &devmode
->color
))
616 if (!prs_uint16("duplex", ps
, depth
, &devmode
->duplex
))
618 if (!prs_uint16("yresolution", ps
, depth
, &devmode
->yresolution
))
620 if (!prs_uint16("ttoption", ps
, depth
, &devmode
->ttoption
))
622 if (!prs_uint16("collate", ps
, depth
, &devmode
->collate
))
625 if (UNMARSHALLING(ps
)) {
626 devmode
->formname
.buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
627 if (devmode
->formname
.buffer
== NULL
)
629 unistr_buffer
= devmode
->formname
.buffer
;
632 /* devicename is a static sized string but the buffer we set is not */
633 unistr_buffer
= PRS_ALLOC_MEM(ps
, uint16
, MAXDEVICENAME
);
634 memset( unistr_buffer
, 0x0, MAXDEVICENAME
);
635 for ( j
=0; devmode
->formname
.buffer
[j
]; j
++ )
636 unistr_buffer
[j
] = devmode
->formname
.buffer
[j
];
639 if (!prs_uint16uni(True
, "formname", ps
, depth
, unistr_buffer
, MAXDEVICENAME
))
641 if (!prs_uint16("logpixels", ps
, depth
, &devmode
->logpixels
))
643 if (!prs_uint32("bitsperpel", ps
, depth
, &devmode
->bitsperpel
))
645 if (!prs_uint32("pelswidth", ps
, depth
, &devmode
->pelswidth
))
647 if (!prs_uint32("pelsheight", ps
, depth
, &devmode
->pelsheight
))
649 if (!prs_uint32("displayflags", ps
, depth
, &devmode
->displayflags
))
651 if (!prs_uint32("displayfrequency", ps
, depth
, &devmode
->displayfrequency
))
654 * every device mode I've ever seen on the wire at least has up
655 * to the displayfrequency field. --jerry (05-09-2002)
658 /* add uint32's + uint16's + two UNICODE strings */
660 available_space
= devmode
->size
- (sizeof(uint32
)*6 + sizeof(uint16
)*18 + sizeof(uint16
)*64);
662 /* Sanity check - we only have uint32's left tp parse */
664 if ( available_space
&& ((available_space
% sizeof(uint32
)) != 0) ) {
665 DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n",
666 available_space
, devmode
->size
));
667 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
672 * Conditional parsing. Assume that the DeviceMode has been
673 * zero'd by the caller.
676 while ((available_space
> 0) && (i
< DM_NUM_OPTIONAL_FIELDS
))
678 DEBUG(11, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space
));
679 if (!prs_uint32(opt_fields
[i
].name
, ps
, depth
, opt_fields
[i
].field
))
681 available_space
-= sizeof(uint32
);
685 /* Sanity Check - we should no available space at this point unless
686 MS changes the device mode structure */
688 if (available_space
) {
689 DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n"));
690 DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n",
691 available_space
, devmode
->size
));
692 DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n"));
697 if (devmode
->driverextra
!=0) {
698 if (UNMARSHALLING(ps
)) {
699 devmode
->dev_private
=PRS_ALLOC_MEM(ps
, uint8
, devmode
->driverextra
);
700 if(devmode
->dev_private
== NULL
)
702 DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for dev_private\n",devmode
->driverextra
));
705 DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of dev_private\n",devmode
->driverextra
));
706 if (!prs_uint8s(False
, "dev_private", ps
, depth
,
707 devmode
->dev_private
, devmode
->driverextra
))
714 /*******************************************************************
715 Read or write a DEVICEMODE container
716 ********************************************************************/
718 static bool spoolss_io_devmode_cont(const char *desc
, DEVMODE_CTR
*dm_c
, prs_struct
*ps
, int depth
)
723 prs_debug(ps
, depth
, desc
, "spoolss_io_devmode_cont");
729 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
732 if (!prs_uint32("devmode_ptr", ps
, depth
, &dm_c
->devmode_ptr
))
735 if (dm_c
->size
==0 || dm_c
->devmode_ptr
==0) {
736 if (UNMARSHALLING(ps
))
737 /* if while reading there is no DEVMODE ... */
742 /* so we have a DEVICEMODE to follow */
743 if (UNMARSHALLING(ps
)) {
744 DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
745 dm_c
->devmode
=PRS_ALLOC_MEM(ps
,DEVICEMODE
,1);
746 if(dm_c
->devmode
== NULL
)
750 /* this is bad code, shouldn't be there */
751 if (!prs_uint32("size", ps
, depth
, &dm_c
->size
))
754 if (!spoolss_io_devmode(desc
, ps
, depth
, dm_c
->devmode
))
760 /*******************************************************************
762 ********************************************************************/
764 bool make_spoolss_q_addprinterex( TALLOC_CTX
*mem_ctx
, SPOOL_Q_ADDPRINTEREX
*q_u
,
765 const char *srv_name
, const char* clientname
, const char* user_name
,
766 uint32 level
, PRINTER_INFO_CTR
*ctr
)
768 DEBUG(5,("make_spoolss_q_addprinterex\n"));
770 if (!ctr
|| !ctr
->printers_2
)
775 q_u
->server_name
= TALLOC_P( mem_ctx
, UNISTR2
);
776 if (!q_u
->server_name
) {
779 init_unistr2(q_u
->server_name
, srv_name
, UNI_FLAGS_NONE
);
783 q_u
->info
.level
= level
;
784 q_u
->info
.info_ptr
= (ctr
->printers_2
!=NULL
)?1:0;
787 /* init q_u->info.info2 from *info */
788 if (!make_spoolss_printer_info_2(mem_ctx
, &q_u
->info
.info_2
, ctr
->printers_2
)) {
789 DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
799 q_u
->user_ctr
.level
= 1;
800 q_u
->user_ctr
.user
.user1
= TALLOC_P( talloc_tos(), SPOOL_USER_1
);
801 if (!q_u
->user_ctr
.user
.user1
) {
804 q_u
->user_ctr
.user
.user1
->build
= 1381;
805 q_u
->user_ctr
.user
.user1
->major
= 2;
806 q_u
->user_ctr
.user
.user1
->minor
= 0;
807 q_u
->user_ctr
.user
.user1
->processor
= 0;
809 q_u
->user_ctr
.user
.user1
->client_name
= TALLOC_P( mem_ctx
, UNISTR2
);
810 if (!q_u
->user_ctr
.user
.user1
->client_name
) {
813 q_u
->user_ctr
.user
.user1
->user_name
= TALLOC_P( mem_ctx
, UNISTR2
);
814 if (!q_u
->user_ctr
.user
.user1
->user_name
) {
817 init_unistr2(q_u
->user_ctr
.user
.user1
->client_name
, clientname
, UNI_STR_TERMINATE
);
818 init_unistr2(q_u
->user_ctr
.user
.user1
->user_name
, user_name
, UNI_STR_TERMINATE
);
820 q_u
->user_ctr
.user
.user1
->size
= q_u
->user_ctr
.user
.user1
->user_name
->uni_str_len
+
821 q_u
->user_ctr
.user
.user1
->client_name
->uni_str_len
+ 2;
826 /*******************************************************************
827 create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
828 *******************************************************************/
830 bool make_spoolss_printer_info_2(TALLOC_CTX
*ctx
, SPOOL_PRINTER_INFO_LEVEL_2
**spool_info2
,
831 PRINTER_INFO_2
*info
)
834 SPOOL_PRINTER_INFO_LEVEL_2
*inf
;
836 /* allocate the necessary memory */
837 if (!(inf
=TALLOC_P(ctx
, SPOOL_PRINTER_INFO_LEVEL_2
))) {
838 DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
842 inf
->servername_ptr
= (info
->servername
.buffer
!=NULL
)?1:0;
843 inf
->printername_ptr
= (info
->printername
.buffer
!=NULL
)?1:0;
844 inf
->sharename_ptr
= (info
->sharename
.buffer
!=NULL
)?1:0;
845 inf
->portname_ptr
= (info
->portname
.buffer
!=NULL
)?1:0;
846 inf
->drivername_ptr
= (info
->drivername
.buffer
!=NULL
)?1:0;
847 inf
->comment_ptr
= (info
->comment
.buffer
!=NULL
)?1:0;
848 inf
->location_ptr
= (info
->location
.buffer
!=NULL
)?1:0;
849 inf
->devmode_ptr
= (info
->devmode
!=NULL
)?1:0;
850 inf
->sepfile_ptr
= (info
->sepfile
.buffer
!=NULL
)?1:0;
851 inf
->printprocessor_ptr
= (info
->printprocessor
.buffer
!=NULL
)?1:0;
852 inf
->datatype_ptr
= (info
->datatype
.buffer
!=NULL
)?1:0;
853 inf
->parameters_ptr
= (info
->parameters
.buffer
!=NULL
)?1:0;
854 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
855 inf
->attributes
= info
->attributes
;
856 inf
->priority
= info
->priority
;
857 inf
->default_priority
= info
->defaultpriority
;
858 inf
->starttime
= info
->starttime
;
859 inf
->untiltime
= info
->untiltime
;
860 inf
->cjobs
= info
->cjobs
;
861 inf
->averageppm
= info
->averageppm
;
862 init_unistr2_from_unistr(inf
, &inf
->servername
, &info
->servername
);
863 init_unistr2_from_unistr(inf
, &inf
->printername
, &info
->printername
);
864 init_unistr2_from_unistr(inf
, &inf
->sharename
, &info
->sharename
);
865 init_unistr2_from_unistr(inf
, &inf
->portname
, &info
->portname
);
866 init_unistr2_from_unistr(inf
, &inf
->drivername
, &info
->drivername
);
867 init_unistr2_from_unistr(inf
, &inf
->comment
, &info
->comment
);
868 init_unistr2_from_unistr(inf
, &inf
->location
, &info
->location
);
869 init_unistr2_from_unistr(inf
, &inf
->sepfile
, &info
->sepfile
);
870 init_unistr2_from_unistr(inf
, &inf
->printprocessor
, &info
->printprocessor
);
871 init_unistr2_from_unistr(inf
, &inf
->datatype
, &info
->datatype
);
872 init_unistr2_from_unistr(inf
, &inf
->parameters
, &info
->parameters
);
873 init_unistr2_from_unistr(inf
, &inf
->datatype
, &info
->datatype
);
880 /*******************************************************************
881 create a SPOOL_PRINTER_INFO_3 struct from a PRINTER_INFO_3 struct
882 *******************************************************************/
884 bool make_spoolss_printer_info_3(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_3
**spool_info3
,
885 PRINTER_INFO_3
*info
)
888 SPOOL_PRINTER_INFO_LEVEL_3
*inf
;
890 /* allocate the necessary memory */
891 if (!(inf
=TALLOC_P(mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_3
))) {
892 DEBUG(0,("make_spoolss_printer_info_3: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_3 sruct!\n"));
896 inf
->secdesc_ptr
= (info
->secdesc
!=NULL
)?1:0;
903 /*******************************************************************
904 create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
905 *******************************************************************/
907 bool make_spoolss_printer_info_7(TALLOC_CTX
*mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_7
**spool_info7
,
908 PRINTER_INFO_7
*info
)
911 SPOOL_PRINTER_INFO_LEVEL_7
*inf
;
913 /* allocate the necessary memory */
914 if (!(inf
=TALLOC_P(mem_ctx
, SPOOL_PRINTER_INFO_LEVEL_7
))) {
915 DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
919 inf
->guid_ptr
= (info
->guid
.buffer
!=NULL
)?1:0;
920 inf
->action
= info
->action
;
921 init_unistr2_from_unistr(inf
, &inf
->guid
, &info
->guid
);
928 /*******************************************************************
930 ********************************************************************/
932 bool make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA
*q_u
,
933 const POLICY_HND
*handle
,
934 const char *valuename
, uint32 size
)
936 if (q_u
== NULL
) return False
;
938 DEBUG(5,("make_spoolss_q_getprinterdata\n"));
940 q_u
->handle
= *handle
;
941 init_unistr2(&q_u
->valuename
, valuename
, UNI_STR_TERMINATE
);
947 /*******************************************************************
949 * called from spoolss_q_getprinterdata (srv_spoolss.c)
950 ********************************************************************/
952 bool spoolss_io_q_getprinterdata(const char *desc
, SPOOL_Q_GETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
957 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdata");
962 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
966 if (!smb_io_unistr2("valuename", &q_u
->valuename
,True
,ps
,depth
))
970 if (!prs_uint32("size", ps
, depth
, &q_u
->size
))
976 /*******************************************************************
978 * called from spoolss_r_getprinterdata (srv_spoolss.c)
979 ********************************************************************/
981 bool spoolss_io_r_getprinterdata(const char *desc
, SPOOL_R_GETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
986 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdata");
991 if (!prs_uint32("type", ps
, depth
, &r_u
->type
))
993 if (!prs_uint32("size", ps
, depth
, &r_u
->size
))
996 if (UNMARSHALLING(ps
) && r_u
->size
) {
997 r_u
->data
= PRS_ALLOC_MEM(ps
, unsigned char, r_u
->size
);
1002 if (!prs_uint8s( False
, "data", ps
, depth
, r_u
->data
, r_u
->size
))
1008 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
1010 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
1016 /*******************************************************************
1018 * called from spoolss_q_rffpcnex (srv_spoolss.c)
1019 ********************************************************************/
1021 bool spoolss_io_q_rffpcnex(const char *desc
, SPOOL_Q_RFFPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1023 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rffpcnex");
1029 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
1031 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
1033 if(!prs_uint32("options", ps
, depth
, &q_u
->options
))
1035 if(!prs_uint32("localmachine_ptr", ps
, depth
, &q_u
->localmachine_ptr
))
1037 if(!smb_io_unistr2("localmachine", &q_u
->localmachine
, q_u
->localmachine_ptr
, ps
, depth
))
1043 if(!prs_uint32("printerlocal", ps
, depth
, &q_u
->printerlocal
))
1046 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1049 if (q_u
->option_ptr
!=0) {
1051 if (UNMARSHALLING(ps
))
1052 if((q_u
->option
=PRS_ALLOC_MEM(ps
,SPOOL_NOTIFY_OPTION
,1)) == NULL
)
1055 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1062 /*******************************************************************
1063 * write a structure.
1064 * called from spoolss_r_rffpcnex (srv_spoolss.c)
1065 ********************************************************************/
1067 bool spoolss_io_r_rffpcnex(const char *desc
, SPOOL_R_RFFPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1069 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rffpcnex");
1072 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1078 /*******************************************************************
1080 * called from spoolss_q_rfnpcnex (srv_spoolss.c)
1081 ********************************************************************/
1083 bool spoolss_io_q_rfnpcnex(const char *desc
, SPOOL_Q_RFNPCNEX
*q_u
, prs_struct
*ps
, int depth
)
1085 prs_debug(ps
, depth
, desc
, "spoolss_io_q_rfnpcnex");
1091 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
1094 if(!prs_uint32("change", ps
, depth
, &q_u
->change
))
1097 if(!prs_uint32("option_ptr", ps
, depth
, &q_u
->option_ptr
))
1100 if (q_u
->option_ptr
!=0) {
1102 if (UNMARSHALLING(ps
))
1103 if((q_u
->option
=PRS_ALLOC_MEM(ps
,SPOOL_NOTIFY_OPTION
,1)) == NULL
)
1106 if(!smb_io_notify_option("notify option", q_u
->option
, ps
, depth
))
1113 /*******************************************************************
1114 * write a structure.
1115 * called from spoolss_r_rfnpcnex (srv_spoolss.c)
1116 ********************************************************************/
1118 bool spoolss_io_r_rfnpcnex(const char *desc
, SPOOL_R_RFNPCNEX
*r_u
, prs_struct
*ps
, int depth
)
1120 prs_debug(ps
, depth
, desc
, "spoolss_io_r_rfnpcnex");
1126 if (!prs_uint32("info_ptr", ps
, depth
, &r_u
->info_ptr
))
1129 if(!smb_io_notify_info("notify info", &r_u
->info
,ps
,depth
))
1134 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
1140 /*******************************************************************
1141 * return the length of a uint16 (obvious, but the code is clean)
1142 ********************************************************************/
1144 static uint32
size_of_uint16(uint16
*value
)
1146 return (sizeof(*value
));
1149 /*******************************************************************
1150 * return the length of a uint32 (obvious, but the code is clean)
1151 ********************************************************************/
1153 static uint32
size_of_uint32(uint32
*value
)
1155 return (sizeof(*value
));
1158 /*******************************************************************
1159 * return the length of a NTTIME (obvious, but the code is clean)
1160 ********************************************************************/
1162 static uint32
size_of_nttime(NTTIME
*value
)
1164 return (sizeof(*value
));
1167 /*******************************************************************
1168 * return the length of a uint32 (obvious, but the code is clean)
1169 ********************************************************************/
1171 static uint32
size_of_device_mode(DEVICEMODE
*devmode
)
1176 return (4+devmode
->size
+devmode
->driverextra
);
1179 /*******************************************************************
1180 * return the length of a uint32 (obvious, but the code is clean)
1181 ********************************************************************/
1183 static uint32
size_of_systemtime(SYSTEMTIME
*systime
)
1188 return (sizeof(SYSTEMTIME
) +4);
1191 /*******************************************************************
1192 Parse a DEVMODE structure and its relative pointer.
1193 ********************************************************************/
1195 static bool smb_io_reldevmode(const char *desc
, RPC_BUFFER
*buffer
, int depth
, DEVICEMODE
**devmode
)
1197 prs_struct
*ps
=&buffer
->prs
;
1199 prs_debug(ps
, depth
, desc
, "smb_io_reldevmode");
1202 if (MARSHALLING(ps
)) {
1203 uint32 struct_offset
= prs_offset(ps
);
1204 uint32 relative_offset
;
1206 if (*devmode
== NULL
) {
1208 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1210 DEBUG(8, ("boing, the devmode was NULL\n"));
1215 buffer
->string_at_end
-= ((*devmode
)->size
+ (*devmode
)->driverextra
);
1217 /* mz: we have to align the device mode for VISTA */
1218 if (buffer
->string_at_end
% 4) {
1219 buffer
->string_at_end
+= 4 - (buffer
->string_at_end
% 4);
1222 if(!prs_set_offset(ps
, buffer
->string_at_end
))
1225 /* write the DEVMODE */
1226 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1229 if(!prs_set_offset(ps
, struct_offset
))
1232 relative_offset
=buffer
->string_at_end
- buffer
->struct_start
;
1233 /* write its offset */
1234 if (!prs_uint32("offset", ps
, depth
, &relative_offset
))
1240 /* read the offset */
1241 if (!prs_uint32("offset", ps
, depth
, &buffer
->string_at_end
))
1243 if (buffer
->string_at_end
== 0) {
1248 old_offset
= prs_offset(ps
);
1249 if(!prs_set_offset(ps
, buffer
->string_at_end
+ buffer
->struct_start
))
1252 /* read the string */
1253 if((*devmode
=PRS_ALLOC_MEM(ps
,DEVICEMODE
,1)) == NULL
)
1255 if (!spoolss_io_devmode(desc
, ps
, depth
, *devmode
))
1258 if(!prs_set_offset(ps
, old_offset
))
1264 /*******************************************************************
1265 Parse a PRINTER_INFO_0 structure.
1266 ********************************************************************/
1268 bool smb_io_printer_info_0(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_0
*info
, int depth
)
1270 prs_struct
*ps
=&buffer
->prs
;
1272 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_0");
1275 buffer
->struct_start
=prs_offset(ps
);
1277 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1279 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
1282 if(!prs_uint32("cjobs", ps
, depth
, &info
->cjobs
))
1284 if(!prs_uint32("total_jobs", ps
, depth
, &info
->total_jobs
))
1286 if(!prs_uint32("total_bytes", ps
, depth
, &info
->total_bytes
))
1289 if(!prs_uint16("year", ps
, depth
, &info
->year
))
1291 if(!prs_uint16("month", ps
, depth
, &info
->month
))
1293 if(!prs_uint16("dayofweek", ps
, depth
, &info
->dayofweek
))
1295 if(!prs_uint16("day", ps
, depth
, &info
->day
))
1297 if(!prs_uint16("hour", ps
, depth
, &info
->hour
))
1299 if(!prs_uint16("minute", ps
, depth
, &info
->minute
))
1301 if(!prs_uint16("second", ps
, depth
, &info
->second
))
1303 if(!prs_uint16("milliseconds", ps
, depth
, &info
->milliseconds
))
1306 if(!prs_uint32("global_counter", ps
, depth
, &info
->global_counter
))
1308 if(!prs_uint32("total_pages", ps
, depth
, &info
->total_pages
))
1311 if(!prs_uint16("major_version", ps
, depth
, &info
->major_version
))
1313 if(!prs_uint16("build_version", ps
, depth
, &info
->build_version
))
1315 if(!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
1317 if(!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
1319 if(!prs_uint32("unknown9", ps
, depth
, &info
->unknown9
))
1321 if(!prs_uint32("session_counter", ps
, depth
, &info
->session_counter
))
1323 if(!prs_uint32("unknown11", ps
, depth
, &info
->unknown11
))
1325 if(!prs_uint32("printer_errors", ps
, depth
, &info
->printer_errors
))
1327 if(!prs_uint32("unknown13", ps
, depth
, &info
->unknown13
))
1329 if(!prs_uint32("unknown14", ps
, depth
, &info
->unknown14
))
1331 if(!prs_uint32("unknown15", ps
, depth
, &info
->unknown15
))
1333 if(!prs_uint32("unknown16", ps
, depth
, &info
->unknown16
))
1335 if(!prs_uint32("change_id", ps
, depth
, &info
->change_id
))
1337 if(!prs_uint32("unknown18", ps
, depth
, &info
->unknown18
))
1339 if(!prs_uint32("status" , ps
, depth
, &info
->status
))
1341 if(!prs_uint32("unknown20", ps
, depth
, &info
->unknown20
))
1343 if(!prs_uint32("c_setprinter", ps
, depth
, &info
->c_setprinter
))
1345 if(!prs_uint16("unknown22", ps
, depth
, &info
->unknown22
))
1347 if(!prs_uint16("unknown23", ps
, depth
, &info
->unknown23
))
1349 if(!prs_uint16("unknown24", ps
, depth
, &info
->unknown24
))
1351 if(!prs_uint16("unknown25", ps
, depth
, &info
->unknown25
))
1353 if(!prs_uint16("unknown26", ps
, depth
, &info
->unknown26
))
1355 if(!prs_uint16("unknown27", ps
, depth
, &info
->unknown27
))
1357 if(!prs_uint16("unknown28", ps
, depth
, &info
->unknown28
))
1359 if(!prs_uint16("unknown29", ps
, depth
, &info
->unknown29
))
1365 /*******************************************************************
1366 Parse a PRINTER_INFO_1 structure.
1367 ********************************************************************/
1369 bool smb_io_printer_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_1
*info
, int depth
)
1371 prs_struct
*ps
=&buffer
->prs
;
1373 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_1");
1376 buffer
->struct_start
=prs_offset(ps
);
1378 if (!prs_uint32("flags", ps
, depth
, &info
->flags
))
1380 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
1382 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
1384 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
1390 /*******************************************************************
1391 Parse a PRINTER_INFO_2 structure.
1392 ********************************************************************/
1394 bool smb_io_printer_info_2(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_2
*info
, int depth
)
1396 prs_struct
*ps
=&buffer
->prs
;
1397 uint32 dm_offset
, sd_offset
, current_offset
;
1398 uint32 dummy_value
= 0, has_secdesc
= 0;
1400 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_2");
1403 buffer
->struct_start
=prs_offset(ps
);
1405 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
1407 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1409 if (!smb_io_relstr("sharename", buffer
, depth
, &info
->sharename
))
1411 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
1413 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
1415 if (!smb_io_relstr("comment", buffer
, depth
, &info
->comment
))
1417 if (!smb_io_relstr("location", buffer
, depth
, &info
->location
))
1420 /* save current offset and wind forwared by a uint32 */
1421 dm_offset
= prs_offset(ps
);
1422 if (!prs_uint32("devmode", ps
, depth
, &dummy_value
))
1425 if (!smb_io_relstr("sepfile", buffer
, depth
, &info
->sepfile
))
1427 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
1429 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
1431 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
1434 /* save current offset for the sec_desc */
1435 sd_offset
= prs_offset(ps
);
1436 if (!prs_uint32("sec_desc", ps
, depth
, &has_secdesc
))
1440 /* save current location so we can pick back up here */
1441 current_offset
= prs_offset(ps
);
1443 /* parse the devmode */
1444 if (!prs_set_offset(ps
, dm_offset
))
1446 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
1449 /* parse the sec_desc */
1450 if (info
->secdesc
) {
1451 if (!prs_set_offset(ps
, sd_offset
))
1453 if (!smb_io_relsecdesc("secdesc", buffer
, depth
, &info
->secdesc
))
1457 /* pick up where we left off */
1458 if (!prs_set_offset(ps
, current_offset
))
1461 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
1463 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
1465 if (!prs_uint32("defpriority", ps
, depth
, &info
->defaultpriority
))
1467 if (!prs_uint32("starttime", ps
, depth
, &info
->starttime
))
1469 if (!prs_uint32("untiltime", ps
, depth
, &info
->untiltime
))
1471 if (!prs_uint32("status", ps
, depth
, &info
->status
))
1473 if (!prs_uint32("jobs", ps
, depth
, &info
->cjobs
))
1475 if (!prs_uint32("averageppm", ps
, depth
, &info
->averageppm
))
1481 /*******************************************************************
1482 Parse a PRINTER_INFO_3 structure.
1483 ********************************************************************/
1485 bool smb_io_printer_info_3(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_3
*info
, int depth
)
1488 prs_struct
*ps
=&buffer
->prs
;
1490 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_3");
1493 buffer
->struct_start
=prs_offset(ps
);
1495 if (MARSHALLING(ps
)) {
1496 /* Ensure the SD is 8 byte aligned in the buffer. */
1497 uint32 start
= prs_offset(ps
); /* Remember the start position. */
1500 /* Write a dummy value. */
1501 if (!prs_uint32("offset", ps
, depth
, &off_val
))
1505 if (!prs_align_uint64(ps
))
1508 /* Remember where we must seek back to write the SD. */
1509 offset
= prs_offset(ps
);
1511 /* Calculate the real offset for the SD. */
1513 off_val
= offset
- start
;
1515 /* Seek back to where we store the SD offset & store. */
1516 prs_set_offset(ps
, start
);
1517 if (!prs_uint32("offset", ps
, depth
, &off_val
))
1520 /* Return to after the 8 byte align. */
1521 prs_set_offset(ps
, offset
);
1524 if (!prs_uint32("offset", ps
, depth
, &offset
))
1526 /* Seek within the buffer. */
1527 if (!prs_set_offset(ps
, offset
))
1530 if (!sec_io_desc("sec_desc", &info
->secdesc
, ps
, depth
))
1536 /*******************************************************************
1537 Parse a PRINTER_INFO_4 structure.
1538 ********************************************************************/
1540 bool smb_io_printer_info_4(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_4
*info
, int depth
)
1542 prs_struct
*ps
=&buffer
->prs
;
1544 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_4");
1547 buffer
->struct_start
=prs_offset(ps
);
1549 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1551 if (!smb_io_relstr("servername", buffer
, depth
, &info
->servername
))
1553 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
1558 /*******************************************************************
1559 Parse a PRINTER_INFO_5 structure.
1560 ********************************************************************/
1562 bool smb_io_printer_info_5(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_5
*info
, int depth
)
1564 prs_struct
*ps
=&buffer
->prs
;
1566 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_5");
1569 buffer
->struct_start
=prs_offset(ps
);
1571 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1573 if (!smb_io_relstr("portname", buffer
, depth
, &info
->portname
))
1575 if (!prs_uint32("attributes", ps
, depth
, &info
->attributes
))
1577 if (!prs_uint32("device_not_selected_timeout", ps
, depth
, &info
->device_not_selected_timeout
))
1579 if (!prs_uint32("transmission_retry_timeout", ps
, depth
, &info
->transmission_retry_timeout
))
1584 /*******************************************************************
1585 Parse a PRINTER_INFO_6 structure.
1586 ********************************************************************/
1588 bool smb_io_printer_info_6(const char *desc
, RPC_BUFFER
*buffer
,
1589 PRINTER_INFO_6
*info
, int depth
)
1591 prs_struct
*ps
=&buffer
->prs
;
1593 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_6");
1596 if (!prs_uint32("status", ps
, depth
, &info
->status
))
1602 /*******************************************************************
1603 Parse a PRINTER_INFO_7 structure.
1604 ********************************************************************/
1606 bool smb_io_printer_info_7(const char *desc
, RPC_BUFFER
*buffer
, PRINTER_INFO_7
*info
, int depth
)
1608 prs_struct
*ps
=&buffer
->prs
;
1610 prs_debug(ps
, depth
, desc
, "smb_io_printer_info_7");
1613 buffer
->struct_start
=prs_offset(ps
);
1615 if (!smb_io_relstr("guid", buffer
, depth
, &info
->guid
))
1617 if (!prs_uint32("action", ps
, depth
, &info
->action
))
1622 /*******************************************************************
1623 Parse a PORT_INFO_1 structure.
1624 ********************************************************************/
1626 bool smb_io_port_info_1(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
1628 prs_struct
*ps
=&buffer
->prs
;
1630 prs_debug(ps
, depth
, desc
, "smb_io_port_info_1");
1633 buffer
->struct_start
=prs_offset(ps
);
1635 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
1641 /*******************************************************************
1642 Parse a PORT_INFO_2 structure.
1643 ********************************************************************/
1645 bool smb_io_port_info_2(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
1647 prs_struct
*ps
=&buffer
->prs
;
1649 prs_debug(ps
, depth
, desc
, "smb_io_port_info_2");
1652 buffer
->struct_start
=prs_offset(ps
);
1654 if (!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
1656 if (!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
1658 if (!smb_io_relstr("description", buffer
, depth
, &info
->description
))
1660 if (!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
1662 if (!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
1668 /*******************************************************************
1669 Parse a DRIVER_INFO_1 structure.
1670 ********************************************************************/
1672 bool smb_io_printer_driver_info_1(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_1
*info
, int depth
)
1674 prs_struct
*ps
=&buffer
->prs
;
1676 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_1");
1679 buffer
->struct_start
=prs_offset(ps
);
1681 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
1687 /*******************************************************************
1688 Parse a DRIVER_INFO_2 structure.
1689 ********************************************************************/
1691 bool smb_io_printer_driver_info_2(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_2
*info
, int depth
)
1693 prs_struct
*ps
=&buffer
->prs
;
1695 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_2");
1698 buffer
->struct_start
=prs_offset(ps
);
1700 if (!prs_uint32("version", ps
, depth
, &info
->version
))
1702 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
1704 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
1706 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
1708 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
1710 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
1716 /*******************************************************************
1717 Parse a DRIVER_INFO_3 structure.
1718 ********************************************************************/
1720 bool smb_io_printer_driver_info_3(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_3
*info
, int depth
)
1722 prs_struct
*ps
=&buffer
->prs
;
1724 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_3");
1727 buffer
->struct_start
=prs_offset(ps
);
1729 if (!prs_uint32("version", ps
, depth
, &info
->version
))
1731 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
1733 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
1735 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
1737 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
1739 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
1741 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
1744 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
1747 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
1749 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
1755 /*******************************************************************
1756 Parse a DRIVER_INFO_6 structure.
1757 ********************************************************************/
1759 bool smb_io_printer_driver_info_6(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_INFO_6
*info
, int depth
)
1761 prs_struct
*ps
=&buffer
->prs
;
1763 prs_debug(ps
, depth
, desc
, "smb_io_printer_driver_info_6");
1766 buffer
->struct_start
=prs_offset(ps
);
1768 if (!prs_uint32("version", ps
, depth
, &info
->version
))
1770 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
1772 if (!smb_io_relstr("architecture", buffer
, depth
, &info
->architecture
))
1774 if (!smb_io_relstr("driverpath", buffer
, depth
, &info
->driverpath
))
1776 if (!smb_io_relstr("datafile", buffer
, depth
, &info
->datafile
))
1778 if (!smb_io_relstr("configfile", buffer
, depth
, &info
->configfile
))
1780 if (!smb_io_relstr("helpfile", buffer
, depth
, &info
->helpfile
))
1783 if (!smb_io_relarraystr("dependentfiles", buffer
, depth
, &info
->dependentfiles
))
1786 if (!smb_io_relstr("monitorname", buffer
, depth
, &info
->monitorname
))
1788 if (!smb_io_relstr("defaultdatatype", buffer
, depth
, &info
->defaultdatatype
))
1791 if (!smb_io_relarraystr("previousdrivernames", buffer
, depth
, &info
->previousdrivernames
))
1794 if (!prs_uint64("date", ps
, depth
, &info
->driver_date
))
1797 if (!prs_uint32("padding", ps
, depth
, &info
->padding
))
1800 if (!prs_uint32("driver_version_low", ps
, depth
, &info
->driver_version_low
))
1803 if (!prs_uint32("driver_version_high", ps
, depth
, &info
->driver_version_high
))
1806 if (!smb_io_relstr("mfgname", buffer
, depth
, &info
->mfgname
))
1808 if (!smb_io_relstr("oem_url", buffer
, depth
, &info
->oem_url
))
1810 if (!smb_io_relstr("hardware_id", buffer
, depth
, &info
->hardware_id
))
1812 if (!smb_io_relstr("provider", buffer
, depth
, &info
->provider
))
1818 /*******************************************************************
1819 Parse a JOB_INFO_1 structure.
1820 ********************************************************************/
1822 bool smb_io_job_info_1(const char *desc
, RPC_BUFFER
*buffer
, JOB_INFO_1
*info
, int depth
)
1824 prs_struct
*ps
=&buffer
->prs
;
1826 prs_debug(ps
, depth
, desc
, "smb_io_job_info_1");
1829 buffer
->struct_start
=prs_offset(ps
);
1831 if (!prs_uint32("jobid", ps
, depth
, &info
->jobid
))
1833 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1835 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
1837 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
1839 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
1841 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
1843 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
1845 if (!prs_uint32("status", ps
, depth
, &info
->status
))
1847 if (!prs_uint32("priority", ps
, depth
, &info
->priority
))
1849 if (!prs_uint32("position", ps
, depth
, &info
->position
))
1851 if (!prs_uint32("totalpages", ps
, depth
, &info
->totalpages
))
1853 if (!prs_uint32("pagesprinted", ps
, depth
, &info
->pagesprinted
))
1855 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
))
1861 /*******************************************************************
1862 Parse a JOB_INFO_2 structure.
1863 ********************************************************************/
1865 bool smb_io_job_info_2(const char *desc
, RPC_BUFFER
*buffer
, JOB_INFO_2
*info
, int depth
)
1868 prs_struct
*ps
=&buffer
->prs
;
1870 prs_debug(ps
, depth
, desc
, "smb_io_job_info_2");
1873 buffer
->struct_start
=prs_offset(ps
);
1875 if (!prs_uint32("jobid",ps
, depth
, &info
->jobid
))
1877 if (!smb_io_relstr("printername", buffer
, depth
, &info
->printername
))
1879 if (!smb_io_relstr("machinename", buffer
, depth
, &info
->machinename
))
1881 if (!smb_io_relstr("username", buffer
, depth
, &info
->username
))
1883 if (!smb_io_relstr("document", buffer
, depth
, &info
->document
))
1885 if (!smb_io_relstr("notifyname", buffer
, depth
, &info
->notifyname
))
1887 if (!smb_io_relstr("datatype", buffer
, depth
, &info
->datatype
))
1890 if (!smb_io_relstr("printprocessor", buffer
, depth
, &info
->printprocessor
))
1892 if (!smb_io_relstr("parameters", buffer
, depth
, &info
->parameters
))
1894 if (!smb_io_relstr("drivername", buffer
, depth
, &info
->drivername
))
1896 if (!smb_io_reldevmode("devmode", buffer
, depth
, &info
->devmode
))
1898 if (!smb_io_relstr("text_status", buffer
, depth
, &info
->text_status
))
1901 /* SEC_DESC sec_desc;*/
1902 if (!prs_uint32("Hack! sec desc", ps
, depth
, &pipo
))
1905 if (!prs_uint32("status",ps
, depth
, &info
->status
))
1907 if (!prs_uint32("priority",ps
, depth
, &info
->priority
))
1909 if (!prs_uint32("position",ps
, depth
, &info
->position
))
1911 if (!prs_uint32("starttime",ps
, depth
, &info
->starttime
))
1913 if (!prs_uint32("untiltime",ps
, depth
, &info
->untiltime
))
1915 if (!prs_uint32("totalpages",ps
, depth
, &info
->totalpages
))
1917 if (!prs_uint32("size",ps
, depth
, &info
->size
))
1919 if (!spoolss_io_system_time("submitted", ps
, depth
, &info
->submitted
) )
1921 if (!prs_uint32("timeelapsed",ps
, depth
, &info
->timeelapsed
))
1923 if (!prs_uint32("pagesprinted",ps
, depth
, &info
->pagesprinted
))
1929 /*******************************************************************
1930 ********************************************************************/
1932 bool smb_io_form_1(const char *desc
, RPC_BUFFER
*buffer
, FORM_1
*info
, int depth
)
1934 prs_struct
*ps
=&buffer
->prs
;
1936 prs_debug(ps
, depth
, desc
, "smb_io_form_1");
1939 buffer
->struct_start
=prs_offset(ps
);
1941 if (!prs_uint32("flag", ps
, depth
, &info
->flag
))
1944 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
1947 if (!prs_uint32("width", ps
, depth
, &info
->width
))
1949 if (!prs_uint32("length", ps
, depth
, &info
->length
))
1951 if (!prs_uint32("left", ps
, depth
, &info
->left
))
1953 if (!prs_uint32("top", ps
, depth
, &info
->top
))
1955 if (!prs_uint32("right", ps
, depth
, &info
->right
))
1957 if (!prs_uint32("bottom", ps
, depth
, &info
->bottom
))
1965 /*******************************************************************
1966 Parse a DRIVER_DIRECTORY_1 structure.
1967 ********************************************************************/
1969 bool smb_io_driverdir_1(const char *desc
, RPC_BUFFER
*buffer
, DRIVER_DIRECTORY_1
*info
, int depth
)
1971 prs_struct
*ps
=&buffer
->prs
;
1973 prs_debug(ps
, depth
, desc
, "smb_io_driverdir_1");
1976 buffer
->struct_start
=prs_offset(ps
);
1978 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
1984 /*******************************************************************
1985 Parse a PORT_INFO_1 structure.
1986 ********************************************************************/
1988 bool smb_io_port_1(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_1
*info
, int depth
)
1990 prs_struct
*ps
=&buffer
->prs
;
1992 prs_debug(ps
, depth
, desc
, "smb_io_port_1");
1995 buffer
->struct_start
=prs_offset(ps
);
1997 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2003 /*******************************************************************
2004 Parse a PORT_INFO_2 structure.
2005 ********************************************************************/
2007 bool smb_io_port_2(const char *desc
, RPC_BUFFER
*buffer
, PORT_INFO_2
*info
, int depth
)
2009 prs_struct
*ps
=&buffer
->prs
;
2011 prs_debug(ps
, depth
, desc
, "smb_io_port_2");
2014 buffer
->struct_start
=prs_offset(ps
);
2016 if(!smb_io_relstr("port_name", buffer
, depth
, &info
->port_name
))
2018 if(!smb_io_relstr("monitor_name", buffer
, depth
, &info
->monitor_name
))
2020 if(!smb_io_relstr("description", buffer
, depth
, &info
->description
))
2022 if(!prs_uint32("port_type", ps
, depth
, &info
->port_type
))
2024 if(!prs_uint32("reserved", ps
, depth
, &info
->reserved
))
2030 /*******************************************************************
2031 ********************************************************************/
2033 bool smb_io_printprocessor_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTPROCESSOR_1
*info
, int depth
)
2035 prs_struct
*ps
=&buffer
->prs
;
2037 prs_debug(ps
, depth
, desc
, "smb_io_printprocessor_info_1");
2040 buffer
->struct_start
=prs_offset(ps
);
2042 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2048 /*******************************************************************
2049 ********************************************************************/
2051 bool smb_io_printprocdatatype_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTPROCDATATYPE_1
*info
, int depth
)
2053 prs_struct
*ps
=&buffer
->prs
;
2055 prs_debug(ps
, depth
, desc
, "smb_io_printprocdatatype_info_1");
2058 buffer
->struct_start
=prs_offset(ps
);
2060 if (smb_io_relstr("name", buffer
, depth
, &info
->name
))
2066 /*******************************************************************
2067 ********************************************************************/
2069 bool smb_io_printmonitor_info_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTMONITOR_1
*info
, int depth
)
2071 prs_struct
*ps
=&buffer
->prs
;
2073 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_1");
2076 buffer
->struct_start
=prs_offset(ps
);
2078 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2084 /*******************************************************************
2085 ********************************************************************/
2087 bool smb_io_printmonitor_info_2(const char *desc
, RPC_BUFFER
*buffer
, PRINTMONITOR_2
*info
, int depth
)
2089 prs_struct
*ps
=&buffer
->prs
;
2091 prs_debug(ps
, depth
, desc
, "smb_io_printmonitor_info_2");
2094 buffer
->struct_start
=prs_offset(ps
);
2096 if (!smb_io_relstr("name", buffer
, depth
, &info
->name
))
2098 if (!smb_io_relstr("environment", buffer
, depth
, &info
->environment
))
2100 if (!smb_io_relstr("dll_name", buffer
, depth
, &info
->dll_name
))
2106 /*******************************************************************
2107 return the size required by a struct in the stream
2108 ********************************************************************/
2110 uint32
spoolss_size_printer_info_0(PRINTER_INFO_0
*info
)
2114 size
+=size_of_relative_string( &info
->printername
);
2115 size
+=size_of_relative_string( &info
->servername
);
2117 size
+=size_of_uint32( &info
->cjobs
);
2118 size
+=size_of_uint32( &info
->total_jobs
);
2119 size
+=size_of_uint32( &info
->total_bytes
);
2121 size
+=size_of_uint16( &info
->year
);
2122 size
+=size_of_uint16( &info
->month
);
2123 size
+=size_of_uint16( &info
->dayofweek
);
2124 size
+=size_of_uint16( &info
->day
);
2125 size
+=size_of_uint16( &info
->hour
);
2126 size
+=size_of_uint16( &info
->minute
);
2127 size
+=size_of_uint16( &info
->second
);
2128 size
+=size_of_uint16( &info
->milliseconds
);
2130 size
+=size_of_uint32( &info
->global_counter
);
2131 size
+=size_of_uint32( &info
->total_pages
);
2133 size
+=size_of_uint16( &info
->major_version
);
2134 size
+=size_of_uint16( &info
->build_version
);
2136 size
+=size_of_uint32( &info
->unknown7
);
2137 size
+=size_of_uint32( &info
->unknown8
);
2138 size
+=size_of_uint32( &info
->unknown9
);
2139 size
+=size_of_uint32( &info
->session_counter
);
2140 size
+=size_of_uint32( &info
->unknown11
);
2141 size
+=size_of_uint32( &info
->printer_errors
);
2142 size
+=size_of_uint32( &info
->unknown13
);
2143 size
+=size_of_uint32( &info
->unknown14
);
2144 size
+=size_of_uint32( &info
->unknown15
);
2145 size
+=size_of_uint32( &info
->unknown16
);
2146 size
+=size_of_uint32( &info
->change_id
);
2147 size
+=size_of_uint32( &info
->unknown18
);
2148 size
+=size_of_uint32( &info
->status
);
2149 size
+=size_of_uint32( &info
->unknown20
);
2150 size
+=size_of_uint32( &info
->c_setprinter
);
2152 size
+=size_of_uint16( &info
->unknown22
);
2153 size
+=size_of_uint16( &info
->unknown23
);
2154 size
+=size_of_uint16( &info
->unknown24
);
2155 size
+=size_of_uint16( &info
->unknown25
);
2156 size
+=size_of_uint16( &info
->unknown26
);
2157 size
+=size_of_uint16( &info
->unknown27
);
2158 size
+=size_of_uint16( &info
->unknown28
);
2159 size
+=size_of_uint16( &info
->unknown29
);
2164 /*******************************************************************
2165 return the size required by a struct in the stream
2166 ********************************************************************/
2168 uint32
spoolss_size_printer_info_1(PRINTER_INFO_1
*info
)
2172 size
+=size_of_uint32( &info
->flags
);
2173 size
+=size_of_relative_string( &info
->description
);
2174 size
+=size_of_relative_string( &info
->name
);
2175 size
+=size_of_relative_string( &info
->comment
);
2180 /*******************************************************************
2181 return the size required by a struct in the stream
2182 ********************************************************************/
2184 uint32
spoolss_size_printer_info_2(PRINTER_INFO_2
*info
)
2190 size
+= ndr_size_security_descriptor( info
->secdesc
, NULL
, 0 );
2192 size
+=size_of_device_mode( info
->devmode
);
2194 size
+=size_of_relative_string( &info
->servername
);
2195 size
+=size_of_relative_string( &info
->printername
);
2196 size
+=size_of_relative_string( &info
->sharename
);
2197 size
+=size_of_relative_string( &info
->portname
);
2198 size
+=size_of_relative_string( &info
->drivername
);
2199 size
+=size_of_relative_string( &info
->comment
);
2200 size
+=size_of_relative_string( &info
->location
);
2202 size
+=size_of_relative_string( &info
->sepfile
);
2203 size
+=size_of_relative_string( &info
->printprocessor
);
2204 size
+=size_of_relative_string( &info
->datatype
);
2205 size
+=size_of_relative_string( &info
->parameters
);
2207 size
+=size_of_uint32( &info
->attributes
);
2208 size
+=size_of_uint32( &info
->priority
);
2209 size
+=size_of_uint32( &info
->defaultpriority
);
2210 size
+=size_of_uint32( &info
->starttime
);
2211 size
+=size_of_uint32( &info
->untiltime
);
2212 size
+=size_of_uint32( &info
->status
);
2213 size
+=size_of_uint32( &info
->cjobs
);
2214 size
+=size_of_uint32( &info
->averageppm
);
2217 * add any adjustments for alignment. This is
2218 * not optimal since we could be calling this
2219 * function from a loop (e.g. enumprinters), but
2220 * it is easier to maintain the calculation here and
2221 * not place the burden on the caller to remember. --jerry
2223 if ((size
% 4) != 0)
2224 size
+= 4 - (size
% 4);
2229 /*******************************************************************
2230 return the size required by a struct in the stream
2231 ********************************************************************/
2233 uint32
spoolss_size_printer_info_4(PRINTER_INFO_4
*info
)
2237 size
+=size_of_relative_string( &info
->printername
);
2238 size
+=size_of_relative_string( &info
->servername
);
2240 size
+=size_of_uint32( &info
->attributes
);
2244 /*******************************************************************
2245 return the size required by a struct in the stream
2246 ********************************************************************/
2248 uint32
spoolss_size_printer_info_5(PRINTER_INFO_5
*info
)
2252 size
+=size_of_relative_string( &info
->printername
);
2253 size
+=size_of_relative_string( &info
->portname
);
2255 size
+=size_of_uint32( &info
->attributes
);
2256 size
+=size_of_uint32( &info
->device_not_selected_timeout
);
2257 size
+=size_of_uint32( &info
->transmission_retry_timeout
);
2261 /*******************************************************************
2262 return the size required by a struct in the stream
2263 ********************************************************************/
2265 uint32
spoolss_size_printer_info_6(PRINTER_INFO_6
*info
)
2267 return sizeof(uint32
);
2270 /*******************************************************************
2271 return the size required by a struct in the stream
2272 ********************************************************************/
2274 uint32
spoolss_size_printer_info_3(PRINTER_INFO_3
*info
)
2276 /* The 8 is for the self relative pointer - 8 byte aligned.. */
2277 return 8 + (uint32
)ndr_size_security_descriptor( info
->secdesc
, NULL
, 0 );
2280 /*******************************************************************
2281 return the size required by a struct in the stream
2282 ********************************************************************/
2284 uint32
spoolss_size_printer_info_7(PRINTER_INFO_7
*info
)
2288 size
+=size_of_relative_string( &info
->guid
);
2289 size
+=size_of_uint32( &info
->action
);
2293 /*******************************************************************
2294 return the size required by a struct in the stream
2295 ********************************************************************/
2297 uint32
spoolss_size_printer_driver_info_1(DRIVER_INFO_1
*info
)
2300 size
+=size_of_relative_string( &info
->name
);
2305 /*******************************************************************
2306 return the size required by a struct in the stream
2307 ********************************************************************/
2309 uint32
spoolss_size_printer_driver_info_2(DRIVER_INFO_2
*info
)
2312 size
+=size_of_uint32( &info
->version
);
2313 size
+=size_of_relative_string( &info
->name
);
2314 size
+=size_of_relative_string( &info
->architecture
);
2315 size
+=size_of_relative_string( &info
->driverpath
);
2316 size
+=size_of_relative_string( &info
->datafile
);
2317 size
+=size_of_relative_string( &info
->configfile
);
2322 /*******************************************************************
2323 return the size required by a string array.
2324 ********************************************************************/
2326 uint32
spoolss_size_string_array(uint16
*string
)
2331 for (i
=0; (string
[i
]!=0x0000) || (string
[i
+1]!=0x0000); i
++);
2333 i
=i
+2; /* to count all chars including the leading zero */
2334 i
=2*i
; /* because we need the value in bytes */
2335 i
=i
+4; /* the offset pointer size */
2340 /*******************************************************************
2341 return the size required by a struct in the stream
2342 ********************************************************************/
2344 uint32
spoolss_size_printer_driver_info_3(DRIVER_INFO_3
*info
)
2348 size
+=size_of_uint32( &info
->version
);
2349 size
+=size_of_relative_string( &info
->name
);
2350 size
+=size_of_relative_string( &info
->architecture
);
2351 size
+=size_of_relative_string( &info
->driverpath
);
2352 size
+=size_of_relative_string( &info
->datafile
);
2353 size
+=size_of_relative_string( &info
->configfile
);
2354 size
+=size_of_relative_string( &info
->helpfile
);
2355 size
+=size_of_relative_string( &info
->monitorname
);
2356 size
+=size_of_relative_string( &info
->defaultdatatype
);
2358 size
+=spoolss_size_string_array(info
->dependentfiles
);
2363 /*******************************************************************
2364 return the size required by a struct in the stream
2365 ********************************************************************/
2367 uint32
spoolss_size_printer_driver_info_6(DRIVER_INFO_6
*info
)
2371 size
+=size_of_uint32( &info
->version
);
2372 size
+=size_of_relative_string( &info
->name
);
2373 size
+=size_of_relative_string( &info
->architecture
);
2374 size
+=size_of_relative_string( &info
->driverpath
);
2375 size
+=size_of_relative_string( &info
->datafile
);
2376 size
+=size_of_relative_string( &info
->configfile
);
2377 size
+=size_of_relative_string( &info
->helpfile
);
2379 size
+=spoolss_size_string_array(info
->dependentfiles
);
2381 size
+=size_of_relative_string( &info
->monitorname
);
2382 size
+=size_of_relative_string( &info
->defaultdatatype
);
2384 size
+=spoolss_size_string_array(info
->previousdrivernames
);
2386 size
+=size_of_nttime(&info
->driver_date
);
2387 size
+=size_of_uint32( &info
->padding
);
2388 size
+=size_of_uint32( &info
->driver_version_low
);
2389 size
+=size_of_uint32( &info
->driver_version_high
);
2390 size
+=size_of_relative_string( &info
->mfgname
);
2391 size
+=size_of_relative_string( &info
->oem_url
);
2392 size
+=size_of_relative_string( &info
->hardware_id
);
2393 size
+=size_of_relative_string( &info
->provider
);
2398 /*******************************************************************
2399 return the size required by a struct in the stream
2400 ********************************************************************/
2402 uint32
spoolss_size_job_info_1(JOB_INFO_1
*info
)
2405 size
+=size_of_uint32( &info
->jobid
);
2406 size
+=size_of_relative_string( &info
->printername
);
2407 size
+=size_of_relative_string( &info
->machinename
);
2408 size
+=size_of_relative_string( &info
->username
);
2409 size
+=size_of_relative_string( &info
->document
);
2410 size
+=size_of_relative_string( &info
->datatype
);
2411 size
+=size_of_relative_string( &info
->text_status
);
2412 size
+=size_of_uint32( &info
->status
);
2413 size
+=size_of_uint32( &info
->priority
);
2414 size
+=size_of_uint32( &info
->position
);
2415 size
+=size_of_uint32( &info
->totalpages
);
2416 size
+=size_of_uint32( &info
->pagesprinted
);
2417 size
+=size_of_systemtime( &info
->submitted
);
2422 /*******************************************************************
2423 return the size required by a struct in the stream
2424 ********************************************************************/
2426 uint32
spoolss_size_job_info_2(JOB_INFO_2
*info
)
2430 size
+=4; /* size of sec desc ptr */
2432 size
+=size_of_uint32( &info
->jobid
);
2433 size
+=size_of_relative_string( &info
->printername
);
2434 size
+=size_of_relative_string( &info
->machinename
);
2435 size
+=size_of_relative_string( &info
->username
);
2436 size
+=size_of_relative_string( &info
->document
);
2437 size
+=size_of_relative_string( &info
->notifyname
);
2438 size
+=size_of_relative_string( &info
->datatype
);
2439 size
+=size_of_relative_string( &info
->printprocessor
);
2440 size
+=size_of_relative_string( &info
->parameters
);
2441 size
+=size_of_relative_string( &info
->drivername
);
2442 size
+=size_of_device_mode( info
->devmode
);
2443 size
+=size_of_relative_string( &info
->text_status
);
2444 /* SEC_DESC sec_desc;*/
2445 size
+=size_of_uint32( &info
->status
);
2446 size
+=size_of_uint32( &info
->priority
);
2447 size
+=size_of_uint32( &info
->position
);
2448 size
+=size_of_uint32( &info
->starttime
);
2449 size
+=size_of_uint32( &info
->untiltime
);
2450 size
+=size_of_uint32( &info
->totalpages
);
2451 size
+=size_of_uint32( &info
->size
);
2452 size
+=size_of_systemtime( &info
->submitted
);
2453 size
+=size_of_uint32( &info
->timeelapsed
);
2454 size
+=size_of_uint32( &info
->pagesprinted
);
2459 /*******************************************************************
2460 return the size required by a struct in the stream
2461 ********************************************************************/
2463 uint32
spoolss_size_form_1(FORM_1
*info
)
2467 size
+=size_of_uint32( &info
->flag
);
2468 size
+=size_of_relative_string( &info
->name
);
2469 size
+=size_of_uint32( &info
->width
);
2470 size
+=size_of_uint32( &info
->length
);
2471 size
+=size_of_uint32( &info
->left
);
2472 size
+=size_of_uint32( &info
->top
);
2473 size
+=size_of_uint32( &info
->right
);
2474 size
+=size_of_uint32( &info
->bottom
);
2479 /*******************************************************************
2480 return the size required by a struct in the stream
2481 ********************************************************************/
2483 uint32
spoolss_size_port_info_1(PORT_INFO_1
*info
)
2487 size
+=size_of_relative_string( &info
->port_name
);
2492 /*******************************************************************
2493 return the size required by a struct in the stream
2494 ********************************************************************/
2496 uint32
spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1
*info
)
2500 size
=str_len_uni(&info
->name
); /* the string length */
2501 size
=size
+1; /* add the leading zero */
2502 size
=size
*2; /* convert in char */
2507 /*******************************************************************
2508 return the size required by a struct in the stream
2509 ********************************************************************/
2511 uint32
spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1
*info
)
2515 size
=str_len_uni(&info
->name
); /* the string length */
2516 size
=size
+1; /* add the leading zero */
2517 size
=size
*2; /* convert in char */
2522 /*******************************************************************
2523 return the size required by a struct in the stream
2524 ********************************************************************/
2526 uint32
spoolss_size_port_info_2(PORT_INFO_2
*info
)
2530 size
+=size_of_relative_string( &info
->port_name
);
2531 size
+=size_of_relative_string( &info
->monitor_name
);
2532 size
+=size_of_relative_string( &info
->description
);
2534 size
+=size_of_uint32( &info
->port_type
);
2535 size
+=size_of_uint32( &info
->reserved
);
2540 /*******************************************************************
2541 return the size required by a struct in the stream
2542 ********************************************************************/
2544 uint32
spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1
*info
)
2547 size
+=size_of_relative_string( &info
->name
);
2552 /*******************************************************************
2553 return the size required by a struct in the stream
2554 ********************************************************************/
2556 uint32
spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1
*info
)
2559 size
+=size_of_relative_string( &info
->name
);
2564 /*******************************************************************
2565 return the size required by a struct in the stream
2566 ********************************************************************/
2567 uint32
spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES
*p
)
2574 /* uint32(offset) + uint32(length) + length) */
2575 size
+= (size_of_uint32(&p
->value_len
)*2) + p
->value_len
;
2576 size
+= (size_of_uint32(&p
->data_len
)*2) + p
->data_len
+ (p
->data_len
%2) ;
2578 size
+= size_of_uint32(&p
->type
);
2583 /*******************************************************************
2584 return the size required by a struct in the stream
2585 ********************************************************************/
2587 uint32
spoolss_size_printmonitor_info_1(PRINTMONITOR_1
*info
)
2590 size
+=size_of_relative_string( &info
->name
);
2595 /*******************************************************************
2596 return the size required by a struct in the stream
2597 ********************************************************************/
2599 uint32
spoolss_size_printmonitor_info_2(PRINTMONITOR_2
*info
)
2602 size
+=size_of_relative_string( &info
->name
);
2603 size
+=size_of_relative_string( &info
->environment
);
2604 size
+=size_of_relative_string( &info
->dll_name
);
2609 /*******************************************************************
2611 ********************************************************************/
2613 bool make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2
*q_u
,
2614 const POLICY_HND
*hnd
,
2615 const fstring architecture
,
2616 uint32 level
, uint32 clientmajor
, uint32 clientminor
,
2617 RPC_BUFFER
*buffer
, uint32 offered
)
2622 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
2624 init_buf_unistr2(&q_u
->architecture
, &q_u
->architecture_ptr
, architecture
);
2627 q_u
->clientmajorversion
=clientmajor
;
2628 q_u
->clientminorversion
=clientminor
;
2631 q_u
->offered
=offered
;
2636 /*******************************************************************
2638 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
2639 ********************************************************************/
2641 bool spoolss_io_q_getprinterdriver2(const char *desc
, SPOOL_Q_GETPRINTERDRIVER2
*q_u
, prs_struct
*ps
, int depth
)
2643 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriver2");
2649 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
2651 if(!prs_uint32("architecture_ptr", ps
, depth
, &q_u
->architecture_ptr
))
2653 if(!smb_io_unistr2("architecture", &q_u
->architecture
, q_u
->architecture_ptr
, ps
, depth
))
2658 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
2661 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
2667 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
2670 if(!prs_uint32("clientmajorversion", ps
, depth
, &q_u
->clientmajorversion
))
2672 if(!prs_uint32("clientminorversion", ps
, depth
, &q_u
->clientminorversion
))
2678 /*******************************************************************
2680 * called from spoolss_getprinterdriver2 (srv_spoolss.c)
2681 ********************************************************************/
2683 bool spoolss_io_r_getprinterdriver2(const char *desc
, SPOOL_R_GETPRINTERDRIVER2
*r_u
, prs_struct
*ps
, int depth
)
2685 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriver2");
2691 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
2696 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
2698 if (!prs_uint32("servermajorversion", ps
, depth
, &r_u
->servermajorversion
))
2700 if (!prs_uint32("serverminorversion", ps
, depth
, &r_u
->serverminorversion
))
2702 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
2708 /*******************************************************************
2710 ********************************************************************/
2712 bool make_spoolss_q_enumprinters(
2713 SPOOL_Q_ENUMPRINTERS
*q_u
,
2723 q_u
->servername_ptr
= (servername
!= NULL
) ? 1 : 0;
2724 init_buf_unistr2(&q_u
->servername
, &q_u
->servername_ptr
, servername
);
2728 q_u
->offered
=offered
;
2733 /*******************************************************************
2735 ********************************************************************/
2737 bool make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS
*q_u
,
2738 fstring servername
, uint32 level
,
2739 RPC_BUFFER
*buffer
, uint32 offered
)
2741 q_u
->name_ptr
= (servername
!= NULL
) ? 1 : 0;
2742 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
2746 q_u
->offered
=offered
;
2751 /*******************************************************************
2753 * called from spoolss_enumprinters (srv_spoolss.c)
2754 ********************************************************************/
2756 bool spoolss_io_q_enumprinters(const char *desc
, SPOOL_Q_ENUMPRINTERS
*q_u
, prs_struct
*ps
, int depth
)
2758 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinters");
2764 if (!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
2766 if (!prs_uint32("servername_ptr", ps
, depth
, &q_u
->servername_ptr
))
2769 if (!smb_io_unistr2("", &q_u
->servername
, q_u
->servername_ptr
, ps
, depth
))
2774 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
2777 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
2782 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
2788 /*******************************************************************
2789 Parse a SPOOL_R_ENUMPRINTERS structure.
2790 ********************************************************************/
2792 bool spoolss_io_r_enumprinters(const char *desc
, SPOOL_R_ENUMPRINTERS
*r_u
, prs_struct
*ps
, int depth
)
2794 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinters");
2800 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
2806 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
2809 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
2812 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
2818 /*******************************************************************
2819 * write a structure.
2820 * called from spoolss_r_enum_printers (srv_spoolss.c)
2822 ********************************************************************/
2824 bool spoolss_io_r_getprinter(const char *desc
, SPOOL_R_GETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
2826 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinter");
2832 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
2838 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
2841 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
2847 /*******************************************************************
2849 * called from spoolss_getprinter (srv_spoolss.c)
2850 ********************************************************************/
2852 bool spoolss_io_q_getprinter(const char *desc
, SPOOL_Q_GETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
2854 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinter");
2860 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
2862 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
2865 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
2870 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
2876 /*******************************************************************
2878 ********************************************************************/
2880 bool make_spoolss_q_getprinter(
2881 TALLOC_CTX
*mem_ctx
,
2882 SPOOL_Q_GETPRINTER
*q_u
,
2883 const POLICY_HND
*hnd
,
2893 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
2897 q_u
->offered
=offered
;
2902 /*******************************************************************
2904 ********************************************************************/
2905 bool make_spoolss_q_setprinter(TALLOC_CTX
*mem_ctx
, SPOOL_Q_SETPRINTER
*q_u
,
2906 const POLICY_HND
*hnd
, uint32 level
, PRINTER_INFO_CTR
*info
,
2910 DEVICEMODE
*devmode
;
2915 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
2918 q_u
->info
.level
= level
;
2919 q_u
->info
.info_ptr
= 1; /* Info is != NULL, see above */
2922 /* There's no such thing as a setprinter level 1 */
2925 secdesc
= info
->printers_2
->secdesc
;
2926 devmode
= info
->printers_2
->devmode
;
2928 make_spoolss_printer_info_2 (mem_ctx
, &q_u
->info
.info_2
, info
->printers_2
);
2929 #if 1 /* JERRY TEST */
2930 q_u
->secdesc_ctr
= SMB_MALLOC_P(SEC_DESC_BUF
);
2931 if (!q_u
->secdesc_ctr
)
2933 q_u
->secdesc_ctr
->sd
= secdesc
;
2934 q_u
->secdesc_ctr
->sd_size
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
2936 q_u
->devmode_ctr
.devmode_ptr
= (devmode
!= NULL
) ? 1 : 0;
2937 q_u
->devmode_ctr
.size
= (devmode
!= NULL
) ? sizeof(DEVICEMODE
) + (3*sizeof(uint32
)) : 0;
2938 q_u
->devmode_ctr
.devmode
= devmode
;
2940 q_u
->secdesc_ctr
= NULL
;
2942 q_u
->devmode_ctr
.devmode_ptr
= 0;
2943 q_u
->devmode_ctr
.size
= 0;
2944 q_u
->devmode_ctr
.devmode
= NULL
;
2948 secdesc
= info
->printers_3
->secdesc
;
2950 make_spoolss_printer_info_3 (mem_ctx
, &q_u
->info
.info_3
, info
->printers_3
);
2952 q_u
->secdesc_ctr
= SMB_MALLOC_P(SEC_DESC_BUF
);
2953 if (!q_u
->secdesc_ctr
)
2955 q_u
->secdesc_ctr
->sd_size
= (secdesc
) ? sizeof(SEC_DESC
) + (2*sizeof(uint32
)) : 0;
2956 q_u
->secdesc_ctr
->sd
= secdesc
;
2960 make_spoolss_printer_info_7 (mem_ctx
, &q_u
->info
.info_7
, info
->printers_7
);
2964 DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level
));
2969 q_u
->command
= command
;
2975 /*******************************************************************
2976 ********************************************************************/
2978 bool spoolss_io_r_setprinter(const char *desc
, SPOOL_R_SETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
2980 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinter");
2986 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
2992 /*******************************************************************
2993 Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
2994 ********************************************************************/
2996 bool spoolss_io_q_setprinter(const char *desc
, SPOOL_Q_SETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
2998 uint32 ptr_sec_desc
= 0;
3000 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinter");
3006 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
,ps
, depth
))
3008 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
3011 /* check for supported levels and structures we know about */
3013 switch ( q_u
->level
) {
3018 /* supported levels */
3021 DEBUG(0,("spoolss_io_q_setprinter: unsupported printer info level [%d]\n",
3027 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3030 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3040 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3045 /* FIXME ! Our parsing here is wrong I think,
3046 * but for a level3 it makes no sense for
3047 * ptr_sec_desc to be NULL. JRA. Based on
3048 * a Vista sniff from Martin Zielinski <mz@seh.de>.
3050 if (UNMARSHALLING(ps
)) {
3053 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3060 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3065 /* Parse a NULL security descriptor. This should really
3066 happen inside the sec_io_desc_buf() function. */
3068 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3069 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
3071 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
3075 if(!prs_uint32("command", ps
, depth
, &q_u
->command
))
3081 /*******************************************************************
3082 ********************************************************************/
3084 bool spoolss_io_r_enumjobs(const char *desc
, SPOOL_R_ENUMJOBS
*r_u
, prs_struct
*ps
, int depth
)
3086 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumjobs");
3092 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
3098 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3101 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3104 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3110 /*******************************************************************
3111 ********************************************************************/
3113 bool make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS
*q_u
, const POLICY_HND
*hnd
,
3124 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
3125 q_u
->firstjob
= firstjob
;
3126 q_u
->numofjobs
= numofjobs
;
3128 q_u
->buffer
= buffer
;
3129 q_u
->offered
= offered
;
3133 /*******************************************************************
3134 ********************************************************************/
3136 bool spoolss_io_q_enumjobs(const char *desc
, SPOOL_Q_ENUMJOBS
*q_u
, prs_struct
*ps
, int depth
)
3138 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumjobs");
3144 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
, ps
, depth
))
3147 if (!prs_uint32("firstjob", ps
, depth
, &q_u
->firstjob
))
3149 if (!prs_uint32("numofjobs", ps
, depth
, &q_u
->numofjobs
))
3151 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3154 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
3160 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3166 /*******************************************************************
3167 Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
3168 ********************************************************************/
3170 bool spoolss_io_r_enumprinterdrivers(const char *desc
, SPOOL_R_ENUMPRINTERDRIVERS
*r_u
, prs_struct
*ps
, int depth
)
3172 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdrivers");
3178 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
3184 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3187 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3190 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3196 /*******************************************************************
3198 ********************************************************************/
3200 bool make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
,
3202 const char *environment
,
3204 RPC_BUFFER
*buffer
, uint32 offered
)
3206 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, name
);
3207 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, environment
);
3211 q_u
->offered
=offered
;
3216 /*******************************************************************
3217 Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
3218 ********************************************************************/
3220 bool spoolss_io_q_enumprinterdrivers(const char *desc
, SPOOL_Q_ENUMPRINTERDRIVERS
*q_u
, prs_struct
*ps
, int depth
)
3223 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdrivers");
3229 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
3231 if (!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
,ps
, depth
))
3236 if (!prs_uint32("environment_ptr", ps
, depth
, &q_u
->environment_ptr
))
3238 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
3243 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3246 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
3252 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3258 /*******************************************************************
3259 ********************************************************************/
3261 bool spoolss_io_q_enumforms(const char *desc
, SPOOL_Q_ENUMFORMS
*q_u
, prs_struct
*ps
, int depth
)
3264 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumforms");
3269 if (!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
3271 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3274 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
3279 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3285 /*******************************************************************
3286 ********************************************************************/
3288 bool spoolss_io_r_enumforms(const char *desc
, SPOOL_R_ENUMFORMS
*r_u
, prs_struct
*ps
, int depth
)
3290 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumforms");
3296 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
3302 if (!prs_uint32("size of buffer needed", ps
, depth
, &r_u
->needed
))
3305 if (!prs_uint32("numofforms", ps
, depth
, &r_u
->numofforms
))
3308 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3314 /*******************************************************************
3315 Parse a SPOOL_R_ENUMPORTS structure.
3316 ********************************************************************/
3318 bool spoolss_io_r_enumports(const char *desc
, SPOOL_R_ENUMPORTS
*r_u
, prs_struct
*ps
, int depth
)
3320 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumports");
3326 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
3332 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
3335 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
3338 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
3344 /*******************************************************************
3345 ********************************************************************/
3347 bool spoolss_io_q_enumports(const char *desc
, SPOOL_Q_ENUMPORTS
*q_u
, prs_struct
*ps
, int depth
)
3349 prs_debug(ps
, depth
, desc
, "");
3355 if (!prs_uint32("", ps
, depth
, &q_u
->name_ptr
))
3357 if (!smb_io_unistr2("", &q_u
->name
,True
,ps
,depth
))
3362 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
3365 if (!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
3370 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
3376 /*******************************************************************
3377 Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
3378 ********************************************************************/
3380 bool spool_io_printer_info_level_1(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_1
*il
, prs_struct
*ps
, int depth
)
3382 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_1");
3388 if(!prs_uint32("flags", ps
, depth
, &il
->flags
))
3390 if(!prs_uint32("description_ptr", ps
, depth
, &il
->description_ptr
))
3392 if(!prs_uint32("name_ptr", ps
, depth
, &il
->name_ptr
))
3394 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
3397 if(!smb_io_unistr2("description", &il
->description
, il
->description_ptr
, ps
, depth
))
3399 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
3401 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
3407 /*******************************************************************
3408 Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
3409 ********************************************************************/
3411 bool spool_io_printer_info_level_3(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_3
*il
, prs_struct
*ps
, int depth
)
3413 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_3");
3419 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
3425 /*******************************************************************
3426 Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
3427 ********************************************************************/
3429 bool spool_io_printer_info_level_2(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_2
*il
, prs_struct
*ps
, int depth
)
3431 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_2");
3437 if(!prs_uint32("servername_ptr", ps
, depth
, &il
->servername_ptr
))
3439 if(!prs_uint32("printername_ptr", ps
, depth
, &il
->printername_ptr
))
3441 if(!prs_uint32("sharename_ptr", ps
, depth
, &il
->sharename_ptr
))
3443 if(!prs_uint32("portname_ptr", ps
, depth
, &il
->portname_ptr
))
3446 if(!prs_uint32("drivername_ptr", ps
, depth
, &il
->drivername_ptr
))
3448 if(!prs_uint32("comment_ptr", ps
, depth
, &il
->comment_ptr
))
3450 if(!prs_uint32("location_ptr", ps
, depth
, &il
->location_ptr
))
3452 if(!prs_uint32("devmode_ptr", ps
, depth
, &il
->devmode_ptr
))
3454 if(!prs_uint32("sepfile_ptr", ps
, depth
, &il
->sepfile_ptr
))
3456 if(!prs_uint32("printprocessor_ptr", ps
, depth
, &il
->printprocessor_ptr
))
3458 if(!prs_uint32("datatype_ptr", ps
, depth
, &il
->datatype_ptr
))
3460 if(!prs_uint32("parameters_ptr", ps
, depth
, &il
->parameters_ptr
))
3462 if(!prs_uint32("secdesc_ptr", ps
, depth
, &il
->secdesc_ptr
))
3465 if(!prs_uint32("attributes", ps
, depth
, &il
->attributes
))
3467 if(!prs_uint32("priority", ps
, depth
, &il
->priority
))
3469 if(!prs_uint32("default_priority", ps
, depth
, &il
->default_priority
))
3471 if(!prs_uint32("starttime", ps
, depth
, &il
->starttime
))
3473 if(!prs_uint32("untiltime", ps
, depth
, &il
->untiltime
))
3475 if(!prs_uint32("status", ps
, depth
, &il
->status
))
3477 if(!prs_uint32("cjobs", ps
, depth
, &il
->cjobs
))
3479 if(!prs_uint32("averageppm", ps
, depth
, &il
->averageppm
))
3482 if(!smb_io_unistr2("servername", &il
->servername
, il
->servername_ptr
, ps
, depth
))
3484 if(!smb_io_unistr2("printername", &il
->printername
, il
->printername_ptr
, ps
, depth
))
3486 if(!smb_io_unistr2("sharename", &il
->sharename
, il
->sharename_ptr
, ps
, depth
))
3488 if(!smb_io_unistr2("portname", &il
->portname
, il
->portname_ptr
, ps
, depth
))
3490 if(!smb_io_unistr2("drivername", &il
->drivername
, il
->drivername_ptr
, ps
, depth
))
3492 if(!smb_io_unistr2("comment", &il
->comment
, il
->comment_ptr
, ps
, depth
))
3494 if(!smb_io_unistr2("location", &il
->location
, il
->location_ptr
, ps
, depth
))
3496 if(!smb_io_unistr2("sepfile", &il
->sepfile
, il
->sepfile_ptr
, ps
, depth
))
3498 if(!smb_io_unistr2("printprocessor", &il
->printprocessor
, il
->printprocessor_ptr
, ps
, depth
))
3500 if(!smb_io_unistr2("datatype", &il
->datatype
, il
->datatype_ptr
, ps
, depth
))
3502 if(!smb_io_unistr2("parameters", &il
->parameters
, il
->parameters_ptr
, ps
, depth
))
3508 bool spool_io_printer_info_level_7(const char *desc
, SPOOL_PRINTER_INFO_LEVEL_7
*il
, prs_struct
*ps
, int depth
)
3510 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level_7");
3516 if(!prs_uint32("guid_ptr", ps
, depth
, &il
->guid_ptr
))
3518 if(!prs_uint32("action", ps
, depth
, &il
->action
))
3521 if(!smb_io_unistr2("servername", &il
->guid
, il
->guid_ptr
, ps
, depth
))
3526 /*******************************************************************
3527 ********************************************************************/
3529 bool spool_io_printer_info_level(const char *desc
, SPOOL_PRINTER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
3531 prs_debug(ps
, depth
, desc
, "spool_io_printer_info_level");
3536 if(!prs_uint32("level", ps
, depth
, &il
->level
))
3538 if(!prs_uint32("info_ptr", ps
, depth
, &il
->info_ptr
))
3541 /* if no struct inside just return */
3542 if (il
->info_ptr
==0) {
3543 if (UNMARSHALLING(ps
)) {
3550 switch (il
->level
) {
3552 * level 0 is used by setprinter when managing the queue
3553 * (hold, stop, start a queue)
3557 /* DOCUMENT ME!!! What is level 1 used for? */
3560 if (UNMARSHALLING(ps
)) {
3561 if ((il
->info_1
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_1
,1)) == NULL
)
3564 if (!spool_io_printer_info_level_1("", il
->info_1
, ps
, depth
))
3569 * level 2 is used by addprinter
3570 * and by setprinter when updating printer's info
3573 if (UNMARSHALLING(ps
)) {
3574 if ((il
->info_2
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_2
,1)) == NULL
)
3577 if (!spool_io_printer_info_level_2("", il
->info_2
, ps
, depth
))
3580 /* DOCUMENT ME!!! What is level 3 used for? */
3583 if (UNMARSHALLING(ps
)) {
3584 if ((il
->info_3
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_3
,1)) == NULL
)
3587 if (!spool_io_printer_info_level_3("", il
->info_3
, ps
, depth
))
3592 if (UNMARSHALLING(ps
))
3593 if ((il
->info_7
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_INFO_LEVEL_7
,1)) == NULL
)
3595 if (!spool_io_printer_info_level_7("", il
->info_7
, ps
, depth
))
3603 /*******************************************************************
3604 ********************************************************************/
3606 bool spoolss_io_q_addprinterex(const char *desc
, SPOOL_Q_ADDPRINTEREX
*q_u
, prs_struct
*ps
, int depth
)
3608 uint32 ptr_sec_desc
= 0;
3610 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterex");
3616 if (!prs_io_unistr2_p("ptr", ps
, depth
, &q_u
->server_name
))
3618 if (!prs_io_unistr2("servername", ps
, depth
, q_u
->server_name
))
3624 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
3627 if(!spool_io_printer_info_level("", &q_u
->info
, ps
, depth
))
3630 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
3636 switch (q_u
->level
) {
3638 ptr_sec_desc
= q_u
->info
.info_2
->secdesc_ptr
;
3641 ptr_sec_desc
= q_u
->info
.info_3
->secdesc_ptr
;
3645 if (!sec_io_desc_buf(desc
, &q_u
->secdesc_ctr
, ps
, depth
))
3650 /* Parse a NULL security descriptor. This should really
3651 happen inside the sec_io_desc_buf() function. */
3653 prs_debug(ps
, depth
, "", "sec_io_desc_buf");
3654 if (!prs_uint32("size", ps
, depth
+ 1, &dummy
))
3656 if (!prs_uint32("ptr", ps
, depth
+ 1, &dummy
))
3660 if(!prs_uint32("user_switch", ps
, depth
, &q_u
->user_switch
))
3662 if(!spool_io_user_level("", &q_u
->user_ctr
, ps
, depth
))
3668 /*******************************************************************
3669 ********************************************************************/
3671 bool spoolss_io_r_addprinterex(const char *desc
, SPOOL_R_ADDPRINTEREX
*r_u
,
3672 prs_struct
*ps
, int depth
)
3674 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterex");
3677 if(!smb_io_pol_hnd("printer handle",&r_u
->handle
,ps
,depth
))
3680 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
3686 /*******************************************************************
3687 ********************************************************************/
3689 bool spool_io_printer_driver_info_level_3(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**q_u
,
3690 prs_struct
*ps
, int depth
)
3692 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*il
;
3694 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_3");
3698 if (UNMARSHALLING(ps
)) {
3699 il
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
,1);
3711 if(!prs_uint32("cversion", ps
, depth
, &il
->cversion
))
3713 if(!prs_uint32("name", ps
, depth
, &il
->name_ptr
))
3715 if(!prs_uint32("environment", ps
, depth
, &il
->environment_ptr
))
3717 if(!prs_uint32("driverpath", ps
, depth
, &il
->driverpath_ptr
))
3719 if(!prs_uint32("datafile", ps
, depth
, &il
->datafile_ptr
))
3721 if(!prs_uint32("configfile", ps
, depth
, &il
->configfile_ptr
))
3723 if(!prs_uint32("helpfile", ps
, depth
, &il
->helpfile_ptr
))
3725 if(!prs_uint32("monitorname", ps
, depth
, &il
->monitorname_ptr
))
3727 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
3729 if(!prs_uint32("dependentfilessize", ps
, depth
, &il
->dependentfilessize
))
3731 if(!prs_uint32("dependentfiles", ps
, depth
, &il
->dependentfiles_ptr
))
3737 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
3739 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
3741 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
3743 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
3745 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
3747 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
3749 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
3751 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
3757 if (il
->dependentfiles_ptr
)
3758 smb_io_buffer5("", &il
->dependentfiles
, ps
, depth
);
3763 /*******************************************************************
3764 parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
3765 ********************************************************************/
3767 bool spool_io_printer_driver_info_level_6(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
**q_u
,
3768 prs_struct
*ps
, int depth
)
3770 SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*il
;
3772 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level_6");
3776 if (UNMARSHALLING(ps
)) {
3777 il
=PRS_ALLOC_MEM(ps
,SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
,1);
3790 * I know this seems weird, but I have no other explanation.
3791 * This is observed behavior on both NT4 and 2K servers.
3795 if (!prs_align_uint64(ps
))
3798 /* parse the main elements the packet */
3800 if(!prs_uint32("cversion ", ps
, depth
, &il
->version
))
3802 if(!prs_uint32("name ", ps
, depth
, &il
->name_ptr
))
3804 if(!prs_uint32("environment ", ps
, depth
, &il
->environment_ptr
))
3806 if(!prs_uint32("driverpath ", ps
, depth
, &il
->driverpath_ptr
))
3808 if(!prs_uint32("datafile ", ps
, depth
, &il
->datafile_ptr
))
3810 if(!prs_uint32("configfile ", ps
, depth
, &il
->configfile_ptr
))
3812 if(!prs_uint32("helpfile ", ps
, depth
, &il
->helpfile_ptr
))
3814 if(!prs_uint32("monitorname ", ps
, depth
, &il
->monitorname_ptr
))
3816 if(!prs_uint32("defaultdatatype", ps
, depth
, &il
->defaultdatatype_ptr
))
3818 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_len
))
3820 if(!prs_uint32("dependentfiles ", ps
, depth
, &il
->dependentfiles_ptr
))
3822 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_len
))
3824 if(!prs_uint32("previousnames ", ps
, depth
, &il
->previousnames_ptr
))
3826 if(!smb_io_time("driverdate ", &il
->driverdate
, ps
, depth
))
3828 if(!prs_uint32("dummy4 ", ps
, depth
, &il
->dummy4
))
3830 if(!prs_uint64("driverversion ", ps
, depth
, &il
->driverversion
))
3832 if(!prs_uint32("mfgname ", ps
, depth
, &il
->mfgname_ptr
))
3834 if(!prs_uint32("oemurl ", ps
, depth
, &il
->oemurl_ptr
))
3836 if(!prs_uint32("hardwareid ", ps
, depth
, &il
->hardwareid_ptr
))
3838 if(!prs_uint32("provider ", ps
, depth
, &il
->provider_ptr
))
3841 /* parse the structures in the packet */
3843 if(!smb_io_unistr2("name", &il
->name
, il
->name_ptr
, ps
, depth
))
3848 if(!smb_io_unistr2("environment", &il
->environment
, il
->environment_ptr
, ps
, depth
))
3853 if(!smb_io_unistr2("driverpath", &il
->driverpath
, il
->driverpath_ptr
, ps
, depth
))
3858 if(!smb_io_unistr2("datafile", &il
->datafile
, il
->datafile_ptr
, ps
, depth
))
3863 if(!smb_io_unistr2("configfile", &il
->configfile
, il
->configfile_ptr
, ps
, depth
))
3868 if(!smb_io_unistr2("helpfile", &il
->helpfile
, il
->helpfile_ptr
, ps
, depth
))
3873 if(!smb_io_unistr2("monitorname", &il
->monitorname
, il
->monitorname_ptr
, ps
, depth
))
3878 if(!smb_io_unistr2("defaultdatatype", &il
->defaultdatatype
, il
->defaultdatatype_ptr
, ps
, depth
))
3882 if (il
->dependentfiles_ptr
) {
3883 if(!smb_io_buffer5("dependentfiles", &il
->dependentfiles
, ps
, depth
))
3888 if (il
->previousnames_ptr
) {
3889 if(!smb_io_buffer5("previousnames", &il
->previousnames
, ps
, depth
))
3894 if(!smb_io_unistr2("mfgname", &il
->mfgname
, il
->mfgname_ptr
, ps
, depth
))
3898 if(!smb_io_unistr2("oemurl", &il
->oemurl
, il
->oemurl_ptr
, ps
, depth
))
3902 if(!smb_io_unistr2("hardwareid", &il
->hardwareid
, il
->hardwareid_ptr
, ps
, depth
))
3906 if(!smb_io_unistr2("provider", &il
->provider
, il
->provider_ptr
, ps
, depth
))
3912 /*******************************************************************
3913 convert a buffer of UNICODE strings null terminated
3914 the buffer is terminated by a NULL
3916 convert to an dos codepage array (null terminated)
3918 dynamically allocate memory
3920 ********************************************************************/
3922 static bool uniarray_2_dosarray(BUFFER5
*buf5
, fstring
**ar
)
3931 src
= (char *)buf5
->buffer
;
3932 *ar
= SMB_MALLOC_ARRAY(fstring
, 1);
3937 while (src
< ((char *)buf5
->buffer
) + buf5
->buf_len
*2) {
3938 rpcstr_pull(f
, src
, sizeof(f
)-1, -1, STR_TERMINATE
);
3939 src
= skip_unibuf(src
, 2*buf5
->buf_len
- PTR_DIFF(src
,buf5
->buffer
));
3940 *ar
= SMB_REALLOC_ARRAY(*ar
, fstring
, n
+2);
3944 fstrcpy((*ar
)[n
], f
);
3948 fstrcpy((*ar
)[n
], "");
3953 /*******************************************************************
3954 read a UNICODE array with null terminated strings
3955 and null terminated array
3956 and size of array at beginning
3957 ********************************************************************/
3959 bool smb_io_unibuffer(const char *desc
, UNISTR2
*buffer
, prs_struct
*ps
, int depth
)
3961 if (buffer
==NULL
) return False
;
3964 buffer
->uni_str_len
=buffer
->uni_max_len
;
3966 if(!prs_uint32("buffer_size", ps
, depth
, &buffer
->uni_max_len
))
3969 if(!prs_unistr2(True
, "buffer ", ps
, depth
, buffer
))
3975 /*******************************************************************
3976 ********************************************************************/
3978 bool spool_io_printer_driver_info_level(const char *desc
, SPOOL_PRINTER_DRIVER_INFO_LEVEL
*il
, prs_struct
*ps
, int depth
)
3980 prs_debug(ps
, depth
, desc
, "spool_io_printer_driver_info_level");
3985 if(!prs_uint32("level", ps
, depth
, &il
->level
))
3987 if(!prs_uint32("ptr", ps
, depth
, &il
->ptr
))
3993 switch (il
->level
) {
3995 if(!spool_io_printer_driver_info_level_3("", &il
->info_3
, ps
, depth
))
3999 if(!spool_io_printer_driver_info_level_6("", &il
->info_6
, ps
, depth
))
4009 /*******************************************************************
4010 init a SPOOL_Q_ADDPRINTERDRIVER struct
4011 ******************************************************************/
4013 bool make_spoolss_q_addprinterdriver(TALLOC_CTX
*mem_ctx
,
4014 SPOOL_Q_ADDPRINTERDRIVER
*q_u
, const char* srv_name
,
4015 uint32 level
, PRINTER_DRIVER_CTR
*info
)
4017 DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
4019 if (!srv_name
|| !info
) {
4023 q_u
->server_name_ptr
= 1; /* srv_name is != NULL, see above */
4024 init_unistr2(&q_u
->server_name
, srv_name
, UNI_STR_TERMINATE
);
4028 q_u
->info
.level
= level
;
4029 q_u
->info
.ptr
= 1; /* Info is != NULL, see above */
4032 /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
4034 make_spoolss_driver_info_3(mem_ctx
, &q_u
->info
.info_3
, info
->info3
);
4038 DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level
));
4045 bool make_spoolss_driver_info_3(TALLOC_CTX
*mem_ctx
,
4046 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
**spool_drv_info
,
4047 DRIVER_INFO_3
*info3
)
4050 SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*inf
;
4052 if (!(inf
=TALLOC_ZERO_P(mem_ctx
, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
)))
4055 inf
->cversion
= info3
->version
;
4056 inf
->name_ptr
= (info3
->name
.buffer
!=NULL
)?1:0;
4057 inf
->environment_ptr
= (info3
->architecture
.buffer
!=NULL
)?1:0;
4058 inf
->driverpath_ptr
= (info3
->driverpath
.buffer
!=NULL
)?1:0;
4059 inf
->datafile_ptr
= (info3
->datafile
.buffer
!=NULL
)?1:0;
4060 inf
->configfile_ptr
= (info3
->configfile
.buffer
!=NULL
)?1:0;
4061 inf
->helpfile_ptr
= (info3
->helpfile
.buffer
!=NULL
)?1:0;
4062 inf
->monitorname_ptr
= (info3
->monitorname
.buffer
!=NULL
)?1:0;
4063 inf
->defaultdatatype_ptr
= (info3
->defaultdatatype
.buffer
!=NULL
)?1:0;
4065 init_unistr2_from_unistr(inf
, &inf
->name
, &info3
->name
);
4066 init_unistr2_from_unistr(inf
, &inf
->environment
, &info3
->architecture
);
4067 init_unistr2_from_unistr(inf
, &inf
->driverpath
, &info3
->driverpath
);
4068 init_unistr2_from_unistr(inf
, &inf
->datafile
, &info3
->datafile
);
4069 init_unistr2_from_unistr(inf
, &inf
->configfile
, &info3
->configfile
);
4070 init_unistr2_from_unistr(inf
, &inf
->helpfile
, &info3
->helpfile
);
4071 init_unistr2_from_unistr(inf
, &inf
->monitorname
, &info3
->monitorname
);
4072 init_unistr2_from_unistr(inf
, &inf
->defaultdatatype
, &info3
->defaultdatatype
);
4074 if (info3
->dependentfiles
) {
4076 bool null_char
= False
;
4077 uint16
*ptr
= info3
->dependentfiles
;
4082 /* the null_char bool is used to help locate
4083 two '\0's back to back */
4100 inf
->dependentfiles_ptr
= (info3
->dependentfiles
!= NULL
) ? 1 : 0;
4101 inf
->dependentfilessize
= (info3
->dependentfiles
!= NULL
) ? len
: 0;
4102 if(!make_spoolss_buffer5(mem_ctx
, &inf
->dependentfiles
, len
, info3
->dependentfiles
)) {
4107 *spool_drv_info
= inf
;
4112 /*******************************************************************
4113 make a BUFFER5 struct from a uint16*
4114 ******************************************************************/
4116 bool make_spoolss_buffer5(TALLOC_CTX
*mem_ctx
, BUFFER5
*buf5
, uint32 len
, uint16
*src
)
4119 buf5
->buf_len
= len
;
4122 if((buf5
->buffer
=(uint16
*)TALLOC_MEMDUP(mem_ctx
, src
, sizeof(uint16
)*len
)) == NULL
) {
4123 DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n"));
4127 buf5
->buffer
= NULL
;
4136 /*******************************************************************
4137 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
4138 ********************************************************************/
4140 bool spoolss_io_q_addprinterdriver(const char *desc
, SPOOL_Q_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4142 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriver");
4148 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
4150 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4155 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4158 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
4164 /*******************************************************************
4165 ********************************************************************/
4167 bool spoolss_io_r_addprinterdriver(const char *desc
, SPOOL_R_ADDPRINTERDRIVER
*q_u
, prs_struct
*ps
, int depth
)
4169 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriver");
4172 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
4178 /*******************************************************************
4179 fill in the prs_struct for a ADDPRINTERDRIVER request PDU
4180 ********************************************************************/
4182 bool spoolss_io_q_addprinterdriverex(const char *desc
, SPOOL_Q_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
4184 prs_debug(ps
, depth
, desc
, "spoolss_io_q_addprinterdriverex");
4190 if(!prs_uint32("server_name_ptr", ps
, depth
, &q_u
->server_name_ptr
))
4192 if(!smb_io_unistr2("server_name", &q_u
->server_name
, q_u
->server_name_ptr
, ps
, depth
))
4197 if(!prs_uint32("info_level", ps
, depth
, &q_u
->level
))
4200 if(!spool_io_printer_driver_info_level("", &q_u
->info
, ps
, depth
))
4205 if(!prs_uint32("copy flags", ps
, depth
, &q_u
->copy_flags
))
4211 /*******************************************************************
4212 ********************************************************************/
4214 bool spoolss_io_r_addprinterdriverex(const char *desc
, SPOOL_R_ADDPRINTERDRIVEREX
*q_u
, prs_struct
*ps
, int depth
)
4216 prs_debug(ps
, depth
, desc
, "spoolss_io_r_addprinterdriverex");
4219 if(!prs_werror("status", ps
, depth
, &q_u
->status
))
4225 /*******************************************************************
4226 ********************************************************************/
4228 bool uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3
*uni
,
4229 NT_PRINTER_DRIVER_INFO_LEVEL_3
**asc
)
4231 NT_PRINTER_DRIVER_INFO_LEVEL_3
*d
;
4233 DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n"));
4237 *asc
=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_3
);
4245 d
->cversion
=uni
->cversion
;
4247 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
));
4248 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
));
4249 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
));
4250 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
));
4251 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
));
4252 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
));
4253 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
));
4254 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
));
4256 DEBUGADD(8,( "version: %d\n", d
->cversion
));
4257 DEBUGADD(8,( "name: %s\n", d
->name
));
4258 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4259 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4260 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4261 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4262 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4263 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4264 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4266 if (uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
4273 /*******************************************************************
4274 ********************************************************************/
4275 bool uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6
*uni
,
4276 NT_PRINTER_DRIVER_INFO_LEVEL_6
**asc
)
4278 NT_PRINTER_DRIVER_INFO_LEVEL_6
*d
;
4280 DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n"));
4284 *asc
=SMB_MALLOC_P(NT_PRINTER_DRIVER_INFO_LEVEL_6
);
4292 d
->version
=uni
->version
;
4294 unistr2_to_ascii(d
->name
, &uni
->name
, sizeof(d
->name
));
4295 unistr2_to_ascii(d
->environment
, &uni
->environment
, sizeof(d
->environment
));
4296 unistr2_to_ascii(d
->driverpath
, &uni
->driverpath
, sizeof(d
->driverpath
));
4297 unistr2_to_ascii(d
->datafile
, &uni
->datafile
, sizeof(d
->datafile
));
4298 unistr2_to_ascii(d
->configfile
, &uni
->configfile
, sizeof(d
->configfile
));
4299 unistr2_to_ascii(d
->helpfile
, &uni
->helpfile
, sizeof(d
->helpfile
));
4300 unistr2_to_ascii(d
->monitorname
, &uni
->monitorname
, sizeof(d
->monitorname
));
4301 unistr2_to_ascii(d
->defaultdatatype
, &uni
->defaultdatatype
, sizeof(d
->defaultdatatype
));
4303 DEBUGADD(8,( "version: %d\n", d
->version
));
4304 DEBUGADD(8,( "name: %s\n", d
->name
));
4305 DEBUGADD(8,( "environment: %s\n", d
->environment
));
4306 DEBUGADD(8,( "driverpath: %s\n", d
->driverpath
));
4307 DEBUGADD(8,( "datafile: %s\n", d
->datafile
));
4308 DEBUGADD(8,( "configfile: %s\n", d
->configfile
));
4309 DEBUGADD(8,( "helpfile: %s\n", d
->helpfile
));
4310 DEBUGADD(8,( "monitorname: %s\n", d
->monitorname
));
4311 DEBUGADD(8,( "defaultdatatype: %s\n", d
->defaultdatatype
));
4313 if (!uniarray_2_dosarray(&uni
->dependentfiles
, &d
->dependentfiles
))
4315 if (!uniarray_2_dosarray(&uni
->previousnames
, &d
->previousnames
))
4325 bool uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2
*uni
,
4326 NT_PRINTER_INFO_LEVEL_2
*d
)
4328 DEBUG(7,("Converting from UNICODE to ASCII\n"));
4330 d
->attributes
=uni
->attributes
;
4331 d
->priority
=uni
->priority
;
4332 d
->default_priority
=uni
->default_priority
;
4333 d
->starttime
=uni
->starttime
;
4334 d
->untiltime
=uni
->untiltime
;
4335 d
->status
=uni
->status
;
4336 d
->cjobs
=uni
->cjobs
;
4338 unistr2_to_ascii(d
->servername
, &uni
->servername
, sizeof(d
->servername
));
4339 unistr2_to_ascii(d
->printername
, &uni
->printername
, sizeof(d
->printername
));
4340 unistr2_to_ascii(d
->sharename
, &uni
->sharename
, sizeof(d
->sharename
));
4341 unistr2_to_ascii(d
->portname
, &uni
->portname
, sizeof(d
->portname
));
4342 unistr2_to_ascii(d
->drivername
, &uni
->drivername
, sizeof(d
->drivername
));
4343 unistr2_to_ascii(d
->comment
, &uni
->comment
, sizeof(d
->comment
));
4344 unistr2_to_ascii(d
->location
, &uni
->location
, sizeof(d
->location
));
4345 unistr2_to_ascii(d
->sepfile
, &uni
->sepfile
, sizeof(d
->sepfile
));
4346 unistr2_to_ascii(d
->printprocessor
, &uni
->printprocessor
, sizeof(d
->printprocessor
));
4347 unistr2_to_ascii(d
->datatype
, &uni
->datatype
, sizeof(d
->datatype
));
4348 unistr2_to_ascii(d
->parameters
, &uni
->parameters
, sizeof(d
->parameters
));
4353 /*******************************************************************
4355 ********************************************************************/
4357 bool make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
,
4358 fstring servername
, fstring env_name
, uint32 level
,
4359 RPC_BUFFER
*buffer
, uint32 offered
)
4361 init_buf_unistr2(&q_u
->name
, &q_u
->name_ptr
, servername
);
4362 init_buf_unistr2(&q_u
->environment
, &q_u
->environment_ptr
, env_name
);
4366 q_u
->offered
=offered
;
4371 /*******************************************************************
4372 Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure.
4373 ********************************************************************/
4375 bool spoolss_io_q_getprinterdriverdir(const char *desc
, SPOOL_Q_GETPRINTERDRIVERDIR
*q_u
, prs_struct
*ps
, int depth
)
4377 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprinterdriverdir");
4382 if(!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4384 if(!smb_io_unistr2("", &q_u
->name
, q_u
->name_ptr
, ps
, depth
))
4390 if(!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
4392 if(!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4398 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4401 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4407 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4413 /*******************************************************************
4414 Parse a SPOOL_R_GETPRINTERDRIVERDIR structure.
4415 ********************************************************************/
4417 bool spoolss_io_r_getprinterdriverdir(const char *desc
, SPOOL_R_GETPRINTERDRIVERDIR
*r_u
, prs_struct
*ps
, int depth
)
4419 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprinterdriverdir");
4425 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4431 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4434 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4440 /*******************************************************************
4441 ********************************************************************/
4443 bool spoolss_io_r_enumprintprocessors(const char *desc
, SPOOL_R_ENUMPRINTPROCESSORS
*r_u
, prs_struct
*ps
, int depth
)
4445 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocessors");
4451 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4457 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4460 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4463 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4469 /*******************************************************************
4470 ********************************************************************/
4472 bool spoolss_io_q_enumprintprocessors(const char *desc
, SPOOL_Q_ENUMPRINTPROCESSORS
*q_u
, prs_struct
*ps
, int depth
)
4474 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocessors");
4480 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4482 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
4488 if (!prs_uint32("", ps
, depth
, &q_u
->environment_ptr
))
4490 if (!smb_io_unistr2("", &q_u
->environment
, q_u
->environment_ptr
, ps
, depth
))
4496 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4499 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4505 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4511 /*******************************************************************
4512 ********************************************************************/
4514 bool spoolss_io_r_enumprintprocdatatypes(const char *desc
, SPOOL_R_ENUMPRINTPROCDATATYPES
*r_u
, prs_struct
*ps
, int depth
)
4516 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintprocdatatypes");
4522 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4528 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4531 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4534 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4540 /*******************************************************************
4541 ********************************************************************/
4543 bool spoolss_io_q_enumprintprocdatatypes(const char *desc
, SPOOL_Q_ENUMPRINTPROCDATATYPES
*q_u
, prs_struct
*ps
, int depth
)
4545 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintprocdatatypes");
4551 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4553 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
4559 if (!prs_uint32("processor_ptr", ps
, depth
, &q_u
->processor_ptr
))
4561 if (!smb_io_unistr2("processor", &q_u
->processor
, q_u
->processor_ptr
, ps
, depth
))
4567 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4570 if(!prs_rpcbuffer_p("buffer", ps
, depth
, &q_u
->buffer
))
4576 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4582 /*******************************************************************
4583 Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
4584 ********************************************************************/
4586 bool spoolss_io_q_enumprintmonitors(const char *desc
, SPOOL_Q_ENUMPRINTMONITORS
*q_u
, prs_struct
*ps
, int depth
)
4588 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprintmonitors");
4594 if (!prs_uint32("name_ptr", ps
, depth
, &q_u
->name_ptr
))
4596 if (!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
4602 if (!prs_uint32("level", ps
, depth
, &q_u
->level
))
4605 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4611 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4617 /*******************************************************************
4618 ********************************************************************/
4620 bool spoolss_io_r_enumprintmonitors(const char *desc
, SPOOL_R_ENUMPRINTMONITORS
*r_u
, prs_struct
*ps
, int depth
)
4622 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprintmonitors");
4628 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4634 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4637 if (!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
4640 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4646 /*******************************************************************
4647 ********************************************************************/
4649 bool spoolss_io_r_enumprinterdata(const char *desc
, SPOOL_R_ENUMPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
4651 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdata");
4656 if(!prs_uint32("valuesize", ps
, depth
, &r_u
->valuesize
))
4659 if (UNMARSHALLING(ps
) && r_u
->valuesize
) {
4660 r_u
->value
= PRS_ALLOC_MEM(ps
, uint16
, r_u
->valuesize
);
4662 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n"));
4667 if(!prs_uint16uni(False
, "value", ps
, depth
, r_u
->value
, r_u
->valuesize
))
4673 if(!prs_uint32("realvaluesize", ps
, depth
, &r_u
->realvaluesize
))
4676 if(!prs_uint32("type", ps
, depth
, &r_u
->type
))
4679 if(!prs_uint32("datasize", ps
, depth
, &r_u
->datasize
))
4682 if (UNMARSHALLING(ps
) && r_u
->datasize
) {
4683 r_u
->data
= PRS_ALLOC_MEM(ps
, uint8
, r_u
->datasize
);
4685 DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n"));
4690 if(!prs_uint8s(False
, "data", ps
, depth
, r_u
->data
, r_u
->datasize
))
4695 if(!prs_uint32("realdatasize", ps
, depth
, &r_u
->realdatasize
))
4697 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4703 /*******************************************************************
4704 ********************************************************************/
4706 bool spoolss_io_q_enumprinterdata(const char *desc
, SPOOL_Q_ENUMPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
4708 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdata");
4713 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4715 if(!prs_uint32("index", ps
, depth
, &q_u
->index
))
4717 if(!prs_uint32("valuesize", ps
, depth
, &q_u
->valuesize
))
4719 if(!prs_uint32("datasize", ps
, depth
, &q_u
->datasize
))
4725 /*******************************************************************
4726 ********************************************************************/
4728 bool make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA
*q_u
,
4729 const POLICY_HND
*hnd
,
4730 uint32 idx
, uint32 valuelen
, uint32 datalen
)
4732 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4734 q_u
->valuesize
=valuelen
;
4735 q_u
->datasize
=datalen
;
4740 /*******************************************************************
4741 ********************************************************************/
4743 bool make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX
*q_u
,
4744 const POLICY_HND
*hnd
, const char *key
,
4747 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4748 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
4754 /*******************************************************************
4755 ********************************************************************/
4756 bool make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA
*q_u
, const POLICY_HND
*hnd
,
4757 char* value
, uint32 data_type
, char* data
, uint32 data_size
)
4759 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
4760 q_u
->type
= data_type
;
4761 init_unistr2(&q_u
->value
, value
, UNI_STR_TERMINATE
);
4763 q_u
->max_len
= q_u
->real_len
= data_size
;
4764 q_u
->data
= (unsigned char *)data
;
4769 /*******************************************************************
4770 ********************************************************************/
4772 bool spoolss_io_q_setprinterdata(const char *desc
, SPOOL_Q_SETPRINTERDATA
*q_u
, prs_struct
*ps
, int depth
)
4774 prs_debug(ps
, depth
, desc
, "spoolss_io_q_setprinterdata");
4779 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4781 if(!smb_io_unistr2("", &q_u
->value
, True
, ps
, depth
))
4787 if(!prs_uint32("type", ps
, depth
, &q_u
->type
))
4790 if(!prs_uint32("max_len", ps
, depth
, &q_u
->max_len
))
4800 if (UNMARSHALLING(ps
))
4801 q_u
->data
=PRS_ALLOC_MEM(ps
, uint8
, q_u
->max_len
);
4802 if(q_u
->data
== NULL
)
4804 if(!prs_uint8s(False
,"data", ps
, depth
, q_u
->data
, q_u
->max_len
))
4812 if(!prs_uint32("real_len", ps
, depth
, &q_u
->real_len
))
4818 /*******************************************************************
4819 ********************************************************************/
4821 bool spoolss_io_r_setprinterdata(const char *desc
, SPOOL_R_SETPRINTERDATA
*r_u
, prs_struct
*ps
, int depth
)
4823 prs_debug(ps
, depth
, desc
, "spoolss_io_r_setprinterdata");
4828 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4834 /*******************************************************************
4835 ********************************************************************/
4836 bool spoolss_io_q_resetprinter(const char *desc
, SPOOL_Q_RESETPRINTER
*q_u
, prs_struct
*ps
, int depth
)
4838 prs_debug(ps
, depth
, desc
, "spoolss_io_q_resetprinter");
4843 if (!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
4846 if (!prs_uint32("datatype_ptr", ps
, depth
, &q_u
->datatype_ptr
))
4849 if (q_u
->datatype_ptr
) {
4850 if (!smb_io_unistr2("datatype", &q_u
->datatype
, q_u
->datatype_ptr
?True
:False
, ps
, depth
))
4854 if (!spoolss_io_devmode_cont(desc
, &q_u
->devmode_ctr
, ps
, depth
))
4861 /*******************************************************************
4862 ********************************************************************/
4863 bool spoolss_io_r_resetprinter(const char *desc
, SPOOL_R_RESETPRINTER
*r_u
, prs_struct
*ps
, int depth
)
4865 prs_debug(ps
, depth
, desc
, "spoolss_io_r_resetprinter");
4870 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
4876 /*******************************************************************
4877 Parse a SPOOL_R_GETJOB structure.
4878 ********************************************************************/
4880 bool spoolss_io_r_getjob(const char *desc
, SPOOL_R_GETJOB
*r_u
, prs_struct
*ps
, int depth
)
4882 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getjob");
4888 if (!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
4894 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
4897 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
4903 /*******************************************************************
4904 Parse a SPOOL_Q_GETJOB structure.
4905 ********************************************************************/
4907 bool spoolss_io_q_getjob(const char *desc
, SPOOL_Q_GETJOB
*q_u
, prs_struct
*ps
, int depth
)
4909 prs_debug(ps
, depth
, desc
, "");
4915 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
4917 if(!prs_uint32("jobid", ps
, depth
, &q_u
->jobid
))
4919 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
4922 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
4928 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
4934 void free_devmode(DEVICEMODE
*devmode
)
4936 if (devmode
!=NULL
) {
4937 SAFE_FREE(devmode
->dev_private
);
4942 void free_printer_info_1(PRINTER_INFO_1
*printer
)
4947 void free_printer_info_2(PRINTER_INFO_2
*printer
)
4949 if (printer
!=NULL
) {
4950 free_devmode(printer
->devmode
);
4951 printer
->devmode
= NULL
;
4956 void free_printer_info_3(PRINTER_INFO_3
*printer
)
4961 void free_printer_info_4(PRINTER_INFO_4
*printer
)
4966 void free_printer_info_5(PRINTER_INFO_5
*printer
)
4971 void free_printer_info_6(PRINTER_INFO_6
*printer
)
4976 void free_printer_info_7(PRINTER_INFO_7
*printer
)
4981 void free_job_info_2(JOB_INFO_2
*job
)
4984 free_devmode(job
->devmode
);
4987 #if 0 /* JERRY - not currently used but could be :-) */
4989 /*******************************************************************
4990 Deep copy a SPOOL_NOTIFY_INFO_DATA structure
4991 ******************************************************************/
4992 static bool copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA
*dst
,
4993 SPOOL_NOTIFY_INFO_DATA
*src
, int n
)
4997 memcpy(dst
, src
, sizeof(SPOOL_NOTIFY_INFO_DATA
)*n
);
4999 for (i
=0; i
<n
; i
++) {
5003 if (src
->size
!= POINTER
)
5005 len
= src
->notify_data
.data
.length
;
5006 s
= SMB_MALLOC_ARRAY(uint16
, len
);
5008 DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n"));
5012 memcpy(s
, src
->notify_data
.data
.string
, len
*2);
5013 dst
->notify_data
.data
.string
= s
;
5019 /*******************************************************************
5020 Deep copy a SPOOL_NOTIFY_INFO structure
5021 ******************************************************************/
5022 static bool copy_spool_notify_info(SPOOL_NOTIFY_INFO
*dst
, SPOOL_NOTIFY_INFO
*src
)
5025 DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n"));
5029 dst
->version
= src
->version
;
5030 dst
->flags
= src
->flags
;
5031 dst
->count
= src
->count
;
5035 dst
->data
= SMB_MALLOC_ARRAY(SPOOL_NOTIFY_INFO_DATA
, dst
->count
);
5037 DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n",
5040 if (dst
->data
== NULL
) {
5041 DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n",
5046 return (copy_spool_notify_info_data(dst
->data
, src
->data
, src
->count
));
5053 /*******************************************************************
5055 ********************************************************************/
5057 bool make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN
*q_u
, POLICY_HND
*hnd
,
5058 uint32 change_low
, uint32 change_high
,
5059 SPOOL_NOTIFY_INFO
*info
)
5064 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5066 q_u
->change_low
=change_low
;
5067 q_u
->change_high
=change_high
;
5072 q_u
->info_ptr
=0x0FF0ADDE;
5074 q_u
->info
.version
=2;
5077 DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n",
5079 q_u
->info
.version
= info
->version
;
5080 q_u
->info
.flags
= info
->flags
;
5081 q_u
->info
.count
= info
->count
;
5082 /* pointer field - be careful! */
5083 q_u
->info
.data
= info
->data
;
5086 q_u
->info
.flags
=PRINTER_NOTIFY_INFO_DISCARDED
;
5093 /*******************************************************************
5094 Parse a SPOOL_Q_REPLY_RRPCN structure.
5095 ********************************************************************/
5097 bool spoolss_io_q_reply_rrpcn(const char *desc
, SPOOL_Q_REPLY_RRPCN
*q_u
, prs_struct
*ps
, int depth
)
5099 prs_debug(ps
, depth
, desc
, "spoolss_io_q_reply_rrpcn");
5105 if(!smb_io_pol_hnd("printer handle",&q_u
->handle
,ps
,depth
))
5108 if (!prs_uint32("change_low", ps
, depth
, &q_u
->change_low
))
5111 if (!prs_uint32("change_high", ps
, depth
, &q_u
->change_high
))
5114 if (!prs_uint32("unknown0", ps
, depth
, &q_u
->unknown0
))
5117 if (!prs_uint32("unknown1", ps
, depth
, &q_u
->unknown1
))
5120 if (!prs_uint32("info_ptr", ps
, depth
, &q_u
->info_ptr
))
5123 if(q_u
->info_ptr
!=0)
5124 if(!smb_io_notify_info(desc
, &q_u
->info
, ps
, depth
))
5130 /*******************************************************************
5131 Parse a SPOOL_R_REPLY_RRPCN structure.
5132 ********************************************************************/
5134 bool spoolss_io_r_reply_rrpcn(const char *desc
, SPOOL_R_REPLY_RRPCN
*r_u
, prs_struct
*ps
, int depth
)
5136 prs_debug(ps
, depth
, desc
, "spoolss_io_r_reply_rrpcn");
5142 if (!prs_uint32("unknown0", ps
, depth
, &r_u
->unknown0
))
5145 if (!prs_werror("status", ps
, depth
, &r_u
->status
))
5151 /*******************************************************************
5153 ********************************************************************/
5154 bool make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY
*q_u
,
5155 POLICY_HND
*hnd
, const char *key
,
5158 DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
5160 memcpy(&q_u
->handle
, hnd
, sizeof(q_u
->handle
));
5161 init_unistr2(&q_u
->key
, key
, UNI_STR_TERMINATE
);
5167 /*******************************************************************
5169 ********************************************************************/
5171 bool spoolss_io_q_enumprinterkey(const char *desc
, SPOOL_Q_ENUMPRINTERKEY
*q_u
, prs_struct
*ps
, int depth
)
5173 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterkey");
5178 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5181 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
5187 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
5193 /*******************************************************************
5194 * write a structure.
5195 ********************************************************************/
5197 bool spoolss_io_r_enumprinterkey(const char *desc
, SPOOL_R_ENUMPRINTERKEY
*r_u
, prs_struct
*ps
, int depth
)
5199 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterkey");
5205 if (!smb_io_buffer5("", &r_u
->keys
, ps
, depth
))
5211 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5214 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5220 /*******************************************************************
5222 ********************************************************************/
5224 bool spoolss_io_q_enumprinterdataex(const char *desc
, SPOOL_Q_ENUMPRINTERDATAEX
*q_u
, prs_struct
*ps
, int depth
)
5226 prs_debug(ps
, depth
, desc
, "spoolss_io_q_enumprinterdataex");
5231 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5234 if(!smb_io_unistr2("", &q_u
->key
, True
, ps
, depth
))
5240 if(!prs_uint32("size", ps
, depth
, &q_u
->size
))
5246 /*******************************************************************
5247 ********************************************************************/
5249 static bool spoolss_io_printer_enum_values_ctr(const char *desc
, prs_struct
*ps
,
5250 PRINTER_ENUM_VALUES_CTR
*ctr
, int depth
)
5253 uint32 valuename_offset
,
5256 const uint32 basic_unit
= 20; /* size of static portion of enum_values */
5258 prs_debug(ps
, depth
, desc
, "spoolss_io_printer_enum_values_ctr");
5262 * offset data begins at 20 bytes per structure * size_of_array.
5263 * Don't forget the uint32 at the beginning
5266 current_offset
= basic_unit
* ctr
->size_of_array
;
5268 /* first loop to write basic enum_value information */
5270 if (UNMARSHALLING(ps
) && ctr
->size_of_array
) {
5271 ctr
->values
= PRS_ALLOC_MEM(ps
, PRINTER_ENUM_VALUES
, ctr
->size_of_array
);
5276 for (i
=0; i
<ctr
->size_of_array
; i
++) {
5277 uint32 base_offset
, return_offset
;
5279 base_offset
= prs_offset(ps
);
5281 valuename_offset
= current_offset
;
5282 if (!prs_uint32("valuename_offset", ps
, depth
, &valuename_offset
))
5285 /* Read or write the value. */
5287 return_offset
= prs_offset(ps
);
5289 if (!prs_set_offset(ps
, base_offset
+ valuename_offset
)) {
5293 if (!prs_unistr("valuename", ps
, depth
, &ctr
->values
[i
].valuename
))
5297 if (!prs_set_offset(ps
, return_offset
))
5300 if (!prs_uint32("value_len", ps
, depth
, &ctr
->values
[i
].value_len
))
5303 if (!prs_uint32("type", ps
, depth
, &ctr
->values
[i
].type
))
5306 data_offset
= ctr
->values
[i
].value_len
+ valuename_offset
;
5308 if (!prs_uint32("data_offset", ps
, depth
, &data_offset
))
5311 if (!prs_uint32("data_len", ps
, depth
, &ctr
->values
[i
].data_len
))
5314 /* Read or write the data. */
5316 return_offset
= prs_offset(ps
);
5318 if (!prs_set_offset(ps
, base_offset
+ data_offset
)) {
5322 if ( ctr
->values
[i
].data_len
) {
5323 if ( UNMARSHALLING(ps
) ) {
5324 ctr
->values
[i
].data
= PRS_ALLOC_MEM(ps
, uint8
, ctr
->values
[i
].data_len
);
5325 if (!ctr
->values
[i
].data
)
5328 if (!prs_uint8s(False
, "data", ps
, depth
, ctr
->values
[i
].data
, ctr
->values
[i
].data_len
))
5332 current_offset
= data_offset
+ ctr
->values
[i
].data_len
- basic_unit
;
5333 /* account for 2 byte alignment */
5334 current_offset
+= (current_offset
% 2);
5336 /* Remember how far we got. */
5337 data_offset
= prs_offset(ps
);
5340 if (!prs_set_offset(ps
, return_offset
))
5345 /* Go to the last data offset we got to. */
5347 if (!prs_set_offset(ps
, data_offset
))
5350 /* And ensure we're 2 byte aligned. */
5352 if ( !prs_align_uint16(ps
) )
5358 /*******************************************************************
5359 * write a structure.
5360 ********************************************************************/
5362 bool spoolss_io_r_enumprinterdataex(const char *desc
, SPOOL_R_ENUMPRINTERDATAEX
*r_u
, prs_struct
*ps
, int depth
)
5364 uint32 data_offset
, end_offset
;
5365 prs_debug(ps
, depth
, desc
, "spoolss_io_r_enumprinterdataex");
5371 if (!prs_uint32("size", ps
, depth
, &r_u
->ctr
.size
))
5374 data_offset
= prs_offset(ps
);
5376 if (!prs_set_offset(ps
, data_offset
+ r_u
->ctr
.size
))
5382 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5385 if(!prs_uint32("returned", ps
, depth
, &r_u
->returned
))
5388 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5391 r_u
->ctr
.size_of_array
= r_u
->returned
;
5393 end_offset
= prs_offset(ps
);
5395 if (!prs_set_offset(ps
, data_offset
))
5399 if (!spoolss_io_printer_enum_values_ctr("", ps
, &r_u
->ctr
, depth
))
5402 if (!prs_set_offset(ps
, end_offset
))
5407 /*******************************************************************
5408 * write a structure.
5409 ********************************************************************/
5412 uint32 GetPrintProcessorDirectory(
5414 [in] unistr2 *environment,
5416 [in,out] RPC_BUFFER buffer,
5417 [in] uint32 offered,
5418 [out] uint32 needed,
5419 [out] uint32 returned
5424 bool make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, const char *name
, char *environment
, int level
, RPC_BUFFER
*buffer
, uint32 offered
)
5426 DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
5428 init_unistr2(&q_u
->name
, name
, UNI_STR_TERMINATE
);
5429 init_unistr2(&q_u
->environment
, environment
, UNI_STR_TERMINATE
);
5433 q_u
->buffer
= buffer
;
5434 q_u
->offered
= offered
;
5439 bool spoolss_io_q_getprintprocessordirectory(const char *desc
, SPOOL_Q_GETPRINTPROCESSORDIRECTORY
*q_u
, prs_struct
*ps
, int depth
)
5443 prs_debug(ps
, depth
, desc
, "spoolss_io_q_getprintprocessordirectory");
5449 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
5453 if(!smb_io_unistr2("name", &q_u
->name
, True
, ps
, depth
))
5460 if (!prs_uint32("ptr", ps
, depth
, &ptr
))
5464 if(!smb_io_unistr2("environment", &q_u
->environment
, True
,
5472 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
5475 if(!prs_rpcbuffer_p("", ps
, depth
, &q_u
->buffer
))
5481 if(!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5487 /*******************************************************************
5488 * write a structure.
5489 ********************************************************************/
5491 bool spoolss_io_r_getprintprocessordirectory(const char *desc
, SPOOL_R_GETPRINTPROCESSORDIRECTORY
*r_u
, prs_struct
*ps
, int depth
)
5493 prs_debug(ps
, depth
, desc
, "spoolss_io_r_getprintprocessordirectory");
5499 if(!prs_rpcbuffer_p("", ps
, depth
, &r_u
->buffer
))
5505 if(!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5508 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5514 bool smb_io_printprocessordirectory_1(const char *desc
, RPC_BUFFER
*buffer
, PRINTPROCESSOR_DIRECTORY_1
*info
, int depth
)
5516 prs_struct
*ps
=&buffer
->prs
;
5518 prs_debug(ps
, depth
, desc
, "smb_io_printprocessordirectory_1");
5521 buffer
->struct_start
=prs_offset(ps
);
5523 if (!smb_io_unistr(desc
, &info
->name
, ps
, depth
))
5529 /*******************************************************************
5531 ********************************************************************/
5533 bool make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS
*q_u
, POLICY_HND
*handle
,
5534 uint32 level
, RPC_BUFFER
*buffer
,
5537 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
5540 q_u
->offered
=offered
;
5545 /*******************************************************************
5547 ********************************************************************/
5549 bool make_spoolss_q_getjob(SPOOL_Q_GETJOB
*q_u
, POLICY_HND
*handle
,
5550 uint32 jobid
, uint32 level
, RPC_BUFFER
*buffer
,
5553 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
5556 q_u
->buffer
= buffer
;
5557 q_u
->offered
= offered
;
5562 /*******************************************************************
5564 ********************************************************************/
5566 bool make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX
*q_u
, POLICY_HND
*handle
,
5567 uint32 flags
, uint32 options
, const char *localmachine
,
5568 uint32 printerlocal
, SPOOL_NOTIFY_OPTION
*option
)
5570 memcpy(&q_u
->handle
, handle
, sizeof(POLICY_HND
));
5573 q_u
->options
= options
;
5575 q_u
->localmachine_ptr
= 1;
5577 init_unistr2(&q_u
->localmachine
, localmachine
, UNI_STR_TERMINATE
);
5579 q_u
->printerlocal
= printerlocal
;
5582 q_u
->option_ptr
= 1;
5584 q_u
->option
= option
;
5590 /*******************************************************************
5591 ********************************************************************/
5593 bool spoolss_io_q_xcvdataport(const char *desc
, SPOOL_Q_XCVDATAPORT
*q_u
, prs_struct
*ps
, int depth
)
5595 prs_debug(ps
, depth
, desc
, "spoolss_io_q_xcvdataport");
5601 if(!smb_io_pol_hnd("printer handle", &q_u
->handle
, ps
, depth
))
5604 if(!smb_io_unistr2("", &q_u
->dataname
, True
, ps
, depth
))
5610 if(!prs_rpcbuffer("", ps
, depth
, &q_u
->indata
))
5616 if (!prs_uint32("indata_len", ps
, depth
, &q_u
->indata_len
))
5618 if (!prs_uint32("offered", ps
, depth
, &q_u
->offered
))
5620 if (!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
5626 /*******************************************************************
5627 ********************************************************************/
5629 bool spoolss_io_r_xcvdataport(const char *desc
, SPOOL_R_XCVDATAPORT
*r_u
, prs_struct
*ps
, int depth
)
5631 prs_debug(ps
, depth
, desc
, "spoolss_io_r_xcvdataport");
5636 if(!prs_rpcbuffer("", ps
, depth
, &r_u
->outdata
))
5642 if (!prs_uint32("needed", ps
, depth
, &r_u
->needed
))
5644 if (!prs_uint32("unknown", ps
, depth
, &r_u
->unknown
))
5647 if(!prs_werror("status", ps
, depth
, &r_u
->status
))
5653 /*******************************************************************
5654 ********************************************************************/
5656 bool make_monitorui_buf( RPC_BUFFER
*buf
, const char *dllname
)
5663 init_unistr( &string
, dllname
);
5665 if ( !prs_unistr( "ui_dll", &buf
->prs
, 0, &string
) )
5671 /*******************************************************************
5672 ********************************************************************/
5674 #define PORT_DATA_1_PAD 540
5676 static bool smb_io_port_data_1( const char *desc
, RPC_BUFFER
*buf
, int depth
, SPOOL_PORT_DATA_1
*p1
)
5678 prs_struct
*ps
= &buf
->prs
;
5679 uint8 padding
[PORT_DATA_1_PAD
];
5681 prs_debug(ps
, depth
, desc
, "smb_io_port_data_1");
5687 if( !prs_uint16s(True
, "portname", ps
, depth
, p1
->portname
, MAX_PORTNAME
))
5690 if (!prs_uint32("version", ps
, depth
, &p1
->version
))
5692 if (!prs_uint32("protocol", ps
, depth
, &p1
->protocol
))
5694 if (!prs_uint32("size", ps
, depth
, &p1
->size
))
5696 if (!prs_uint32("reserved", ps
, depth
, &p1
->reserved
))
5699 if( !prs_uint16s(True
, "hostaddress", ps
, depth
, p1
->hostaddress
, MAX_NETWORK_NAME
))
5701 if( !prs_uint16s(True
, "snmpcommunity", ps
, depth
, p1
->snmpcommunity
, MAX_SNMP_COMM_NAME
))
5704 if (!prs_uint32("dblspool", ps
, depth
, &p1
->dblspool
))
5707 if( !prs_uint16s(True
, "queue", ps
, depth
, p1
->queue
, MAX_QUEUE_NAME
))
5709 if( !prs_uint16s(True
, "ipaddress", ps
, depth
, p1
->ipaddress
, MAX_IPADDR_STRING
))
5712 if( !prs_uint8s(False
, "", ps
, depth
, padding
, PORT_DATA_1_PAD
))
5715 if (!prs_uint32("port", ps
, depth
, &p1
->port
))
5717 if (!prs_uint32("snmpenabled", ps
, depth
, &p1
->snmpenabled
))
5719 if (!prs_uint32("snmpdevindex", ps
, depth
, &p1
->snmpdevindex
))
5725 /*******************************************************************
5726 ********************************************************************/
5728 bool convert_port_data_1( NT_PORT_DATA_1
*port1
, RPC_BUFFER
*buf
)
5730 SPOOL_PORT_DATA_1 spdata_1
;
5732 ZERO_STRUCT( spdata_1
);
5734 if ( !smb_io_port_data_1( "port_data_1", buf
, 0, &spdata_1
) )
5737 rpcstr_pull(port1
->name
, spdata_1
.portname
, sizeof(port1
->name
), -1, 0);
5738 rpcstr_pull(port1
->queue
, spdata_1
.queue
, sizeof(port1
->queue
), -1, 0);
5739 rpcstr_pull(port1
->hostaddr
, spdata_1
.hostaddress
, sizeof(port1
->hostaddr
), -1, 0);
5741 port1
->port
= spdata_1
.port
;
5743 switch ( spdata_1
.protocol
) {
5745 port1
->protocol
= PORT_PROTOCOL_DIRECT
;
5748 port1
->protocol
= PORT_PROTOCOL_LPR
;
5751 DEBUG(3,("convert_port_data_1: unknown protocol [%d]!\n",
5752 spdata_1
.protocol
));